Skip to content

chore: EnforcerAddressesByName has enforcer name specific keys#278

Open
jeffsmale90 wants to merge 1 commit into
mainfrom
chore/specific-deployed-contracts-type
Open

chore: EnforcerAddressesByName has enforcer name specific keys#278
jeffsmale90 wants to merge 1 commit into
mainfrom
chore/specific-deployed-contracts-type

Conversation

@jeffsmale90

@jeffsmale90 jeffsmale90 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

📝 Description

In @metamask/7715-permission-types, DeployedContractsByName is defined as Record<string, Hex>, which introduces risk of miskeyed contract accesses.

In @metamask/delegation-deployments the DeployedContracts is equally loosely typed, but the contract names are PascalCase.

This PR updates @metamask/delegation-deployments to expect EnforcerAddressesByName which is specifically keyed with enforcer contract names in camelCase - a consumer providing the addresses from @metamask/delegation-deployments would need to map the PascalCase names to camelCase.

🔄 What Changed?

List the specific changes made:

🚀 Why?

Explain the motivation behind these changes:

🧪 How to Test?

Describe how to test these changes:

  • Manual testing steps:
  • Automated tests added/updated
  • All existing tests pass

⚠️ Breaking Changes

List any breaking changes:

  • No breaking changes
  • Breaking changes (describe below):

📋 Checklist

Check off completed items:

  • Code follows the project's coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated
  • Changelog updated (if needed)
  • All CI checks pass

🔗 Related Issues

Link to related issues:
Closes #
Related to #

📚 Additional Notes

Any additional information, concerns, or context:


Note

Medium Risk
Breaking public API for permission decoding; integrators must remap deployment addresses correctly or decoders could bind to wrong enforcer contracts, which affects permission enforcement semantics.

Overview
Breaking change to how enforcer contract addresses are passed into permission decoders in @metamask/7715-permission-types.

makePermissionDecoderConfigs and all decoder/caveat helpers now take EnforcerAddressesByName—a map with fixed camelCase keys (erc20PeriodTransferEnforcer, timestampEnforcer, etc.) via the new EnforcerContractName union—instead of loose DeployedContractsByName (Record<string, Hex>). Public exports drop DeployedContractsByName and ChecksumEnforcersByChainId in favor of EnforcerAddressesByName.

Address resolution no longer looks up PascalCase names from a full deployment map: getChecksumEnforcersByChainId is replaced by checksumEnforcerAddresses, which checksums each field on an already-keyed EnforcerAddressesByName object. Callers that used @metamask/delegation-deployments must map PascalCase contract names to these camelCase keys themselves.

Tests switch from chain deployment fixtures to a shared EnforcerAddressesByName stub in test-utils; the changelog documents the breaking API under Unreleased.

Reviewed by Cursor Bugbot for commit f74e1c1. Bugbot is set up for automated code reviews on this repo. Configure here.

@jeffsmale90
jeffsmale90 requested a review from a team as a code owner July 15, 2026 23:28
@jeffsmale90
jeffsmale90 force-pushed the chore/specific-deployed-contracts-type branch from e0a99db to 7fc369a Compare July 15, 2026 23:30
Comment thread packages/7715-permission-types/src/permissions/types.ts Outdated
@jeffsmale90
jeffsmale90 force-pushed the chore/specific-deployed-contracts-type branch from 7fc369a to 2b592f3 Compare July 16, 2026 04:24
Comment thread packages/7715-permission-types/src/permissions/utils.ts
@jeffsmale90
jeffsmale90 force-pushed the chore/specific-deployed-contracts-type branch from 2b592f3 to ad33706 Compare July 16, 2026 04:36
@jeffsmale90 jeffsmale90 changed the title chore: DeployedContractsByName updated to have specific keys chore: EnforcerAddressesByName has enforcer name specific keys Jul 16, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ad33706. Configure here.

Comment thread packages/7715-permission-types/test/test-utils.ts
- simplifies address mapping to accept camelcased names
@jeffsmale90
jeffsmale90 force-pushed the chore/specific-deployed-contracts-type branch from ad33706 to f74e1c1 Compare July 16, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant