github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/SetFeeAuthority.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  // SetFeeAuthority is the `setFeeAuthority` instruction.
    14  type SetFeeAuthority struct {
    15  
    16  	// [0] = [WRITE] whirlpoolsConfig
    17  	//
    18  	// [1] = [SIGNER] feeAuthority
    19  	//
    20  	// [2] = [] newFeeAuthority
    21  	ag_solanago.AccountMetaSlice `bin:"-"`
    22  }
    23  
    24  // NewSetFeeAuthorityInstructionBuilder creates a new `SetFeeAuthority` instruction builder.
    25  func NewSetFeeAuthorityInstructionBuilder() *SetFeeAuthority {
    26  	nd := &SetFeeAuthority{
    27  		AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 3),
    28  	}
    29  	return nd
    30  }
    31  
    32  // SetWhirlpoolsConfigAccount sets the "whirlpoolsConfig" account.
    33  func (inst *SetFeeAuthority) SetWhirlpoolsConfigAccount(whirlpoolsConfig ag_solanago.PublicKey) *SetFeeAuthority {
    34  	inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpoolsConfig).WRITE()
    35  	return inst
    36  }
    37  
    38  // GetWhirlpoolsConfigAccount gets the "whirlpoolsConfig" account.
    39  func (inst *SetFeeAuthority) GetWhirlpoolsConfigAccount() *ag_solanago.AccountMeta {
    40  	return inst.AccountMetaSlice.Get(0)
    41  }
    42  
    43  // SetFeeAuthorityAccount sets the "feeAuthority" account.
    44  func (inst *SetFeeAuthority) SetFeeAuthorityAccount(feeAuthority ag_solanago.PublicKey) *SetFeeAuthority {
    45  	inst.AccountMetaSlice[1] = ag_solanago.Meta(feeAuthority).SIGNER()
    46  	return inst
    47  }
    48  
    49  // GetFeeAuthorityAccount gets the "feeAuthority" account.
    50  func (inst *SetFeeAuthority) GetFeeAuthorityAccount() *ag_solanago.AccountMeta {
    51  	return inst.AccountMetaSlice.Get(1)
    52  }
    53  
    54  // SetNewFeeAuthorityAccount sets the "newFeeAuthority" account.
    55  func (inst *SetFeeAuthority) SetNewFeeAuthorityAccount(newFeeAuthority ag_solanago.PublicKey) *SetFeeAuthority {
    56  	inst.AccountMetaSlice[2] = ag_solanago.Meta(newFeeAuthority)
    57  	return inst
    58  }
    59  
    60  // GetNewFeeAuthorityAccount gets the "newFeeAuthority" account.
    61  func (inst *SetFeeAuthority) GetNewFeeAuthorityAccount() *ag_solanago.AccountMeta {
    62  	return inst.AccountMetaSlice.Get(2)
    63  }
    64  
    65  func (inst SetFeeAuthority) Build() *Instruction {
    66  	return &Instruction{BaseVariant: ag_binary.BaseVariant{
    67  		Impl:   inst,
    68  		TypeID: Instruction_SetFeeAuthority,
    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 SetFeeAuthority) 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 *SetFeeAuthority) 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.FeeAuthority is not set")
    90  		}
    91  		if inst.AccountMetaSlice[2] == nil {
    92  			return errors.New("accounts.NewFeeAuthority is not set")
    93  		}
    94  	}
    95  	return nil
    96  }
    97  
    98  func (inst *SetFeeAuthority) 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("SetFeeAuthority")).
   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("    feeAuthority", inst.AccountMetaSlice.Get(1)))
   113  						accountsBranch.Child(ag_format.Meta(" newFeeAuthority", inst.AccountMetaSlice.Get(2)))
   114  					})
   115  				})
   116  		})
   117  }
   118  
   119  func (obj SetFeeAuthority) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
   120  	return nil
   121  }
   122  func (obj *SetFeeAuthority) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
   123  	return nil
   124  }
   125  
   126  // NewSetFeeAuthorityInstruction declares a new SetFeeAuthority instruction with the provided parameters and accounts.
   127  func NewSetFeeAuthorityInstruction(
   128  	// Accounts:
   129  	whirlpoolsConfig ag_solanago.PublicKey,
   130  	feeAuthority ag_solanago.PublicKey,
   131  	newFeeAuthority ag_solanago.PublicKey) *SetFeeAuthority {
   132  	return NewSetFeeAuthorityInstructionBuilder().
   133  		SetWhirlpoolsConfigAccount(whirlpoolsConfig).
   134  		SetFeeAuthorityAccount(feeAuthority).
   135  		SetNewFeeAuthorityAccount(newFeeAuthority)
   136  }