Documentation
¶
Index ¶
- Constants
- Variables
- func RawPlanCellsToBatch(selector types.ChainSelector, plans []*tlbe.Cell[tlb.InternalMessage], ...) (types.BatchOperation, error)
- func RawPlansToBatch(selector types.ChainSelector, plans []opston.MessagePlanRaw, ...) (types.BatchOperation, error)
- func WithOperationOutput(out sequences.OnChainOutput, _out any, selector types.ChainSelector, ...) (sequences.OnChainOutput, error)
- type DeployMCMSSeqInput
- type Messages
- type SendOrPlanInput
- type SetConfigInput
- type TimelockAnySequenceInput
- type TimelockAnySequenceOutput
- type TimelockOpts
Constants ¶
View Source
const ( DefaultMinDelay = 1 * 60 * 60 // 1 hour in seconds DefaultOpFinalizationTimeout = 30 // 30 seconds // DefaultDeployValueTON is the default amount of TON coins to allocate for MCMS/Timelock contract deployment. // MCMS contracts require more storage and operational capacity, hence the higher allocation compared to CCIP contracts. DefaultDeployValueTON = "1.5" // TON )
View Source
const ( DefaultMinDelayHours = 3 DefaultValidUntilHours = 72 )
Variables ¶
View Source
var DeployMCMSSequence = cldfops.NewSequence( "ton/sequences/mcms/deploy-mcms-suite", semver.MustParse("0.1.0"), "Deploys MCMS suite (MCMS/Proposer, MCMS/Canceller, MCMS/Bypasser, Timelock) with the provided config", deployMCMSSequence, )
View Source
var SendOrPlan = cldf_ops.NewOperation( "ton/ops/mcms/send-or-plan", semver.MustParse("0.1.0"), "Sends messages or proposes them as a BatchOperation if the destination is ownable and the sender is not the owner", func(b cldf_ops.Bundle, dp *dep.DependencyProvider, in SendOrPlanInput) (sequences.OnChainOutput, error) { if len(in.Messages) > 0 { _, err := cldf_ops.ExecuteOperation(b, opston.SendMessagesRaw, dp, opston.SendMessagesRawInput{Messages: in.Messages}) if err != nil { return sequences.OnChainOutput{}, fmt.Errorf("failed to send messages: %w", err) } } out := sequences.OnChainOutput{} return WithOperationOutput(out, in.Plans, in.ChainSelector, in.Metadata) }, )
View Source
var SetConfig = cldfops.NewOperation( "ton/ops/mcms/set-config", semver.MustParse("0.1.0"), "Sets the configuration for MCMS contracts", func(b cldfops.Bundle, dp *dep.DependencyProvider, in SetConfigInput) (opston.SendMessagesOutput, error) { chain, err := dep.Resolve[cldfton.Chain](dp) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to resolve chain: %w", err) } configurer, err := mcmston.NewConfigurer(chain.Wallet, tlb.MustFromTON("0"), mcmston.WithDoNotSendInstructionsOnChain()) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to transform MCMS config to chain format: %w", err) } if in.DstAddr == nil { return opston.SendMessagesOutput{}, errors.New("destination address (DstAddr) is required") } tr, err := configurer.SetConfig(b.GetContext(), in.DstAddr.String(), in.Config, in.ClearRoot) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to transform MCMS config to chain format: %w", err) } tx, ok := tr.RawData.(mcmstypes.Transaction) if !ok { return opston.SendMessagesOutput{}, fmt.Errorf("unexpected type for configurer output: %T", tr.RawData) } body, err := cell.FromBOC(tx.Data) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to parse MCMS setC BOC: %w", err) } mcell, err := tlbe.NewCellFrom(tlb.InternalMessage{ Bounce: in.Bounce, DstAddr: in.DstAddr, Amount: in.Amount, Body: body, }) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to create message cell: %w", err) } opcode, err := tvm.ExtractOpcode(body) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to extract opcode from message body: %w", err) } if in.Plan { plan := opston.MessagePlanRaw{ Opcode: opcode, DstAddr: in.DstAddr, Amount: in.Amount, Cell: mcell, } return opston.SendMessagesOutput{Plans: []opston.MessagePlanRaw{plan}}, nil } msgs := []*tlbe.Cell[tlb.InternalMessage]{mcell} out, err := cldfops.ExecuteOperation(b, opston.SendMessagesRaw, dp, opston.SendMessagesRawInput{Messages: msgs, Wait: in.Wait}) if err != nil { return opston.SendMessagesOutput{}, fmt.Errorf("failed to send messages: %w", err) } return out.Output, nil }, )
View Source
var TimelockAnySequence = operations.NewSequence( "ton/sequences/mcms/timelock/any", semver.MustParse("0.1.0"), "Executes and/or plans (via MCMS/Timelock) a sequence of operations as defined by the inputs", timelockAnySeqHandler, )
Functions ¶
func RawPlanCellsToBatch ¶
func RawPlanCellsToBatch(selector types.ChainSelector, plans []*tlbe.Cell[tlb.InternalMessage], meta []types.OperationMetadata) (types.BatchOperation, error)
RawPlanCellsToBatch converts raw message plan cells (TON) to MCMS batch operation type.
func RawPlansToBatch ¶
func RawPlansToBatch(selector types.ChainSelector, plans []opston.MessagePlanRaw, meta []types.OperationMetadata) (types.BatchOperation, error)
RawPlansToBatch converts raw message plans (TON) to MCMS batch operation type.
func WithOperationOutput ¶
func WithOperationOutput(out sequences.OnChainOutput, _out any, selector types.ChainSelector, meta []types.OperationMetadata) (sequences.OnChainOutput, error)
WithOperationOutput is a helper to extract plans from operation output and map them to batch operations.
Types ¶
type DeployMCMSSeqInput ¶
type DeployMCMSSeqInput struct {
Config ccipddeploy.MCMSDeploymentConfigPerChain `json:"config"`
// Extra TON specific params
Value *tlb.Coins `json:"value"` // value to send with deployment, optional, if not provided, defaults to 1.5 TON
ContractID uint32 `json:"contractID"` // ID (storage data) to use for the deployed contracts, can be used to derive the address pre-deployment.
OpFinalizationTimeout uint32 `json:"opFinalizationTimeout"` // optional, if not provided, defaults to 30 seconds
// Extra Timelock params
// Notice: in.Config.TimelockAdmin is of EVM type common.Address (20 bytes),
// which is not compatible with TON address, so we have a separate field for TON address type.
TimelockAdmin *address.Address `json:"timelockAdmin"` // optional, if not provided, deployer address will be used as initial admin
TimelockExecutorRoleCheckEnabled bool `json:"timelockExecutorRoleCheckEnabled"` // optional, if not provided, defaults to false (TON does not have a CallProxy, so we disable executor role check by default)
// Deployment metadata
ContractsSemverMCMS *semver.Version `json:"contractsSemverMCMS"` // used as DS addr version metadata for the deployed MCMS contracts
ContractsSemverTimelock *semver.Version `json:"contractsSemverTimelock"` // used as DS addr version metadata for the deployed Timelock contracts
}
type Messages ¶
type Messages struct {
Messages []*tlbe.Cell[tlb.InternalMessage] `json:"messages"`
Plans []*tlbe.Cell[tlb.InternalMessage] `json:"plans"`
Metadata []types.OperationMetadata `json:"metadata"`
}
type SendOrPlanInput ¶
type SendOrPlanInput struct {
ChainSelector types.ChainSelector `json:"chainSelector"`
Messages []*tlbe.Cell[tlb.InternalMessage] `json:"messages"`
Plans []*tlbe.Cell[tlb.InternalMessage] `json:"plans"`
Metadata []types.OperationMetadata `json:"metadata"`
}
func NewSendOrPlanInput ¶
func NewSendOrPlanInput(chainSelector types.ChainSelector) SendOrPlanInput
func (*SendOrPlanInput) Add ¶
func (in *SendOrPlanInput) Add(msgs []*tlbe.Cell[tlb.InternalMessage], plan bool, meta []types.OperationMetadata)
type SetConfigInput ¶
type SetConfigInput struct {
// SetConfig message parameters
Bounce bool `json:"bounce"`
DstAddr *address.Address `json:"dstAddr"`
Amount tlb.Coins `json:"amount"`
// Params for setConfig message body
Config *mcmstypes.Config `json:"config"` // Notice: common config input type
ClearRoot bool `json:"clearRoot"`
Plan bool `json:"plan"`
Wait *config.Duration `json:"wait,omitempty"` // optional wait time after sending messages (trace tracking)
}
func (SetConfigInput) IsPlan ¶
func (in SetConfigInput) IsPlan() bool
type TimelockAnySequenceInput ¶
type TimelockAnySequenceInput struct {
AnySequenceIn opston.AnySequenceInput `json:"anySequenceIn"`
Options TimelockOpts `json:"options"`
}
type TimelockAnySequenceOutput ¶
type TimelockAnySequenceOutput struct {
BatchOps []types.BatchOperation
Transactions []*tlbe.Cell[tlb.Transaction]
}
func (TimelockAnySequenceOutput) GetPlans ¶
func (o TimelockAnySequenceOutput) GetPlans() []types.BatchOperation
type TimelockOpts ¶
type TimelockOpts struct {
ChainSelector types.ChainSelector `json:"chainSelector"`
OpsMetadata []types.OperationMetadata `json:"opsMetadata"`
}
Click to show internal directories.
Click to hide internal directories.