@@ -12,7 +12,6 @@ import (
1212 evm_tokens "github.com/smartcontractkit/chainlink-ccip/ccv/chains/evm/deployment/v1_7_0/sequences/tokens"
1313 "github.com/smartcontractkit/chainlink-ccip/ccv/chains/evm/deployment/v2_0_0/operations/siloed_lock_release_token_pool"
1414 "github.com/smartcontractkit/chainlink-ccip/ccv/chains/evm/deployment/v2_0_0/operations/token_pool"
15- evmutils "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/utils"
1615 "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/utils/operations/contract"
1716 bnmOps "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/operations/burn_mint_erc20"
1817 bnmDripOps "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/operations/burn_mint_erc20_with_drip"
@@ -22,12 +21,9 @@ import (
2221 tarseq "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_5_0/sequences"
2322 evm16seq "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/sequences"
2423
25- ownershipAdapters "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_0_0/adapters"
26- deployapi "github.com/smartcontractkit/chainlink-ccip/deployment/deploy"
2724 "github.com/smartcontractkit/chainlink-ccip/deployment/tokens"
2825 cciputils "github.com/smartcontractkit/chainlink-ccip/deployment/utils"
2926 datastore_utils "github.com/smartcontractkit/chainlink-ccip/deployment/utils/datastore"
30- "github.com/smartcontractkit/chainlink-ccip/deployment/utils/mcms"
3127 "github.com/smartcontractkit/chainlink-ccip/deployment/utils/sequences"
3228 "github.com/smartcontractkit/chainlink-deployments-framework/chain"
3329 "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
@@ -39,18 +35,17 @@ import (
3935var _ tokens.TokenAdapter = & TokenAdapter {}
4036
4137// TokenAdapter is the adapter for EVM tokens using 2.0.0 token pools.
42- type TokenAdapter struct {}
38+ // It embeds the v1.6.0 EVMAdapter (which itself embeds EVMTokenBase) and
39+ // overrides only the methods that differ for 2.0.0 pools.
40+ type TokenAdapter struct {
41+ evm16seq.EVMAdapter
42+ }
4343
4444// ConfigureTokenForTransfersSequence returns the sequence for configuring an EVM token with a 2.0.0 token pool.
4545func (t * TokenAdapter ) ConfigureTokenForTransfersSequence () * cldf_ops.Sequence [tokens.ConfigureTokenForTransfersInput , sequences.OnChainOutput , chain.BlockChains ] {
4646 return evm_tokens .ConfigureTokenForTransfers
4747}
4848
49- // AddressRefToBytes returns an EVM address reference as an EVM address.
50- func (t * TokenAdapter ) AddressRefToBytes (ref datastore.AddressRef ) ([]byte , error ) {
51- return common .HexToAddress (ref .Address ).Bytes (), nil
52- }
53-
5449// DeriveTokenAddress derives the token address from a token pool reference, returning it as an EVM address.
5550func (t * TokenAdapter ) DeriveTokenAddress (e deployment.Environment , chainSelector uint64 , poolRef datastore.AddressRef ) ([]byte , error ) {
5651 evmChain , ok := e .BlockChains .EVMChains ()[chainSelector ]
@@ -70,39 +65,6 @@ func (t *TokenAdapter) DeriveTokenAddress(e deployment.Environment, chainSelecto
7065 })
7166}
7267
73- func (t * TokenAdapter ) DeployToken () * cldf_ops.Sequence [tokens.DeployTokenInput , sequences.OnChainOutput , chain.BlockChains ] {
74- return evm16seq .DeployToken
75- }
76-
77- func (t * TokenAdapter ) DeployTokenVerify (e deployment.Environment , input tokens.DeployTokenInput ) error {
78- tokenAddr , err := datastore_utils .FindAndFormatRef (input .ExistingDataStore , datastore.AddressRef {
79- ChainSelector : input .ChainSelector ,
80- Type : datastore .ContractType (input .Type ),
81- Qualifier : input .Symbol ,
82- }, input .ChainSelector , datastore_utils .FullRef )
83- if err == nil {
84- e .OperationsBundle .Logger .Info ("Token already deployed at address:" , tokenAddr .Address )
85- return nil
86- }
87-
88- if err := evmutils .ValidateEVMAddress (input .CCIPAdmin , "CCIPAdmin" ); err != nil {
89- return err
90- }
91- if err := evmutils .ValidateEVMAddress (input .ExternalAdmin , "ExternalAdmin" ); err != nil {
92- return err
93- }
94-
95- if input .Decimals > 18 {
96- return fmt .Errorf ("EVM tokens cannot have more than 18 decimals, got %d" , input .Decimals )
97- }
98-
99- if input .PreMint != nil && input .Supply != nil && * input .Supply != 0 && * input .PreMint > * input .Supply {
100- return fmt .Errorf ("pre-mint amount cannot be greater than max supply, got pre-mint %d and supply %d" , * input .PreMint , * input .Supply )
101- }
102-
103- return nil
104- }
105-
10668func (t * TokenAdapter ) DeployTokenPoolForToken () * cldf_ops.Sequence [tokens.DeployTokenPoolInput , sequences.OnChainOutput , chain.BlockChains ] {
10769 return cldf_ops .NewSequence (
10870 "evm-2.0-adapter:deploy-token-pool-for-token" ,
@@ -286,11 +248,6 @@ func (t *TokenAdapter) DeployTokenPoolForToken() *cldf_ops.Sequence[tokens.Deplo
286248 )
287249}
288250
289- func (t * TokenAdapter ) SetPool () * cldf_ops.Sequence [tokens.TPRLRemotes , sequences.OnChainOutput , chain.BlockChains ] {
290- // TODO implement me
291- return nil
292- }
293-
294251func (t * TokenAdapter ) DeriveTokenDecimals (e deployment.Environment , chainSelector uint64 , poolRef datastore.AddressRef , token []byte ) (uint8 , error ) {
295252 evmChain , ok := e .BlockChains .EVMChains ()[chainSelector ]
296253 if ! ok {
@@ -329,10 +286,6 @@ func (t *TokenAdapter) DeriveTokenDecimals(e deployment.Environment, chainSelect
329286 return decimals , nil
330287}
331288
332- func (t * TokenAdapter ) DeriveTokenPoolCounterpart (e deployment.Environment , chainSelector uint64 , tokenPool []byte , token []byte ) ([]byte , error ) {
333- return tokenPool , nil
334- }
335-
336289func (t * TokenAdapter ) SetTokenPoolRateLimits () * cldf_ops.Sequence [tokens.TPRLRemotes , sequences.OnChainOutput , chain.BlockChains ] {
337290 return cldf_ops .NewSequence (
338291 "evm-2.0-adapter:set-token-pool-rate-limits" ,
@@ -481,55 +434,6 @@ func (t *TokenAdapter) ManualRegistration() *cldf_ops.Sequence[tokens.ManualRegi
481434 })
482435}
483436
484- func (t * TokenAdapter ) UpdateAuthorities () * cldf_ops.Sequence [tokens.UpdateAuthoritiesInput , sequences.OnChainOutput , * deployment.Environment ] {
485- return cldf_ops .NewSequence (
486- "evm-2.0-adapter:update-authorities" ,
487- cciputils .Version_2_0_0 ,
488- "Transfer token pool ownership to timelock on EVM chain" ,
489- func (b cldf_ops.Bundle , e * deployment.Environment , input tokens.UpdateAuthoritiesInput ) (sequences.OnChainOutput , error ) {
490- evmChain , ok := e .BlockChains .EVMChains ()[input .ChainSelector ]
491- if ! ok {
492- return sequences.OnChainOutput {}, fmt .Errorf ("chain with selector %d not found" , input .ChainSelector )
493- }
494-
495- timelockRef , err := datastore_utils .FindAndFormatRef (e .DataStore , datastore.AddressRef {
496- Type : datastore .ContractType (cciputils .RBACTimelock ),
497- ChainSelector : evmChain .Selector ,
498- Qualifier : cciputils .CLLQualifier ,
499- }, evmChain .Selector , datastore_utils .FullRef )
500- if err != nil {
501- return sequences.OnChainOutput {}, fmt .Errorf ("failed to find timelock for chain %d: %w" , input .ChainSelector , err )
502- }
503-
504- adapter := & ownershipAdapters.EVMTransferOwnershipAdapter {}
505- if err := adapter .InitializeTimelockAddress (* e , mcms.Input {Qualifier : cciputils .CLLQualifier }); err != nil {
506- return sequences.OnChainOutput {}, fmt .Errorf ("failed to initialize timelock address: %w" , err )
507- }
508-
509- ownershipInput := deployapi.TransferOwnershipPerChainInput {
510- ChainSelector : evmChain .Selector ,
511- CurrentOwner : evmChain .DeployerKey .From .Hex (),
512- ProposedOwner : timelockRef .Address ,
513- ContractRef : []datastore.AddressRef {input .TokenPoolRef },
514- }
515-
516- var result sequences.OnChainOutput
517- result , err = sequences .RunAndMergeSequence (b , e .BlockChains ,
518- adapter .SequenceTransferOwnershipViaMCMS (), ownershipInput , result )
519- if err != nil {
520- return sequences.OnChainOutput {}, fmt .Errorf ("failed to transfer ownership on chain %d: %w" , input .ChainSelector , err )
521- }
522-
523- result , err = sequences .RunAndMergeSequence (b , e .BlockChains ,
524- adapter .SequenceAcceptOwnership (), ownershipInput , result )
525- if err != nil {
526- return sequences.OnChainOutput {}, fmt .Errorf ("failed to accept ownership on chain %d: %w" , input .ChainSelector , err )
527- }
528-
529- return result , nil
530- })
531- }
532-
533437func (t * TokenAdapter ) MigrateLockReleasePoolLiquiditySequence () * cldf_ops.Sequence [tokens.MigrateLockReleasePoolLiquidityInput , sequences.OnChainOutput , chain.BlockChains ] {
534438 return evm_tokens .MigrateLockReleasePoolLiquidity
535439}
0 commit comments