operations

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildMCMSFiredrillProposalOp = fwops.NewOperation(
	"mcms-firedrill-proposal",
	semver.MustParse("1.0.0"),
	"Build noop MCMS timelock proposal for signing fire drills",
	buildMCMSFiredrillProposal,
)

BuildMCMSFiredrillProposalOp builds a noop MCMS timelock proposal covering the configured chains. Use fwops.WithForceExecute at the call site so repeated drills record fresh proposals under identical inputs.

View Source
var OpSolanaGrantRoleTimelock = fwops.NewOperation(
	"solana-grant-role-timelock",
	semver.MustParse("1.0.0"),
	"Grant a role to an account in a Solana Timelock instance",
	func(b fwops.Bundle, deps OpSolanaGrantRoleTimelockDeps, in OpSolanaGrantRoleTimelockInput) (OpSolanaGrantRoleTimelockOutput, error) {
		if in.ChainState == nil {
			return OpSolanaGrantRoleTimelockOutput{}, errors.New("chainState is required")
		}

		if in.ChainState.TimelockProgram.IsZero() || in.ChainState.AccessControllerProgram.IsZero() {
			return OpSolanaGrantRoleTimelockOutput{}, errors.New("timelock and access controller program IDs are required")
		}

		accessController, err := selectAccessControllerGrantRole(in)
		if err != nil {
			return OpSolanaGrantRoleTimelockOutput{}, fmt.Errorf("failed to select access controller: %w", err)
		}

		timelockbindings.SetProgramID(in.ChainState.TimelockProgram)
		accesscontrollerbindings.SetProgramID(in.ChainState.AccessControllerProgram)
		var signer solana.PublicKey
		if in.IsDeployerKeyAdmin {
			signer = deps.Chain.DeployerKey.PublicKey()
		} else {
			signer = pdasol.GetTimelockSignerPDA(in.ChainState.TimelockProgram, in.ChainState.TimelockSeed)
		}

		ix, err := accesscontrollerbindings.NewAddAccessInstruction(accessController, signer, in.Account).ValidateAndBuild()
		if err != nil {
			return OpSolanaGrantRoleTimelockOutput{}, fmt.Errorf("failed to create add access instruction: %w", err)
		}

		if in.IsDeployerKeyAdmin {
			cerr := deps.Chain.SendAndConfirm(b.GetContext(), []solana.Instruction{ix})
			if cerr != nil {
				return OpSolanaGrantRoleTimelockOutput{}, fmt.Errorf("failed to confirm instructions: %w", cerr)
			}

			return OpSolanaGrantRoleTimelockOutput{}, nil
		}

		transaction, err := mcmssolanasdk.NewTransactionFromInstruction(ix, "AccessController", []string{})
		if err != nil {
			return OpSolanaGrantRoleTimelockOutput{}, fmt.Errorf("failed to create transaction: %w", err)
		}

		return OpSolanaGrantRoleTimelockOutput{MCMSTransaction: transaction}, nil
	},
)
View Source
var SeqSolanaGrantRoleTimelock = fwops.NewSequence(
	"seq-solana-grant-role-timelock",
	semver.MustParse("1.0.0"),
	"Grant a role to multiple accounts in a Solana Timelock instance",
	func(b fwops.Bundle, deps SeqSolanaGrantRoleTimelockDeps, in SeqSolanaGrantRoleTimelockInput) (SeqSolanaGrantRoleTimelockOutput, error) {
		if in.ChainState == nil {
			return SeqSolanaGrantRoleTimelockOutput{}, errors.New("chainState is required")
		}

		mcmsTxs := make([]mcmstypes.Transaction, 0, len(in.Accounts))

		for _, account := range in.Accounts {
			opReport, err := fwops.ExecuteOperation(b, OpSolanaGrantRoleTimelock,
				OpSolanaGrantRoleTimelockDeps(deps),
				OpSolanaGrantRoleTimelockInput{
					ChainState:         in.ChainState,
					Role:               in.Role,
					Account:            account,
					IsDeployerKeyAdmin: in.IsDeployerKeyAdmin,
				},
			)
			if err != nil {
				b.Logger.Errorw("Failed to grant role", "chainSelector", deps.Chain.ChainSelector(), "chainName", deps.Chain.Name(),
					"timelock", solanastate.EncodeAddressWithSeed(in.ChainState.TimelockProgram, in.ChainState.TimelockSeed),
					"role", in.Role, "account", account)

				return SeqSolanaGrantRoleTimelockOutput{}, err
			}

			if !in.IsDeployerKeyAdmin {
				mcmsTxs = append(mcmsTxs, opReport.Output.MCMSTransaction)
			}
		}

		return SeqSolanaGrantRoleTimelockOutput{McmsTransactions: mcmsTxs}, nil
	},
)

Functions

This section is empty.

Types

type FireDrillDeps

type FireDrillDeps struct {
	Environment cldf.Environment
}

FireDrillDeps holds non-serializable dependencies for the fire-drill operation.

type FireDrillInput

type FireDrillInput struct {
	TimelockCfg cldfproposalutils.TimelockConfig `json:"timelockCfg"`
	Selectors   []uint64                         `json:"selectors,omitempty"`
}

FireDrillInput is JSON-serializable input for the MCMS signing fire-drill proposal operation.

type FireDrillOutput

type FireDrillOutput struct {
	Proposal mcmslib.TimelockProposal `json:"proposal"`
}

FireDrillOutput is the serializable result of building the fire-drill proposal.

type OpSolanaGrantRoleTimelockDeps

type OpSolanaGrantRoleTimelockDeps struct {
	Chain cldfsolana.Chain
}

type OpSolanaGrantRoleTimelockInput

type OpSolanaGrantRoleTimelockInput struct {
	ChainState         *solanastate.MCMSWithTimelockState `json:"chainState"`
	Role               timelockbindings.Role              `json:"role"`
	Account            solana.PublicKey                   `json:"account"`
	IsDeployerKeyAdmin bool                               `json:"isDeployerKeyAdmin"`
}

type OpSolanaGrantRoleTimelockOutput

type OpSolanaGrantRoleTimelockOutput struct {
	MCMSTransaction mcmstypes.Transaction `json:"mcmsTransaction"`
}

type SeqSolanaGrantRoleTimelockDeps

type SeqSolanaGrantRoleTimelockDeps struct {
	Chain cldfsolana.Chain
}

type SeqSolanaGrantRoleTimelockInput

type SeqSolanaGrantRoleTimelockInput struct {
	ChainState         *solanastate.MCMSWithTimelockState `json:"chainState"`
	Role               timelockbindings.Role              `json:"role"`
	Accounts           []solana.PublicKey                 `json:"accounts"`
	IsDeployerKeyAdmin bool                               `json:"isDeployerKeyAdmin"`
}

type SeqSolanaGrantRoleTimelockOutput

type SeqSolanaGrantRoleTimelockOutput struct {
	McmsTransactions []mcmstypes.Transaction `json:"mcmsTxs"`
}

Jump to

Keyboard shortcuts

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