Skip to content

Commit b401df5

Browse files
More cs (#35)
* add link deployment cs * fix imports * add dummy reciever cs * added registry reciever * cleanup * add addpkgId offramp * ci fixes --------- Co-authored-by: RodrigoAD <15104916+RodrigoAD@users.noreply.github.com>
1 parent 580779c commit b401df5

File tree

15 files changed

+899
-295
lines changed

15 files changed

+899
-295
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package changesets
2+
3+
import (
4+
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
5+
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
6+
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
7+
"github.com/smartcontractkit/chainlink-sui/deployment"
8+
sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops"
9+
burnminttokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_burn_mint_token_pool"
10+
lockreleasetokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_lock_release_token_pool"
11+
managedtokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_managed_token_pool"
12+
)
13+
14+
type DeployTPAndConfigureConfig struct {
15+
SuiChainSelector uint64
16+
TokenPoolTypes []string
17+
ManagedTPInput managedtokenpoolops.SeqDeployAndInitManagedTokenPoolInput
18+
LockReleaseTPInput lockreleasetokenpoolops.DeployAndInitLockReleaseTokenPoolInput
19+
BurnMintTpInput burnminttokenpoolops.DeployAndInitBurnMintTokenPoolInput
20+
}
21+
22+
// ConnectSuiToEVM connects sui chain with EVM
23+
type DeployTPAndConfigure struct{}
24+
25+
var _ cldf.ChangeSetV2[DeployTPAndConfigureConfig] = DeployTPAndConfigure{}
26+
27+
// Apply implements deployment.ChangeSetV2.
28+
func (d DeployTPAndConfigure) Apply(e cldf.Environment, config DeployTPAndConfigureConfig) (cldf.ChangesetOutput, error) {
29+
state, err := deployment.LoadOnchainStatesui(e)
30+
if err != nil {
31+
return cldf.ChangesetOutput{}, err
32+
}
33+
34+
seqReports := make([]operations.Report[any, any], 0)
35+
36+
suiChains := e.BlockChains.SuiChains()
37+
suiChain := suiChains[config.SuiChainSelector]
38+
39+
deployerAddr, err := suiChain.Signer.GetAddress()
40+
if err != nil {
41+
return cldf.ChangesetOutput{}, err
42+
}
43+
44+
deps := sui_ops.OpTxDeps{
45+
Client: suiChain.Client,
46+
Signer: suiChain.Signer,
47+
GetCallOpts: func() *bind.CallOpts {
48+
b := uint64(400_000_000)
49+
return &bind.CallOpts{
50+
WaitForExecution: true,
51+
GasBudget: &b,
52+
}
53+
},
54+
}
55+
// the below can be part of (DeployAndInitBurnMintTokenPoolSequence)
56+
// Initialize TP
57+
// ApplyChainUpdates
58+
// SetChainRateLimiterConfigs
59+
// Add remote TP
60+
61+
for _, tokenPoolType := range config.TokenPoolTypes {
62+
if tokenPoolType == "bnm" {
63+
config.BurnMintTpInput.CCIPPackageId = state[config.SuiChainSelector].CCIPAddress
64+
config.BurnMintTpInput.CCIPTokenPoolPackageId = state[config.SuiChainSelector].TokenPoolAddress
65+
config.BurnMintTpInput.MCMSAddress = state[config.SuiChainSelector].MCMsAddress
66+
config.BurnMintTpInput.MCMSOwnerAddress = deployerAddr
67+
config.BurnMintTpInput.CCIPObjectRefObjectId = state[config.SuiChainSelector].CCIPObjectRef
68+
config.BurnMintTpInput.TokenPoolAdministrator = deployerAddr // check with felix if this is fine
69+
70+
_, err = operations.ExecuteSequence(e.OperationsBundle, burnminttokenpoolops.DeployAndInitBurnMintTokenPoolSequence, deps, config.BurnMintTpInput)
71+
if err != nil {
72+
return cldf.ChangesetOutput{}, err
73+
}
74+
}
75+
76+
if tokenPoolType == "lnr" {
77+
config.LockReleaseTPInput.CCIPPackageId = state[config.SuiChainSelector].CCIPAddress
78+
config.LockReleaseTPInput.CCIPTokenPoolPackageId = state[config.SuiChainSelector].TokenPoolAddress
79+
config.LockReleaseTPInput.MCMSAddress = state[config.SuiChainSelector].MCMsAddress
80+
config.LockReleaseTPInput.MCMSOwnerAddress = deployerAddr
81+
config.LockReleaseTPInput.CCIPObjectRefObjectId = state[config.SuiChainSelector].CCIPObjectRef
82+
config.LockReleaseTPInput.TokenPoolAdministrator = deployerAddr
83+
84+
_, err = operations.ExecuteSequence(e.OperationsBundle, lockreleasetokenpoolops.DeployAndInitLockReleaseTokenPoolSequence, deps, config.LockReleaseTPInput)
85+
if err != nil {
86+
return cldf.ChangesetOutput{}, err
87+
}
88+
}
89+
90+
if tokenPoolType == "managed" {
91+
config.ManagedTPInput.CCIPPackageId = state[config.SuiChainSelector].CCIPAddress
92+
config.ManagedTPInput.CCIPTokenPoolPackageId = state[config.SuiChainSelector].TokenPoolAddress
93+
config.ManagedTPInput.MCMSAddress = state[config.SuiChainSelector].MCMsAddress
94+
config.ManagedTPInput.MCMSOwnerAddress = deployerAddr
95+
config.ManagedTPInput.CCIPObjectRefObjectId = state[config.SuiChainSelector].CCIPObjectRef
96+
config.ManagedTPInput.TokenPoolAdministrator = deployerAddr
97+
98+
_, err = operations.ExecuteSequence(e.OperationsBundle, managedtokenpoolops.DeployAndInitManagedTokenPoolSequence, deps, config.ManagedTPInput)
99+
if err != nil {
100+
return cldf.ChangesetOutput{}, err
101+
}
102+
}
103+
}
104+
105+
return cldf.ChangesetOutput{
106+
Reports: seqReports,
107+
}, nil
108+
}
109+
110+
// VerifyPreconditions implements deployment.ChangeSetV2.
111+
func (d DeployTPAndConfigure) VerifyPreconditions(e cldf.Environment, config DeployTPAndConfigureConfig) error {
112+
return nil
113+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package changesets
2+
3+
import (
4+
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
5+
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
6+
cld_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations"
7+
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
8+
sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops"
9+
burnminttokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_burn_mint_token_pool"
10+
lockreleasetokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_lock_release_token_pool"
11+
managedtokenpoolops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_managed_token_pool"
12+
)
13+
14+
type AddRemoteTPConfig struct {
15+
SuiChainSelector uint64
16+
TokenPoolTypes []string
17+
18+
PoolPackageId string
19+
TokenpoolStateObjectId string
20+
TokenPoolOwnerCapId string
21+
CoinObjectTypeArg string
22+
RemoteChainSelectors []uint64
23+
RemotePoolAddressToAdd []string
24+
}
25+
26+
var _ cldf.ChangeSetV2[AddRemoteTPConfig] = AddRemoteTP{}
27+
28+
// DeployAptosChain deploys Sui chain packages and modules
29+
type AddRemoteTP struct{}
30+
31+
// Apply implements deployment.ChangeSetV2.
32+
func (d AddRemoteTP) Apply(e cldf.Environment, config AddRemoteTPConfig) (cldf.ChangesetOutput, error) {
33+
ab := cldf.NewMemoryAddressBook()
34+
seqReports := make([]operations.Report[any, any], 0)
35+
36+
suiChains := e.BlockChains.SuiChains()
37+
38+
suiChain := suiChains[config.SuiChainSelector]
39+
40+
deps := sui_ops.OpTxDeps{
41+
Client: suiChain.Client,
42+
Signer: suiChain.Signer,
43+
GetCallOpts: func() *bind.CallOpts {
44+
b := uint64(400_000_000)
45+
return &bind.CallOpts{
46+
WaitForExecution: true,
47+
GasBudget: &b,
48+
}
49+
},
50+
}
51+
52+
// Todo: validate that len of TokenpoolTypes == RemoteChainSelectors == RemotePoolAddressToAdd
53+
54+
for _, tokenPoolType := range config.TokenPoolTypes {
55+
if tokenPoolType == "lnr" {
56+
for i, chainSelector := range config.RemoteChainSelectors {
57+
_, err := cld_ops.ExecuteOperation(
58+
e.OperationsBundle,
59+
lockreleasetokenpoolops.LockReleaseTokenPoolAddRemotePoolOp,
60+
deps,
61+
lockreleasetokenpoolops.LockReleaseTokenPoolAddRemotePoolInput{
62+
LockReleaseTokenPoolPackageId: config.PoolPackageId,
63+
CoinObjectTypeArg: config.CoinObjectTypeArg,
64+
StateObjectId: config.TokenpoolStateObjectId,
65+
OwnerCap: config.TokenPoolOwnerCapId,
66+
RemoteChainSelector: chainSelector,
67+
RemotePoolAddress: config.RemotePoolAddressToAdd[i], // one address at a time
68+
},
69+
)
70+
if err != nil {
71+
return cldf.ChangesetOutput{}, err
72+
}
73+
}
74+
}
75+
76+
if tokenPoolType == "bnm" {
77+
for i, chainSelector := range config.RemoteChainSelectors {
78+
_, err := cld_ops.ExecuteOperation(
79+
e.OperationsBundle,
80+
burnminttokenpoolops.BurnMintTokenPoolAddRemotePoolOp,
81+
deps,
82+
burnminttokenpoolops.BurnMintTokenPoolAddRemotePoolInput{
83+
BurnMintTokenPoolPackageId: config.PoolPackageId,
84+
CoinObjectTypeArg: config.CoinObjectTypeArg,
85+
StateObjectId: config.TokenpoolStateObjectId,
86+
OwnerCap: config.TokenPoolOwnerCapId,
87+
RemoteChainSelector: chainSelector,
88+
RemotePoolAddress: config.RemotePoolAddressToAdd[i], // one address at a time
89+
},
90+
)
91+
if err != nil {
92+
return cldf.ChangesetOutput{}, err
93+
}
94+
}
95+
}
96+
97+
if tokenPoolType == "managed" {
98+
for i, chainSelector := range config.RemoteChainSelectors {
99+
100+
_, err := cld_ops.ExecuteOperation(
101+
e.OperationsBundle,
102+
managedtokenpoolops.ManagedTokenPoolAddRemotePoolOp,
103+
deps,
104+
managedtokenpoolops.ManagedTokenPoolAddRemotePoolInput{
105+
ManagedTokenPoolPackageId: config.PoolPackageId,
106+
CoinObjectTypeArg: config.CoinObjectTypeArg,
107+
StateObjectId: config.TokenpoolStateObjectId,
108+
OwnerCap: config.TokenPoolOwnerCapId,
109+
RemoteChainSelector: chainSelector,
110+
RemotePoolAddress: config.RemotePoolAddressToAdd[i], // one address at a time
111+
},
112+
)
113+
if err != nil {
114+
return cldf.ChangesetOutput{}, err
115+
}
116+
}
117+
}
118+
}
119+
120+
return cldf.ChangesetOutput{
121+
AddressBook: ab,
122+
Reports: seqReports,
123+
}, nil
124+
}
125+
126+
// VerifyPreconditions implements deployment.ChangeSetV2.
127+
func (d AddRemoteTP) VerifyPreconditions(e cldf.Environment, config AddRemoteTPConfig) error {
128+
return nil
129+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package changesets
2+
3+
import (
4+
"fmt"
5+
6+
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
7+
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
8+
"github.com/smartcontractkit/chainlink-sui/bindings/bind"
9+
"github.com/smartcontractkit/chainlink-sui/deployment"
10+
sui_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops"
11+
ccip_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip"
12+
ccip_offramp_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_offramp"
13+
ccip_onramp_ops "github.com/smartcontractkit/chainlink-sui/deployment/ops/ccip_onramp"
14+
)
15+
16+
type ConnectSuiToEVMConfig struct {
17+
SuiChainSelector uint64
18+
FeeQuoterApplyTokenTransferFeeConfigUpdatesInput ccip_ops.FeeQuoterApplyTokenTransferFeeConfigUpdatesInput
19+
FeeQuoterApplyDestChainConfigUpdatesInput ccip_ops.FeeQuoterApplyDestChainConfigUpdatesInput
20+
FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput ccip_ops.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput
21+
ApplyDestChainConfigureOnRampInput ccip_onramp_ops.ApplyDestChainConfigureOnRampInput
22+
ApplySourceChainConfigUpdateInput ccip_offramp_ops.ApplySourceChainConfigUpdateInput
23+
}
24+
25+
// ConnectSuiToEVM connects sui chain with EVM
26+
type ConnectSuiToEVM struct{}
27+
28+
var _ cldf.ChangeSetV2[ConnectSuiToEVMConfig] = ConnectSuiToEVM{}
29+
30+
// Apply implements deployment.ChangeSetV2.
31+
func (d ConnectSuiToEVM) Apply(e cldf.Environment, config ConnectSuiToEVMConfig) (cldf.ChangesetOutput, error) {
32+
state, err := deployment.LoadOnchainStatesui(e)
33+
if err != nil {
34+
return cldf.ChangesetOutput{}, err
35+
}
36+
37+
seqReports := make([]operations.Report[any, any], 0)
38+
39+
suiChains := e.BlockChains.SuiChains()
40+
suiChain := suiChains[config.SuiChainSelector]
41+
42+
deps := sui_ops.OpTxDeps{
43+
Client: suiChain.Client,
44+
Signer: suiChain.Signer,
45+
GetCallOpts: func() *bind.CallOpts {
46+
b := uint64(400_000_000)
47+
return &bind.CallOpts{
48+
WaitForExecution: true,
49+
GasBudget: &b,
50+
}
51+
},
52+
}
53+
54+
// Configure FeeQuoter
55+
config.FeeQuoterApplyTokenTransferFeeConfigUpdatesInput.CCIPPackageId = state[config.SuiChainSelector].CCIPAddress
56+
config.FeeQuoterApplyTokenTransferFeeConfigUpdatesInput.StateObjectId = state[config.SuiChainSelector].CCIPObjectRef
57+
config.FeeQuoterApplyTokenTransferFeeConfigUpdatesInput.OwnerCapObjectId = state[config.SuiChainSelector].CCIPOwnerCapObjectId
58+
reportFeeQuoterApplyTokenTransferFeeConfigUpdatesOp, err := operations.ExecuteOperation(e.OperationsBundle, ccip_ops.FeeQuoterApplyTokenTransferFeeConfigUpdatesOp, deps, config.FeeQuoterApplyTokenTransferFeeConfigUpdatesInput)
59+
if err != nil {
60+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to run FeeQuoterApplyTokenTransferFeeConfigUpdatesOp for Sui chain %d: %w", config.SuiChainSelector, err)
61+
}
62+
seqReports = append(seqReports, []operations.Report[any, any]{reportFeeQuoterApplyTokenTransferFeeConfigUpdatesOp.ToGenericReport()}...)
63+
64+
config.FeeQuoterApplyDestChainConfigUpdatesInput.CCIPPackageId = state[config.SuiChainSelector].CCIPAddress
65+
config.FeeQuoterApplyDestChainConfigUpdatesInput.StateObjectId = state[config.SuiChainSelector].CCIPObjectRef
66+
config.FeeQuoterApplyDestChainConfigUpdatesInput.OwnerCapObjectId = state[config.SuiChainSelector].CCIPOwnerCapObjectId
67+
reportFeeQuoterApplyDestChainConfigUpdatesOp, err := operations.ExecuteOperation(e.OperationsBundle, ccip_ops.FeeQuoterApplyDestChainConfigUpdatesOp, deps, config.FeeQuoterApplyDestChainConfigUpdatesInput)
68+
if err != nil {
69+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to run FeeQuoterApplyDestChainConfigUpdatesOp for Sui chain %d: %w", config.SuiChainSelector, err)
70+
}
71+
seqReports = append(seqReports, []operations.Report[any, any]{reportFeeQuoterApplyDestChainConfigUpdatesOp.ToGenericReport()}...)
72+
73+
config.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput.CCIPPackageId = state[config.SuiChainSelector].CCIPAddress
74+
config.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput.StateObjectId = state[config.SuiChainSelector].CCIPObjectRef
75+
config.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput.OwnerCapObjectId = state[config.SuiChainSelector].CCIPOwnerCapObjectId
76+
reportFeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesOp, err := operations.ExecuteOperation(e.OperationsBundle, ccip_ops.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesOp, deps, config.FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesInput)
77+
if err != nil {
78+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to run FeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesOp for Sui chain %d: %w", config.SuiChainSelector, err)
79+
}
80+
seqReports = append(seqReports, []operations.Report[any, any]{reportFeeQuoterApplyPremiumMultiplierWeiPerEthUpdatesOp.ToGenericReport()}...)
81+
82+
// Configure OnRamp
83+
config.ApplyDestChainConfigureOnRampInput.OnRampPackageId = state[config.SuiChainSelector].OnRampAddress
84+
config.ApplyDestChainConfigureOnRampInput.OwnerCapObjectId = state[config.SuiChainSelector].OnRampOwnerCapObjectId
85+
config.ApplyDestChainConfigureOnRampInput.StateObjectId = state[config.SuiChainSelector].OnRampStateObjectId
86+
config.ApplyDestChainConfigureOnRampInput.CCIPObjectRefId = state[config.SuiChainSelector].CCIPObjectRef
87+
reportApplyDestChainConfigUpdateOp, err := operations.ExecuteOperation(e.OperationsBundle, ccip_onramp_ops.ApplyDestChainConfigUpdateOp, deps, config.ApplyDestChainConfigureOnRampInput)
88+
if err != nil {
89+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to run ApplyDestChainConfigUpdateOp for Sui chain %d: %w", config.SuiChainSelector, err)
90+
}
91+
seqReports = append(seqReports, []operations.Report[any, any]{reportApplyDestChainConfigUpdateOp.ToGenericReport()}...)
92+
93+
// Configure OffRamp
94+
config.ApplySourceChainConfigUpdateInput.CCIPObjectRef = state[config.SuiChainSelector].CCIPObjectRef
95+
config.ApplySourceChainConfigUpdateInput.OffRampPackageId = state[config.SuiChainSelector].OffRampAddress
96+
config.ApplySourceChainConfigUpdateInput.OffRampStateId = state[config.SuiChainSelector].OffRampStateObjectId
97+
config.ApplySourceChainConfigUpdateInput.OwnerCapObjectId = state[config.SuiChainSelector].OffRampOwnerCapId
98+
reportApplySourceChainConfigUpdatesOp, err := operations.ExecuteOperation(e.OperationsBundle, ccip_offramp_ops.ApplySourceChainConfigUpdatesOp, deps, config.ApplySourceChainConfigUpdateInput)
99+
if err != nil {
100+
return cldf.ChangesetOutput{}, fmt.Errorf("failed to run ApplySourceChainConfigUpdatesOp for Sui chain %d: %w", config.SuiChainSelector, err)
101+
}
102+
seqReports = append(seqReports, []operations.Report[any, any]{reportApplySourceChainConfigUpdatesOp.ToGenericReport()}...)
103+
104+
return cldf.ChangesetOutput{
105+
Reports: seqReports,
106+
}, nil
107+
}
108+
109+
// VerifyPreconditions implements deployment.ChangeSetV2.
110+
func (d ConnectSuiToEVM) VerifyPreconditions(e cldf.Environment, config ConnectSuiToEVMConfig) error {
111+
return nil
112+
}

0 commit comments

Comments
 (0)