seqs

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SeqEVMDeployMCMWithConfig = 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) (opsevm.EVMDeployOutput, error) {
		// Deploy MCM contract
		var deployReport operations.Report[opsevm.EVMDeployInput[any], opsevm.EVMDeployOutput]
		var deployErr error
		switch in.ContractType {
		case mcmscontracts.BypasserManyChainMultisig:
			deployReport, deployErr = operations.ExecuteOperation(b, opsevm.OpEVMDeployBypasserMCM, deps, opsevm.EVMDeployInput[any]{
				ChainSelector: in.ChainSelector,
				Qualifier:     in.Qualifier,
			}, opsevm.RetryDeploymentWithGasBoost[any](in.GasBoostConfig))
		case mcmscontracts.ProposerManyChainMultisig:
			deployReport, deployErr = operations.ExecuteOperation(b, opsevm.OpEVMDeployProposerMCM, deps, opsevm.EVMDeployInput[any]{
				ChainSelector: in.ChainSelector,
				Qualifier:     in.Qualifier,
			}, opsevm.RetryDeploymentWithGasBoost[any](in.GasBoostConfig))
		case mcmscontracts.CancellerManyChainMultisig:
			deployReport, deployErr = operations.ExecuteOperation(b, opsevm.OpEVMDeployCancellerMCM, deps, opsevm.EVMDeployInput[any]{
				ChainSelector: in.ChainSelector,
				Qualifier:     in.Qualifier,
			}, opsevm.RetryDeploymentWithGasBoost[any](in.GasBoostConfig))
		default:
			return opsevm.EVMDeployOutput{}, fmt.Errorf("unsupported contract type for seq-deploy-mcm-with-config: %s", in.ContractType)
		}
		if deployErr != nil {
			return opsevm.EVMDeployOutput{}, fmt.Errorf("failed to deploy %s: %w", in.ContractType, deployErr)
		}

		groupQuorums, groupParents, signerAddresses, signerGroups, err := sdk.ExtractSetConfigInputs(&in.MCMConfig)
		if err != nil {
			return opsevm.EVMDeployOutput{}, err
		}
		_, err = operations.ExecuteOperation(b, opsevm.OpEVMSetConfigMCM,
			deps,
			opsevm.EVMCallInput[opsevm.OpEVMSetConfigMCMInput]{
				ChainSelector: in.ChainSelector,
				Address:       deployReport.Output.Address,
				NoSend:        false,
				CallInput: opsevm.OpEVMSetConfigMCMInput{
					SignerAddresses: signerAddresses,
					SignerGroups:    signerGroups,
					GroupQuorums:    groupQuorums,
					GroupParents:    groupParents,
				},
			},
			opsevm.RetryCallWithGasBoost[opsevm.OpEVMSetConfigMCMInput](in.GasBoostConfig),
		)
		if err != nil {
			return opsevm.EVMDeployOutput{}, err
		}

		return deployReport.Output, nil
	},
)
View Source
var SeqGrantRolesTimelock = operations.NewSequence(
	"seq-grant-role-with-config",
	semver.MustParse("1.0.0"),
	"Grants appropriate roles to MCMS contracts in the EVM Timelock contract",
	func(b operations.Bundle, deps SeqGrantRolesTimelockDeps, in SeqGrantRolesTimelockInput) (map[uint64][]opsevm.EVMCallOutput, error) {
		var (
			addressesInInspector []string
			err2                 error
		)
		out := make([]opsevm.EVMCallOutput, 0)

		timelockInspector := evmMcms.NewTimelockInspector(deps.Chain.Client)

		for _, roleAndAddress := range in.RolesAndAddresses {
			switch roleAndAddress.Role {
			case v1_0.PROPOSER_ROLE.ID:
				addressesInInspector, err2 = timelockInspector.GetProposers(b.GetContext(), in.Timelock.Hex())
			case v1_0.CANCELLER_ROLE.ID:
				addressesInInspector, err2 = timelockInspector.GetCancellers(b.GetContext(), in.Timelock.Hex())
			case v1_0.BYPASSER_ROLE.ID:
				addressesInInspector, err2 = timelockInspector.GetBypassers(b.GetContext(), in.Timelock.Hex())
			case v1_0.EXECUTOR_ROLE.ID:
				addressesInInspector, err2 = timelockInspector.GetExecutors(b.GetContext(), in.Timelock.Hex())
			case v1_0.ADMIN_ROLE.ID:
				addressesInInspector = []string{}
			}
			if err2 != nil {
				b.Logger.Errorw("Failed to get addresses from Timelock Inspector",
					"chainSelector", deps.Chain.ChainSelector(),
					"chainName", deps.Chain.Name(),
					"Timelock Address", in.Timelock.Hex(),
					"Role", roleAndAddress.Name,
					"Error", err2,
				)

				return nil, err2
			}
			for _, addressToGrantRole := range roleAndAddress.Addresses {
				if !slices.Contains(addressesInInspector, addressToGrantRole.Hex()) {
					opReport, err := operations.ExecuteOperation(b, opsevm.OpEVMGrantRole,
						deps.Chain,
						opsevm.EVMCallInput[opsevm.OpEVMGrantRoleInput]{
							ChainSelector: in.ChainSelector,
							CallInput: opsevm.OpEVMGrantRoleInput{
								Account: addressToGrantRole,
								RoleID:  roleAndAddress.Role,
							},
							NoSend:  !in.IsDeployerKeyAdmin,
							Address: in.Timelock,
						},
						opsevm.RetryCallWithGasBoost[opsevm.OpEVMGrantRoleInput](in.GasBoostConfig),
					)
					if err != nil {
						b.Logger.Errorw("Failed to grant role",
							"chainSelector", deps.Chain.ChainSelector(),
							"chainName", deps.Chain.Name(),
							"Timelock Address", in.Timelock.Hex(),
							"Role Name", roleAndAddress.Name,
							"Address", addressToGrantRole.Hex(),
						)

						return nil, err
					}
					out = append(out, opReport.Output)

					if in.IsDeployerKeyAdmin {
						b.Logger.Infow("Role granted",
							"Role Name", roleAndAddress.Name,
							"chainSelector", deps.Chain.ChainSelector(),
							"chainName", deps.Chain.Name(),
							"Timelock Address", in.Timelock.Hex(),
							"Address", addressToGrantRole.Hex(),
						)
					}
				}
			}
		}

		return map[uint64][]opsevm.EVMCallOutput{
			in.ChainSelector: out,
		}, nil
	},
)
View Source
var SeqTransferToMCMSWithTimelockV2 = operations.NewSequence(
	"seq-transfer-to-mcms-with-timelock-v2",
	semver.MustParse("1.0.0"),
	"Transfers ownership to the Timelock contract",
	func(b operations.Bundle, deps SeqTransferToMCMSWithTimelockV2Deps, in SeqTransferToMCMSWithTimelockV2Input) (SeqTransferToMCMSWithTimelockV2Output, error) {
		var (
			mcsmOps []mcmsTypes.Transaction
		)

		for _, contract := range in.Contracts {

			owner, c, err := LoadOwnableContract(contract, deps.Chain.Client)
			if err != nil {
				b.Logger.Errorf("failed to load ownable contract %s: %v", contract.Hex(), err)
				return SeqTransferToMCMSWithTimelockV2Output{}, fmt.Errorf("error loading ownable contract %s: %w", contract.Hex(), err)
			}

			if owner.String() == in.Timelock.Hex() {

				b.Logger.Infof("contract %s already owned by timelock", contract)
				continue
			}

			if !in.OnlyAcceptOwnership {

				_, err = operations.ExecuteOperation(b, opsevm.OpEVMTransferOwnership,
					opsevm.OpEVMOwnershipDeps{
						Chain:    deps.Chain,
						OwnableC: c,
					},
					opsevm.OpEVMTransferOwnershipInput{
						ChainSelector:   in.ChainSelector,
						TimelockAddress: in.Timelock,
						Address:         contract,
					},
				)

				if err != nil {
					return SeqTransferToMCMSWithTimelockV2Output{}, err
				}
			}

			opReport, err := operations.ExecuteOperation(b, opsevm.OpEVMAcceptOwnership,
				opsevm.OpEVMOwnershipDeps{
					Chain:    deps.Chain,
					OwnableC: c,
				},
				opsevm.OpEVMTransferOwnershipInput{
					ChainSelector:   in.ChainSelector,
					TimelockAddress: in.Timelock,
					Address:         contract,
				},
			)
			if err != nil {
				return SeqTransferToMCMSWithTimelockV2Output{}, err
			}

			mcsmOps = append(mcsmOps, mcmsTypes.Transaction{
				To:               contract.Hex(),
				Data:             opReport.Output.Tx.Data(),
				AdditionalFields: json.RawMessage(`{"value": 0}`),
			})
		}

		return SeqTransferToMCMSWithTimelockV2Output{OpsMcms: mcsmOps}, nil
	},
)

