Skip to content

POC impl for token type adaptors to encapsulate token logic#2015

Merged
tt-cll merged 16 commits intomainfrom
token-type-adaptor-poc
May 5, 2026
Merged

POC impl for token type adaptors to encapsulate token logic#2015
tt-cll merged 16 commits intomainfrom
token-type-adaptor-poc

Conversation

@matYang
Copy link
Copy Markdown
Collaborator

@matYang matYang commented Apr 28, 2026

core ref: 2a52a992df57d88d85e2d6d6aad393950af0944a

Copilot AI review requested due to automatic review settings April 28, 2026 22:47
@matYang matYang requested review from a team as code owners April 28, 2026 22:47
@github-actions
Copy link
Copy Markdown

👋 matYang, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a per-token-contract-type strategy registry to encapsulate EVM token deployment and pool-wiring logic, replacing scattered token-type switches across adapters/sequences and enabling reuse across pool versions.

Changes:

  • Added strategy package (interface + singleton registry) and registrations package to register known EVM token strategies at init.
  • Refactored v1.0.0 token deployment sequence and pool adapter role-grant logic to use the strategy registry.
  • Refactored v2.0.0 token pool deployment role-grant logic to use the strategy registry and added a TIP-20 “v2.0 unsupported” guard.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
chains/evm/deployment/v2_0_0/adapters/tokens.go Uses strategy registry for pool role grants; adds TIP-20 guard prior to pool deployment.
chains/evm/deployment/v1_0_0/sequences/token.go Replaces token-type switches/predicates with strategy registry dispatch (deploy, capabilities, admin grants).
chains/evm/deployment/v1_0_0/sequences/token_test.go Updates tests to query strategy capabilities instead of removed predicate helpers.
chains/evm/deployment/v1_0_0/adapters/pool_adapter.go Replaces token-type switch for pool role grants with strategy registry lookup.
chains/evm/deployment/v1_0_0/adapters/init.go Adds blank import to ensure strategies are registered before adapter usage.
chains/evm/deployment/tokens/strategy/strategy.go Defines the EVMTokenStrategy interface and capability flags.
chains/evm/deployment/tokens/strategy/registry.go Implements singleton registry and lookup helpers for EVM strategies.
chains/evm/deployment/tokens/strategy/registrations/registrations.go Registers concrete strategies for known token types (ERC20, BnM variants, TIP-20).
STRATEGY_REFACTOR.md Documents motivation, design, and refactor plan/decisions.
.gitignore Ignores new agent-related files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chains/evm/deployment/tokens/strategy/registrations/registrations.go Outdated
Comment thread chains/evm/deployment/tokens/strategy/registry.go Outdated
Comment thread chains/evm/deployment/v2_0_0/adapters/tokens.go Outdated
Comment thread chains/evm/deployment/v2_0_0/adapters/tokens.go Outdated
Comment thread chains/evm/deployment/tokens/strategy/registry.go Outdated
AnieeG
AnieeG previously approved these changes Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chains/evm/deployment/tokens/tokenimpl/impl.go Outdated
Comment thread chains/evm/deployment/v1_0_0/operations/tip20/tip20_ops.go
Comment thread chains/evm/deployment/v1_0_0/sequences/token.go
Comment thread chains/evm/deployment/v1_0_0/adapters/pool_adapter.go
Comment thread chains/evm/deployment/v1_0_0/adapters/pool_adapter.go Outdated
Comment thread chains/evm/deployment/tokens/tokenimpl/lookup.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

chains/evm/deployment/v1_0_0/sequences/token_test.go:207

  • The external-admin role assertions are currently nested under if caps.SupportsCCIPAdmin { ... }. That means tokens which support admin roles but don’t support CCIP admin would skip the admin-role verification. Consider gating CCIP-admin checks on SupportsCCIPAdmin, but gating admin-role checks separately on SupportsAdminRole (and only checking DEFAULT_ADMIN_ROLE when the underlying contract type supports it).
					caps := tokenimpl.Capabilities(tc.tokenType)
					if caps.SupportsCCIPAdmin {
						// Verify CCIP Admin was set correctly
						t.Log("  Verifying CCIP Admin...")
						onChainCCIPAdmin, err := tokenContract.GetCCIPAdmin(&bind.CallOpts{})
						require.NoError(t, err, "Failed to get CCIP admin from chain")
						require.Equal(t, ccipAdminAddr, onChainCCIPAdmin, "CCIP admin mismatch")
						t.Logf("  On-chain CCIP admin: %s (expected: %s)", onChainCCIPAdmin.Hex(), ccipAdminAddr.Hex())

						// TEST 2: Verify External Admins have the DEFAULT_ADMIN_ROLE
						t.Log("  Verifying External Admin roles...")
						defaultAdminRole, err := tokenContract.DEFAULTADMINROLE(&bind.CallOpts{})

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chains/evm/deployment/v1_0_0/sequences/token.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

chains/evm/deployment/v1_0_0/sequences/token_test.go:223

  • The admin-role assertions are currently gated on caps.SupportsCCIPAdmin, but the checks inside this block verify DEFAULT_ADMIN_ROLE membership (admin-role support), not CCIP-admin support. This will skip admin-role verification for token types that support admin roles but not CCIP admin, and it also couples two independent capabilities. Split this into separate conditionals (e.g., if caps.SupportsCCIPAdmin { ...GetCCIPAdmin... } and if caps.SupportsAdminRole { ...DEFAULT_ADMIN_ROLE/HasRole... }).
					caps := tokenimpl.Capabilities(tc.tokenType)
					if caps.SupportsCCIPAdmin {
						// Verify CCIP Admin was set correctly
						t.Log("  Verifying CCIP Admin...")
						onChainCCIPAdmin, err := tokenContract.GetCCIPAdmin(&bind.CallOpts{})
						require.NoError(t, err, "Failed to get CCIP admin from chain")
						require.Equal(t, ccipAdminAddr, onChainCCIPAdmin, "CCIP admin mismatch")
						t.Logf("  On-chain CCIP admin: %s (expected: %s)", onChainCCIPAdmin.Hex(), ccipAdminAddr.Hex())

						// TEST 2: Verify External Admins have the DEFAULT_ADMIN_ROLE
						t.Log("  Verifying External Admin roles...")
						defaultAdminRole, err := tokenContract.DEFAULTADMINROLE(&bind.CallOpts{})
						require.NoError(t, err, "Failed to get DEFAULT_ADMIN_ROLE")
						t.Logf("  DEFAULT_ADMIN_ROLE: 0x%x", defaultAdminRole)

						// Verify externalAdmin has the admin role
						hasRole, err := tokenContract.HasRole(&bind.CallOpts{}, defaultAdminRole, common.HexToAddress(externalAdmin))
						require.NoError(t, err, "Failed to check HasRole for externalAdmin")
						require.True(t, hasRole, "External admin should have DEFAULT_ADMIN_ROLE")
						t.Logf("  External admin (%s) has DEFAULT_ADMIN_ROLE: %v", externalAdmin, hasRole)

						// Verify deployer still has the admin role (original deployer should retain role)
						deployerHasRole, err := tokenContract.HasRole(&bind.CallOpts{}, defaultAdminRole, deployerAddr)
						require.NoError(t, err, "Failed to check HasRole for deployer")
						require.True(t, deployerHasRole, "Deployer should still have DEFAULT_ADMIN_ROLE")
						t.Logf("  Deployer (%s) has DEFAULT_ADMIN_ROLE: %v", deployerAddr.Hex(), deployerHasRole)
					}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chains/evm/deployment/v1_0_0/sequences/token.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Metric token-type-adaptor-poc main
Coverage 70.1% 69.9%

@tt-cll tt-cll added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit 9611361 May 5, 2026
47 checks passed
@tt-cll tt-cll deleted the token-type-adaptor-poc branch May 5, 2026 18:37
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.

5 participants