diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/AcceptAdminRoleTokenAdminRegistry.go b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptAdminRoleTokenAdminRegistry.go new file mode 100644 index 00000000000..6afa27007fe --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptAdminRoleTokenAdminRegistry.go @@ -0,0 +1,146 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Pending Admin can accept the Admin Role of the Token Admin Registry +type AcceptAdminRoleTokenAdminRegistry struct { + Mint *ag_solanago.PublicKey + + // [0] = [WRITE] tokenAdminRegistry + // + // [1] = [WRITE, SIGNER] authority + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewAcceptAdminRoleTokenAdminRegistryInstructionBuilder creates a new `AcceptAdminRoleTokenAdminRegistry` instruction builder. +func NewAcceptAdminRoleTokenAdminRegistryInstructionBuilder() *AcceptAdminRoleTokenAdminRegistry { + nd := &AcceptAdminRoleTokenAdminRegistry{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetMint sets the "mint" parameter. +func (inst *AcceptAdminRoleTokenAdminRegistry) SetMint(mint ag_solanago.PublicKey) *AcceptAdminRoleTokenAdminRegistry { + inst.Mint = &mint + return inst +} + +// SetTokenAdminRegistryAccount sets the "tokenAdminRegistry" account. +func (inst *AcceptAdminRoleTokenAdminRegistry) SetTokenAdminRegistryAccount(tokenAdminRegistry ag_solanago.PublicKey) *AcceptAdminRoleTokenAdminRegistry { + inst.AccountMetaSlice[0] = ag_solanago.Meta(tokenAdminRegistry).WRITE() + return inst +} + +// GetTokenAdminRegistryAccount gets the "tokenAdminRegistry" account. +func (inst *AcceptAdminRoleTokenAdminRegistry) GetTokenAdminRegistryAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *AcceptAdminRoleTokenAdminRegistry) SetAuthorityAccount(authority ag_solanago.PublicKey) *AcceptAdminRoleTokenAdminRegistry { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *AcceptAdminRoleTokenAdminRegistry) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +func (inst AcceptAdminRoleTokenAdminRegistry) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_AcceptAdminRoleTokenAdminRegistry, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst AcceptAdminRoleTokenAdminRegistry) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *AcceptAdminRoleTokenAdminRegistry) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Mint == nil { + return errors.New("Mint parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.TokenAdminRegistry is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + } + return nil +} + +func (inst *AcceptAdminRoleTokenAdminRegistry) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("AcceptAdminRoleTokenAdminRegistry")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Mint", *inst.Mint)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("tokenAdminRegistry", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + }) + }) + }) +} + +func (obj AcceptAdminRoleTokenAdminRegistry) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Mint` param: + err = encoder.Encode(obj.Mint) + if err != nil { + return err + } + return nil +} +func (obj *AcceptAdminRoleTokenAdminRegistry) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Mint`: + err = decoder.Decode(&obj.Mint) + if err != nil { + return err + } + return nil +} + +// NewAcceptAdminRoleTokenAdminRegistryInstruction declares a new AcceptAdminRoleTokenAdminRegistry instruction with the provided parameters and accounts. +func NewAcceptAdminRoleTokenAdminRegistryInstruction( + // Parameters: + mint ag_solanago.PublicKey, + // Accounts: + tokenAdminRegistry ag_solanago.PublicKey, + authority ag_solanago.PublicKey) *AcceptAdminRoleTokenAdminRegistry { + return NewAcceptAdminRoleTokenAdminRegistryInstructionBuilder(). + SetMint(mint). + SetTokenAdminRegistryAccount(tokenAdminRegistry). + SetAuthorityAccount(authority) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/AcceptAdminRoleTokenAdminRegistry_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptAdminRoleTokenAdminRegistry_test.go new file mode 100644 index 00000000000..44baeb8e004 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptAdminRoleTokenAdminRegistry_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_AcceptAdminRoleTokenAdminRegistry(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("AcceptAdminRoleTokenAdminRegistry"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(AcceptAdminRoleTokenAdminRegistry) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(AcceptAdminRoleTokenAdminRegistry) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/AcceptOwnership.go b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptOwnership.go new file mode 100644 index 00000000000..9354db59224 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptOwnership.go @@ -0,0 +1,117 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// AcceptOwnership is the `acceptOwnership` instruction. +type AcceptOwnership struct { + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewAcceptOwnershipInstructionBuilder creates a new `AcceptOwnership` instruction builder. +func NewAcceptOwnershipInstructionBuilder() *AcceptOwnership { + nd := &AcceptOwnership{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetConfigAccount sets the "config" account. +func (inst *AcceptOwnership) SetConfigAccount(config ag_solanago.PublicKey) *AcceptOwnership { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *AcceptOwnership) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *AcceptOwnership) SetAuthorityAccount(authority ag_solanago.PublicKey) *AcceptOwnership { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *AcceptOwnership) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +func (inst AcceptOwnership) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_AcceptOwnership, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst AcceptOwnership) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *AcceptOwnership) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + } + return nil +} + +func (inst *AcceptOwnership) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("AcceptOwnership")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta("authority", inst.AccountMetaSlice[1])) + }) + }) + }) +} + +func (obj AcceptOwnership) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *AcceptOwnership) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewAcceptOwnershipInstruction declares a new AcceptOwnership instruction with the provided parameters and accounts. +func NewAcceptOwnershipInstruction( + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey) *AcceptOwnership { + return NewAcceptOwnershipInstructionBuilder(). + SetConfigAccount(config). + SetAuthorityAccount(authority) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/AcceptOwnership_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptOwnership_test.go new file mode 100644 index 00000000000..da475cd5d24 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/AcceptOwnership_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_AcceptOwnership(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("AcceptOwnership"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(AcceptOwnership) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(AcceptOwnership) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/AddChainSelector.go b/core/capabilities/ccip/ccipsolana/ccip_router/AddChainSelector.go new file mode 100644 index 00000000000..743d44c41e1 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/AddChainSelector.go @@ -0,0 +1,207 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin needs to add any new chain supported (this means both OnRamp and OffRamp). +type AddChainSelector struct { + NewChainSelector *uint64 + OnRampAddress *[]byte + + // [0] = [WRITE] chainState + // + // [1] = [] config + // + // [2] = [WRITE, SIGNER] authority + // + // [3] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewAddChainSelectorInstructionBuilder creates a new `AddChainSelector` instruction builder. +func NewAddChainSelectorInstructionBuilder() *AddChainSelector { + nd := &AddChainSelector{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetNewChainSelector sets the "newChainSelector" parameter. +func (inst *AddChainSelector) SetNewChainSelector(newChainSelector uint64) *AddChainSelector { + inst.NewChainSelector = &newChainSelector + return inst +} + +// SetOnRampAddress sets the "onRampAddress" parameter. +func (inst *AddChainSelector) SetOnRampAddress(onRampAddress []byte) *AddChainSelector { + inst.OnRampAddress = &onRampAddress + return inst +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *AddChainSelector) SetChainStateAccount(chainState ag_solanago.PublicKey) *AddChainSelector { + inst.AccountMetaSlice[0] = ag_solanago.Meta(chainState).WRITE() + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *AddChainSelector) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetConfigAccount sets the "config" account. +func (inst *AddChainSelector) SetConfigAccount(config ag_solanago.PublicKey) *AddChainSelector { + inst.AccountMetaSlice[1] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *AddChainSelector) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *AddChainSelector) SetAuthorityAccount(authority ag_solanago.PublicKey) *AddChainSelector { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *AddChainSelector) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *AddChainSelector) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *AddChainSelector { + inst.AccountMetaSlice[3] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *AddChainSelector) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +func (inst AddChainSelector) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_AddChainSelector, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst AddChainSelector) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *AddChainSelector) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewChainSelector == nil { + return errors.New("NewChainSelector parameter is not set") + } + if inst.OnRampAddress == nil { + return errors.New("OnRampAddress parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *AddChainSelector) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("AddChainSelector")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewChainSelector", *inst.NewChainSelector)) + paramsBranch.Child(ag_format.Param(" OnRampAddress", *inst.OnRampAddress)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[3])) + }) + }) + }) +} + +func (obj AddChainSelector) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewChainSelector` param: + err = encoder.Encode(obj.NewChainSelector) + if err != nil { + return err + } + // Serialize `OnRampAddress` param: + err = encoder.Encode(obj.OnRampAddress) + if err != nil { + return err + } + return nil +} +func (obj *AddChainSelector) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewChainSelector`: + err = decoder.Decode(&obj.NewChainSelector) + if err != nil { + return err + } + // Deserialize `OnRampAddress`: + err = decoder.Decode(&obj.OnRampAddress) + if err != nil { + return err + } + return nil +} + +// NewAddChainSelectorInstruction declares a new AddChainSelector instruction with the provided parameters and accounts. +func NewAddChainSelectorInstruction( + // Parameters: + newChainSelector uint64, + onRampAddress []byte, + // Accounts: + chainState ag_solanago.PublicKey, + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *AddChainSelector { + return NewAddChainSelectorInstructionBuilder(). + SetNewChainSelector(newChainSelector). + SetOnRampAddress(onRampAddress). + SetChainStateAccount(chainState). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/AddChainSelector_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/AddChainSelector_test.go new file mode 100644 index 00000000000..8398360f7f6 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/AddChainSelector_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_AddChainSelector(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("AddChainSelector"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(AddChainSelector) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(AddChainSelector) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/CcipSend.go b/core/capabilities/ccip/ccipsolana/ccip_router/CcipSend.go new file mode 100644 index 00000000000..61cd343e929 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/CcipSend.go @@ -0,0 +1,250 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// ON RAMP FLOW +// The method name needs to be ccip_send with Anchor encoding. +// This function is called by the CCIP Sender Contract (or final user) to send a message to the CCIP Router. +// The size limit of data is 256 bytes. +// The message is sent to the receiver on the destination chain selector. +// This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code +type CcipSend struct { + DestChainSelector *uint64 + Message *Solana2AnyMessage + + // [0] = [] config + // + // [1] = [WRITE] chainState + // + // [2] = [WRITE] nonce + // + // [3] = [WRITE, SIGNER] authority + // + // [4] = [] systemProgram + // + // [5] = [WRITE] tokenPoolsSigner + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewCcipSendInstructionBuilder creates a new `CcipSend` instruction builder. +func NewCcipSendInstructionBuilder() *CcipSend { + nd := &CcipSend{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), + } + return nd +} + +// SetDestChainSelector sets the "destChainSelector" parameter. +func (inst *CcipSend) SetDestChainSelector(destChainSelector uint64) *CcipSend { + inst.DestChainSelector = &destChainSelector + return inst +} + +// SetMessage sets the "message" parameter. +func (inst *CcipSend) SetMessage(message Solana2AnyMessage) *CcipSend { + inst.Message = &message + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *CcipSend) SetConfigAccount(config ag_solanago.PublicKey) *CcipSend { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *CcipSend) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *CcipSend) SetChainStateAccount(chainState ag_solanago.PublicKey) *CcipSend { + inst.AccountMetaSlice[1] = ag_solanago.Meta(chainState).WRITE() + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *CcipSend) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetNonceAccount sets the "nonce" account. +func (inst *CcipSend) SetNonceAccount(nonce ag_solanago.PublicKey) *CcipSend { + inst.AccountMetaSlice[2] = ag_solanago.Meta(nonce).WRITE() + return inst +} + +// GetNonceAccount gets the "nonce" account. +func (inst *CcipSend) GetNonceAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *CcipSend) SetAuthorityAccount(authority ag_solanago.PublicKey) *CcipSend { + inst.AccountMetaSlice[3] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *CcipSend) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *CcipSend) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *CcipSend { + inst.AccountMetaSlice[4] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *CcipSend) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[4] +} + +// SetTokenPoolsSignerAccount sets the "tokenPoolsSigner" account. +func (inst *CcipSend) SetTokenPoolsSignerAccount(tokenPoolsSigner ag_solanago.PublicKey) *CcipSend { + inst.AccountMetaSlice[5] = ag_solanago.Meta(tokenPoolsSigner).WRITE() + return inst +} + +// GetTokenPoolsSignerAccount gets the "tokenPoolsSigner" account. +func (inst *CcipSend) GetTokenPoolsSignerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[5] +} + +func (inst CcipSend) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_CcipSend, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst CcipSend) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *CcipSend) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.DestChainSelector == nil { + return errors.New("DestChainSelector parameter is not set") + } + if inst.Message == nil { + return errors.New("Message parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Nonce is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.TokenPoolsSigner is not set") + } + } + return nil +} + +func (inst *CcipSend) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("CcipSend")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("DestChainSelector", *inst.DestChainSelector)) + paramsBranch.Child(ag_format.Param(" Message", *inst.Message)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" nonce", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[3])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[4])) + accountsBranch.Child(ag_format.Meta("tokenPoolsSigner", inst.AccountMetaSlice[5])) + }) + }) + }) +} + +func (obj CcipSend) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `DestChainSelector` param: + err = encoder.Encode(obj.DestChainSelector) + if err != nil { + return err + } + // Serialize `Message` param: + err = encoder.Encode(obj.Message) + if err != nil { + return err + } + return nil +} +func (obj *CcipSend) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `DestChainSelector`: + err = decoder.Decode(&obj.DestChainSelector) + if err != nil { + return err + } + // Deserialize `Message`: + err = decoder.Decode(&obj.Message) + if err != nil { + return err + } + return nil +} + +// NewCcipSendInstruction declares a new CcipSend instruction with the provided parameters and accounts. +func NewCcipSendInstruction( + // Parameters: + destChainSelector uint64, + message Solana2AnyMessage, + // Accounts: + config ag_solanago.PublicKey, + chainState ag_solanago.PublicKey, + nonce ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + tokenPoolsSigner ag_solanago.PublicKey) *CcipSend { + return NewCcipSendInstructionBuilder(). + SetDestChainSelector(destChainSelector). + SetMessage(message). + SetConfigAccount(config). + SetChainStateAccount(chainState). + SetNonceAccount(nonce). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram). + SetTokenPoolsSignerAccount(tokenPoolsSigner) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/CcipSend_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/CcipSend_test.go new file mode 100644 index 00000000000..a9f819342cb --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/CcipSend_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_CcipSend(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("CcipSend"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(CcipSend) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(CcipSend) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/Commit.go b/core/capabilities/ccip/ccipsolana/ccip_router/Commit.go new file mode 100644 index 00000000000..898c086029b --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/Commit.go @@ -0,0 +1,279 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// OFF RAMP FLOW +// +// The method name needs to be commit with Anchor encoding. +// +// This function is called by the OffChain when committing one Report to the Solana Router. +// In this Flow only one report is sent, the Commit Report. This is different as EVM does, +// this is because here all the chain state is stored in one account per Merkle Tree Root. +// So, to avoid having to send a dynamic size array of accounts, in this message only one Commit Report Account is sent. +// This message validates the signatures of the report and stores the Merkle Root in the Commit Report Account. +// The Report must contain an interval of messages, and the min of them must be the next sequence number expected. +// The max size of the interval is 64. +// This message emits two events: CommitReportAccepted and Transmitted. +type Commit struct { + ReportContext *[3][32]uint8 + Report *CommitInput + Signatures *[][65]uint8 + + // [0] = [] config + // + // [1] = [WRITE] chainState + // + // [2] = [WRITE] commitReport + // + // [3] = [WRITE, SIGNER] authority + // + // [4] = [] systemProgram + // + // [5] = [] sysvarInstructions + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewCommitInstructionBuilder creates a new `Commit` instruction builder. +func NewCommitInstructionBuilder() *Commit { + nd := &Commit{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), + } + return nd +} + +// SetReportContext sets the "reportContext" parameter. +func (inst *Commit) SetReportContext(reportContext [3][32]uint8) *Commit { + inst.ReportContext = &reportContext + return inst +} + +// SetReport sets the "report" parameter. +func (inst *Commit) SetReport(report CommitInput) *Commit { + inst.Report = &report + return inst +} + +// SetSignatures sets the "signatures" parameter. +func (inst *Commit) SetSignatures(signatures [][65]uint8) *Commit { + inst.Signatures = &signatures + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *Commit) SetConfigAccount(config ag_solanago.PublicKey) *Commit { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *Commit) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *Commit) SetChainStateAccount(chainState ag_solanago.PublicKey) *Commit { + inst.AccountMetaSlice[1] = ag_solanago.Meta(chainState).WRITE() + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *Commit) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetCommitReportAccount sets the "commitReport" account. +func (inst *Commit) SetCommitReportAccount(commitReport ag_solanago.PublicKey) *Commit { + inst.AccountMetaSlice[2] = ag_solanago.Meta(commitReport).WRITE() + return inst +} + +// GetCommitReportAccount gets the "commitReport" account. +func (inst *Commit) GetCommitReportAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Commit) SetAuthorityAccount(authority ag_solanago.PublicKey) *Commit { + inst.AccountMetaSlice[3] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Commit) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Commit) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Commit { + inst.AccountMetaSlice[4] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Commit) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[4] +} + +// SetSysvarInstructionsAccount sets the "sysvarInstructions" account. +func (inst *Commit) SetSysvarInstructionsAccount(sysvarInstructions ag_solanago.PublicKey) *Commit { + inst.AccountMetaSlice[5] = ag_solanago.Meta(sysvarInstructions) + return inst +} + +// GetSysvarInstructionsAccount gets the "sysvarInstructions" account. +func (inst *Commit) GetSysvarInstructionsAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[5] +} + +func (inst Commit) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Commit, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Commit) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Commit) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.ReportContext == nil { + return errors.New("ReportContext parameter is not set") + } + if inst.Report == nil { + return errors.New("Report parameter is not set") + } + if inst.Signatures == nil { + return errors.New("Signatures parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.CommitReport is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.SysvarInstructions is not set") + } + } + return nil +} + +func (inst *Commit) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Commit")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("ReportContext", *inst.ReportContext)) + paramsBranch.Child(ag_format.Param(" Report", *inst.Report)) + paramsBranch.Child(ag_format.Param(" Signatures", *inst.Signatures)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" commitReport", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[3])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[4])) + accountsBranch.Child(ag_format.Meta("sysvarInstructions", inst.AccountMetaSlice[5])) + }) + }) + }) +} + +func (obj Commit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ReportContext` param: + err = encoder.Encode(obj.ReportContext) + if err != nil { + return err + } + // Serialize `Report` param: + err = encoder.Encode(obj.Report) + if err != nil { + return err + } + // Serialize `Signatures` param: + err = encoder.Encode(obj.Signatures) + if err != nil { + return err + } + return nil +} +func (obj *Commit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ReportContext`: + err = decoder.Decode(&obj.ReportContext) + if err != nil { + return err + } + // Deserialize `Report`: + err = decoder.Decode(&obj.Report) + if err != nil { + return err + } + // Deserialize `Signatures`: + err = decoder.Decode(&obj.Signatures) + if err != nil { + return err + } + return nil +} + +// NewCommitInstruction declares a new Commit instruction with the provided parameters and accounts. +func NewCommitInstruction( + // Parameters: + reportContext [3][32]uint8, + report CommitInput, + signatures [][65]uint8, + // Accounts: + config ag_solanago.PublicKey, + chainState ag_solanago.PublicKey, + commitReport ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + sysvarInstructions ag_solanago.PublicKey) *Commit { + return NewCommitInstructionBuilder(). + SetReportContext(reportContext). + SetReport(report). + SetSignatures(signatures). + SetConfigAccount(config). + SetChainStateAccount(chainState). + SetCommitReportAccount(commitReport). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram). + SetSysvarInstructionsAccount(sysvarInstructions) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/Commit_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/Commit_test.go new file mode 100644 index 00000000000..fcaf33cc942 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/Commit_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Commit(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Commit"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Commit) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Commit) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/DisableChainSelector.go b/core/capabilities/ccip/ccipsolana/ccip_router/DisableChainSelector.go new file mode 100644 index 00000000000..772c3391061 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/DisableChainSelector.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin is the only one able to enable or disable the chain selector +type DisableChainSelector struct { + NewChainSelector *uint64 + + // [0] = [WRITE] chainState + // + // [1] = [] config + // + // [2] = [WRITE, SIGNER] authority + // + // [3] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewDisableChainSelectorInstructionBuilder creates a new `DisableChainSelector` instruction builder. +func NewDisableChainSelectorInstructionBuilder() *DisableChainSelector { + nd := &DisableChainSelector{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetNewChainSelector sets the "newChainSelector" parameter. +func (inst *DisableChainSelector) SetNewChainSelector(newChainSelector uint64) *DisableChainSelector { + inst.NewChainSelector = &newChainSelector + return inst +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *DisableChainSelector) SetChainStateAccount(chainState ag_solanago.PublicKey) *DisableChainSelector { + inst.AccountMetaSlice[0] = ag_solanago.Meta(chainState).WRITE() + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *DisableChainSelector) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetConfigAccount sets the "config" account. +func (inst *DisableChainSelector) SetConfigAccount(config ag_solanago.PublicKey) *DisableChainSelector { + inst.AccountMetaSlice[1] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *DisableChainSelector) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *DisableChainSelector) SetAuthorityAccount(authority ag_solanago.PublicKey) *DisableChainSelector { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *DisableChainSelector) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *DisableChainSelector) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *DisableChainSelector { + inst.AccountMetaSlice[3] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *DisableChainSelector) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +func (inst DisableChainSelector) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_DisableChainSelector, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst DisableChainSelector) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *DisableChainSelector) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewChainSelector == nil { + return errors.New("NewChainSelector parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *DisableChainSelector) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("DisableChainSelector")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewChainSelector", *inst.NewChainSelector)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[3])) + }) + }) + }) +} + +func (obj DisableChainSelector) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewChainSelector` param: + err = encoder.Encode(obj.NewChainSelector) + if err != nil { + return err + } + return nil +} +func (obj *DisableChainSelector) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewChainSelector`: + err = decoder.Decode(&obj.NewChainSelector) + if err != nil { + return err + } + return nil +} + +// NewDisableChainSelectorInstruction declares a new DisableChainSelector instruction with the provided parameters and accounts. +func NewDisableChainSelectorInstruction( + // Parameters: + newChainSelector uint64, + // Accounts: + chainState ag_solanago.PublicKey, + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *DisableChainSelector { + return NewDisableChainSelectorInstructionBuilder(). + SetNewChainSelector(newChainSelector). + SetChainStateAccount(chainState). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/DisableChainSelector_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/DisableChainSelector_test.go new file mode 100644 index 00000000000..6d4d01c9feb --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/DisableChainSelector_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_DisableChainSelector(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("DisableChainSelector"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(DisableChainSelector) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(DisableChainSelector) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/EnableChainSelector.go b/core/capabilities/ccip/ccipsolana/ccip_router/EnableChainSelector.go new file mode 100644 index 00000000000..b3b45bb7f91 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/EnableChainSelector.go @@ -0,0 +1,184 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin is the only one able to enable or disable the chain selector +type EnableChainSelector struct { + NewChainSelector *uint64 + + // [0] = [WRITE] chainState + // + // [1] = [] config + // + // [2] = [WRITE, SIGNER] authority + // + // [3] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewEnableChainSelectorInstructionBuilder creates a new `EnableChainSelector` instruction builder. +func NewEnableChainSelectorInstructionBuilder() *EnableChainSelector { + nd := &EnableChainSelector{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetNewChainSelector sets the "newChainSelector" parameter. +func (inst *EnableChainSelector) SetNewChainSelector(newChainSelector uint64) *EnableChainSelector { + inst.NewChainSelector = &newChainSelector + return inst +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *EnableChainSelector) SetChainStateAccount(chainState ag_solanago.PublicKey) *EnableChainSelector { + inst.AccountMetaSlice[0] = ag_solanago.Meta(chainState).WRITE() + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *EnableChainSelector) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetConfigAccount sets the "config" account. +func (inst *EnableChainSelector) SetConfigAccount(config ag_solanago.PublicKey) *EnableChainSelector { + inst.AccountMetaSlice[1] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *EnableChainSelector) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *EnableChainSelector) SetAuthorityAccount(authority ag_solanago.PublicKey) *EnableChainSelector { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *EnableChainSelector) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *EnableChainSelector) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *EnableChainSelector { + inst.AccountMetaSlice[3] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *EnableChainSelector) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +func (inst EnableChainSelector) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_EnableChainSelector, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst EnableChainSelector) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *EnableChainSelector) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewChainSelector == nil { + return errors.New("NewChainSelector parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *EnableChainSelector) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("EnableChainSelector")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewChainSelector", *inst.NewChainSelector)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[3])) + }) + }) + }) +} + +func (obj EnableChainSelector) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewChainSelector` param: + err = encoder.Encode(obj.NewChainSelector) + if err != nil { + return err + } + return nil +} +func (obj *EnableChainSelector) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewChainSelector`: + err = decoder.Decode(&obj.NewChainSelector) + if err != nil { + return err + } + return nil +} + +// NewEnableChainSelectorInstruction declares a new EnableChainSelector instruction with the provided parameters and accounts. +func NewEnableChainSelectorInstruction( + // Parameters: + newChainSelector uint64, + // Accounts: + chainState ag_solanago.PublicKey, + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *EnableChainSelector { + return NewEnableChainSelectorInstructionBuilder(). + SetNewChainSelector(newChainSelector). + SetChainStateAccount(chainState). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/EnableChainSelector_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/EnableChainSelector_test.go new file mode 100644 index 00000000000..f14c09f534a --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/EnableChainSelector_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_EnableChainSelector(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("EnableChainSelector"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(EnableChainSelector) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(EnableChainSelector) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/Execute.go b/core/capabilities/ccip/ccipsolana/ccip_router/Execute.go new file mode 100644 index 00000000000..5ed3628dd1f --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/Execute.go @@ -0,0 +1,293 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// OFF RAMP FLOW +// +// The method name needs to be execute with Anchor encoding. +// +// This function is called by the OffChain when executing one Report to the Solana Router. +// In this Flow only one message is sent, the Execution Report. This is different as EVM does, +// this is because there is no try/catch mechanism to allow batch execution. +// This message validates that the Merkle Tree Proof of the given message is correct and is stored in the Commit Report Account. +// The message must be untouched to be executed. +// This message emits the event ExecutionStateChanged with the new state of the message. +// Finally, executes the CPI instruction to the receiver program in the ccip_receive message. +type Execute struct { + ExecutionReport *ExecutionReportSingleChain + ReportContext *[3][32]uint8 + + // [0] = [] config + // + // [1] = [] chainState + // + // [2] = [WRITE] commitReport + // + // [3] = [] externalExecutionConfig + // + // [4] = [WRITE, SIGNER] authority + // + // [5] = [] systemProgram + // + // [6] = [] sysvarInstructions + // + // [7] = [] tokenPoolsSigner + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewExecuteInstructionBuilder creates a new `Execute` instruction builder. +func NewExecuteInstructionBuilder() *Execute { + nd := &Execute{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 8), + } + return nd +} + +// SetExecutionReport sets the "executionReport" parameter. +func (inst *Execute) SetExecutionReport(executionReport ExecutionReportSingleChain) *Execute { + inst.ExecutionReport = &executionReport + return inst +} + +// SetReportContext sets the "reportContext" parameter. +func (inst *Execute) SetReportContext(reportContext [3][32]uint8) *Execute { + inst.ReportContext = &reportContext + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *Execute) SetConfigAccount(config ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *Execute) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *Execute) SetChainStateAccount(chainState ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[1] = ag_solanago.Meta(chainState) + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *Execute) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetCommitReportAccount sets the "commitReport" account. +func (inst *Execute) SetCommitReportAccount(commitReport ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[2] = ag_solanago.Meta(commitReport).WRITE() + return inst +} + +// GetCommitReportAccount gets the "commitReport" account. +func (inst *Execute) GetCommitReportAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetExternalExecutionConfigAccount sets the "externalExecutionConfig" account. +func (inst *Execute) SetExternalExecutionConfigAccount(externalExecutionConfig ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[3] = ag_solanago.Meta(externalExecutionConfig) + return inst +} + +// GetExternalExecutionConfigAccount gets the "externalExecutionConfig" account. +func (inst *Execute) GetExternalExecutionConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Execute) SetAuthorityAccount(authority ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[4] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Execute) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[4] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Execute) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[5] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Execute) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[5] +} + +// SetSysvarInstructionsAccount sets the "sysvarInstructions" account. +func (inst *Execute) SetSysvarInstructionsAccount(sysvarInstructions ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[6] = ag_solanago.Meta(sysvarInstructions) + return inst +} + +// GetSysvarInstructionsAccount gets the "sysvarInstructions" account. +func (inst *Execute) GetSysvarInstructionsAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[6] +} + +// SetTokenPoolsSignerAccount sets the "tokenPoolsSigner" account. +func (inst *Execute) SetTokenPoolsSignerAccount(tokenPoolsSigner ag_solanago.PublicKey) *Execute { + inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenPoolsSigner) + return inst +} + +// GetTokenPoolsSignerAccount gets the "tokenPoolsSigner" account. +func (inst *Execute) GetTokenPoolsSignerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[7] +} + +func (inst Execute) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Execute, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Execute) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Execute) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.ExecutionReport == nil { + return errors.New("ExecutionReport parameter is not set") + } + if inst.ReportContext == nil { + return errors.New("ReportContext parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.CommitReport is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.ExternalExecutionConfig is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.SysvarInstructions is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.TokenPoolsSigner is not set") + } + } + return nil +} + +func (inst *Execute) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Execute")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("ExecutionReport", *inst.ExecutionReport)) + paramsBranch.Child(ag_format.Param(" ReportContext", *inst.ReportContext)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=8]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" commitReport", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta("externalExecutionConfig", inst.AccountMetaSlice[3])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[4])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[5])) + accountsBranch.Child(ag_format.Meta(" sysvarInstructions", inst.AccountMetaSlice[6])) + accountsBranch.Child(ag_format.Meta(" tokenPoolsSigner", inst.AccountMetaSlice[7])) + }) + }) + }) +} + +func (obj Execute) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ExecutionReport` param: + err = encoder.Encode(obj.ExecutionReport) + if err != nil { + return err + } + // Serialize `ReportContext` param: + err = encoder.Encode(obj.ReportContext) + if err != nil { + return err + } + return nil +} +func (obj *Execute) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ExecutionReport`: + err = decoder.Decode(&obj.ExecutionReport) + if err != nil { + return err + } + // Deserialize `ReportContext`: + err = decoder.Decode(&obj.ReportContext) + if err != nil { + return err + } + return nil +} + +// NewExecuteInstruction declares a new Execute instruction with the provided parameters and accounts. +func NewExecuteInstruction( + // Parameters: + executionReport ExecutionReportSingleChain, + reportContext [3][32]uint8, + // Accounts: + config ag_solanago.PublicKey, + chainState ag_solanago.PublicKey, + commitReport ag_solanago.PublicKey, + externalExecutionConfig ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + sysvarInstructions ag_solanago.PublicKey, + tokenPoolsSigner ag_solanago.PublicKey) *Execute { + return NewExecuteInstructionBuilder(). + SetExecutionReport(executionReport). + SetReportContext(reportContext). + SetConfigAccount(config). + SetChainStateAccount(chainState). + SetCommitReportAccount(commitReport). + SetExternalExecutionConfigAccount(externalExecutionConfig). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram). + SetSysvarInstructionsAccount(sysvarInstructions). + SetTokenPoolsSignerAccount(tokenPoolsSigner) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/Execute_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/Execute_test.go new file mode 100644 index 00000000000..5c0f4d7b7ff --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/Execute_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Execute(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Execute"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Execute) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Execute) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/Initialize.go b/core/capabilities/ccip/ccipsolana/ccip_router/Initialize.go new file mode 100644 index 00000000000..ed65234f3e7 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/Initialize.go @@ -0,0 +1,310 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The initialization is responsibility of Admin, nothing more than calling this method should be done first. +type Initialize struct { + SolanaChainSelector *uint64 + DefaultGasLimit *ag_binary.Uint128 + DefaultAllowOutOfOrderExecution *bool + EnableExecutionAfter *int64 + + // [0] = [WRITE] config + // + // [1] = [WRITE, SIGNER] authority + // + // [2] = [] systemProgram + // + // [3] = [] program + // + // [4] = [] programData + // + // [5] = [WRITE] externalExecutionConfig + // + // [6] = [WRITE] tokenPoolsSigner + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewInitializeInstructionBuilder creates a new `Initialize` instruction builder. +func NewInitializeInstructionBuilder() *Initialize { + nd := &Initialize{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 7), + } + return nd +} + +// SetSolanaChainSelector sets the "solanaChainSelector" parameter. +func (inst *Initialize) SetSolanaChainSelector(solanaChainSelector uint64) *Initialize { + inst.SolanaChainSelector = &solanaChainSelector + return inst +} + +// SetDefaultGasLimit sets the "defaultGasLimit" parameter. +func (inst *Initialize) SetDefaultGasLimit(defaultGasLimit ag_binary.Uint128) *Initialize { + inst.DefaultGasLimit = &defaultGasLimit + return inst +} + +// SetDefaultAllowOutOfOrderExecution sets the "defaultAllowOutOfOrderExecution" parameter. +func (inst *Initialize) SetDefaultAllowOutOfOrderExecution(defaultAllowOutOfOrderExecution bool) *Initialize { + inst.DefaultAllowOutOfOrderExecution = &defaultAllowOutOfOrderExecution + return inst +} + +// SetEnableExecutionAfter sets the "enableExecutionAfter" parameter. +func (inst *Initialize) SetEnableExecutionAfter(enableExecutionAfter int64) *Initialize { + inst.EnableExecutionAfter = &enableExecutionAfter + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *Initialize) SetConfigAccount(config ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *Initialize) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *Initialize) SetAuthorityAccount(authority ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *Initialize) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Initialize) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Initialize) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetProgramAccount sets the "program" account. +func (inst *Initialize) SetProgramAccount(program ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[3] = ag_solanago.Meta(program) + return inst +} + +// GetProgramAccount gets the "program" account. +func (inst *Initialize) GetProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +// SetProgramDataAccount sets the "programData" account. +func (inst *Initialize) SetProgramDataAccount(programData ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[4] = ag_solanago.Meta(programData) + return inst +} + +// GetProgramDataAccount gets the "programData" account. +func (inst *Initialize) GetProgramDataAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[4] +} + +// SetExternalExecutionConfigAccount sets the "externalExecutionConfig" account. +func (inst *Initialize) SetExternalExecutionConfigAccount(externalExecutionConfig ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[5] = ag_solanago.Meta(externalExecutionConfig).WRITE() + return inst +} + +// GetExternalExecutionConfigAccount gets the "externalExecutionConfig" account. +func (inst *Initialize) GetExternalExecutionConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[5] +} + +// SetTokenPoolsSignerAccount sets the "tokenPoolsSigner" account. +func (inst *Initialize) SetTokenPoolsSignerAccount(tokenPoolsSigner ag_solanago.PublicKey) *Initialize { + inst.AccountMetaSlice[6] = ag_solanago.Meta(tokenPoolsSigner).WRITE() + return inst +} + +// GetTokenPoolsSignerAccount gets the "tokenPoolsSigner" account. +func (inst *Initialize) GetTokenPoolsSignerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[6] +} + +func (inst Initialize) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Initialize, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Initialize) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Initialize) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.SolanaChainSelector == nil { + return errors.New("SolanaChainSelector parameter is not set") + } + if inst.DefaultGasLimit == nil { + return errors.New("DefaultGasLimit parameter is not set") + } + if inst.DefaultAllowOutOfOrderExecution == nil { + return errors.New("DefaultAllowOutOfOrderExecution parameter is not set") + } + if inst.EnableExecutionAfter == nil { + return errors.New("EnableExecutionAfter parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.Program is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.ProgramData is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.ExternalExecutionConfig is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.TokenPoolsSigner is not set") + } + } + return nil +} + +func (inst *Initialize) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Initialize")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=4]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" SolanaChainSelector", *inst.SolanaChainSelector)) + paramsBranch.Child(ag_format.Param(" DefaultGasLimit", *inst.DefaultGasLimit)) + paramsBranch.Child(ag_format.Param("DefaultAllowOutOfOrderExecution", *inst.DefaultAllowOutOfOrderExecution)) + paramsBranch.Child(ag_format.Param(" EnableExecutionAfter", *inst.EnableExecutionAfter)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=7]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta(" program", inst.AccountMetaSlice[3])) + accountsBranch.Child(ag_format.Meta(" programData", inst.AccountMetaSlice[4])) + accountsBranch.Child(ag_format.Meta("externalExecutionConfig", inst.AccountMetaSlice[5])) + accountsBranch.Child(ag_format.Meta(" tokenPoolsSigner", inst.AccountMetaSlice[6])) + }) + }) + }) +} + +func (obj Initialize) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SolanaChainSelector` param: + err = encoder.Encode(obj.SolanaChainSelector) + if err != nil { + return err + } + // Serialize `DefaultGasLimit` param: + err = encoder.Encode(obj.DefaultGasLimit) + if err != nil { + return err + } + // Serialize `DefaultAllowOutOfOrderExecution` param: + err = encoder.Encode(obj.DefaultAllowOutOfOrderExecution) + if err != nil { + return err + } + // Serialize `EnableExecutionAfter` param: + err = encoder.Encode(obj.EnableExecutionAfter) + if err != nil { + return err + } + return nil +} +func (obj *Initialize) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SolanaChainSelector`: + err = decoder.Decode(&obj.SolanaChainSelector) + if err != nil { + return err + } + // Deserialize `DefaultGasLimit`: + err = decoder.Decode(&obj.DefaultGasLimit) + if err != nil { + return err + } + // Deserialize `DefaultAllowOutOfOrderExecution`: + err = decoder.Decode(&obj.DefaultAllowOutOfOrderExecution) + if err != nil { + return err + } + // Deserialize `EnableExecutionAfter`: + err = decoder.Decode(&obj.EnableExecutionAfter) + if err != nil { + return err + } + return nil +} + +// NewInitializeInstruction declares a new Initialize instruction with the provided parameters and accounts. +func NewInitializeInstruction( + // Parameters: + solanaChainSelector uint64, + defaultGasLimit ag_binary.Uint128, + defaultAllowOutOfOrderExecution bool, + enableExecutionAfter int64, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + program ag_solanago.PublicKey, + programData ag_solanago.PublicKey, + externalExecutionConfig ag_solanago.PublicKey, + tokenPoolsSigner ag_solanago.PublicKey) *Initialize { + return NewInitializeInstructionBuilder(). + SetSolanaChainSelector(solanaChainSelector). + SetDefaultGasLimit(defaultGasLimit). + SetDefaultAllowOutOfOrderExecution(defaultAllowOutOfOrderExecution). + SetEnableExecutionAfter(enableExecutionAfter). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram). + SetProgramAccount(program). + SetProgramDataAccount(programData). + SetExternalExecutionConfigAccount(externalExecutionConfig). + SetTokenPoolsSignerAccount(tokenPoolsSigner) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/Initialize_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/Initialize_test.go new file mode 100644 index 00000000000..51eed3384b8 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/Initialize_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Initialize(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Initialize"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Initialize) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Initialize) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/ManuallyExecute.go b/core/capabilities/ccip/ccipsolana/ccip_router/ManuallyExecute.go new file mode 100644 index 00000000000..7ec00306a8f --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/ManuallyExecute.go @@ -0,0 +1,261 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// When a message is not being executed, then the user can trigger the execution manually. +// No verification over the transmitter, but the message needs to be in some commit report. +type ManuallyExecute struct { + ExecutionReport *ExecutionReportSingleChain + + // [0] = [] config + // + // [1] = [] chainState + // + // [2] = [WRITE] commitReport + // + // [3] = [] externalExecutionConfig + // + // [4] = [WRITE, SIGNER] authority + // + // [5] = [] systemProgram + // + // [6] = [] sysvarInstructions + // + // [7] = [] tokenPoolsSigner + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewManuallyExecuteInstructionBuilder creates a new `ManuallyExecute` instruction builder. +func NewManuallyExecuteInstructionBuilder() *ManuallyExecute { + nd := &ManuallyExecute{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 8), + } + return nd +} + +// SetExecutionReport sets the "executionReport" parameter. +func (inst *ManuallyExecute) SetExecutionReport(executionReport ExecutionReportSingleChain) *ManuallyExecute { + inst.ExecutionReport = &executionReport + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *ManuallyExecute) SetConfigAccount(config ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *ManuallyExecute) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetChainStateAccount sets the "chainState" account. +func (inst *ManuallyExecute) SetChainStateAccount(chainState ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[1] = ag_solanago.Meta(chainState) + return inst +} + +// GetChainStateAccount gets the "chainState" account. +func (inst *ManuallyExecute) GetChainStateAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetCommitReportAccount sets the "commitReport" account. +func (inst *ManuallyExecute) SetCommitReportAccount(commitReport ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[2] = ag_solanago.Meta(commitReport).WRITE() + return inst +} + +// GetCommitReportAccount gets the "commitReport" account. +func (inst *ManuallyExecute) GetCommitReportAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetExternalExecutionConfigAccount sets the "externalExecutionConfig" account. +func (inst *ManuallyExecute) SetExternalExecutionConfigAccount(externalExecutionConfig ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[3] = ag_solanago.Meta(externalExecutionConfig) + return inst +} + +// GetExternalExecutionConfigAccount gets the "externalExecutionConfig" account. +func (inst *ManuallyExecute) GetExternalExecutionConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *ManuallyExecute) SetAuthorityAccount(authority ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[4] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *ManuallyExecute) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[4] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *ManuallyExecute) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[5] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *ManuallyExecute) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[5] +} + +// SetSysvarInstructionsAccount sets the "sysvarInstructions" account. +func (inst *ManuallyExecute) SetSysvarInstructionsAccount(sysvarInstructions ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[6] = ag_solanago.Meta(sysvarInstructions) + return inst +} + +// GetSysvarInstructionsAccount gets the "sysvarInstructions" account. +func (inst *ManuallyExecute) GetSysvarInstructionsAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[6] +} + +// SetTokenPoolsSignerAccount sets the "tokenPoolsSigner" account. +func (inst *ManuallyExecute) SetTokenPoolsSignerAccount(tokenPoolsSigner ag_solanago.PublicKey) *ManuallyExecute { + inst.AccountMetaSlice[7] = ag_solanago.Meta(tokenPoolsSigner) + return inst +} + +// GetTokenPoolsSignerAccount gets the "tokenPoolsSigner" account. +func (inst *ManuallyExecute) GetTokenPoolsSignerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[7] +} + +func (inst ManuallyExecute) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_ManuallyExecute, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst ManuallyExecute) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *ManuallyExecute) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.ExecutionReport == nil { + return errors.New("ExecutionReport parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.ChainState is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.CommitReport is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.ExternalExecutionConfig is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.SystemProgram is not set") + } + if inst.AccountMetaSlice[6] == nil { + return errors.New("accounts.SysvarInstructions is not set") + } + if inst.AccountMetaSlice[7] == nil { + return errors.New("accounts.TokenPoolsSigner is not set") + } + } + return nil +} + +func (inst *ManuallyExecute) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("ManuallyExecute")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("ExecutionReport", *inst.ExecutionReport)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=8]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" chainState", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" commitReport", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta("externalExecutionConfig", inst.AccountMetaSlice[3])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[4])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[5])) + accountsBranch.Child(ag_format.Meta(" sysvarInstructions", inst.AccountMetaSlice[6])) + accountsBranch.Child(ag_format.Meta(" tokenPoolsSigner", inst.AccountMetaSlice[7])) + }) + }) + }) +} + +func (obj ManuallyExecute) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ExecutionReport` param: + err = encoder.Encode(obj.ExecutionReport) + if err != nil { + return err + } + return nil +} +func (obj *ManuallyExecute) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ExecutionReport`: + err = decoder.Decode(&obj.ExecutionReport) + if err != nil { + return err + } + return nil +} + +// NewManuallyExecuteInstruction declares a new ManuallyExecute instruction with the provided parameters and accounts. +func NewManuallyExecuteInstruction( + // Parameters: + executionReport ExecutionReportSingleChain, + // Accounts: + config ag_solanago.PublicKey, + chainState ag_solanago.PublicKey, + commitReport ag_solanago.PublicKey, + externalExecutionConfig ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey, + sysvarInstructions ag_solanago.PublicKey, + tokenPoolsSigner ag_solanago.PublicKey) *ManuallyExecute { + return NewManuallyExecuteInstructionBuilder(). + SetExecutionReport(executionReport). + SetConfigAccount(config). + SetChainStateAccount(chainState). + SetCommitReportAccount(commitReport). + SetExternalExecutionConfigAccount(externalExecutionConfig). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram). + SetSysvarInstructionsAccount(sysvarInstructions). + SetTokenPoolsSignerAccount(tokenPoolsSigner) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/ManuallyExecute_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/ManuallyExecute_test.go new file mode 100644 index 00000000000..38f8fe33c61 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/ManuallyExecute_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_ManuallyExecute(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("ManuallyExecute"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(ManuallyExecute) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(ManuallyExecute) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaGetCcipAdmin.go b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaGetCcipAdmin.go new file mode 100644 index 00000000000..20ed495cdb4 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaGetCcipAdmin.go @@ -0,0 +1,207 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The CCIP Admin or the Mint Authority of the Token can register the Token Admin Registry +type RegisterTokenAdminRegistryViaGetCcipAdmin struct { + Mint *ag_solanago.PublicKey + TokenAdminRegistryAdmin *ag_solanago.PublicKey + + // [0] = [] config + // + // [1] = [WRITE] tokenAdminRegistry + // + // [2] = [WRITE, SIGNER] authority + // + // [3] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewRegisterTokenAdminRegistryViaGetCcipAdminInstructionBuilder creates a new `RegisterTokenAdminRegistryViaGetCcipAdmin` instruction builder. +func NewRegisterTokenAdminRegistryViaGetCcipAdminInstructionBuilder() *RegisterTokenAdminRegistryViaGetCcipAdmin { + nd := &RegisterTokenAdminRegistryViaGetCcipAdmin{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetMint sets the "mint" parameter. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) SetMint(mint ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + inst.Mint = &mint + return inst +} + +// SetTokenAdminRegistryAdmin sets the "tokenAdminRegistryAdmin" parameter. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) SetTokenAdminRegistryAdmin(tokenAdminRegistryAdmin ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + inst.TokenAdminRegistryAdmin = &tokenAdminRegistryAdmin + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) SetConfigAccount(config ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetTokenAdminRegistryAccount sets the "tokenAdminRegistry" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) SetTokenAdminRegistryAccount(tokenAdminRegistry ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + inst.AccountMetaSlice[1] = ag_solanago.Meta(tokenAdminRegistry).WRITE() + return inst +} + +// GetTokenAdminRegistryAccount gets the "tokenAdminRegistry" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) GetTokenAdminRegistryAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) SetAuthorityAccount(authority ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + inst.AccountMetaSlice[3] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +func (inst RegisterTokenAdminRegistryViaGetCcipAdmin) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RegisterTokenAdminRegistryViaGetCcipAdmin, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RegisterTokenAdminRegistryViaGetCcipAdmin) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Mint == nil { + return errors.New("Mint parameter is not set") + } + if inst.TokenAdminRegistryAdmin == nil { + return errors.New("TokenAdminRegistryAdmin parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.TokenAdminRegistry is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *RegisterTokenAdminRegistryViaGetCcipAdmin) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RegisterTokenAdminRegistryViaGetCcipAdmin")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Mint", *inst.Mint)) + paramsBranch.Child(ag_format.Param("TokenAdminRegistryAdmin", *inst.TokenAdminRegistryAdmin)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta("tokenAdminRegistry", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[3])) + }) + }) + }) +} + +func (obj RegisterTokenAdminRegistryViaGetCcipAdmin) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Mint` param: + err = encoder.Encode(obj.Mint) + if err != nil { + return err + } + // Serialize `TokenAdminRegistryAdmin` param: + err = encoder.Encode(obj.TokenAdminRegistryAdmin) + if err != nil { + return err + } + return nil +} +func (obj *RegisterTokenAdminRegistryViaGetCcipAdmin) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Mint`: + err = decoder.Decode(&obj.Mint) + if err != nil { + return err + } + // Deserialize `TokenAdminRegistryAdmin`: + err = decoder.Decode(&obj.TokenAdminRegistryAdmin) + if err != nil { + return err + } + return nil +} + +// NewRegisterTokenAdminRegistryViaGetCcipAdminInstruction declares a new RegisterTokenAdminRegistryViaGetCcipAdmin instruction with the provided parameters and accounts. +func NewRegisterTokenAdminRegistryViaGetCcipAdminInstruction( + // Parameters: + mint ag_solanago.PublicKey, + tokenAdminRegistryAdmin ag_solanago.PublicKey, + // Accounts: + config ag_solanago.PublicKey, + tokenAdminRegistry ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaGetCcipAdmin { + return NewRegisterTokenAdminRegistryViaGetCcipAdminInstructionBuilder(). + SetMint(mint). + SetTokenAdminRegistryAdmin(tokenAdminRegistryAdmin). + SetConfigAccount(config). + SetTokenAdminRegistryAccount(tokenAdminRegistry). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaGetCcipAdmin_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaGetCcipAdmin_test.go new file mode 100644 index 00000000000..29a2c212a49 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaGetCcipAdmin_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RegisterTokenAdminRegistryViaGetCcipAdmin(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RegisterTokenAdminRegistryViaGetCcipAdmin"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RegisterTokenAdminRegistryViaGetCcipAdmin) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RegisterTokenAdminRegistryViaGetCcipAdmin) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaOwner.go b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaOwner.go new file mode 100644 index 00000000000..eb79b822606 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaOwner.go @@ -0,0 +1,155 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Token's mint_authority can register themselves to the Token Admin Registry +type RegisterTokenAdminRegistryViaOwner struct { + + // [0] = [WRITE] tokenAdminRegistry + // + // [1] = [WRITE] mint + // + // [2] = [WRITE, SIGNER] authority + // + // [3] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewRegisterTokenAdminRegistryViaOwnerInstructionBuilder creates a new `RegisterTokenAdminRegistryViaOwner` instruction builder. +func NewRegisterTokenAdminRegistryViaOwnerInstructionBuilder() *RegisterTokenAdminRegistryViaOwner { + nd := &RegisterTokenAdminRegistryViaOwner{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetTokenAdminRegistryAccount sets the "tokenAdminRegistry" account. +func (inst *RegisterTokenAdminRegistryViaOwner) SetTokenAdminRegistryAccount(tokenAdminRegistry ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaOwner { + inst.AccountMetaSlice[0] = ag_solanago.Meta(tokenAdminRegistry).WRITE() + return inst +} + +// GetTokenAdminRegistryAccount gets the "tokenAdminRegistry" account. +func (inst *RegisterTokenAdminRegistryViaOwner) GetTokenAdminRegistryAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetMintAccount sets the "mint" account. +func (inst *RegisterTokenAdminRegistryViaOwner) SetMintAccount(mint ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaOwner { + inst.AccountMetaSlice[1] = ag_solanago.Meta(mint).WRITE() + return inst +} + +// GetMintAccount gets the "mint" account. +func (inst *RegisterTokenAdminRegistryViaOwner) GetMintAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *RegisterTokenAdminRegistryViaOwner) SetAuthorityAccount(authority ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaOwner { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *RegisterTokenAdminRegistryViaOwner) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *RegisterTokenAdminRegistryViaOwner) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaOwner { + inst.AccountMetaSlice[3] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *RegisterTokenAdminRegistryViaOwner) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +func (inst RegisterTokenAdminRegistryViaOwner) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_RegisterTokenAdminRegistryViaOwner, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst RegisterTokenAdminRegistryViaOwner) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *RegisterTokenAdminRegistryViaOwner) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.TokenAdminRegistry is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Mint is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *RegisterTokenAdminRegistryViaOwner) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("RegisterTokenAdminRegistryViaOwner")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("tokenAdminRegistry", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" mint", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[3])) + }) + }) + }) +} + +func (obj RegisterTokenAdminRegistryViaOwner) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *RegisterTokenAdminRegistryViaOwner) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewRegisterTokenAdminRegistryViaOwnerInstruction declares a new RegisterTokenAdminRegistryViaOwner instruction with the provided parameters and accounts. +func NewRegisterTokenAdminRegistryViaOwnerInstruction( + // Accounts: + tokenAdminRegistry ag_solanago.PublicKey, + mint ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *RegisterTokenAdminRegistryViaOwner { + return NewRegisterTokenAdminRegistryViaOwnerInstructionBuilder(). + SetTokenAdminRegistryAccount(tokenAdminRegistry). + SetMintAccount(mint). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaOwner_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaOwner_test.go new file mode 100644 index 00000000000..ea293f88b2e --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/RegisterTokenAdminRegistryViaOwner_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_RegisterTokenAdminRegistryViaOwner(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("RegisterTokenAdminRegistryViaOwner"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(RegisterTokenAdminRegistryViaOwner) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(RegisterTokenAdminRegistryViaOwner) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/SetOcrConfig.go b/core/capabilities/ccip/ccipsolana/ccip_router/SetOcrConfig.go new file mode 100644 index 00000000000..3a6420a6980 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/SetOcrConfig.go @@ -0,0 +1,215 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// SetOcrConfig is the `setOcrConfig` instruction. +type SetOcrConfig struct { + PluginType *uint8 + ConfigInfo *Ocr3ConfigInfo + Signers *[][20]uint8 + Transmitters *[]ag_solanago.PublicKey + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewSetOcrConfigInstructionBuilder creates a new `SetOcrConfig` instruction builder. +func NewSetOcrConfigInstructionBuilder() *SetOcrConfig { + nd := &SetOcrConfig{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetPluginType sets the "pluginType" parameter. +func (inst *SetOcrConfig) SetPluginType(pluginType uint8) *SetOcrConfig { + inst.PluginType = &pluginType + return inst +} + +// SetConfigInfo sets the "configInfo" parameter. +func (inst *SetOcrConfig) SetConfigInfo(configInfo Ocr3ConfigInfo) *SetOcrConfig { + inst.ConfigInfo = &configInfo + return inst +} + +// SetSigners sets the "signers" parameter. +func (inst *SetOcrConfig) SetSigners(signers [][20]uint8) *SetOcrConfig { + inst.Signers = &signers + return inst +} + +// SetTransmitters sets the "transmitters" parameter. +func (inst *SetOcrConfig) SetTransmitters(transmitters []ag_solanago.PublicKey) *SetOcrConfig { + inst.Transmitters = &transmitters + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *SetOcrConfig) SetConfigAccount(config ag_solanago.PublicKey) *SetOcrConfig { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *SetOcrConfig) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *SetOcrConfig) SetAuthorityAccount(authority ag_solanago.PublicKey) *SetOcrConfig { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *SetOcrConfig) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +func (inst SetOcrConfig) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SetOcrConfig, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SetOcrConfig) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SetOcrConfig) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.PluginType == nil { + return errors.New("PluginType parameter is not set") + } + if inst.ConfigInfo == nil { + return errors.New("ConfigInfo parameter is not set") + } + if inst.Signers == nil { + return errors.New("Signers parameter is not set") + } + if inst.Transmitters == nil { + return errors.New("Transmitters parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + } + return nil +} + +func (inst *SetOcrConfig) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SetOcrConfig")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=4]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" PluginType", *inst.PluginType)) + paramsBranch.Child(ag_format.Param(" ConfigInfo", *inst.ConfigInfo)) + paramsBranch.Child(ag_format.Param(" Signers", *inst.Signers)) + paramsBranch.Child(ag_format.Param("Transmitters", *inst.Transmitters)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta("authority", inst.AccountMetaSlice[1])) + }) + }) + }) +} + +func (obj SetOcrConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PluginType` param: + err = encoder.Encode(obj.PluginType) + if err != nil { + return err + } + // Serialize `ConfigInfo` param: + err = encoder.Encode(obj.ConfigInfo) + if err != nil { + return err + } + // Serialize `Signers` param: + err = encoder.Encode(obj.Signers) + if err != nil { + return err + } + // Serialize `Transmitters` param: + err = encoder.Encode(obj.Transmitters) + if err != nil { + return err + } + return nil +} +func (obj *SetOcrConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PluginType`: + err = decoder.Decode(&obj.PluginType) + if err != nil { + return err + } + // Deserialize `ConfigInfo`: + err = decoder.Decode(&obj.ConfigInfo) + if err != nil { + return err + } + // Deserialize `Signers`: + err = decoder.Decode(&obj.Signers) + if err != nil { + return err + } + // Deserialize `Transmitters`: + err = decoder.Decode(&obj.Transmitters) + if err != nil { + return err + } + return nil +} + +// NewSetOcrConfigInstruction declares a new SetOcrConfig instruction with the provided parameters and accounts. +func NewSetOcrConfigInstruction( + // Parameters: + pluginType uint8, + configInfo Ocr3ConfigInfo, + signers [][20]uint8, + transmitters []ag_solanago.PublicKey, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey) *SetOcrConfig { + return NewSetOcrConfigInstructionBuilder(). + SetPluginType(pluginType). + SetConfigInfo(configInfo). + SetSigners(signers). + SetTransmitters(transmitters). + SetConfigAccount(config). + SetAuthorityAccount(authority) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/SetOcrConfig_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/SetOcrConfig_test.go new file mode 100644 index 00000000000..88528fc48ea --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/SetOcrConfig_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SetOcrConfig(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SetOcrConfig"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SetOcrConfig) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SetOcrConfig) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/SetPool.go b/core/capabilities/ccip/ccipsolana/ccip_router/SetPool.go new file mode 100644 index 00000000000..69cdc9ba5e1 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/SetPool.go @@ -0,0 +1,169 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The administrator of the token can setup the token pool +type SetPool struct { + Mint *ag_solanago.PublicKey + PoolLookupTable *ag_solanago.PublicKey + + // [0] = [WRITE] tokenAdminRegistry + // + // [1] = [WRITE, SIGNER] authority + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewSetPoolInstructionBuilder creates a new `SetPool` instruction builder. +func NewSetPoolInstructionBuilder() *SetPool { + nd := &SetPool{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetMint sets the "mint" parameter. +func (inst *SetPool) SetMint(mint ag_solanago.PublicKey) *SetPool { + inst.Mint = &mint + return inst +} + +// SetPoolLookupTable sets the "poolLookupTable" parameter. +func (inst *SetPool) SetPoolLookupTable(poolLookupTable ag_solanago.PublicKey) *SetPool { + inst.PoolLookupTable = &poolLookupTable + return inst +} + +// SetTokenAdminRegistryAccount sets the "tokenAdminRegistry" account. +func (inst *SetPool) SetTokenAdminRegistryAccount(tokenAdminRegistry ag_solanago.PublicKey) *SetPool { + inst.AccountMetaSlice[0] = ag_solanago.Meta(tokenAdminRegistry).WRITE() + return inst +} + +// GetTokenAdminRegistryAccount gets the "tokenAdminRegistry" account. +func (inst *SetPool) GetTokenAdminRegistryAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *SetPool) SetAuthorityAccount(authority ag_solanago.PublicKey) *SetPool { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *SetPool) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +func (inst SetPool) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SetPool, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SetPool) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SetPool) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Mint == nil { + return errors.New("Mint parameter is not set") + } + if inst.PoolLookupTable == nil { + return errors.New("PoolLookupTable parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.TokenAdminRegistry is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + } + return nil +} + +func (inst *SetPool) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SetPool")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Mint", *inst.Mint)) + paramsBranch.Child(ag_format.Param("PoolLookupTable", *inst.PoolLookupTable)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("tokenAdminRegistry", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + }) + }) + }) +} + +func (obj SetPool) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Mint` param: + err = encoder.Encode(obj.Mint) + if err != nil { + return err + } + // Serialize `PoolLookupTable` param: + err = encoder.Encode(obj.PoolLookupTable) + if err != nil { + return err + } + return nil +} +func (obj *SetPool) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Mint`: + err = decoder.Decode(&obj.Mint) + if err != nil { + return err + } + // Deserialize `PoolLookupTable`: + err = decoder.Decode(&obj.PoolLookupTable) + if err != nil { + return err + } + return nil +} + +// NewSetPoolInstruction declares a new SetPool instruction with the provided parameters and accounts. +func NewSetPoolInstruction( + // Parameters: + mint ag_solanago.PublicKey, + poolLookupTable ag_solanago.PublicKey, + // Accounts: + tokenAdminRegistry ag_solanago.PublicKey, + authority ag_solanago.PublicKey) *SetPool { + return NewSetPoolInstructionBuilder(). + SetMint(mint). + SetPoolLookupTable(poolLookupTable). + SetTokenAdminRegistryAccount(tokenAdminRegistry). + SetAuthorityAccount(authority) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/SetPool_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/SetPool_test.go new file mode 100644 index 00000000000..249513a25ba --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/SetPool_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SetPool(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SetPool"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SetPool) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SetPool) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/SetTokenBilling.go b/core/capabilities/ccip/ccipsolana/ccip_router/SetTokenBilling.go new file mode 100644 index 00000000000..41f1bcd34a5 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/SetTokenBilling.go @@ -0,0 +1,230 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// SetTokenBilling is the `setTokenBilling` instruction. +type SetTokenBilling struct { + ChainSelector *uint64 + Mint *ag_solanago.PublicKey + Cfg *TokenBilling + + // [0] = [] config + // + // [1] = [WRITE] perChainPerTokenConfig + // + // [2] = [WRITE, SIGNER] authority + // + // [3] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewSetTokenBillingInstructionBuilder creates a new `SetTokenBilling` instruction builder. +func NewSetTokenBillingInstructionBuilder() *SetTokenBilling { + nd := &SetTokenBilling{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4), + } + return nd +} + +// SetChainSelector sets the "chainSelector" parameter. +func (inst *SetTokenBilling) SetChainSelector(chainSelector uint64) *SetTokenBilling { + inst.ChainSelector = &chainSelector + return inst +} + +// SetMint sets the "mint" parameter. +func (inst *SetTokenBilling) SetMint(mint ag_solanago.PublicKey) *SetTokenBilling { + inst.Mint = &mint + return inst +} + +// SetCfg sets the "cfg" parameter. +func (inst *SetTokenBilling) SetCfg(cfg TokenBilling) *SetTokenBilling { + inst.Cfg = &cfg + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *SetTokenBilling) SetConfigAccount(config ag_solanago.PublicKey) *SetTokenBilling { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config) + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *SetTokenBilling) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetPerChainPerTokenConfigAccount sets the "perChainPerTokenConfig" account. +func (inst *SetTokenBilling) SetPerChainPerTokenConfigAccount(perChainPerTokenConfig ag_solanago.PublicKey) *SetTokenBilling { + inst.AccountMetaSlice[1] = ag_solanago.Meta(perChainPerTokenConfig).WRITE() + return inst +} + +// GetPerChainPerTokenConfigAccount gets the "perChainPerTokenConfig" account. +func (inst *SetTokenBilling) GetPerChainPerTokenConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *SetTokenBilling) SetAuthorityAccount(authority ag_solanago.PublicKey) *SetTokenBilling { + inst.AccountMetaSlice[2] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *SetTokenBilling) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *SetTokenBilling) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *SetTokenBilling { + inst.AccountMetaSlice[3] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *SetTokenBilling) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[3] +} + +func (inst SetTokenBilling) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_SetTokenBilling, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst SetTokenBilling) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *SetTokenBilling) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.ChainSelector == nil { + return errors.New("ChainSelector parameter is not set") + } + if inst.Mint == nil { + return errors.New("Mint parameter is not set") + } + if inst.Cfg == nil { + return errors.New("Cfg parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.PerChainPerTokenConfig is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *SetTokenBilling) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("SetTokenBilling")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=3]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("ChainSelector", *inst.ChainSelector)) + paramsBranch.Child(ag_format.Param(" Mint", *inst.Mint)) + paramsBranch.Child(ag_format.Param(" Cfg", *inst.Cfg)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta("perChainPerTokenConfig", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[2])) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice[3])) + }) + }) + }) +} + +func (obj SetTokenBilling) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ChainSelector` param: + err = encoder.Encode(obj.ChainSelector) + if err != nil { + return err + } + // Serialize `Mint` param: + err = encoder.Encode(obj.Mint) + if err != nil { + return err + } + // Serialize `Cfg` param: + err = encoder.Encode(obj.Cfg) + if err != nil { + return err + } + return nil +} +func (obj *SetTokenBilling) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ChainSelector`: + err = decoder.Decode(&obj.ChainSelector) + if err != nil { + return err + } + // Deserialize `Mint`: + err = decoder.Decode(&obj.Mint) + if err != nil { + return err + } + // Deserialize `Cfg`: + err = decoder.Decode(&obj.Cfg) + if err != nil { + return err + } + return nil +} + +// NewSetTokenBillingInstruction declares a new SetTokenBilling instruction with the provided parameters and accounts. +func NewSetTokenBillingInstruction( + // Parameters: + chainSelector uint64, + mint ag_solanago.PublicKey, + cfg TokenBilling, + // Accounts: + config ag_solanago.PublicKey, + perChainPerTokenConfig ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *SetTokenBilling { + return NewSetTokenBillingInstructionBuilder(). + SetChainSelector(chainSelector). + SetMint(mint). + SetCfg(cfg). + SetConfigAccount(config). + SetPerChainPerTokenConfigAccount(perChainPerTokenConfig). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/SetTokenBilling_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/SetTokenBilling_test.go new file mode 100644 index 00000000000..aff9d60f3d3 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/SetTokenBilling_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_SetTokenBilling(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("SetTokenBilling"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(SetTokenBilling) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(SetTokenBilling) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/TransferAdminRoleTokenAdminRegistry.go b/core/capabilities/ccip/ccipsolana/ccip_router/TransferAdminRoleTokenAdminRegistry.go new file mode 100644 index 00000000000..269a086456d --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/TransferAdminRoleTokenAdminRegistry.go @@ -0,0 +1,169 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin can transfer the Admin Role of the Token Admin Registry +type TransferAdminRoleTokenAdminRegistry struct { + Mint *ag_solanago.PublicKey + NewAdmin *ag_solanago.PublicKey + + // [0] = [WRITE] tokenAdminRegistry + // + // [1] = [WRITE, SIGNER] authority + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewTransferAdminRoleTokenAdminRegistryInstructionBuilder creates a new `TransferAdminRoleTokenAdminRegistry` instruction builder. +func NewTransferAdminRoleTokenAdminRegistryInstructionBuilder() *TransferAdminRoleTokenAdminRegistry { + nd := &TransferAdminRoleTokenAdminRegistry{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetMint sets the "mint" parameter. +func (inst *TransferAdminRoleTokenAdminRegistry) SetMint(mint ag_solanago.PublicKey) *TransferAdminRoleTokenAdminRegistry { + inst.Mint = &mint + return inst +} + +// SetNewAdmin sets the "newAdmin" parameter. +func (inst *TransferAdminRoleTokenAdminRegistry) SetNewAdmin(newAdmin ag_solanago.PublicKey) *TransferAdminRoleTokenAdminRegistry { + inst.NewAdmin = &newAdmin + return inst +} + +// SetTokenAdminRegistryAccount sets the "tokenAdminRegistry" account. +func (inst *TransferAdminRoleTokenAdminRegistry) SetTokenAdminRegistryAccount(tokenAdminRegistry ag_solanago.PublicKey) *TransferAdminRoleTokenAdminRegistry { + inst.AccountMetaSlice[0] = ag_solanago.Meta(tokenAdminRegistry).WRITE() + return inst +} + +// GetTokenAdminRegistryAccount gets the "tokenAdminRegistry" account. +func (inst *TransferAdminRoleTokenAdminRegistry) GetTokenAdminRegistryAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *TransferAdminRoleTokenAdminRegistry) SetAuthorityAccount(authority ag_solanago.PublicKey) *TransferAdminRoleTokenAdminRegistry { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).WRITE().SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *TransferAdminRoleTokenAdminRegistry) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +func (inst TransferAdminRoleTokenAdminRegistry) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_TransferAdminRoleTokenAdminRegistry, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst TransferAdminRoleTokenAdminRegistry) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *TransferAdminRoleTokenAdminRegistry) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Mint == nil { + return errors.New("Mint parameter is not set") + } + if inst.NewAdmin == nil { + return errors.New("NewAdmin parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.TokenAdminRegistry is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + } + return nil +} + +func (inst *TransferAdminRoleTokenAdminRegistry) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("TransferAdminRoleTokenAdminRegistry")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=2]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param(" Mint", *inst.Mint)) + paramsBranch.Child(ag_format.Param("NewAdmin", *inst.NewAdmin)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta("tokenAdminRegistry", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + }) + }) + }) +} + +func (obj TransferAdminRoleTokenAdminRegistry) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Mint` param: + err = encoder.Encode(obj.Mint) + if err != nil { + return err + } + // Serialize `NewAdmin` param: + err = encoder.Encode(obj.NewAdmin) + if err != nil { + return err + } + return nil +} +func (obj *TransferAdminRoleTokenAdminRegistry) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Mint`: + err = decoder.Decode(&obj.Mint) + if err != nil { + return err + } + // Deserialize `NewAdmin`: + err = decoder.Decode(&obj.NewAdmin) + if err != nil { + return err + } + return nil +} + +// NewTransferAdminRoleTokenAdminRegistryInstruction declares a new TransferAdminRoleTokenAdminRegistry instruction with the provided parameters and accounts. +func NewTransferAdminRoleTokenAdminRegistryInstruction( + // Parameters: + mint ag_solanago.PublicKey, + newAdmin ag_solanago.PublicKey, + // Accounts: + tokenAdminRegistry ag_solanago.PublicKey, + authority ag_solanago.PublicKey) *TransferAdminRoleTokenAdminRegistry { + return NewTransferAdminRoleTokenAdminRegistryInstructionBuilder(). + SetMint(mint). + SetNewAdmin(newAdmin). + SetTokenAdminRegistryAccount(tokenAdminRegistry). + SetAuthorityAccount(authority) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/TransferAdminRoleTokenAdminRegistry_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/TransferAdminRoleTokenAdminRegistry_test.go new file mode 100644 index 00000000000..e52c1a9983e --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/TransferAdminRoleTokenAdminRegistry_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_TransferAdminRoleTokenAdminRegistry(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("TransferAdminRoleTokenAdminRegistry"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(TransferAdminRoleTokenAdminRegistry) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(TransferAdminRoleTokenAdminRegistry) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/TransferOwnership.go b/core/capabilities/ccip/ccipsolana/ccip_router/TransferOwnership.go new file mode 100644 index 00000000000..37a129be90c --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/TransferOwnership.go @@ -0,0 +1,146 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// TransferOwnership is the `transferOwnership` instruction. +type TransferOwnership struct { + ProposedOwner *ag_solanago.PublicKey + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewTransferOwnershipInstructionBuilder creates a new `TransferOwnership` instruction builder. +func NewTransferOwnershipInstructionBuilder() *TransferOwnership { + nd := &TransferOwnership{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetProposedOwner sets the "proposedOwner" parameter. +func (inst *TransferOwnership) SetProposedOwner(proposedOwner ag_solanago.PublicKey) *TransferOwnership { + inst.ProposedOwner = &proposedOwner + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *TransferOwnership) SetConfigAccount(config ag_solanago.PublicKey) *TransferOwnership { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *TransferOwnership) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *TransferOwnership) SetAuthorityAccount(authority ag_solanago.PublicKey) *TransferOwnership { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *TransferOwnership) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +func (inst TransferOwnership) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_TransferOwnership, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst TransferOwnership) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *TransferOwnership) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.ProposedOwner == nil { + return errors.New("ProposedOwner parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + } + return nil +} + +func (inst *TransferOwnership) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("TransferOwnership")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("ProposedOwner", *inst.ProposedOwner)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta("authority", inst.AccountMetaSlice[1])) + }) + }) + }) +} + +func (obj TransferOwnership) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ProposedOwner` param: + err = encoder.Encode(obj.ProposedOwner) + if err != nil { + return err + } + return nil +} +func (obj *TransferOwnership) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ProposedOwner`: + err = decoder.Decode(&obj.ProposedOwner) + if err != nil { + return err + } + return nil +} + +// NewTransferOwnershipInstruction declares a new TransferOwnership instruction with the provided parameters and accounts. +func NewTransferOwnershipInstruction( + // Parameters: + proposedOwner ag_solanago.PublicKey, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey) *TransferOwnership { + return NewTransferOwnershipInstructionBuilder(). + SetProposedOwner(proposedOwner). + SetConfigAccount(config). + SetAuthorityAccount(authority) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/TransferOwnership_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/TransferOwnership_test.go new file mode 100644 index 00000000000..38ea4ea34f1 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/TransferOwnership_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_TransferOwnership(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("TransferOwnership"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(TransferOwnership) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(TransferOwnership) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultAllowOutOfOrderExecution.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultAllowOutOfOrderExecution.go new file mode 100644 index 00000000000..87e10696877 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultAllowOutOfOrderExecution.go @@ -0,0 +1,165 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin can update the configuration of the Router, in this case the Default Allow Out Of Order Execution (True/False) +type UpdateDefaultAllowOutOfOrderExecution struct { + NewAllowOutOfOrderExecution *bool + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + // + // [2] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewUpdateDefaultAllowOutOfOrderExecutionInstructionBuilder creates a new `UpdateDefaultAllowOutOfOrderExecution` instruction builder. +func NewUpdateDefaultAllowOutOfOrderExecutionInstructionBuilder() *UpdateDefaultAllowOutOfOrderExecution { + nd := &UpdateDefaultAllowOutOfOrderExecution{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetNewAllowOutOfOrderExecution sets the "newAllowOutOfOrderExecution" parameter. +func (inst *UpdateDefaultAllowOutOfOrderExecution) SetNewAllowOutOfOrderExecution(newAllowOutOfOrderExecution bool) *UpdateDefaultAllowOutOfOrderExecution { + inst.NewAllowOutOfOrderExecution = &newAllowOutOfOrderExecution + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *UpdateDefaultAllowOutOfOrderExecution) SetConfigAccount(config ag_solanago.PublicKey) *UpdateDefaultAllowOutOfOrderExecution { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *UpdateDefaultAllowOutOfOrderExecution) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *UpdateDefaultAllowOutOfOrderExecution) SetAuthorityAccount(authority ag_solanago.PublicKey) *UpdateDefaultAllowOutOfOrderExecution { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *UpdateDefaultAllowOutOfOrderExecution) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *UpdateDefaultAllowOutOfOrderExecution) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *UpdateDefaultAllowOutOfOrderExecution { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *UpdateDefaultAllowOutOfOrderExecution) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +func (inst UpdateDefaultAllowOutOfOrderExecution) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_UpdateDefaultAllowOutOfOrderExecution, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst UpdateDefaultAllowOutOfOrderExecution) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *UpdateDefaultAllowOutOfOrderExecution) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewAllowOutOfOrderExecution == nil { + return errors.New("NewAllowOutOfOrderExecution parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *UpdateDefaultAllowOutOfOrderExecution) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("UpdateDefaultAllowOutOfOrderExecution")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewAllowOutOfOrderExecution", *inst.NewAllowOutOfOrderExecution)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[2])) + }) + }) + }) +} + +func (obj UpdateDefaultAllowOutOfOrderExecution) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewAllowOutOfOrderExecution` param: + err = encoder.Encode(obj.NewAllowOutOfOrderExecution) + if err != nil { + return err + } + return nil +} +func (obj *UpdateDefaultAllowOutOfOrderExecution) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewAllowOutOfOrderExecution`: + err = decoder.Decode(&obj.NewAllowOutOfOrderExecution) + if err != nil { + return err + } + return nil +} + +// NewUpdateDefaultAllowOutOfOrderExecutionInstruction declares a new UpdateDefaultAllowOutOfOrderExecution instruction with the provided parameters and accounts. +func NewUpdateDefaultAllowOutOfOrderExecutionInstruction( + // Parameters: + newAllowOutOfOrderExecution bool, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *UpdateDefaultAllowOutOfOrderExecution { + return NewUpdateDefaultAllowOutOfOrderExecutionInstructionBuilder(). + SetNewAllowOutOfOrderExecution(newAllowOutOfOrderExecution). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultAllowOutOfOrderExecution_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultAllowOutOfOrderExecution_test.go new file mode 100644 index 00000000000..70a0674748c --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultAllowOutOfOrderExecution_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_UpdateDefaultAllowOutOfOrderExecution(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("UpdateDefaultAllowOutOfOrderExecution"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(UpdateDefaultAllowOutOfOrderExecution) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(UpdateDefaultAllowOutOfOrderExecution) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultGasLimit.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultGasLimit.go new file mode 100644 index 00000000000..c1791685884 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultGasLimit.go @@ -0,0 +1,165 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin can update the configuration of the Router, in this case the Default Gas Limit +type UpdateDefaultGasLimit struct { + NewGasLimit *ag_binary.Uint128 + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + // + // [2] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewUpdateDefaultGasLimitInstructionBuilder creates a new `UpdateDefaultGasLimit` instruction builder. +func NewUpdateDefaultGasLimitInstructionBuilder() *UpdateDefaultGasLimit { + nd := &UpdateDefaultGasLimit{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetNewGasLimit sets the "newGasLimit" parameter. +func (inst *UpdateDefaultGasLimit) SetNewGasLimit(newGasLimit ag_binary.Uint128) *UpdateDefaultGasLimit { + inst.NewGasLimit = &newGasLimit + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *UpdateDefaultGasLimit) SetConfigAccount(config ag_solanago.PublicKey) *UpdateDefaultGasLimit { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *UpdateDefaultGasLimit) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *UpdateDefaultGasLimit) SetAuthorityAccount(authority ag_solanago.PublicKey) *UpdateDefaultGasLimit { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *UpdateDefaultGasLimit) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *UpdateDefaultGasLimit) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *UpdateDefaultGasLimit { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *UpdateDefaultGasLimit) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +func (inst UpdateDefaultGasLimit) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_UpdateDefaultGasLimit, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst UpdateDefaultGasLimit) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *UpdateDefaultGasLimit) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewGasLimit == nil { + return errors.New("NewGasLimit parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *UpdateDefaultGasLimit) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("UpdateDefaultGasLimit")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewGasLimit", *inst.NewGasLimit)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[2])) + }) + }) + }) +} + +func (obj UpdateDefaultGasLimit) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewGasLimit` param: + err = encoder.Encode(obj.NewGasLimit) + if err != nil { + return err + } + return nil +} +func (obj *UpdateDefaultGasLimit) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewGasLimit`: + err = decoder.Decode(&obj.NewGasLimit) + if err != nil { + return err + } + return nil +} + +// NewUpdateDefaultGasLimitInstruction declares a new UpdateDefaultGasLimit instruction with the provided parameters and accounts. +func NewUpdateDefaultGasLimitInstruction( + // Parameters: + newGasLimit ag_binary.Uint128, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *UpdateDefaultGasLimit { + return NewUpdateDefaultGasLimitInstructionBuilder(). + SetNewGasLimit(newGasLimit). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultGasLimit_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultGasLimit_test.go new file mode 100644 index 00000000000..f323c69e6b8 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateDefaultGasLimit_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_UpdateDefaultGasLimit(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("UpdateDefaultGasLimit"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(UpdateDefaultGasLimit) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(UpdateDefaultGasLimit) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateEnableManualExecutionAfter.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateEnableManualExecutionAfter.go new file mode 100644 index 00000000000..5adb9d10708 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateEnableManualExecutionAfter.go @@ -0,0 +1,165 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin can update the configuration of the Router, in this case the Enable Manual Execution After +type UpdateEnableManualExecutionAfter struct { + NewEnableManualExecutionAfter *int64 + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + // + // [2] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewUpdateEnableManualExecutionAfterInstructionBuilder creates a new `UpdateEnableManualExecutionAfter` instruction builder. +func NewUpdateEnableManualExecutionAfterInstructionBuilder() *UpdateEnableManualExecutionAfter { + nd := &UpdateEnableManualExecutionAfter{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetNewEnableManualExecutionAfter sets the "newEnableManualExecutionAfter" parameter. +func (inst *UpdateEnableManualExecutionAfter) SetNewEnableManualExecutionAfter(newEnableManualExecutionAfter int64) *UpdateEnableManualExecutionAfter { + inst.NewEnableManualExecutionAfter = &newEnableManualExecutionAfter + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *UpdateEnableManualExecutionAfter) SetConfigAccount(config ag_solanago.PublicKey) *UpdateEnableManualExecutionAfter { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *UpdateEnableManualExecutionAfter) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *UpdateEnableManualExecutionAfter) SetAuthorityAccount(authority ag_solanago.PublicKey) *UpdateEnableManualExecutionAfter { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *UpdateEnableManualExecutionAfter) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *UpdateEnableManualExecutionAfter) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *UpdateEnableManualExecutionAfter { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *UpdateEnableManualExecutionAfter) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +func (inst UpdateEnableManualExecutionAfter) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_UpdateEnableManualExecutionAfter, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst UpdateEnableManualExecutionAfter) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *UpdateEnableManualExecutionAfter) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewEnableManualExecutionAfter == nil { + return errors.New("NewEnableManualExecutionAfter parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *UpdateEnableManualExecutionAfter) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("UpdateEnableManualExecutionAfter")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewEnableManualExecutionAfter", *inst.NewEnableManualExecutionAfter)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[2])) + }) + }) + }) +} + +func (obj UpdateEnableManualExecutionAfter) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewEnableManualExecutionAfter` param: + err = encoder.Encode(obj.NewEnableManualExecutionAfter) + if err != nil { + return err + } + return nil +} +func (obj *UpdateEnableManualExecutionAfter) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewEnableManualExecutionAfter`: + err = decoder.Decode(&obj.NewEnableManualExecutionAfter) + if err != nil { + return err + } + return nil +} + +// NewUpdateEnableManualExecutionAfterInstruction declares a new UpdateEnableManualExecutionAfter instruction with the provided parameters and accounts. +func NewUpdateEnableManualExecutionAfterInstruction( + // Parameters: + newEnableManualExecutionAfter int64, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *UpdateEnableManualExecutionAfter { + return NewUpdateEnableManualExecutionAfterInstructionBuilder(). + SetNewEnableManualExecutionAfter(newEnableManualExecutionAfter). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateEnableManualExecutionAfter_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateEnableManualExecutionAfter_test.go new file mode 100644 index 00000000000..cc37505f599 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateEnableManualExecutionAfter_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_UpdateEnableManualExecutionAfter(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("UpdateEnableManualExecutionAfter"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(UpdateEnableManualExecutionAfter) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(UpdateEnableManualExecutionAfter) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateSolanaChainSelector.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateSolanaChainSelector.go new file mode 100644 index 00000000000..58796f4e381 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateSolanaChainSelector.go @@ -0,0 +1,165 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "errors" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_format "github.com/gagliardetto/solana-go/text/format" + ag_treeout "github.com/gagliardetto/treeout" +) + +// The Admin can update the configuration of the Router, in this case the Solana Chain Selector +type UpdateSolanaChainSelector struct { + NewChainSelector *uint64 + + // [0] = [WRITE] config + // + // [1] = [SIGNER] authority + // + // [2] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-" borsh_skip:"true"` +} + +// NewUpdateSolanaChainSelectorInstructionBuilder creates a new `UpdateSolanaChainSelector` instruction builder. +func NewUpdateSolanaChainSelectorInstructionBuilder() *UpdateSolanaChainSelector { + nd := &UpdateSolanaChainSelector{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), + } + return nd +} + +// SetNewChainSelector sets the "newChainSelector" parameter. +func (inst *UpdateSolanaChainSelector) SetNewChainSelector(newChainSelector uint64) *UpdateSolanaChainSelector { + inst.NewChainSelector = &newChainSelector + return inst +} + +// SetConfigAccount sets the "config" account. +func (inst *UpdateSolanaChainSelector) SetConfigAccount(config ag_solanago.PublicKey) *UpdateSolanaChainSelector { + inst.AccountMetaSlice[0] = ag_solanago.Meta(config).WRITE() + return inst +} + +// GetConfigAccount gets the "config" account. +func (inst *UpdateSolanaChainSelector) GetConfigAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[0] +} + +// SetAuthorityAccount sets the "authority" account. +func (inst *UpdateSolanaChainSelector) SetAuthorityAccount(authority ag_solanago.PublicKey) *UpdateSolanaChainSelector { + inst.AccountMetaSlice[1] = ag_solanago.Meta(authority).SIGNER() + return inst +} + +// GetAuthorityAccount gets the "authority" account. +func (inst *UpdateSolanaChainSelector) GetAuthorityAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[1] +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *UpdateSolanaChainSelector) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *UpdateSolanaChainSelector { + inst.AccountMetaSlice[2] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *UpdateSolanaChainSelector) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice[2] +} + +func (inst UpdateSolanaChainSelector) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_UpdateSolanaChainSelector, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst UpdateSolanaChainSelector) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *UpdateSolanaChainSelector) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.NewChainSelector == nil { + return errors.New("NewChainSelector parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Config is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.Authority is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *UpdateSolanaChainSelector) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("UpdateSolanaChainSelector")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("NewChainSelector", *inst.NewChainSelector)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" config", inst.AccountMetaSlice[0])) + accountsBranch.Child(ag_format.Meta(" authority", inst.AccountMetaSlice[1])) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice[2])) + }) + }) + }) +} + +func (obj UpdateSolanaChainSelector) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `NewChainSelector` param: + err = encoder.Encode(obj.NewChainSelector) + if err != nil { + return err + } + return nil +} +func (obj *UpdateSolanaChainSelector) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `NewChainSelector`: + err = decoder.Decode(&obj.NewChainSelector) + if err != nil { + return err + } + return nil +} + +// NewUpdateSolanaChainSelectorInstruction declares a new UpdateSolanaChainSelector instruction with the provided parameters and accounts. +func NewUpdateSolanaChainSelectorInstruction( + // Parameters: + newChainSelector uint64, + // Accounts: + config ag_solanago.PublicKey, + authority ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *UpdateSolanaChainSelector { + return NewUpdateSolanaChainSelectorInstructionBuilder(). + SetNewChainSelector(newChainSelector). + SetConfigAccount(config). + SetAuthorityAccount(authority). + SetSystemProgramAccount(systemProgram) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/UpdateSolanaChainSelector_test.go b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateSolanaChainSelector_test.go new file mode 100644 index 00000000000..00901a4a9af --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/UpdateSolanaChainSelector_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_UpdateSolanaChainSelector(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("UpdateSolanaChainSelector"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(UpdateSolanaChainSelector) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(UpdateSolanaChainSelector) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/accounts.go b/core/capabilities/ccip/ccipsolana/ccip_router/accounts.go new file mode 100644 index 00000000000..44c43c1d364 --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/accounts.go @@ -0,0 +1,661 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "fmt" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type Config struct { + Version uint8 + DefaultAllowOutOfOrderExecution uint8 + Padding0 [6]uint8 + SolanaChainSelector uint64 + DefaultGasLimit ag_binary.Uint128 + Padding1 [8]uint8 + Owner ag_solanago.PublicKey + ProposedOwner ag_solanago.PublicKey + EnableManualExecutionAfter int64 + Padding2 [8]uint8 + Ocr3 [2]Ocr3Config +} + +var ConfigDiscriminator = [8]byte{155, 12, 170, 224, 30, 250, 204, 130} + +func (obj Config) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(ConfigDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `DefaultAllowOutOfOrderExecution` param: + err = encoder.Encode(obj.DefaultAllowOutOfOrderExecution) + if err != nil { + return err + } + // Serialize `Padding0` param: + err = encoder.Encode(obj.Padding0) + if err != nil { + return err + } + // Serialize `SolanaChainSelector` param: + err = encoder.Encode(obj.SolanaChainSelector) + if err != nil { + return err + } + // Serialize `DefaultGasLimit` param: + err = encoder.Encode(obj.DefaultGasLimit) + if err != nil { + return err + } + // Serialize `Padding1` param: + err = encoder.Encode(obj.Padding1) + if err != nil { + return err + } + // Serialize `Owner` param: + err = encoder.Encode(obj.Owner) + if err != nil { + return err + } + // Serialize `ProposedOwner` param: + err = encoder.Encode(obj.ProposedOwner) + if err != nil { + return err + } + // Serialize `EnableManualExecutionAfter` param: + err = encoder.Encode(obj.EnableManualExecutionAfter) + if err != nil { + return err + } + // Serialize `Padding2` param: + err = encoder.Encode(obj.Padding2) + if err != nil { + return err + } + // Serialize `Ocr3` param: + err = encoder.Encode(obj.Ocr3) + if err != nil { + return err + } + return nil +} + +func (obj *Config) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(ConfigDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[155 12 170 224 30 250 204 130]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `DefaultAllowOutOfOrderExecution`: + err = decoder.Decode(&obj.DefaultAllowOutOfOrderExecution) + if err != nil { + return err + } + // Deserialize `Padding0`: + err = decoder.Decode(&obj.Padding0) + if err != nil { + return err + } + // Deserialize `SolanaChainSelector`: + err = decoder.Decode(&obj.SolanaChainSelector) + if err != nil { + return err + } + // Deserialize `DefaultGasLimit`: + err = decoder.Decode(&obj.DefaultGasLimit) + if err != nil { + return err + } + // Deserialize `Padding1`: + err = decoder.Decode(&obj.Padding1) + if err != nil { + return err + } + // Deserialize `Owner`: + err = decoder.Decode(&obj.Owner) + if err != nil { + return err + } + // Deserialize `ProposedOwner`: + err = decoder.Decode(&obj.ProposedOwner) + if err != nil { + return err + } + // Deserialize `EnableManualExecutionAfter`: + err = decoder.Decode(&obj.EnableManualExecutionAfter) + if err != nil { + return err + } + // Deserialize `Padding2`: + err = decoder.Decode(&obj.Padding2) + if err != nil { + return err + } + // Deserialize `Ocr3`: + err = decoder.Decode(&obj.Ocr3) + if err != nil { + return err + } + return nil +} + +type ChainState struct { + Version uint8 + SourceChainConfig SourceChainConfig + DestChainConfig DestChainConfig +} + +var ChainStateDiscriminator = [8]byte{130, 46, 94, 156, 79, 53, 170, 50} + +func (obj ChainState) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(ChainStateDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `SourceChainConfig` param: + err = encoder.Encode(obj.SourceChainConfig) + if err != nil { + return err + } + // Serialize `DestChainConfig` param: + err = encoder.Encode(obj.DestChainConfig) + if err != nil { + return err + } + return nil +} + +func (obj *ChainState) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(ChainStateDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[130 46 94 156 79 53 170 50]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `SourceChainConfig`: + err = decoder.Decode(&obj.SourceChainConfig) + if err != nil { + return err + } + // Deserialize `DestChainConfig`: + err = decoder.Decode(&obj.DestChainConfig) + if err != nil { + return err + } + return nil +} + +type Nonce struct { + Version uint8 + Counter uint64 +} + +var NonceDiscriminator = [8]byte{143, 197, 147, 95, 106, 165, 50, 43} + +func (obj Nonce) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(NonceDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `Counter` param: + err = encoder.Encode(obj.Counter) + if err != nil { + return err + } + return nil +} + +func (obj *Nonce) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(NonceDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[143 197 147 95 106 165 50 43]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `Counter`: + err = decoder.Decode(&obj.Counter) + if err != nil { + return err + } + return nil +} + +type ExternalExecutionConfig struct{} + +var ExternalExecutionConfigDiscriminator = [8]byte{159, 157, 150, 212, 168, 103, 117, 39} + +func (obj ExternalExecutionConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(ExternalExecutionConfigDiscriminator[:], false) + if err != nil { + return err + } + return nil +} + +func (obj *ExternalExecutionConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(ExternalExecutionConfigDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[159 157 150 212 168 103 117 39]", + fmt.Sprint(discriminator[:])) + } + } + return nil +} + +type CommitReport struct { + Version uint8 + Timestamp int64 + MinMsgNr uint64 + MaxMsgNr uint64 + ExecutionStates ag_binary.Uint128 +} + +var CommitReportDiscriminator = [8]byte{46, 231, 247, 231, 174, 68, 34, 26} + +func (obj CommitReport) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(CommitReportDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `Timestamp` param: + err = encoder.Encode(obj.Timestamp) + if err != nil { + return err + } + // Serialize `MinMsgNr` param: + err = encoder.Encode(obj.MinMsgNr) + if err != nil { + return err + } + // Serialize `MaxMsgNr` param: + err = encoder.Encode(obj.MaxMsgNr) + if err != nil { + return err + } + // Serialize `ExecutionStates` param: + err = encoder.Encode(obj.ExecutionStates) + if err != nil { + return err + } + return nil +} + +func (obj *CommitReport) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(CommitReportDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[46 231 247 231 174 68 34 26]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `Timestamp`: + err = decoder.Decode(&obj.Timestamp) + if err != nil { + return err + } + // Deserialize `MinMsgNr`: + err = decoder.Decode(&obj.MinMsgNr) + if err != nil { + return err + } + // Deserialize `MaxMsgNr`: + err = decoder.Decode(&obj.MaxMsgNr) + if err != nil { + return err + } + // Deserialize `ExecutionStates`: + err = decoder.Decode(&obj.ExecutionStates) + if err != nil { + return err + } + return nil +} + +type PerChainPerTokenConfig struct { + Version uint8 + ChainSelector uint64 + Mint ag_solanago.PublicKey + Billing TokenBilling +} + +var PerChainPerTokenConfigDiscriminator = [8]byte{183, 88, 20, 99, 246, 46, 51, 230} + +func (obj PerChainPerTokenConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(PerChainPerTokenConfigDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `ChainSelector` param: + err = encoder.Encode(obj.ChainSelector) + if err != nil { + return err + } + // Serialize `Mint` param: + err = encoder.Encode(obj.Mint) + if err != nil { + return err + } + // Serialize `Billing` param: + err = encoder.Encode(obj.Billing) + if err != nil { + return err + } + return nil +} + +func (obj *PerChainPerTokenConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(PerChainPerTokenConfigDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[183 88 20 99 246 46 51 230]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `ChainSelector`: + err = decoder.Decode(&obj.ChainSelector) + if err != nil { + return err + } + // Deserialize `Mint`: + err = decoder.Decode(&obj.Mint) + if err != nil { + return err + } + // Deserialize `Billing`: + err = decoder.Decode(&obj.Billing) + if err != nil { + return err + } + return nil +} + +type BillingTokenConfig struct { + Version uint8 + Enabled bool + UsdPerToken TimestampedPackedU224 + PremiumMultiplierWeiPerEth uint64 +} + +var BillingTokenConfigDiscriminator = [8]byte{191, 91, 1, 0, 93, 250, 239, 41} + +func (obj BillingTokenConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(BillingTokenConfigDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `Enabled` param: + err = encoder.Encode(obj.Enabled) + if err != nil { + return err + } + // Serialize `UsdPerToken` param: + err = encoder.Encode(obj.UsdPerToken) + if err != nil { + return err + } + // Serialize `PremiumMultiplierWeiPerEth` param: + err = encoder.Encode(obj.PremiumMultiplierWeiPerEth) + if err != nil { + return err + } + return nil +} + +func (obj *BillingTokenConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(BillingTokenConfigDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[191 91 1 0 93 250 239 41]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `Enabled`: + err = decoder.Decode(&obj.Enabled) + if err != nil { + return err + } + // Deserialize `UsdPerToken`: + err = decoder.Decode(&obj.UsdPerToken) + if err != nil { + return err + } + // Deserialize `PremiumMultiplierWeiPerEth`: + err = decoder.Decode(&obj.PremiumMultiplierWeiPerEth) + if err != nil { + return err + } + return nil +} + +type TokenAdminRegistry struct { + Version uint8 + Administrator ag_solanago.PublicKey + PendingAdministrator *ag_solanago.PublicKey `bin:"optional"` + TokenPoolProgram *ag_solanago.PublicKey `bin:"optional"` +} + +var TokenAdminRegistryDiscriminator = [8]byte{70, 92, 207, 200, 76, 17, 57, 114} + +func (obj TokenAdminRegistry) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Write account discriminator: + err = encoder.WriteBytes(TokenAdminRegistryDiscriminator[:], false) + if err != nil { + return err + } + // Serialize `Version` param: + err = encoder.Encode(obj.Version) + if err != nil { + return err + } + // Serialize `Administrator` param: + err = encoder.Encode(obj.Administrator) + if err != nil { + return err + } + // Serialize `PendingAdministrator` param (optional): + { + if obj.PendingAdministrator == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.PendingAdministrator) + if err != nil { + return err + } + } + } + // Serialize `TokenPoolProgram` param (optional): + { + if obj.TokenPoolProgram == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.TokenPoolProgram) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *TokenAdminRegistry) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Read and check account discriminator: + { + discriminator, err := decoder.ReadTypeID() + if err != nil { + return err + } + if !discriminator.Equal(TokenAdminRegistryDiscriminator[:]) { + return fmt.Errorf( + "wrong discriminator: wanted %s, got %s", + "[70 92 207 200 76 17 57 114]", + fmt.Sprint(discriminator[:])) + } + } + // Deserialize `Version`: + err = decoder.Decode(&obj.Version) + if err != nil { + return err + } + // Deserialize `Administrator`: + err = decoder.Decode(&obj.Administrator) + if err != nil { + return err + } + // Deserialize `PendingAdministrator` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.PendingAdministrator) + if err != nil { + return err + } + } + } + // Deserialize `TokenPoolProgram` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.TokenPoolProgram) + if err != nil { + return err + } + } + } + return nil +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/instructions.go b/core/capabilities/ccip/ccipsolana/ccip_router/instructions.go new file mode 100644 index 00000000000..395e39da2ea --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/instructions.go @@ -0,0 +1,304 @@ +// This is the Collapsed Router Program for CCIP. +// As it's upgradable persisting the same program id, there is no need to have an indirection of a Proxy Program. +// This Router handles both the OnRamp and OffRamp flow of the CCIP Messages. +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + "fmt" + ag_spew "github.com/davecgh/go-spew/spew" + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" + ag_text "github.com/gagliardetto/solana-go/text" + ag_treeout "github.com/gagliardetto/treeout" +) + +var ProgramID ag_solanago.PublicKey + +func SetProgramID(pubkey ag_solanago.PublicKey) { + ProgramID = pubkey + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) +} + +const ProgramName = "CcipRouter" + +func init() { + if !ProgramID.IsZero() { + ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) + } +} + +var ( + // The initialization is responsibility of Admin, nothing more than calling this method should be done first. + Instruction_Initialize = ag_binary.TypeID([8]byte{175, 175, 109, 31, 13, 152, 155, 237}) + + Instruction_TransferOwnership = ag_binary.TypeID([8]byte{65, 177, 215, 73, 53, 45, 99, 47}) + + Instruction_AcceptOwnership = ag_binary.TypeID([8]byte{172, 23, 43, 13, 238, 213, 85, 150}) + + // The Admin needs to add any new chain supported (this means both OnRamp and OffRamp). + Instruction_AddChainSelector = ag_binary.TypeID([8]byte{28, 60, 171, 0, 195, 113, 56, 7}) + + // The Admin is the only one able to enable or disable the chain selector + Instruction_DisableChainSelector = ag_binary.TypeID([8]byte{24, 245, 159, 178, 139, 200, 133, 218}) + + // The Admin is the only one able to enable or disable the chain selector + Instruction_EnableChainSelector = ag_binary.TypeID([8]byte{29, 175, 195, 14, 137, 66, 194, 25}) + + // The Admin can update the configuration of the Router, in this case the Solana Chain Selector + Instruction_UpdateSolanaChainSelector = ag_binary.TypeID([8]byte{128, 198, 143, 222, 43, 55, 119, 106}) + + // The Admin can update the configuration of the Router, in this case the Default Gas Limit + Instruction_UpdateDefaultGasLimit = ag_binary.TypeID([8]byte{201, 34, 231, 229, 247, 252, 77, 210}) + + // The Admin can update the configuration of the Router, in this case the Default Allow Out Of Order Execution (True/False) + Instruction_UpdateDefaultAllowOutOfOrderExecution = ag_binary.TypeID([8]byte{44, 54, 136, 71, 177, 17, 18, 241}) + + // The Admin can update the configuration of the Router, in this case the Enable Manual Execution After + Instruction_UpdateEnableManualExecutionAfter = ag_binary.TypeID([8]byte{157, 236, 73, 92, 84, 197, 152, 105}) + + // The CCIP Admin or the Mint Authority of the Token can register the Token Admin Registry + Instruction_RegisterTokenAdminRegistryViaGetCcipAdmin = ag_binary.TypeID([8]byte{46, 246, 21, 58, 175, 69, 40, 202}) + + // The Token's mint_authority can register themselves to the Token Admin Registry + Instruction_RegisterTokenAdminRegistryViaOwner = ag_binary.TypeID([8]byte{85, 191, 10, 113, 134, 138, 144, 16}) + + // The administrator of the token can setup the token pool + Instruction_SetPool = ag_binary.TypeID([8]byte{119, 30, 14, 180, 115, 225, 167, 238}) + + // The Admin can transfer the Admin Role of the Token Admin Registry + Instruction_TransferAdminRoleTokenAdminRegistry = ag_binary.TypeID([8]byte{178, 98, 203, 181, 203, 107, 106, 14}) + + // The Pending Admin can accept the Admin Role of the Token Admin Registry + Instruction_AcceptAdminRoleTokenAdminRegistry = ag_binary.TypeID([8]byte{106, 240, 16, 173, 137, 213, 163, 246}) + + Instruction_SetTokenBilling = ag_binary.TypeID([8]byte{225, 230, 37, 71, 131, 209, 54, 230}) + + Instruction_SetOcrConfig = ag_binary.TypeID([8]byte{4, 131, 107, 110, 250, 158, 244, 200}) + + // ON RAMP FLOW + // The method name needs to be ccip_send with Anchor encoding. + // This function is called by the CCIP Sender Contract (or final user) to send a message to the CCIP Router. + // The size limit of data is 256 bytes. + // The message is sent to the receiver on the destination chain selector. + // This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code + Instruction_CcipSend = ag_binary.TypeID([8]byte{108, 216, 134, 191, 249, 234, 33, 84}) + + // OFF RAMP FLOW + // + // The method name needs to be commit with Anchor encoding. + // + // This function is called by the OffChain when committing one Report to the Solana Router. + // In this Flow only one report is sent, the Commit Report. This is different as EVM does, + // this is because here all the chain state is stored in one account per Merkle Tree Root. + // So, to avoid having to send a dynamic size array of accounts, in this message only one Commit Report Account is sent. + // This message validates the signatures of the report and stores the Merkle Root in the Commit Report Account. + // The Report must contain an interval of messages, and the min of them must be the next sequence number expected. + // The max size of the interval is 64. + // This message emits two events: CommitReportAccepted and Transmitted. + Instruction_Commit = ag_binary.TypeID([8]byte{223, 140, 142, 165, 229, 208, 156, 74}) + + // OFF RAMP FLOW + // + // The method name needs to be execute with Anchor encoding. + // + // This function is called by the OffChain when executing one Report to the Solana Router. + // In this Flow only one message is sent, the Execution Report. This is different as EVM does, + // this is because there is no try/catch mechanism to allow batch execution. + // This message validates that the Merkle Tree Proof of the given message is correct and is stored in the Commit Report Account. + // The message must be untouched to be executed. + // This message emits the event ExecutionStateChanged with the new state of the message. + // Finally, executes the CPI instruction to the receiver program in the ccip_receive message. + Instruction_Execute = ag_binary.TypeID([8]byte{130, 221, 242, 154, 13, 193, 189, 29}) + + // When a message is not being executed, then the user can trigger the execution manually. + // No verification over the transmitter, but the message needs to be in some commit report. + Instruction_ManuallyExecute = ag_binary.TypeID([8]byte{238, 219, 224, 11, 226, 248, 47, 192}) +) + +// InstructionIDToName returns the name of the instruction given its ID. +func InstructionIDToName(id ag_binary.TypeID) string { + switch id { + case Instruction_Initialize: + return "Initialize" + case Instruction_TransferOwnership: + return "TransferOwnership" + case Instruction_AcceptOwnership: + return "AcceptOwnership" + case Instruction_AddChainSelector: + return "AddChainSelector" + case Instruction_DisableChainSelector: + return "DisableChainSelector" + case Instruction_EnableChainSelector: + return "EnableChainSelector" + case Instruction_UpdateSolanaChainSelector: + return "UpdateSolanaChainSelector" + case Instruction_UpdateDefaultGasLimit: + return "UpdateDefaultGasLimit" + case Instruction_UpdateDefaultAllowOutOfOrderExecution: + return "UpdateDefaultAllowOutOfOrderExecution" + case Instruction_UpdateEnableManualExecutionAfter: + return "UpdateEnableManualExecutionAfter" + case Instruction_RegisterTokenAdminRegistryViaGetCcipAdmin: + return "RegisterTokenAdminRegistryViaGetCcipAdmin" + case Instruction_RegisterTokenAdminRegistryViaOwner: + return "RegisterTokenAdminRegistryViaOwner" + case Instruction_SetPool: + return "SetPool" + case Instruction_TransferAdminRoleTokenAdminRegistry: + return "TransferAdminRoleTokenAdminRegistry" + case Instruction_AcceptAdminRoleTokenAdminRegistry: + return "AcceptAdminRoleTokenAdminRegistry" + case Instruction_SetTokenBilling: + return "SetTokenBilling" + case Instruction_SetOcrConfig: + return "SetOcrConfig" + case Instruction_CcipSend: + return "CcipSend" + case Instruction_Commit: + return "Commit" + case Instruction_Execute: + return "Execute" + case Instruction_ManuallyExecute: + return "ManuallyExecute" + default: + return "" + } +} + +type Instruction struct { + ag_binary.BaseVariant +} + +func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { + if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + enToTree.EncodeToTree(parent) + } else { + parent.Child(ag_spew.Sdump(inst)) + } +} + +var InstructionImplDef = ag_binary.NewVariantDefinition( + ag_binary.AnchorTypeIDEncoding, + []ag_binary.VariantType{ + { + "initialize", (*Initialize)(nil), + }, + { + "transfer_ownership", (*TransferOwnership)(nil), + }, + { + "accept_ownership", (*AcceptOwnership)(nil), + }, + { + "add_chain_selector", (*AddChainSelector)(nil), + }, + { + "disable_chain_selector", (*DisableChainSelector)(nil), + }, + { + "enable_chain_selector", (*EnableChainSelector)(nil), + }, + { + "update_solana_chain_selector", (*UpdateSolanaChainSelector)(nil), + }, + { + "update_default_gas_limit", (*UpdateDefaultGasLimit)(nil), + }, + { + "update_default_allow_out_of_order_execution", (*UpdateDefaultAllowOutOfOrderExecution)(nil), + }, + { + "update_enable_manual_execution_after", (*UpdateEnableManualExecutionAfter)(nil), + }, + { + "register_token_admin_registry_via_get_ccip_admin", (*RegisterTokenAdminRegistryViaGetCcipAdmin)(nil), + }, + { + "register_token_admin_registry_via_owner", (*RegisterTokenAdminRegistryViaOwner)(nil), + }, + { + "set_pool", (*SetPool)(nil), + }, + { + "transfer_admin_role_token_admin_registry", (*TransferAdminRoleTokenAdminRegistry)(nil), + }, + { + "accept_admin_role_token_admin_registry", (*AcceptAdminRoleTokenAdminRegistry)(nil), + }, + { + "set_token_billing", (*SetTokenBilling)(nil), + }, + { + "set_ocr_config", (*SetOcrConfig)(nil), + }, + { + "ccip_send", (*CcipSend)(nil), + }, + { + "commit", (*Commit)(nil), + }, + { + "execute", (*Execute)(nil), + }, + { + "manually_execute", (*ManuallyExecute)(nil), + }, + }, +) + +func (inst *Instruction) ProgramID() ag_solanago.PublicKey { + return ProgramID +} + +func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { + return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() +} + +func (inst *Instruction) Data() ([]byte, error) { + buf := new(bytes.Buffer) + if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { + return nil, fmt.Errorf("unable to encode instruction: %w", err) + } + return buf.Bytes(), nil +} + +func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { + return encoder.Encode(inst.Impl, option) +} + +func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) +} + +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + err := encoder.WriteBytes(inst.TypeID.Bytes(), false) + if err != nil { + return fmt.Errorf("unable to write variant type: %w", err) + } + return encoder.Encode(inst.Impl) +} + +func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { + inst, err := DecodeInstruction(accounts, data) + if err != nil { + return nil, err + } + return inst, nil +} + +func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { + inst := new(Instruction) + if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + return nil, fmt.Errorf("unable to decode instruction: %w", err) + } + if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + err := v.SetAccounts(accounts) + if err != nil { + return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) + } + } + return inst, nil +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/testing_utils.go b/core/capabilities/ccip/ccipsolana/ccip_router/testing_utils.go new file mode 100644 index 00000000000..aaecdf49bad --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/testing_utils.go @@ -0,0 +1,20 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + "bytes" + "fmt" + ag_binary "github.com/gagliardetto/binary" +) + +func encodeT(data interface{}, buf *bytes.Buffer) error { + if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + return fmt.Errorf("unable to encode instruction: %w", err) + } + return nil +} + +func decodeT(dst interface{}, data []byte) error { + return ag_binary.NewBorshDecoder(data).Decode(dst) +} diff --git a/core/capabilities/ccip/ccipsolana/ccip_router/types.go b/core/capabilities/ccip/ccipsolana/ccip_router/types.go new file mode 100644 index 00000000000..1c3167a1fcc --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/ccip_router/types.go @@ -0,0 +1,1817 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package ccip_router + +import ( + ag_binary "github.com/gagliardetto/binary" + ag_solanago "github.com/gagliardetto/solana-go" +) + +type CommitInput struct { + PriceUpdates PriceUpdates + MerkleRoot MerkleRoot +} + +func (obj CommitInput) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PriceUpdates` param: + err = encoder.Encode(obj.PriceUpdates) + if err != nil { + return err + } + // Serialize `MerkleRoot` param: + err = encoder.Encode(obj.MerkleRoot) + if err != nil { + return err + } + return nil +} + +func (obj *CommitInput) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PriceUpdates`: + err = decoder.Decode(&obj.PriceUpdates) + if err != nil { + return err + } + // Deserialize `MerkleRoot`: + err = decoder.Decode(&obj.MerkleRoot) + if err != nil { + return err + } + return nil +} + +type PriceUpdates struct { + TokenPriceUpdates []TokenPriceUpdate + GasPriceUpdates []GasPriceUpdate +} + +func (obj PriceUpdates) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `TokenPriceUpdates` param: + err = encoder.Encode(obj.TokenPriceUpdates) + if err != nil { + return err + } + // Serialize `GasPriceUpdates` param: + err = encoder.Encode(obj.GasPriceUpdates) + if err != nil { + return err + } + return nil +} + +func (obj *PriceUpdates) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `TokenPriceUpdates`: + err = decoder.Decode(&obj.TokenPriceUpdates) + if err != nil { + return err + } + // Deserialize `GasPriceUpdates`: + err = decoder.Decode(&obj.GasPriceUpdates) + if err != nil { + return err + } + return nil +} + +type TokenPriceUpdate struct { + SourceToken ag_solanago.PublicKey + UsdPerToken [28]uint8 +} + +func (obj TokenPriceUpdate) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SourceToken` param: + err = encoder.Encode(obj.SourceToken) + if err != nil { + return err + } + // Serialize `UsdPerToken` param: + err = encoder.Encode(obj.UsdPerToken) + if err != nil { + return err + } + return nil +} + +func (obj *TokenPriceUpdate) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SourceToken`: + err = decoder.Decode(&obj.SourceToken) + if err != nil { + return err + } + // Deserialize `UsdPerToken`: + err = decoder.Decode(&obj.UsdPerToken) + if err != nil { + return err + } + return nil +} + +type GasPriceUpdate struct { + DestChainSelector uint64 + UsdPerUnitGas [28]uint8 +} + +func (obj GasPriceUpdate) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `DestChainSelector` param: + err = encoder.Encode(obj.DestChainSelector) + if err != nil { + return err + } + // Serialize `UsdPerUnitGas` param: + err = encoder.Encode(obj.UsdPerUnitGas) + if err != nil { + return err + } + return nil +} + +func (obj *GasPriceUpdate) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `DestChainSelector`: + err = decoder.Decode(&obj.DestChainSelector) + if err != nil { + return err + } + // Deserialize `UsdPerUnitGas`: + err = decoder.Decode(&obj.UsdPerUnitGas) + if err != nil { + return err + } + return nil +} + +type MerkleRoot struct { + SourceChainSelector uint64 + OnRampAddress []byte + MinSeqNr uint64 + MaxSeqNr uint64 + MerkleRoot [32]uint8 +} + +func (obj MerkleRoot) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SourceChainSelector` param: + err = encoder.Encode(obj.SourceChainSelector) + if err != nil { + return err + } + // Serialize `OnRampAddress` param: + err = encoder.Encode(obj.OnRampAddress) + if err != nil { + return err + } + // Serialize `MinSeqNr` param: + err = encoder.Encode(obj.MinSeqNr) + if err != nil { + return err + } + // Serialize `MaxSeqNr` param: + err = encoder.Encode(obj.MaxSeqNr) + if err != nil { + return err + } + // Serialize `MerkleRoot` param: + err = encoder.Encode(obj.MerkleRoot) + if err != nil { + return err + } + return nil +} + +func (obj *MerkleRoot) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SourceChainSelector`: + err = decoder.Decode(&obj.SourceChainSelector) + if err != nil { + return err + } + // Deserialize `OnRampAddress`: + err = decoder.Decode(&obj.OnRampAddress) + if err != nil { + return err + } + // Deserialize `MinSeqNr`: + err = decoder.Decode(&obj.MinSeqNr) + if err != nil { + return err + } + // Deserialize `MaxSeqNr`: + err = decoder.Decode(&obj.MaxSeqNr) + if err != nil { + return err + } + // Deserialize `MerkleRoot`: + err = decoder.Decode(&obj.MerkleRoot) + if err != nil { + return err + } + return nil +} + +type Solana2AnyMessage struct { + Receiver []byte + Data []byte + TokenAmounts []SolanaTokenAmount + FeeToken ag_solanago.PublicKey + ExtraArgs ExtraArgsInput + TokenIndexes []byte +} + +func (obj Solana2AnyMessage) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Receiver` param: + err = encoder.Encode(obj.Receiver) + if err != nil { + return err + } + // Serialize `Data` param: + err = encoder.Encode(obj.Data) + if err != nil { + return err + } + // Serialize `TokenAmounts` param: + err = encoder.Encode(obj.TokenAmounts) + if err != nil { + return err + } + // Serialize `FeeToken` param: + err = encoder.Encode(obj.FeeToken) + if err != nil { + return err + } + // Serialize `ExtraArgs` param: + err = encoder.Encode(obj.ExtraArgs) + if err != nil { + return err + } + // Serialize `TokenIndexes` param: + err = encoder.Encode(obj.TokenIndexes) + if err != nil { + return err + } + return nil +} + +func (obj *Solana2AnyMessage) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Receiver`: + err = decoder.Decode(&obj.Receiver) + if err != nil { + return err + } + // Deserialize `Data`: + err = decoder.Decode(&obj.Data) + if err != nil { + return err + } + // Deserialize `TokenAmounts`: + err = decoder.Decode(&obj.TokenAmounts) + if err != nil { + return err + } + // Deserialize `FeeToken`: + err = decoder.Decode(&obj.FeeToken) + if err != nil { + return err + } + // Deserialize `ExtraArgs`: + err = decoder.Decode(&obj.ExtraArgs) + if err != nil { + return err + } + // Deserialize `TokenIndexes`: + err = decoder.Decode(&obj.TokenIndexes) + if err != nil { + return err + } + return nil +} + +type SolanaTokenAmount struct { + Token ag_solanago.PublicKey + Amount uint64 +} + +func (obj SolanaTokenAmount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Token` param: + err = encoder.Encode(obj.Token) + if err != nil { + return err + } + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + return nil +} + +func (obj *SolanaTokenAmount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Token`: + err = decoder.Decode(&obj.Token) + if err != nil { + return err + } + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + return nil +} + +type ExtraArgsInput struct { + GasLimit *ag_binary.Uint128 `bin:"optional"` + AllowOutOfOrderExecution *bool `bin:"optional"` +} + +func (obj ExtraArgsInput) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `GasLimit` param (optional): + { + if obj.GasLimit == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.GasLimit) + if err != nil { + return err + } + } + } + // Serialize `AllowOutOfOrderExecution` param (optional): + { + if obj.AllowOutOfOrderExecution == nil { + err = encoder.WriteBool(false) + if err != nil { + return err + } + } else { + err = encoder.WriteBool(true) + if err != nil { + return err + } + err = encoder.Encode(obj.AllowOutOfOrderExecution) + if err != nil { + return err + } + } + } + return nil +} + +func (obj *ExtraArgsInput) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `GasLimit` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.GasLimit) + if err != nil { + return err + } + } + } + // Deserialize `AllowOutOfOrderExecution` (optional): + { + ok, err := decoder.ReadBool() + if err != nil { + return err + } + if ok { + err = decoder.Decode(&obj.AllowOutOfOrderExecution) + if err != nil { + return err + } + } + } + return nil +} + +type Any2SolanaMessage struct { + MessageId [32]uint8 + SourceChainSelector uint64 + Sender []byte + Data []byte + TokenAmounts []SolanaTokenAmount +} + +func (obj Any2SolanaMessage) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MessageId` param: + err = encoder.Encode(obj.MessageId) + if err != nil { + return err + } + // Serialize `SourceChainSelector` param: + err = encoder.Encode(obj.SourceChainSelector) + if err != nil { + return err + } + // Serialize `Sender` param: + err = encoder.Encode(obj.Sender) + if err != nil { + return err + } + // Serialize `Data` param: + err = encoder.Encode(obj.Data) + if err != nil { + return err + } + // Serialize `TokenAmounts` param: + err = encoder.Encode(obj.TokenAmounts) + if err != nil { + return err + } + return nil +} + +func (obj *Any2SolanaMessage) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MessageId`: + err = decoder.Decode(&obj.MessageId) + if err != nil { + return err + } + // Deserialize `SourceChainSelector`: + err = decoder.Decode(&obj.SourceChainSelector) + if err != nil { + return err + } + // Deserialize `Sender`: + err = decoder.Decode(&obj.Sender) + if err != nil { + return err + } + // Deserialize `Data`: + err = decoder.Decode(&obj.Data) + if err != nil { + return err + } + // Deserialize `TokenAmounts`: + err = decoder.Decode(&obj.TokenAmounts) + if err != nil { + return err + } + return nil +} + +type RampMessageHeader struct { + MessageId [32]uint8 + SourceChainSelector uint64 + DestChainSelector uint64 + SequenceNumber uint64 + Nonce uint64 +} + +func (obj RampMessageHeader) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MessageId` param: + err = encoder.Encode(obj.MessageId) + if err != nil { + return err + } + // Serialize `SourceChainSelector` param: + err = encoder.Encode(obj.SourceChainSelector) + if err != nil { + return err + } + // Serialize `DestChainSelector` param: + err = encoder.Encode(obj.DestChainSelector) + if err != nil { + return err + } + // Serialize `SequenceNumber` param: + err = encoder.Encode(obj.SequenceNumber) + if err != nil { + return err + } + // Serialize `Nonce` param: + err = encoder.Encode(obj.Nonce) + if err != nil { + return err + } + return nil +} + +func (obj *RampMessageHeader) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MessageId`: + err = decoder.Decode(&obj.MessageId) + if err != nil { + return err + } + // Deserialize `SourceChainSelector`: + err = decoder.Decode(&obj.SourceChainSelector) + if err != nil { + return err + } + // Deserialize `DestChainSelector`: + err = decoder.Decode(&obj.DestChainSelector) + if err != nil { + return err + } + // Deserialize `SequenceNumber`: + err = decoder.Decode(&obj.SequenceNumber) + if err != nil { + return err + } + // Deserialize `Nonce`: + err = decoder.Decode(&obj.Nonce) + if err != nil { + return err + } + return nil +} + +type ExecutionReportSingleChain struct { + SourceChainSelector uint64 + Message Any2SolanaRampMessage + OffchainTokenData [][]byte + Root [32]uint8 + Proofs [][32]uint8 + TokenIndexes []byte +} + +func (obj ExecutionReportSingleChain) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SourceChainSelector` param: + err = encoder.Encode(obj.SourceChainSelector) + if err != nil { + return err + } + // Serialize `Message` param: + err = encoder.Encode(obj.Message) + if err != nil { + return err + } + // Serialize `OffchainTokenData` param: + err = encoder.Encode(obj.OffchainTokenData) + if err != nil { + return err + } + // Serialize `Root` param: + err = encoder.Encode(obj.Root) + if err != nil { + return err + } + // Serialize `Proofs` param: + err = encoder.Encode(obj.Proofs) + if err != nil { + return err + } + // Serialize `TokenIndexes` param: + err = encoder.Encode(obj.TokenIndexes) + if err != nil { + return err + } + return nil +} + +func (obj *ExecutionReportSingleChain) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SourceChainSelector`: + err = decoder.Decode(&obj.SourceChainSelector) + if err != nil { + return err + } + // Deserialize `Message`: + err = decoder.Decode(&obj.Message) + if err != nil { + return err + } + // Deserialize `OffchainTokenData`: + err = decoder.Decode(&obj.OffchainTokenData) + if err != nil { + return err + } + // Deserialize `Root`: + err = decoder.Decode(&obj.Root) + if err != nil { + return err + } + // Deserialize `Proofs`: + err = decoder.Decode(&obj.Proofs) + if err != nil { + return err + } + // Deserialize `TokenIndexes`: + err = decoder.Decode(&obj.TokenIndexes) + if err != nil { + return err + } + return nil +} + +type SolanaExtraArgs struct { + ComputeUnits uint32 + AllowOutOfOrderExecution bool +} + +func (obj SolanaExtraArgs) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ComputeUnits` param: + err = encoder.Encode(obj.ComputeUnits) + if err != nil { + return err + } + // Serialize `AllowOutOfOrderExecution` param: + err = encoder.Encode(obj.AllowOutOfOrderExecution) + if err != nil { + return err + } + return nil +} + +func (obj *SolanaExtraArgs) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ComputeUnits`: + err = decoder.Decode(&obj.ComputeUnits) + if err != nil { + return err + } + // Deserialize `AllowOutOfOrderExecution`: + err = decoder.Decode(&obj.AllowOutOfOrderExecution) + if err != nil { + return err + } + return nil +} + +type EvmExtraArgs struct { + GasLimit ag_binary.Uint128 + AllowOutOfOrderExecution bool +} + +func (obj EvmExtraArgs) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `GasLimit` param: + err = encoder.Encode(obj.GasLimit) + if err != nil { + return err + } + // Serialize `AllowOutOfOrderExecution` param: + err = encoder.Encode(obj.AllowOutOfOrderExecution) + if err != nil { + return err + } + return nil +} + +func (obj *EvmExtraArgs) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `GasLimit`: + err = decoder.Decode(&obj.GasLimit) + if err != nil { + return err + } + // Deserialize `AllowOutOfOrderExecution`: + err = decoder.Decode(&obj.AllowOutOfOrderExecution) + if err != nil { + return err + } + return nil +} + +type Any2SolanaRampMessage struct { + Header RampMessageHeader + Sender []byte + Data []byte + Receiver ag_solanago.PublicKey + TokenAmounts []Any2SolanaTokenTransfer + ExtraArgs SolanaExtraArgs +} + +func (obj Any2SolanaRampMessage) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Header` param: + err = encoder.Encode(obj.Header) + if err != nil { + return err + } + // Serialize `Sender` param: + err = encoder.Encode(obj.Sender) + if err != nil { + return err + } + // Serialize `Data` param: + err = encoder.Encode(obj.Data) + if err != nil { + return err + } + // Serialize `Receiver` param: + err = encoder.Encode(obj.Receiver) + if err != nil { + return err + } + // Serialize `TokenAmounts` param: + err = encoder.Encode(obj.TokenAmounts) + if err != nil { + return err + } + // Serialize `ExtraArgs` param: + err = encoder.Encode(obj.ExtraArgs) + if err != nil { + return err + } + return nil +} + +func (obj *Any2SolanaRampMessage) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Header`: + err = decoder.Decode(&obj.Header) + if err != nil { + return err + } + // Deserialize `Sender`: + err = decoder.Decode(&obj.Sender) + if err != nil { + return err + } + // Deserialize `Data`: + err = decoder.Decode(&obj.Data) + if err != nil { + return err + } + // Deserialize `Receiver`: + err = decoder.Decode(&obj.Receiver) + if err != nil { + return err + } + // Deserialize `TokenAmounts`: + err = decoder.Decode(&obj.TokenAmounts) + if err != nil { + return err + } + // Deserialize `ExtraArgs`: + err = decoder.Decode(&obj.ExtraArgs) + if err != nil { + return err + } + return nil +} + +type Solana2AnyRampMessage struct { + Header RampMessageHeader + Sender ag_solanago.PublicKey + Data []byte + Receiver []byte + ExtraArgs EvmExtraArgs + FeeToken ag_solanago.PublicKey + TokenAmounts []Solana2AnyTokenTransfer +} + +func (obj Solana2AnyRampMessage) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Header` param: + err = encoder.Encode(obj.Header) + if err != nil { + return err + } + // Serialize `Sender` param: + err = encoder.Encode(obj.Sender) + if err != nil { + return err + } + // Serialize `Data` param: + err = encoder.Encode(obj.Data) + if err != nil { + return err + } + // Serialize `Receiver` param: + err = encoder.Encode(obj.Receiver) + if err != nil { + return err + } + // Serialize `ExtraArgs` param: + err = encoder.Encode(obj.ExtraArgs) + if err != nil { + return err + } + // Serialize `FeeToken` param: + err = encoder.Encode(obj.FeeToken) + if err != nil { + return err + } + // Serialize `TokenAmounts` param: + err = encoder.Encode(obj.TokenAmounts) + if err != nil { + return err + } + return nil +} + +func (obj *Solana2AnyRampMessage) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Header`: + err = decoder.Decode(&obj.Header) + if err != nil { + return err + } + // Deserialize `Sender`: + err = decoder.Decode(&obj.Sender) + if err != nil { + return err + } + // Deserialize `Data`: + err = decoder.Decode(&obj.Data) + if err != nil { + return err + } + // Deserialize `Receiver`: + err = decoder.Decode(&obj.Receiver) + if err != nil { + return err + } + // Deserialize `ExtraArgs`: + err = decoder.Decode(&obj.ExtraArgs) + if err != nil { + return err + } + // Deserialize `FeeToken`: + err = decoder.Decode(&obj.FeeToken) + if err != nil { + return err + } + // Deserialize `TokenAmounts`: + err = decoder.Decode(&obj.TokenAmounts) + if err != nil { + return err + } + return nil +} + +type Solana2AnyTokenTransfer struct { + SourcePoolAddress ag_solanago.PublicKey + DestTokenAddress []byte + ExtraData []byte + Amount uint64 + DestExecData []byte +} + +func (obj Solana2AnyTokenTransfer) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SourcePoolAddress` param: + err = encoder.Encode(obj.SourcePoolAddress) + if err != nil { + return err + } + // Serialize `DestTokenAddress` param: + err = encoder.Encode(obj.DestTokenAddress) + if err != nil { + return err + } + // Serialize `ExtraData` param: + err = encoder.Encode(obj.ExtraData) + if err != nil { + return err + } + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `DestExecData` param: + err = encoder.Encode(obj.DestExecData) + if err != nil { + return err + } + return nil +} + +func (obj *Solana2AnyTokenTransfer) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SourcePoolAddress`: + err = decoder.Decode(&obj.SourcePoolAddress) + if err != nil { + return err + } + // Deserialize `DestTokenAddress`: + err = decoder.Decode(&obj.DestTokenAddress) + if err != nil { + return err + } + // Deserialize `ExtraData`: + err = decoder.Decode(&obj.ExtraData) + if err != nil { + return err + } + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `DestExecData`: + err = decoder.Decode(&obj.DestExecData) + if err != nil { + return err + } + return nil +} + +type Any2SolanaTokenTransfer struct { + SourcePoolAddress []byte + DestTokenAddress ag_solanago.PublicKey + DestGasAmount uint32 + ExtraData []byte + Amount uint64 +} + +func (obj Any2SolanaTokenTransfer) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SourcePoolAddress` param: + err = encoder.Encode(obj.SourcePoolAddress) + if err != nil { + return err + } + // Serialize `DestTokenAddress` param: + err = encoder.Encode(obj.DestTokenAddress) + if err != nil { + return err + } + // Serialize `DestGasAmount` param: + err = encoder.Encode(obj.DestGasAmount) + if err != nil { + return err + } + // Serialize `ExtraData` param: + err = encoder.Encode(obj.ExtraData) + if err != nil { + return err + } + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + return nil +} + +func (obj *Any2SolanaTokenTransfer) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SourcePoolAddress`: + err = decoder.Decode(&obj.SourcePoolAddress) + if err != nil { + return err + } + // Deserialize `DestTokenAddress`: + err = decoder.Decode(&obj.DestTokenAddress) + if err != nil { + return err + } + // Deserialize `DestGasAmount`: + err = decoder.Decode(&obj.DestGasAmount) + if err != nil { + return err + } + // Deserialize `ExtraData`: + err = decoder.Decode(&obj.ExtraData) + if err != nil { + return err + } + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + return nil +} + +type LockOrBurnInV1 struct { + Receiver []byte + RemoteChainSelector uint64 + OriginalSender ag_solanago.PublicKey + Amount uint64 + LocalToken ag_solanago.PublicKey +} + +func (obj LockOrBurnInV1) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Receiver` param: + err = encoder.Encode(obj.Receiver) + if err != nil { + return err + } + // Serialize `RemoteChainSelector` param: + err = encoder.Encode(obj.RemoteChainSelector) + if err != nil { + return err + } + // Serialize `OriginalSender` param: + err = encoder.Encode(obj.OriginalSender) + if err != nil { + return err + } + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `LocalToken` param: + err = encoder.Encode(obj.LocalToken) + if err != nil { + return err + } + return nil +} + +func (obj *LockOrBurnInV1) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Receiver`: + err = decoder.Decode(&obj.Receiver) + if err != nil { + return err + } + // Deserialize `RemoteChainSelector`: + err = decoder.Decode(&obj.RemoteChainSelector) + if err != nil { + return err + } + // Deserialize `OriginalSender`: + err = decoder.Decode(&obj.OriginalSender) + if err != nil { + return err + } + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `LocalToken`: + err = decoder.Decode(&obj.LocalToken) + if err != nil { + return err + } + return nil +} + +type ReleaseOrMintInV1 struct { + OriginalSender []byte + RemoteChainSelector uint64 + Receiver ag_solanago.PublicKey + Amount uint64 + LocalToken ag_solanago.PublicKey + + // @dev WARNING: sourcePoolAddress should be checked prior to any processing of funds. Make sure it matches the + // expected pool address for the given remoteChainSelector. + SourcePoolAddress []byte + SourcePoolData []byte + + // @dev WARNING: offchainTokenData is untrusted data. + OffchainTokenData []byte +} + +func (obj ReleaseOrMintInV1) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `OriginalSender` param: + err = encoder.Encode(obj.OriginalSender) + if err != nil { + return err + } + // Serialize `RemoteChainSelector` param: + err = encoder.Encode(obj.RemoteChainSelector) + if err != nil { + return err + } + // Serialize `Receiver` param: + err = encoder.Encode(obj.Receiver) + if err != nil { + return err + } + // Serialize `Amount` param: + err = encoder.Encode(obj.Amount) + if err != nil { + return err + } + // Serialize `LocalToken` param: + err = encoder.Encode(obj.LocalToken) + if err != nil { + return err + } + // Serialize `SourcePoolAddress` param: + err = encoder.Encode(obj.SourcePoolAddress) + if err != nil { + return err + } + // Serialize `SourcePoolData` param: + err = encoder.Encode(obj.SourcePoolData) + if err != nil { + return err + } + // Serialize `OffchainTokenData` param: + err = encoder.Encode(obj.OffchainTokenData) + if err != nil { + return err + } + return nil +} + +func (obj *ReleaseOrMintInV1) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `OriginalSender`: + err = decoder.Decode(&obj.OriginalSender) + if err != nil { + return err + } + // Deserialize `RemoteChainSelector`: + err = decoder.Decode(&obj.RemoteChainSelector) + if err != nil { + return err + } + // Deserialize `Receiver`: + err = decoder.Decode(&obj.Receiver) + if err != nil { + return err + } + // Deserialize `Amount`: + err = decoder.Decode(&obj.Amount) + if err != nil { + return err + } + // Deserialize `LocalToken`: + err = decoder.Decode(&obj.LocalToken) + if err != nil { + return err + } + // Deserialize `SourcePoolAddress`: + err = decoder.Decode(&obj.SourcePoolAddress) + if err != nil { + return err + } + // Deserialize `SourcePoolData`: + err = decoder.Decode(&obj.SourcePoolData) + if err != nil { + return err + } + // Deserialize `OffchainTokenData`: + err = decoder.Decode(&obj.OffchainTokenData) + if err != nil { + return err + } + return nil +} + +type LockOrBurnOutV1 struct { + DestTokenAddress []byte + DestPoolData []byte +} + +func (obj LockOrBurnOutV1) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `DestTokenAddress` param: + err = encoder.Encode(obj.DestTokenAddress) + if err != nil { + return err + } + // Serialize `DestPoolData` param: + err = encoder.Encode(obj.DestPoolData) + if err != nil { + return err + } + return nil +} + +func (obj *LockOrBurnOutV1) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `DestTokenAddress`: + err = decoder.Decode(&obj.DestTokenAddress) + if err != nil { + return err + } + // Deserialize `DestPoolData`: + err = decoder.Decode(&obj.DestPoolData) + if err != nil { + return err + } + return nil +} + +type ReleaseOrMintOutV1 struct { + DestinationAmount uint64 +} + +func (obj ReleaseOrMintOutV1) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `DestinationAmount` param: + err = encoder.Encode(obj.DestinationAmount) + if err != nil { + return err + } + return nil +} + +func (obj *ReleaseOrMintOutV1) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `DestinationAmount`: + err = decoder.Decode(&obj.DestinationAmount) + if err != nil { + return err + } + return nil +} + +type Ocr3Config struct { + PluginType uint8 + ConfigInfo Ocr3ConfigInfo + Signers [16][20]uint8 + Transmitters [16][32]uint8 +} + +func (obj Ocr3Config) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `PluginType` param: + err = encoder.Encode(obj.PluginType) + if err != nil { + return err + } + // Serialize `ConfigInfo` param: + err = encoder.Encode(obj.ConfigInfo) + if err != nil { + return err + } + // Serialize `Signers` param: + err = encoder.Encode(obj.Signers) + if err != nil { + return err + } + // Serialize `Transmitters` param: + err = encoder.Encode(obj.Transmitters) + if err != nil { + return err + } + return nil +} + +func (obj *Ocr3Config) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `PluginType`: + err = decoder.Decode(&obj.PluginType) + if err != nil { + return err + } + // Deserialize `ConfigInfo`: + err = decoder.Decode(&obj.ConfigInfo) + if err != nil { + return err + } + // Deserialize `Signers`: + err = decoder.Decode(&obj.Signers) + if err != nil { + return err + } + // Deserialize `Transmitters`: + err = decoder.Decode(&obj.Transmitters) + if err != nil { + return err + } + return nil +} + +type Ocr3ConfigInfo struct { + ConfigDigest [32]uint8 + F uint8 + N uint8 + IsSignatureVerificationEnabled uint8 +} + +func (obj Ocr3ConfigInfo) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `ConfigDigest` param: + err = encoder.Encode(obj.ConfigDigest) + if err != nil { + return err + } + // Serialize `F` param: + err = encoder.Encode(obj.F) + if err != nil { + return err + } + // Serialize `N` param: + err = encoder.Encode(obj.N) + if err != nil { + return err + } + // Serialize `IsSignatureVerificationEnabled` param: + err = encoder.Encode(obj.IsSignatureVerificationEnabled) + if err != nil { + return err + } + return nil +} + +func (obj *Ocr3ConfigInfo) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `ConfigDigest`: + err = decoder.Decode(&obj.ConfigDigest) + if err != nil { + return err + } + // Deserialize `F`: + err = decoder.Decode(&obj.F) + if err != nil { + return err + } + // Deserialize `N`: + err = decoder.Decode(&obj.N) + if err != nil { + return err + } + // Deserialize `IsSignatureVerificationEnabled`: + err = decoder.Decode(&obj.IsSignatureVerificationEnabled) + if err != nil { + return err + } + return nil +} + +type SourceChainConfig struct { + IsEnabled bool + MinSeqNr uint64 + OnRamp []byte +} + +func (obj SourceChainConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `IsEnabled` param: + err = encoder.Encode(obj.IsEnabled) + if err != nil { + return err + } + // Serialize `MinSeqNr` param: + err = encoder.Encode(obj.MinSeqNr) + if err != nil { + return err + } + // Serialize `OnRamp` param: + err = encoder.Encode(obj.OnRamp) + if err != nil { + return err + } + return nil +} + +func (obj *SourceChainConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `IsEnabled`: + err = decoder.Decode(&obj.IsEnabled) + if err != nil { + return err + } + // Deserialize `MinSeqNr`: + err = decoder.Decode(&obj.MinSeqNr) + if err != nil { + return err + } + // Deserialize `OnRamp`: + err = decoder.Decode(&obj.OnRamp) + if err != nil { + return err + } + return nil +} + +type DestChainConfig struct { + SequenceNumber uint64 + UsdPerUnitGas TimestampedPackedU224 + BillingConfig ChainBillingConfig +} + +func (obj DestChainConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `SequenceNumber` param: + err = encoder.Encode(obj.SequenceNumber) + if err != nil { + return err + } + // Serialize `UsdPerUnitGas` param: + err = encoder.Encode(obj.UsdPerUnitGas) + if err != nil { + return err + } + // Serialize `BillingConfig` param: + err = encoder.Encode(obj.BillingConfig) + if err != nil { + return err + } + return nil +} + +func (obj *DestChainConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `SequenceNumber`: + err = decoder.Decode(&obj.SequenceNumber) + if err != nil { + return err + } + // Deserialize `UsdPerUnitGas`: + err = decoder.Decode(&obj.UsdPerUnitGas) + if err != nil { + return err + } + // Deserialize `BillingConfig`: + err = decoder.Decode(&obj.BillingConfig) + if err != nil { + return err + } + return nil +} + +type ChainBillingConfig struct { + IsEnabled bool + MaxNumberOfTokensPerMsg uint16 + MaxDataBytes uint32 + MaxPerMsgGasLimit uint32 + DestGasOverhead uint32 + DestGasPerPayloadByte uint16 + DestDataAvailabilityOverheadGas uint32 + DestGasPerDataAvailabilityByte uint16 + DestDataAvailabilityMultiplierBps uint16 + DefaultTokenFeeUsdcents uint16 + DefaultTokenDestGasOverhead uint32 + DefaultTxGasLimit uint32 + GasMultiplierWeiPerEth uint64 + NetworkFeeUsdcents uint32 + GasPriceStalenessThreshold uint32 + EnforceOutOfOrder bool + ChainFamilySelector [4]uint8 +} + +func (obj ChainBillingConfig) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `IsEnabled` param: + err = encoder.Encode(obj.IsEnabled) + if err != nil { + return err + } + // Serialize `MaxNumberOfTokensPerMsg` param: + err = encoder.Encode(obj.MaxNumberOfTokensPerMsg) + if err != nil { + return err + } + // Serialize `MaxDataBytes` param: + err = encoder.Encode(obj.MaxDataBytes) + if err != nil { + return err + } + // Serialize `MaxPerMsgGasLimit` param: + err = encoder.Encode(obj.MaxPerMsgGasLimit) + if err != nil { + return err + } + // Serialize `DestGasOverhead` param: + err = encoder.Encode(obj.DestGasOverhead) + if err != nil { + return err + } + // Serialize `DestGasPerPayloadByte` param: + err = encoder.Encode(obj.DestGasPerPayloadByte) + if err != nil { + return err + } + // Serialize `DestDataAvailabilityOverheadGas` param: + err = encoder.Encode(obj.DestDataAvailabilityOverheadGas) + if err != nil { + return err + } + // Serialize `DestGasPerDataAvailabilityByte` param: + err = encoder.Encode(obj.DestGasPerDataAvailabilityByte) + if err != nil { + return err + } + // Serialize `DestDataAvailabilityMultiplierBps` param: + err = encoder.Encode(obj.DestDataAvailabilityMultiplierBps) + if err != nil { + return err + } + // Serialize `DefaultTokenFeeUsdcents` param: + err = encoder.Encode(obj.DefaultTokenFeeUsdcents) + if err != nil { + return err + } + // Serialize `DefaultTokenDestGasOverhead` param: + err = encoder.Encode(obj.DefaultTokenDestGasOverhead) + if err != nil { + return err + } + // Serialize `DefaultTxGasLimit` param: + err = encoder.Encode(obj.DefaultTxGasLimit) + if err != nil { + return err + } + // Serialize `GasMultiplierWeiPerEth` param: + err = encoder.Encode(obj.GasMultiplierWeiPerEth) + if err != nil { + return err + } + // Serialize `NetworkFeeUsdcents` param: + err = encoder.Encode(obj.NetworkFeeUsdcents) + if err != nil { + return err + } + // Serialize `GasPriceStalenessThreshold` param: + err = encoder.Encode(obj.GasPriceStalenessThreshold) + if err != nil { + return err + } + // Serialize `EnforceOutOfOrder` param: + err = encoder.Encode(obj.EnforceOutOfOrder) + if err != nil { + return err + } + // Serialize `ChainFamilySelector` param: + err = encoder.Encode(obj.ChainFamilySelector) + if err != nil { + return err + } + return nil +} + +func (obj *ChainBillingConfig) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `IsEnabled`: + err = decoder.Decode(&obj.IsEnabled) + if err != nil { + return err + } + // Deserialize `MaxNumberOfTokensPerMsg`: + err = decoder.Decode(&obj.MaxNumberOfTokensPerMsg) + if err != nil { + return err + } + // Deserialize `MaxDataBytes`: + err = decoder.Decode(&obj.MaxDataBytes) + if err != nil { + return err + } + // Deserialize `MaxPerMsgGasLimit`: + err = decoder.Decode(&obj.MaxPerMsgGasLimit) + if err != nil { + return err + } + // Deserialize `DestGasOverhead`: + err = decoder.Decode(&obj.DestGasOverhead) + if err != nil { + return err + } + // Deserialize `DestGasPerPayloadByte`: + err = decoder.Decode(&obj.DestGasPerPayloadByte) + if err != nil { + return err + } + // Deserialize `DestDataAvailabilityOverheadGas`: + err = decoder.Decode(&obj.DestDataAvailabilityOverheadGas) + if err != nil { + return err + } + // Deserialize `DestGasPerDataAvailabilityByte`: + err = decoder.Decode(&obj.DestGasPerDataAvailabilityByte) + if err != nil { + return err + } + // Deserialize `DestDataAvailabilityMultiplierBps`: + err = decoder.Decode(&obj.DestDataAvailabilityMultiplierBps) + if err != nil { + return err + } + // Deserialize `DefaultTokenFeeUsdcents`: + err = decoder.Decode(&obj.DefaultTokenFeeUsdcents) + if err != nil { + return err + } + // Deserialize `DefaultTokenDestGasOverhead`: + err = decoder.Decode(&obj.DefaultTokenDestGasOverhead) + if err != nil { + return err + } + // Deserialize `DefaultTxGasLimit`: + err = decoder.Decode(&obj.DefaultTxGasLimit) + if err != nil { + return err + } + // Deserialize `GasMultiplierWeiPerEth`: + err = decoder.Decode(&obj.GasMultiplierWeiPerEth) + if err != nil { + return err + } + // Deserialize `NetworkFeeUsdcents`: + err = decoder.Decode(&obj.NetworkFeeUsdcents) + if err != nil { + return err + } + // Deserialize `GasPriceStalenessThreshold`: + err = decoder.Decode(&obj.GasPriceStalenessThreshold) + if err != nil { + return err + } + // Deserialize `EnforceOutOfOrder`: + err = decoder.Decode(&obj.EnforceOutOfOrder) + if err != nil { + return err + } + // Deserialize `ChainFamilySelector`: + err = decoder.Decode(&obj.ChainFamilySelector) + if err != nil { + return err + } + return nil +} + +type TokenBilling struct { + MinFeeUsdcents uint32 + MaxFeeUsdcents uint32 + DeciBps uint16 + DestGasOverhead uint32 + DestBytesOverhead uint32 + IsEnabled bool +} + +func (obj TokenBilling) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `MinFeeUsdcents` param: + err = encoder.Encode(obj.MinFeeUsdcents) + if err != nil { + return err + } + // Serialize `MaxFeeUsdcents` param: + err = encoder.Encode(obj.MaxFeeUsdcents) + if err != nil { + return err + } + // Serialize `DeciBps` param: + err = encoder.Encode(obj.DeciBps) + if err != nil { + return err + } + // Serialize `DestGasOverhead` param: + err = encoder.Encode(obj.DestGasOverhead) + if err != nil { + return err + } + // Serialize `DestBytesOverhead` param: + err = encoder.Encode(obj.DestBytesOverhead) + if err != nil { + return err + } + // Serialize `IsEnabled` param: + err = encoder.Encode(obj.IsEnabled) + if err != nil { + return err + } + return nil +} + +func (obj *TokenBilling) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `MinFeeUsdcents`: + err = decoder.Decode(&obj.MinFeeUsdcents) + if err != nil { + return err + } + // Deserialize `MaxFeeUsdcents`: + err = decoder.Decode(&obj.MaxFeeUsdcents) + if err != nil { + return err + } + // Deserialize `DeciBps`: + err = decoder.Decode(&obj.DeciBps) + if err != nil { + return err + } + // Deserialize `DestGasOverhead`: + err = decoder.Decode(&obj.DestGasOverhead) + if err != nil { + return err + } + // Deserialize `DestBytesOverhead`: + err = decoder.Decode(&obj.DestBytesOverhead) + if err != nil { + return err + } + // Deserialize `IsEnabled`: + err = decoder.Decode(&obj.IsEnabled) + if err != nil { + return err + } + return nil +} + +type TimestampedPackedU224 struct { + Value [28]uint8 + Timestamp uint32 +} + +func (obj TimestampedPackedU224) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Value` param: + err = encoder.Encode(obj.Value) + if err != nil { + return err + } + // Serialize `Timestamp` param: + err = encoder.Encode(obj.Timestamp) + if err != nil { + return err + } + return nil +} + +func (obj *TimestampedPackedU224) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Value`: + err = decoder.Decode(&obj.Value) + if err != nil { + return err + } + // Deserialize `Timestamp`: + err = decoder.Decode(&obj.Timestamp) + if err != nil { + return err + } + return nil +} + +type OcrPluginType ag_binary.BorshEnum + +const ( + Commit_OcrPluginType OcrPluginType = iota + Execution_OcrPluginType +) + +func (value OcrPluginType) String() string { + switch value { + case Commit_OcrPluginType: + return "Commit" + case Execution_OcrPluginType: + return "Execution" + default: + return "" + } +} + +type MerkleError ag_binary.BorshEnum + +const ( + InvalidProof_MerkleError MerkleError = iota +) + +func (value MerkleError) String() string { + switch value { + case InvalidProof_MerkleError: + return "InvalidProof" + default: + return "" + } +} + +type MessageExecutionState ag_binary.BorshEnum + +const ( + Untouched_MessageExecutionState MessageExecutionState = iota + InProgress_MessageExecutionState + Success_MessageExecutionState + Failure_MessageExecutionState +) + +func (value MessageExecutionState) String() string { + switch value { + case Untouched_MessageExecutionState: + return "Untouched" + case InProgress_MessageExecutionState: + return "InProgress" + case Success_MessageExecutionState: + return "Success" + case Failure_MessageExecutionState: + return "Failure" + default: + return "" + } +} + +type CcipRouterError ag_binary.BorshEnum + +const ( + InvalidSequenceInterval_CcipRouterError CcipRouterError = iota + RootNotCommitted_CcipRouterError + ExistingMerkleRoot_CcipRouterError + Unauthorized_CcipRouterError + InvalidInputs_CcipRouterError + UnsupportedSourceChainSelector_CcipRouterError + UnsupportedDestinationChainSelector_CcipRouterError + InvalidProof_CcipRouterError + InvalidMessage_CcipRouterError + ReachedMaxSequenceNumber_CcipRouterError + ManualExecutionNotAllowed_CcipRouterError + InvalidInputsTokenIndices_CcipRouterError + InvalidInputsPoolAccounts_CcipRouterError + InvalidInputsTokenAccounts_CcipRouterError + InvalidInputsConfigAccounts_CcipRouterError + InvalidInputsTokenAmount_CcipRouterError + OfframpReleaseMintBalanceMismatch_CcipRouterError + OfframpInvalidDataLength_CcipRouterError +) + +func (value CcipRouterError) String() string { + switch value { + case InvalidSequenceInterval_CcipRouterError: + return "InvalidSequenceInterval" + case RootNotCommitted_CcipRouterError: + return "RootNotCommitted" + case ExistingMerkleRoot_CcipRouterError: + return "ExistingMerkleRoot" + case Unauthorized_CcipRouterError: + return "Unauthorized" + case InvalidInputs_CcipRouterError: + return "InvalidInputs" + case UnsupportedSourceChainSelector_CcipRouterError: + return "UnsupportedSourceChainSelector" + case UnsupportedDestinationChainSelector_CcipRouterError: + return "UnsupportedDestinationChainSelector" + case InvalidProof_CcipRouterError: + return "InvalidProof" + case InvalidMessage_CcipRouterError: + return "InvalidMessage" + case ReachedMaxSequenceNumber_CcipRouterError: + return "ReachedMaxSequenceNumber" + case ManualExecutionNotAllowed_CcipRouterError: + return "ManualExecutionNotAllowed" + case InvalidInputsTokenIndices_CcipRouterError: + return "InvalidInputsTokenIndices" + case InvalidInputsPoolAccounts_CcipRouterError: + return "InvalidInputsPoolAccounts" + case InvalidInputsTokenAccounts_CcipRouterError: + return "InvalidInputsTokenAccounts" + case InvalidInputsConfigAccounts_CcipRouterError: + return "InvalidInputsConfigAccounts" + case InvalidInputsTokenAmount_CcipRouterError: + return "InvalidInputsTokenAmount" + case OfframpReleaseMintBalanceMismatch_CcipRouterError: + return "OfframpReleaseMintBalanceMismatch" + case OfframpInvalidDataLength_CcipRouterError: + return "OfframpInvalidDataLength" + default: + return "" + } +} diff --git a/core/capabilities/ccip/ccipsolana/commitcodec.go b/core/capabilities/ccip/ccipsolana/commitcodec.go new file mode 100644 index 00000000000..711bb66068a --- /dev/null +++ b/core/capabilities/ccip/ccipsolana/commitcodec.go @@ -0,0 +1,144 @@ +package ccipsolana + +import ( + "bytes" + "context" + "errors" + "fmt" + + "github.com/gagliardetto/solana-go" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipsolana/ccip_router" + + cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3" + + agbinary "github.com/gagliardetto/binary" +) + +// CommitPluginCodecV1 is a codec for encoding and decoding commit plugin reports. +// Compatible with: +// - "OffRamp 1.6.0-dev" +type CommitPluginCodecV1 struct{} + +func NewCommitPluginCodecV1() *CommitPluginCodecV1 { + return &CommitPluginCodecV1{} +} + +func (c *CommitPluginCodecV1) Encode(ctx context.Context, report cciptypes.CommitPluginReport) ([]byte, error) { + var buf bytes.Buffer + encoder := agbinary.NewBorshEncoder(&buf) + + mr := ccip_router.MerkleRoot{ + SourceChainSelector: uint64(report.MerkleRoots[0].ChainSel), + OnRampAddress: report.MerkleRoots[0].OnRampAddress, + MinSeqNr: uint64(report.MerkleRoots[0].SeqNumsRange.Start()), + MaxSeqNr: uint64(report.MerkleRoots[0].SeqNumsRange.End()), + MerkleRoot: report.MerkleRoots[0].MerkleRoot, + } + + tpu := make([]ccip_router.TokenPriceUpdate, 0, len(report.PriceUpdates.TokenPriceUpdates)) + for _, update := range report.PriceUpdates.TokenPriceUpdates { + b, err := update.Price.MarshalJSON() + if err != nil { + return nil, fmt.Errorf("error marshaling token price: %v", err) + } + + if len(b) > 28 { + return nil, errors.New("token price is too large") + } + + tpu = append(tpu, ccip_router.TokenPriceUpdate{ + SourceToken: solana.MPK(string(update.TokenID)), + UsdPerToken: [28]uint8(b), + }) + } + + gpu := make([]ccip_router.GasPriceUpdate, 0, len(report.PriceUpdates.GasPriceUpdates)) + for _, update := range report.PriceUpdates.GasPriceUpdates { + b, err := update.GasPrice.MarshalJSON() + if err != nil { + return nil, fmt.Errorf("error marshaling gas price update: %w", err) + } + + if len(b) > 28 { + return nil, errors.New("error marshaling gas price update: gas price is too large") + } + + gpu = append(gpu, ccip_router.GasPriceUpdate{ + DestChainSelector: uint64(update.ChainSel), + UsdPerUnitGas: [28]uint8(b), + }) + } + + commit := ccip_router.CommitInput{ + MerkleRoot: mr, + PriceUpdates: ccip_router.PriceUpdates{ + TokenPriceUpdates: tpu, + GasPriceUpdates: gpu, + }, + } + + err := commit.MarshalWithEncoder(encoder) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +func (c *CommitPluginCodecV1) Decode(ctx context.Context, bytes []byte) (cciptypes.CommitPluginReport, error) { + decoder := agbinary.NewBorshDecoder(bytes) + commitReport := ccip_router.CommitInput{} + err := commitReport.UnmarshalWithDecoder(decoder) + if err != nil { + return cciptypes.CommitPluginReport{}, err + } + + merkleRoots := []cciptypes.MerkleRootChain{ + { + ChainSel: cciptypes.ChainSelector(commitReport.MerkleRoot.SourceChainSelector), + OnRampAddress: commitReport.MerkleRoot.OnRampAddress, + SeqNumsRange: cciptypes.NewSeqNumRange( + cciptypes.SeqNum(commitReport.MerkleRoot.MinSeqNr), + cciptypes.SeqNum(commitReport.MerkleRoot.MaxSeqNr), + ), + MerkleRoot: commitReport.MerkleRoot.MerkleRoot, + }, + } + + tokenPriceUpdates := make([]cciptypes.TokenPrice, 0, len(commitReport.PriceUpdates.TokenPriceUpdates)) + for _, update := range commitReport.PriceUpdates.TokenPriceUpdates { + price := cciptypes.BigInt{} + err = price.UnmarshalJSON(update.UsdPerToken[:]) + if err != nil { + return cciptypes.CommitPluginReport{}, err + } + tokenPriceUpdates = append(tokenPriceUpdates, cciptypes.TokenPrice{ + TokenID: cciptypes.UnknownEncodedAddress(update.SourceToken.String()), + Price: price, + }) + } + + gasPriceUpdates := make([]cciptypes.GasPriceChain, 0, len(commitReport.PriceUpdates.GasPriceUpdates)) + for _, update := range commitReport.PriceUpdates.GasPriceUpdates { + price := cciptypes.BigInt{} + err = price.UnmarshalJSON(update.UsdPerUnitGas[:]) + if err != nil { + return cciptypes.CommitPluginReport{}, err + } + gasPriceUpdates = append(gasPriceUpdates, cciptypes.GasPriceChain{ + GasPrice: price, + ChainSel: cciptypes.ChainSelector(update.DestChainSelector), + }) + } + + return cciptypes.CommitPluginReport{ + MerkleRoots: merkleRoots, + PriceUpdates: cciptypes.PriceUpdates{ + TokenPriceUpdates: tokenPriceUpdates, + GasPriceUpdates: gasPriceUpdates, + }, + }, nil +} + +// Ensure CommitPluginCodec implements the CommitPluginCodec interface +var _ cciptypes.CommitPluginCodec = (*CommitPluginCodecV1)(nil)