-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathseq_mcm_with_config.go
More file actions
90 lines (81 loc) · 3.72 KB
/
Copy pathseq_mcm_with_config.go
File metadata and controls
90 lines (81 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package sequences
import (
"fmt"
"github.com/Masterminds/semver/v3"
"github.com/ethereum/go-ethereum/common"
cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
mcmscontracts "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/contracts/mcms"
cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils"
"github.com/smartcontractkit/chainlink-deployments-framework/operations"
"github.com/smartcontractkit/mcms/sdk"
mcmsTypes "github.com/smartcontractkit/mcms/types"
opevmlegacy "github.com/smartcontractkit/cld-changesets/legacy/mcms/internal/family/evm/operations"
evmops "github.com/smartcontractkit/cld-changesets/legacy/mcms/oputils"
)
type SeqDeployMCMWithConfigInput struct {
ContractType cldf.ContractType `json:"contractType"`
MCMConfig mcmsTypes.Config `json:"mcmConfig"`
ChainSelector uint64 `json:"chainSelector"`
GasBoostConfig *cldfproposalutils.GasBoostConfig `json:"gasBoostConfig"`
Qualifier *string `json:"qualifier"`
}
type SeqDeployMCMWithConfigOutput struct {
Address common.Address `json:"address"`
}
var SeqDeployMCMWithConfig = operations.NewSequence(
"seq-deploy-mcm-with-config",
semver.MustParse("1.0.0"),
"Deploys MCM contract & sets config",
func(b operations.Bundle, deps cldf_evm.Chain, in SeqDeployMCMWithConfigInput) (evmops.EVMDeployOutput, error) {
// Deploy MCM contract
var deployReport operations.Report[evmops.EVMDeployInput[any], evmops.EVMDeployOutput]
var deployErr error
switch in.ContractType {
case mcmscontracts.BypasserManyChainMultisig:
deployReport, deployErr = operations.ExecuteOperation(b, opevmlegacy.OpDeployBypasserMCM, deps, evmops.EVMDeployInput[any]{
ChainSelector: in.ChainSelector,
Qualifier: in.Qualifier,
}, evmops.RetryDeploymentWithGasBoost[any](in.GasBoostConfig))
case mcmscontracts.ProposerManyChainMultisig:
deployReport, deployErr = operations.ExecuteOperation(b, opevmlegacy.OpDeployProposerMCM, deps, evmops.EVMDeployInput[any]{
ChainSelector: in.ChainSelector,
Qualifier: in.Qualifier,
}, evmops.RetryDeploymentWithGasBoost[any](in.GasBoostConfig))
case mcmscontracts.CancellerManyChainMultisig:
deployReport, deployErr = operations.ExecuteOperation(b, opevmlegacy.OpDeployCancellerMCM, deps, evmops.EVMDeployInput[any]{
ChainSelector: in.ChainSelector,
Qualifier: in.Qualifier,
}, evmops.RetryDeploymentWithGasBoost[any](in.GasBoostConfig))
default:
return evmops.EVMDeployOutput{}, fmt.Errorf("unsupported contract type for seq-deploy-mcm-with-config: %s", in.ContractType)
}
if deployErr != nil {
return evmops.EVMDeployOutput{}, fmt.Errorf("failed to deploy %s: %w", in.ContractType, deployErr)
}
// Set config
groupQuorums, groupParents, signerAddresses, signerGroups, err := sdk.ExtractSetConfigInputs(&in.MCMConfig)
if err != nil {
return evmops.EVMDeployOutput{}, err
}
_, err = operations.ExecuteOperation(b, opevmlegacy.OpEVMSetConfigMCM,
deps,
evmops.EVMCallInput[opevmlegacy.OpEVMSetConfigMCMInput]{
ChainSelector: in.ChainSelector,
Address: deployReport.Output.Address,
NoSend: false,
CallInput: opevmlegacy.OpEVMSetConfigMCMInput{
SignerAddresses: signerAddresses,
SignerGroups: signerGroups,
GroupQuorums: groupQuorums,
GroupParents: groupParents,
},
},
evmops.RetryCallWithGasBoost[opevmlegacy.OpEVMSetConfigMCMInput](in.GasBoostConfig),
)
if err != nil {
return evmops.EVMDeployOutput{}, err
}
return deployReport.Output, nil
},
)