mcmsops

package
v0.0.0-...-6e7f8b6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddModulesMCMSOp = cld_ops.NewOperation(
	sui_ops.NewSuiOperationName("mcms", "package", "add_modules"),
	semver.MustParse("0.1.0"),
	"Add modules to the MCMS registry",
	addModulesHandler,
)
View Source
var AllOperationsMCMS = []cld_ops.Operation[any, any, any]{
	*MCMSAcceptOwnershipOp.AsUntyped(),
	*MCMSTransferOwnershipOp.AsUntyped(),
	*MCMSExecuteTransferOwnershipOp.AsUntyped(),
	*SetConfigMCMSOp.AsUntyped(),
	*AddModulesMCMSOp.AsUntyped(),
}

Exports every operation available so they can be registered to be used in dynamic changesets

View Source
var DeployMCMSOp = cld_ops.NewOperation(
	sui_ops.NewSuiOperationName("mcms", "package", "deploy"),
	semver.MustParse("0.1.0"),
	"Deploys the MCMS contract",
	handler,
)
View Source
var DeployMCMSSequence = cld_ops.NewSequence(
	"sui-deploy-mcms-seq",
	semver.MustParse("0.1.0"),
	"Deploys the MCMS package, sets the initial configuration, init the ownership transfer to self and generates the proposal to accept the ownership",
	func(env cld_ops.Bundle, deps sui_ops.OpTxDeps, input DeployMCMSSeqInput) (DeployMCMSSeqOutput, error) {

		deployReport, err := cld_ops.ExecuteOperation(env, DeployMCMSOp, deps, cld_ops.EmptyInput{})
		if err != nil {
			return DeployMCMSSeqOutput{}, fmt.Errorf("failed to deploy MCMS: %w", err)
		}

		roleConfigs := []struct {
			config *types.Config
			role   suisdk.TimelockRole
			name   string
		}{
			{input.Bypasser, suisdk.TimelockRoleBypasser, "Bypasser"},
			{input.Canceller, suisdk.TimelockRoleCanceller, "Canceller"},
			{input.Proposer, suisdk.TimelockRoleProposer, "Proposer"},
		}

		for _, roleConfig := range roleConfigs {
			if roleConfig.config != nil {
				setConfigInput := MCMSSetConfigInput{
					ChainSelector: input.ChainSelector,
					McmsPackageID: deployReport.Output.PackageId,
					OwnerCap:      deployReport.Output.Objects.McmsAccountOwnerCapObjectId,
					McmsObjectID:  deployReport.Output.Objects.McmsMultisigStateObjectId,
					Role:          roleConfig.role,
					Config:        *roleConfig.config,
				}

				_, err = cld_ops.ExecuteOperation(env, SetConfigMCMSOp, deps, setConfigInput)
				if err != nil {
					return DeployMCMSSeqOutput{}, fmt.Errorf("failed to set config for role %s: %w", roleConfig.name, err)
				}

				env.Logger.Infow("Set MCMS config", "role", roleConfig.name, "chainSelector", input.ChainSelector)
			}
		}

		transferOwnershipInput := MCMSTransferOwnershipInput{
			McmsPackageID:   deployReport.Output.PackageId,
			OwnerCap:        deployReport.Output.Objects.McmsAccountOwnerCapObjectId,
			AccountObjectID: deployReport.Output.Objects.McmsAccountStateObjectId,
		}
		_, err = cld_ops.ExecuteOperation(env, MCMSTransferOwnershipOp, deps, transferOwnershipInput)
		if err != nil {
			return DeployMCMSSeqOutput{}, fmt.Errorf("failed to transfer ownership to MCMS: %w", err)
		}

		proposalInput := ProposalGenerateInput{
			Defs: []cld_ops.Definition{
				MCMSAcceptOwnershipOp.Def(),
			},
			Inputs: []any{
				MCMSAcceptOwnershipInput{
					McmsPackageID:   deployReport.Output.PackageId,
					AccountObjectID: deployReport.Output.Objects.McmsAccountStateObjectId,
				},
			},

			MmcsPackageID:      deployReport.Output.PackageId,
			McmsStateObjID:     deployReport.Output.Objects.McmsMultisigStateObjectId,
			TimelockObjID:      deployReport.Output.Objects.TimelockObjectId,
			AccountObjID:       deployReport.Output.Objects.McmsAccountStateObjectId,
			RegistryObjID:      deployReport.Output.Objects.McmsRegistryObjectId,
			DeployerStateObjID: deployReport.Output.Objects.McmsDeployerStateObjectId,
			ChainSelector:      uint64(input.ChainSelector),

			TimelockConfig: utils.TimelockConfig{
				MCMSAction:   types.TimelockActionSchedule,
				MinDelay:     0,
				OverrideRoot: false,
			},
		}

		acceptOwnershipProposalReport, err := cld_ops.ExecuteSequence(env, MCMSDynamicProposalGenerateSeq, deps, proposalInput)
		if err != nil {
			return DeployMCMSSeqOutput{}, fmt.Errorf("failed to generate accept ownership proposal: %w", err)
		}

		output := DeployMCMSSeqOutput{
			AcceptOwnershipProposal: acceptOwnershipProposalReport.Output,
			PackageId:               deployReport.Output.PackageId,
			Objects:                 deployReport.Output.Objects,
		}

		return output, nil
	},
)
View Source
var MCMSAcceptOwnershipOp = cld_ops.NewOperation(
	sui_ops.NewSuiOperationName("mcms", "mcms_account", "accept_ownership"),
	semver.MustParse("0.1.0"),
	"Accept ownership of the MCMS contract as MCMS",
	acceptOwnershipHandler,
)
View Source
var MCMSDynamicProposalGenerateSeq = cld_ops.NewSequence(
	sui_ops.NewSuiOperationName("mcms", "proposal", "generate"),
	semver.MustParse("0.1.0"),
	"Generates an MCMS timelock proposal that batches multiple operations based on the provided definitions and inputs",
	generateProposalHandler,
)
View Source
var MCMSExecuteTransferOwnershipOp = cld_ops.NewOperation(
	sui_ops.NewSuiOperationName("mcms", "mcms_account", "execute_transfer_ownership"),
	semver.MustParse("0.1.0"),
	"Execute transfer ownership of the MCMS contract to itself",
	executeTransferOwnershipHandler,
)
View Source
var MCMSTransferOwnershipOp = cld_ops.NewOperation(
	sui_ops.NewSuiOperationName("mcms", "mcms_account", "transfer_ownership"),
	semver.MustParse("0.1.0"),
	"Init the transfer ownership of the MCMS contract to itself",
	transferOwnershipHandler,
)
View Source
var SetConfigMCMSOp = cld_ops.NewOperation(
	sui_ops.NewSuiOperationName("mcms", "mcms", "set_config"),
	semver.MustParse("0.1.0"),
	"Set config in the MCMS contract",
	setConfigMcmsHandler,
)

Functions

This section is empty.

Types

type AddModulesMCMSInput

type AddModulesMCMSInput struct {
	MCMSPackageId     string
	MCMSRegistryObjId string
	AllowedModules    []string
}

type DeployMCMSObjects

type DeployMCMSObjects struct {
	// MCMS
	McmsMultisigStateObjectId string
	TimelockObjectId          string
	// MCMS Deployer
	McmsDeployerStateObjectId string
	// MCMS Registry
	McmsRegistryObjectId string
	// MCMS Account
	McmsAccountStateObjectId    string
	McmsAccountOwnerCapObjectId string
}

type DeployMCMSSeqInput

type DeployMCMSSeqInput struct {
	ChainSelector uint64 `json:"chainSelector" yaml:"chainSelector"`

	// Optional configs for each timelock role
	// If nil, the role will not be configured
	Bypasser  *types.Config `json:"bypasser,omitempty" yaml:"bypasser,omitempty"`
	Proposer  *types.Config `json:"proposer,omitempty" yaml:"proposer,omitempty"`
	Canceller *types.Config `json:"canceller,omitempty" yaml:"canceller,omitempty"`
}

DeployMCMSSeqInput defines the input for deploying MCMS with timelock roles configuration

type DeployMCMSSeqOutput

type DeployMCMSSeqOutput struct {
	AcceptOwnershipProposal mcms.TimelockProposal `json:"acceptOwnershipProposal"`
	PackageId               string                `json:"packageId"`
	Objects                 DeployMCMSObjects     `json:"objects"`
}

type MCMSAcceptOwnershipInput

type MCMSAcceptOwnershipInput struct {
	McmsPackageID   string `json:"mcmsPackageID"`
	AccountObjectID string `json:"accountObjectID"`
}

type MCMSExecuteTransferOwnershipInput

type MCMSExecuteTransferOwnershipInput struct {
	// MCMS related
	McmsPackageID         string `json:"mcmsPackageID"`
	OwnerCap              string `json:"ownerCap"`
	AccountObjectID       string `json:"accountObjectID"`
	RegistryObjectID      string `json:"registryObjectID"`
	DeployerStateObjectID string `json:"deployerStateObjectID"`
}

type MCMSSetConfigInput

type MCMSSetConfigInput struct {
	ChainSelector uint64 `json:"chainSelector"`
	// MCMS related
	McmsPackageID string `json:"mcmsPackageID"`
	OwnerCap      string `json:"ownerCap"`
	McmsObjectID  string `json:"mcmsObjectID"`
	// Timelock related
	Role suisdk.TimelockRole `json:"role"`
	// Config related
	Config    types.Config `json:"config"`
	ClearRoot bool         `json:"clearRoot"`
}

type MCMSTransferOwnershipInput

type MCMSTransferOwnershipInput struct {
	McmsPackageID   string `json:"mcmsPackageID"`
	OwnerCap        string `json:"ownerCap"`
	AccountObjectID string `json:"accountObjectID"`
}

type ProposalGenerateInput

type ProposalGenerateInput struct {
	// Ops Related
	// Order matters, each definition should correspond to the input at the same index
	Defs   []cld_ops.Definition
	Inputs []any // Each element should be the corresponding input type for its operation

	// MCMS related
	MmcsPackageID      string `json:"mcmsPackageID"`
	McmsStateObjID     string `json:"mcmsStateObjID"`
	TimelockObjID      string `json:"timelockObjID"`
	AccountObjID       string `json:"accountObjID"`
	RegistryObjID      string `json:"registryObjID"`
	DeployerStateObjID string `json:"deployerStateObjID"`

	// Chain related
	ChainSelector uint64 `json:"chainSelector"`

	// Timelock related
	TimelockConfig utils.TimelockConfig `json:"timelockConfig"`
}

Jump to

Keyboard shortcuts

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