solsetconfig

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpSolanaSetConfigMCM = operations.NewOperation(
	"solana-mcm-set-config",
	semver.MustParse("1.0.0"),
	"Sets MCMS config on a Solana MCM account",
	func(b operations.Bundle, deps cldfsol.Chain, in OpSolanaSetConfigInput) (OpSolanaSetConfigOutput, error) {
		if deps.DeployerKey == nil {
			return OpSolanaSetConfigOutput{}, fmt.Errorf("missing deployer key for chain %d", deps.Selector)
		}

		var configurer *mcmssolana.Configurer

		if in.NoSend {
			configurer = mcmssolana.NewConfigurer(
				deps.Client,
				*deps.DeployerKey,
				mcmstypes.ChainSelector(deps.Selector),
				mcmssolana.WithDoNotSendInstructionsOnChain(),
				mcmssolana.WithAuthorityAccount(in.AuthorityAccount),
			)
		} else {
			configurer = mcmssolana.NewConfigurer(
				deps.Client,
				*deps.DeployerKey,
				mcmstypes.ChainSelector(deps.Selector),
			)
		}

		res, err := configurer.SetConfig(b.GetContext(), in.Target.Address, &in.Target.Config, false)
		if err != nil {
			return OpSolanaSetConfigOutput{}, fmt.Errorf("failed to set config on %s: %w", in.Target.Address, err)
		}

		if in.NoSend {
			instructions, ok := res.RawData.([]solanasdk.Instruction)
			if !ok {
				return OpSolanaSetConfigOutput{}, fmt.Errorf("unexpected raw data type %T from SetConfig", res.RawData)
			}

			txs := make([]mcmstypes.Transaction, 0, len(instructions))
			for _, ix := range instructions {
				tx, txErr := mcmssolana.NewTransactionFromInstruction(ix, in.Target.ContractType, []string{})
				if txErr != nil {
					return OpSolanaSetConfigOutput{}, txErr
				}
				txs = append(txs, tx)
			}

			return OpSolanaSetConfigOutput{
				BatchOperation: mcmstypes.BatchOperation{
					ChainSelector: mcmstypes.ChainSelector(deps.Selector),
					Transactions:  txs,
				},
			}, nil
		}

		b.Logger.Infow("SetConfig tx confirmed", "txHash", res.Hash, "address", in.Target.Address)

		return OpSolanaSetConfigOutput{Confirmed: true}, nil
	},
)

OpSolanaSetConfigMCM sets MCMS config on a Solana MCM account.

Functions

func Registration

func Registration() setconfig.Registration

Types

type MCMSetConfigTarget

type MCMSetConfigTarget struct {
	Address      string           `json:"address"`
	Config       mcmstypes.Config `json:"config"`
	ContractType string           `json:"contractType"`
}

MCMSetConfigTarget identifies one MCM account and the config to apply.

type OpSolanaSetConfigInput

type OpSolanaSetConfigInput struct {
	Target           MCMSetConfigTarget  `json:"target"`
	NoSend           bool                `json:"noSend"`
	AuthorityAccount solanasdk.PublicKey `json:"authorityAccount"`
}

OpSolanaSetConfigInput is the input for setting config on a single Solana MCM account.

type OpSolanaSetConfigOutput

type OpSolanaSetConfigOutput struct {
	Confirmed      bool                     `json:"confirmed"`
	BatchOperation mcmstypes.BatchOperation `json:"batchOperation"`
}

OpSolanaSetConfigOutput is the output of a Solana set-config operation.

Jump to

Keyboard shortcuts

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