Skip to content

Commit

Permalink
CCIP-2573: Adding Test router setup (#16503)
Browse files Browse the repository at this point in the history
* CCIP-2573: Adding Test router setup

add validation

* Adding USDCTokenPools view

* lint fix

* fix side-effects

* Fix state view

* lint fix

* review comments

* additonal check
  • Loading branch information
b-gopalswami authored Feb 27, 2025
1 parent 1efe807 commit b0c08a3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions deployment/ccip/changeset/v1_5_1/cs_deploy_usdc_token_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func (i DeployUSDCTokenPoolInput) Validate(ctx context.Context, chain deployment
// DeployUSDCTokenPoolContractsConfig defines the USDC token pool contracts that need to be deployed on each chain.
type DeployUSDCTokenPoolContractsConfig struct {
// USDCPools defines the per-chain configuration of each new USDC pool.
USDCPools map[uint64]DeployUSDCTokenPoolInput
USDCPools map[uint64]DeployUSDCTokenPoolInput
IsTestRouter bool
}

func (c DeployUSDCTokenPoolContractsConfig) Validate(env deployment.Environment) error {
Expand All @@ -101,9 +102,12 @@ func (c DeployUSDCTokenPoolContractsConfig) Validate(env deployment.Environment)
if !ok {
return fmt.Errorf("chain with selector %d does not exist in state", chainSelector)
}
if chainState.Router == nil {
if !c.IsTestRouter && chainState.Router == nil {
return fmt.Errorf("missing router on %s", chain)
}
if c.IsTestRouter && chainState.TestRouter == nil {
return fmt.Errorf("missing test router on %s", chain)
}
if chainState.RMNProxy == nil {
return fmt.Errorf("missing rmnProxy on %s", chain)
}
Expand All @@ -130,12 +134,15 @@ func DeployUSDCTokenPoolContractsChangeset(env deployment.Environment, c DeployU
for chainSelector, poolConfig := range c.USDCPools {
chain := env.Chains[chainSelector]
chainState := state.Chains[chainSelector]

router := chainState.Router
if c.IsTestRouter {
router = chainState.TestRouter
}
_, err := deployment.DeployContract(env.Logger, chain, newAddresses,
func(chain deployment.Chain) deployment.ContractDeploy[*usdc_token_pool.USDCTokenPool] {
poolAddress, tx, usdcTokenPool, err := usdc_token_pool.DeployUSDCTokenPool(
chain.DeployerKey, chain.Client, poolConfig.TokenMessenger, poolConfig.TokenAddress,
poolConfig.AllowList, chainState.RMNProxy.Address(), chainState.Router.Address(),
poolConfig.AllowList, chainState.RMNProxy.Address(), router.Address(),
)
return deployment.ContractDeploy[*usdc_token_pool.USDCTokenPool]{
Address: poolAddress,
Expand Down

0 comments on commit b0c08a3

Please sign in to comment.