Functions

func LoadOwnableContract added in v0.4.0

func LoadOwnableContract(addr common.Address, client bind.ContractBackend) (common.Address, evmstate.Ownable, error)

TODO: convert this to an OP

Types

type RolesAndAddresses

type RolesAndAddresses struct {
	Role      common.Hash
	Name      string
	Addresses []common.Address
}

type SeqDeployMCMWithConfigInput

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

type SeqDeployMCMWithConfigOutput struct {
	Address common.Address `json:"address"`
}

type SeqGrantRolesTimelockDeps

type SeqGrantRolesTimelockDeps struct {
	Chain cldfevm.Chain
}

type SeqGrantRolesTimelockInput

type SeqGrantRolesTimelockInput struct {
	ContractType       cldf.ContractType                 `json:"contractType"`
	ChainSelector      uint64                            `json:"chainSelector"`
	Timelock           common.Address                    `json:"timelock"`
	RolesAndAddresses  []RolesAndAddresses               `json:"rolesAndAddresses"`
	IsDeployerKeyAdmin bool                              `json:"isDeployerKeyAdmin"`
	GasBoostConfig     *cldfproposalutils.GasBoostConfig `json:"gasBoostConfig"`
}

type SeqGrantRolesTimelockOutput

type SeqGrantRolesTimelockOutput struct {
	McmsTxs []mcmsTypes.Transaction `json:"mcmsTxs"`
}

type SeqTransferToMCMSWithTimelockV2Deps added in v0.4.0

type SeqTransferToMCMSWithTimelockV2Deps struct {
	Chain evm.Chain
}

type SeqTransferToMCMSWithTimelockV2Input added in v0.4.0

type SeqTransferToMCMSWithTimelockV2Input struct {
	ChainSelector uint64           `json:"chainSelector"`
	Timelock      common.Address   `json:"timelock"`
	Contracts     []common.Address `json:"contracts"`

	OnlyAcceptOwnership bool `json:"onlyacceptownership"`
}

type SeqTransferToMCMSWithTimelockV2Output added in v0.4.0

type SeqTransferToMCMSWithTimelockV2Output struct {
	OpsMcms []mcmsTypes.Transaction `json:"opsMcms"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL