diff --git a/contracts/generated/contract_reader_interface/InitializeOnce.go b/contracts/generated/contract_reader_interface/InitializeOnce.go new file mode 100644 index 000000000..096c207c2 --- /dev/null +++ b/contracts/generated/contract_reader_interface/InitializeOnce.go @@ -0,0 +1,193 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package contract_reader_interface + +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" +) + +// InitializeOnce is the `initializeOnce` instruction. +type InitializeOnce struct { + + // [0] = [WRITE, SIGNER] signer + // + // [1] = [WRITE] multiRead1 + // + // [2] = [WRITE] multiRead2 + // + // [3] = [WRITE] configWrapperAccount1 + // + // [4] = [WRITE] configWrapperAccount2 + // + // [5] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewInitializeOnceInstructionBuilder creates a new `InitializeOnce` instruction builder. +func NewInitializeOnceInstructionBuilder() *InitializeOnce { + nd := &InitializeOnce{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 6), + } + return nd +} + +// SetSignerAccount sets the "signer" account. +func (inst *InitializeOnce) SetSignerAccount(signer ag_solanago.PublicKey) *InitializeOnce { + inst.AccountMetaSlice[0] = ag_solanago.Meta(signer).WRITE().SIGNER() + return inst +} + +// GetSignerAccount gets the "signer" account. +func (inst *InitializeOnce) GetSignerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetMultiRead1Account sets the "multiRead1" account. +func (inst *InitializeOnce) SetMultiRead1Account(multiRead1 ag_solanago.PublicKey) *InitializeOnce { + inst.AccountMetaSlice[1] = ag_solanago.Meta(multiRead1).WRITE() + return inst +} + +// GetMultiRead1Account gets the "multiRead1" account. +func (inst *InitializeOnce) GetMultiRead1Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +// SetMultiRead2Account sets the "multiRead2" account. +func (inst *InitializeOnce) SetMultiRead2Account(multiRead2 ag_solanago.PublicKey) *InitializeOnce { + inst.AccountMetaSlice[2] = ag_solanago.Meta(multiRead2).WRITE() + return inst +} + +// GetMultiRead2Account gets the "multiRead2" account. +func (inst *InitializeOnce) GetMultiRead2Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(2) +} + +// SetConfigWrapperAccount1Account sets the "configWrapperAccount1" account. +func (inst *InitializeOnce) SetConfigWrapperAccount1Account(configWrapperAccount1 ag_solanago.PublicKey) *InitializeOnce { + inst.AccountMetaSlice[3] = ag_solanago.Meta(configWrapperAccount1).WRITE() + return inst +} + +// GetConfigWrapperAccount1Account gets the "configWrapperAccount1" account. +func (inst *InitializeOnce) GetConfigWrapperAccount1Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(3) +} + +// SetConfigWrapperAccount2Account sets the "configWrapperAccount2" account. +func (inst *InitializeOnce) SetConfigWrapperAccount2Account(configWrapperAccount2 ag_solanago.PublicKey) *InitializeOnce { + inst.AccountMetaSlice[4] = ag_solanago.Meta(configWrapperAccount2).WRITE() + return inst +} + +// GetConfigWrapperAccount2Account gets the "configWrapperAccount2" account. +func (inst *InitializeOnce) GetConfigWrapperAccount2Account() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(4) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *InitializeOnce) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *InitializeOnce { + inst.AccountMetaSlice[5] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *InitializeOnce) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(5) +} + +func (inst InitializeOnce) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_InitializeOnce, + }} +} + +// 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 InitializeOnce) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *InitializeOnce) Validate() error { + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Signer is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.MultiRead1 is not set") + } + if inst.AccountMetaSlice[2] == nil { + return errors.New("accounts.MultiRead2 is not set") + } + if inst.AccountMetaSlice[3] == nil { + return errors.New("accounts.ConfigWrapperAccount1 is not set") + } + if inst.AccountMetaSlice[4] == nil { + return errors.New("accounts.ConfigWrapperAccount2 is not set") + } + if inst.AccountMetaSlice[5] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *InitializeOnce) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("InitializeOnce")). + // + 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=6]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" signer", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta(" multiRead1", inst.AccountMetaSlice.Get(1))) + accountsBranch.Child(ag_format.Meta(" multiRead2", inst.AccountMetaSlice.Get(2))) + accountsBranch.Child(ag_format.Meta("configWrapperAccount1", inst.AccountMetaSlice.Get(3))) + accountsBranch.Child(ag_format.Meta("configWrapperAccount2", inst.AccountMetaSlice.Get(4))) + accountsBranch.Child(ag_format.Meta(" systemProgram", inst.AccountMetaSlice.Get(5))) + }) + }) + }) +} + +func (obj InitializeOnce) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + return nil +} +func (obj *InitializeOnce) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + return nil +} + +// NewInitializeOnceInstruction declares a new InitializeOnce instruction with the provided parameters and accounts. +func NewInitializeOnceInstruction( + // Accounts: + signer ag_solanago.PublicKey, + multiRead1 ag_solanago.PublicKey, + multiRead2 ag_solanago.PublicKey, + configWrapperAccount1 ag_solanago.PublicKey, + configWrapperAccount2 ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *InitializeOnce { + return NewInitializeOnceInstructionBuilder(). + SetSignerAccount(signer). + SetMultiRead1Account(multiRead1). + SetMultiRead2Account(multiRead2). + SetConfigWrapperAccount1Account(configWrapperAccount1). + SetConfigWrapperAccount2Account(configWrapperAccount2). + SetSystemProgramAccount(systemProgram) +} diff --git a/contracts/generated/contract_reader_interface/InitializeOnce_test.go b/contracts/generated/contract_reader_interface/InitializeOnce_test.go new file mode 100644 index 000000000..2e4a93656 --- /dev/null +++ b/contracts/generated/contract_reader_interface/InitializeOnce_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package contract_reader_interface + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_InitializeOnce(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("InitializeOnce"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(InitializeOnce) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(InitializeOnce) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +}