github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/SetCollectProtocolFeesAuthority.go (about) 1 // Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. 2 3 package whirlpool 4 5 import ( 6 "errors" 7 ag_binary "github.com/gagliardetto/binary" 8 ag_solanago "github.com/gagliardetto/solana-go" 9 ag_format "github.com/gagliardetto/solana-go/text/format" 10 ag_treeout "github.com/gagliardetto/treeout" 11 ) 12 13 // SetCollectProtocolFeesAuthority is the `setCollectProtocolFeesAuthority` instruction. 14 type SetCollectProtocolFeesAuthority struct { 15 16 // [0] = [WRITE] whirlpoolsConfig 17 // 18 // [1] = [SIGNER] collectProtocolFeesAuthority 19 // 20 // [2] = [] newCollectProtocolFeesAuthority 21 ag_solanago.AccountMetaSlice `bin:"-"` 22 } 23 24 // NewSetCollectProtocolFeesAuthorityInstructionBuilder creates a new `SetCollectProtocolFeesAuthority` instruction builder. 25 func NewSetCollectProtocolFeesAuthorityInstructionBuilder() *SetCollectProtocolFeesAuthority { 26 nd := &SetCollectProtocolFeesAuthority{ 27 AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3), 28 } 29 return nd 30 } 31 32 // SetWhirlpoolsConfigAccount sets the "whirlpoolsConfig" account. 33 func (inst *SetCollectProtocolFeesAuthority) SetWhirlpoolsConfigAccount(whirlpoolsConfig ag_solanago.PublicKey) *SetCollectProtocolFeesAuthority { 34 inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpoolsConfig).WRITE() 35 return inst 36 } 37 38 // GetWhirlpoolsConfigAccount gets the "whirlpoolsConfig" account. 39 func (inst *SetCollectProtocolFeesAuthority) GetWhirlpoolsConfigAccount() *ag_solanago.AccountMeta { 40 return inst.AccountMetaSlice.Get(0) 41 } 42 43 // SetCollectProtocolFeesAuthorityAccount sets the "collectProtocolFeesAuthority" account. 44 func (inst *SetCollectProtocolFeesAuthority) SetCollectProtocolFeesAuthorityAccount(collectProtocolFeesAuthority ag_solanago.PublicKey) *SetCollectProtocolFeesAuthority { 45 inst.AccountMetaSlice[1] = ag_solanago.Meta(collectProtocolFeesAuthority).SIGNER() 46 return inst 47 } 48 49 // GetCollectProtocolFeesAuthorityAccount gets the "collectProtocolFeesAuthority" account. 50 func (inst *SetCollectProtocolFeesAuthority) GetCollectProtocolFeesAuthorityAccount() *ag_solanago.AccountMeta { 51 return inst.AccountMetaSlice.Get(1) 52 } 53 54 // SetNewCollectProtocolFeesAuthorityAccount sets the "newCollectProtocolFeesAuthority" account. 55 func (inst *SetCollectProtocolFeesAuthority) SetNewCollectProtocolFeesAuthorityAccount(newCollectProtocolFeesAuthority ag_solanago.PublicKey) *SetCollectProtocolFeesAuthority { 56 inst.AccountMetaSlice[2] = ag_solanago.Meta(newCollectProtocolFeesAuthority) 57 return inst 58 } 59 60 // GetNewCollectProtocolFeesAuthorityAccount gets the "newCollectProtocolFeesAuthority" account. 61 func (inst *SetCollectProtocolFeesAuthority) GetNewCollectProtocolFeesAuthorityAccount() *ag_solanago.AccountMeta { 62 return inst.AccountMetaSlice.Get(2) 63 } 64 65 func (inst SetCollectProtocolFeesAuthority) Build() *Instruction { 66 return &Instruction{BaseVariant: ag_binary.BaseVariant{ 67 Impl: inst, 68 TypeID: Instruction_SetCollectProtocolFeesAuthority, 69 }} 70 } 71 72 // ValidateAndBuild validates the instruction parameters and accounts; 73 // if there is a validation error, it returns the error. 74 // Otherwise, it builds and returns the instruction. 75 func (inst SetCollectProtocolFeesAuthority) ValidateAndBuild() (*Instruction, error) { 76 if err := inst.Validate(); err != nil { 77 return nil, err 78 } 79 return inst.Build(), nil 80 } 81 82 func (inst *SetCollectProtocolFeesAuthority) Validate() error { 83 // Check whether all (required) accounts are set: 84 { 85 if inst.AccountMetaSlice[0] == nil { 86 return errors.New("accounts.WhirlpoolsConfig is not set") 87 } 88 if inst.AccountMetaSlice[1] == nil { 89 return errors.New("accounts.CollectProtocolFeesAuthority is not set") 90 } 91 if inst.AccountMetaSlice[2] == nil { 92 return errors.New("accounts.NewCollectProtocolFeesAuthority is not set") 93 } 94 } 95 return nil 96 } 97 98 func (inst *SetCollectProtocolFeesAuthority) EncodeToTree(parent ag_treeout.Branches) { 99 parent.Child(ag_format.Program(ProgramName, ProgramID)). 100 // 101 ParentFunc(func(programBranch ag_treeout.Branches) { 102 programBranch.Child(ag_format.Instruction("SetCollectProtocolFeesAuthority")). 103 // 104 ParentFunc(func(instructionBranch ag_treeout.Branches) { 105 106 // Parameters of the instruction: 107 instructionBranch.Child("Params[len=0]").ParentFunc(func(paramsBranch ag_treeout.Branches) {}) 108 109 // Accounts of the instruction: 110 instructionBranch.Child("Accounts[len=3]").ParentFunc(func(accountsBranch ag_treeout.Branches) { 111 accountsBranch.Child(ag_format.Meta(" whirlpoolsConfig", inst.AccountMetaSlice.Get(0))) 112 accountsBranch.Child(ag_format.Meta(" collectProtocolFeesAuthority", inst.AccountMetaSlice.Get(1))) 113 accountsBranch.Child(ag_format.Meta("newCollectProtocolFeesAuthority", inst.AccountMetaSlice.Get(2))) 114 }) 115 }) 116 }) 117 } 118 119 func (obj SetCollectProtocolFeesAuthority) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { 120 return nil 121 } 122 func (obj *SetCollectProtocolFeesAuthority) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { 123 return nil 124 } 125 126 // NewSetCollectProtocolFeesAuthorityInstruction declares a new SetCollectProtocolFeesAuthority instruction with the provided parameters and accounts. 127 func NewSetCollectProtocolFeesAuthorityInstruction( 128 // Accounts: 129 whirlpoolsConfig ag_solanago.PublicKey, 130 collectProtocolFeesAuthority ag_solanago.PublicKey, 131 newCollectProtocolFeesAuthority ag_solanago.PublicKey) *SetCollectProtocolFeesAuthority { 132 return NewSetCollectProtocolFeesAuthorityInstructionBuilder(). 133 SetWhirlpoolsConfigAccount(whirlpoolsConfig). 134 SetCollectProtocolFeesAuthorityAccount(collectProtocolFeesAuthority). 135 SetNewCollectProtocolFeesAuthorityAccount(newCollectProtocolFeesAuthority) 136 }