Documentation
¶
Overview ¶
Package fundmcmpdas funds MCMS signer PDAs on Solana chains.
This is a Solana-only changeset: PDAs and signer funding are Solana-specific concepts. Everything — changeset, sequences, and operations — lives in this package under mcms/solana/changesets.
Usage ¶
Import the MCMS reader so datastore refs can be resolved:
import ( fundmcmpdas "github.com/smartcontractkit/cld-changesets/mcms/solana/changesets/fund-mcm-pdas" _ "github.com/smartcontractkit/cld-changesets/mcms/solana/readers" )
Testing:
rt.Exec(runtime.ChangesetTask(fundmcmpdas.Changeset{}, fundmcmpdas.Config{
FundingPerChain: map[uint64]fundmcmpdas.FundingConfig{
selector: {
ProposeMCM: 100,
CancellerMCM: 100,
BypasserMCM: 100,
Timelock: 100,
},
},
}))
CLD:
registry.Add("fund_mcm_pdas", Configure(fundmcmpdas.Changeset{}).WithEnvInput())
Index ¶
Constants ¶
This section is empty.
Variables ¶
var OpFundKey = operations.NewOperation( "solana-fund-key", semver.MustParse("1.0.0"), "Funds a Solana account from the deployer key", func(b operations.Bundle, deps cldfsol.Chain, in OpFundKeyInput) (OpFundKeyOutput, error) { if deps.DeployerKey == nil { return OpFundKeyOutput{}, fmt.Errorf("missing deployer key for chain %d", deps.Selector) } err := solana2.FundFromDeployerKey( deps, []solana.PublicKey{in.Target}, in.Amount, ) if err != nil { return OpFundKeyOutput{}, fmt.Errorf("failed to fund target %s: %w", in.Target, err) } b.Logger.Infow("funding success", "target", in.Target, "amount", in.Amount) return OpFundKeyOutput{Confirmed: true}, nil }, )
OpFundKey funds a single Solana account from the chain deployer key.
var SeqFundMCMPDAs = operations.NewSequence( "seq-solana-fund-mcm-pdas-from-refs", &semvers.V1_0_0, "Funds MCMS signer PDAs on a Solana chain from datastore refs", func(b operations.Bundle, deps Deps, in ChainInput) (sequenceutils.OnChainOutput, error) { chain, ok := deps.BlockChains.SolanaChains()[in.ChainSelector] if !ok { return sequenceutils.OnChainOutput{}, fmt.Errorf("solana chain %d not found in environment", in.ChainSelector) } env := EnvFromDeps(deps) targets, err := ResolveFundingTargets(env, in.ChainSelector, in.FundingConfig) if err != nil { return sequenceutils.OnChainOutput{}, err } seqReport, err := operations.ExecuteSequence( b, SeqFundSolanaMCMPDAs, chain, SeqFundSolanaMCMPDAsInput{ ChainSelector: in.ChainSelector, Targets: targets, }, ) if err != nil { return sequenceutils.OnChainOutput{}, fmt.Errorf("failed to execute Solana fund-mcm-pdas sequence: %w", err) } return seqReport.Output, nil }, )
SeqFundMCMPDAs resolves MCMS signer PDAs from the datastore and funds them on a Solana chain.
var SeqFundSolanaMCMPDAs = operations.NewSequence( "seq-solana-fund-mcm-pdas", &semvers.V1_0_0, "Funds MCMS signer PDAs on a Solana chain", func(b operations.Bundle, deps cldfsol.Chain, in SeqFundSolanaMCMPDAsInput) (sequenceutils.OnChainOutput, error) { if in.ChainSelector != deps.Selector { return sequenceutils.OnChainOutput{}, fmt.Errorf("mismatch between input chain selector and selector defined within dependencies: %d != %d", in.ChainSelector, deps.Selector) } for i, target := range in.Targets { if target.Amount == 0 { continue } _, err := operations.ExecuteOperation( b, OpFundKey, deps, OpFundKeyInput{ Target: target.Address, Amount: target.Amount, }, ) if err != nil { return sequenceutils.OnChainOutput{}, fmt.Errorf("fund target[%d]: %w", i, err) } } return sequenceutils.OnChainOutput{}, nil }, )
SeqFundSolanaMCMPDAs funds each provided signer PDA on a Solana chain.
Functions ¶
func EnvFromDeps ¶
func EnvFromDeps(deps Deps) cldf.Environment
EnvFromDeps reconstructs the environment fields sequences need for ref resolution.
Types ¶
type ChainInput ¶
type ChainInput struct {
ChainSelector uint64
FundingConfig FundingConfig
}
ChainInput is the per-chain request for the fund-mcm-pdas sequence.
type Changeset ¶
type Changeset struct{}
Changeset funds MCMS signer PDAs on each configured Solana chain.
func (Changeset) Apply ¶
func (Changeset) Apply(e cldf.Environment, config Config) (cldf.ChangesetOutput, error)
func (Changeset) VerifyPreconditions ¶
func (Changeset) VerifyPreconditions(env cldf.Environment, config Config) error
type Config ¶
type Config struct {
FundingPerChain map[uint64]FundingConfig `json:"fundingPerChain"`
}
Config holds the funding amounts per chain for the changeset.
type Deps ¶
type Deps struct {
BlockChains chain.BlockChains
DataStore cldfdatastore.DataStore
}
Deps is the read-only dependency bundle available to the fund sequence.
type FundingConfig ¶
type FundingConfig struct {
ProposeMCM uint64 `json:"proposeMcm"`
CancellerMCM uint64 `json:"cancellerMcm"`
BypasserMCM uint64 `json:"bypasserMcm"`
Timelock uint64 `json:"timelock"`
Qualifier string `json:"qualifier,omitempty"`
}
FundingConfig holds the lamport amounts to send to each MCMS signer PDA on a chain.
func (FundingConfig) RequiredFunding ¶
func (c FundingConfig) RequiredFunding() uint64
RequiredFunding returns the total lamports required to fund all MCMS PDAs on a chain.
type FundingTarget ¶
type FundingTarget struct {
Address solanago.PublicKey `json:"address"`
Amount uint64 `json:"amount"`
}
FundingTarget is a signer PDA and the lamports to send to it.
func ResolveFundingTargets ¶
func ResolveFundingTargets(e cldf.Environment, chainSelector uint64, cfg FundingConfig) ([]FundingTarget, error)
ResolveFundingTargets resolves MCMS and timelock signer PDAs from the environment datastore.
type OpFundKeyInput ¶
type OpFundKeyInput struct {
Target solana.PublicKey `json:"target"`
Amount uint64 `json:"amount"`
}
OpFundKeyInput is the input of a Solana PDA funding operation.
type OpFundKeyOutput ¶
type OpFundKeyOutput struct {
Confirmed bool `json:"confirmed"`
}
OpFundKeyOutput is the output of a Solana PDA funding operation.
type SeqFundSolanaMCMPDAsInput ¶
type SeqFundSolanaMCMPDAsInput struct {
ChainSelector uint64 `json:"chainSelector"`
Targets []FundingTarget `json:"targets"`
}
SeqFundSolanaMCMPDAsInput is the input for the low-level Solana fund-mcm-pdas sequence.