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