github.com/diadata-org/diadata@v1.4.593/pkg/dia/scraper/exchange-scrapers/orca/whirlpool/SetRewardAuthorityBySuperAuthority.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  // SetRewardAuthorityBySuperAuthority is the `setRewardAuthorityBySuperAuthority` instruction.
    14  type SetRewardAuthorityBySuperAuthority struct {
    15  	RewardIndex *uint8
    16  
    17  	// [0] = [] whirlpoolsConfig
    18  	//
    19  	// [1] = [WRITE] whirlpool
    20  	//
    21  	// [2] = [SIGNER] rewardEmissionsSuperAuthority
    22  	//
    23  	// [3] = [] newRewardAuthority
    24  	ag_solanago.AccountMetaSlice `bin:"-"`
    25  }
    26  
    27  // NewSetRewardAuthorityBySuperAuthorityInstructionBuilder creates a new `SetRewardAuthorityBySuperAuthority` instruction builder.
    28  func NewSetRewardAuthorityBySuperAuthorityInstructionBuilder() *SetRewardAuthorityBySuperAuthority {
    29  	nd := &SetRewardAuthorityBySuperAuthority{
    30  		AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 4),
    31  	}
    32  	return nd
    33  }
    34  
    35  // SetRewardIndex sets the "rewardIndex" parameter.
    36  func (inst *SetRewardAuthorityBySuperAuthority) SetRewardIndex(rewardIndex uint8) *SetRewardAuthorityBySuperAuthority {
    37  	inst.RewardIndex = &rewardIndex
    38  	return inst
    39  }
    40  
    41  // SetWhirlpoolsConfigAccount sets the "whirlpoolsConfig" account.
    42  func (inst *SetRewardAuthorityBySuperAuthority) SetWhirlpoolsConfigAccount(whirlpoolsConfig ag_solanago.PublicKey) *SetRewardAuthorityBySuperAuthority {
    43  	inst.AccountMetaSlice[0] = ag_solanago.Meta(whirlpoolsConfig)
    44  	return inst
    45  }
    46  
    47  // GetWhirlpoolsConfigAccount gets the "whirlpoolsConfig" account.
    48  func (inst *SetRewardAuthorityBySuperAuthority) GetWhirlpoolsConfigAccount() *ag_solanago.AccountMeta {
    49  	return inst.AccountMetaSlice.Get(0)
    50  }
    51  
    52  // SetWhirlpoolAccount sets the "whirlpool" account.
    53  func (inst *SetRewardAuthorityBySuperAuthority) SetWhirlpoolAccount(whirlpool ag_solanago.PublicKey) *SetRewardAuthorityBySuperAuthority {
    54  	inst.AccountMetaSlice[1] = ag_solanago.Meta(whirlpool).WRITE()
    55  	return inst
    56  }
    57  
    58  // GetWhirlpoolAccount gets the "whirlpool" account.
    59  func (inst *SetRewardAuthorityBySuperAuthority) GetWhirlpoolAccount() *ag_solanago.AccountMeta {
    60  	return inst.AccountMetaSlice.Get(1)
    61  }
    62  
    63  // SetRewardEmissionsSuperAuthorityAccount sets the "rewardEmissionsSuperAuthority" account.
    64  func (inst *SetRewardAuthorityBySuperAuthority) SetRewardEmissionsSuperAuthorityAccount(rewardEmissionsSuperAuthority ag_solanago.PublicKey) *SetRewardAuthorityBySuperAuthority {
    65  	inst.AccountMetaSlice[2] = ag_solanago.Meta(rewardEmissionsSuperAuthority).SIGNER()
    66  	return inst
    67  }
    68  
    69  // GetRewardEmissionsSuperAuthorityAccount gets the "rewardEmissionsSuperAuthority" account.
    70  func (inst *SetRewardAuthorityBySuperAuthority) GetRewardEmissionsSuperAuthorityAccount() *ag_solanago.AccountMeta {
    71  	return inst.AccountMetaSlice.Get(2)
    72  }
    73  
    74  // SetNewRewardAuthorityAccount sets the "newRewardAuthority" account.
    75  func (inst *SetRewardAuthorityBySuperAuthority) SetNewRewardAuthorityAccount(newRewardAuthority ag_solanago.PublicKey) *SetRewardAuthorityBySuperAuthority {
    76  	inst.AccountMetaSlice[3] = ag_solanago.Meta(newRewardAuthority)
    77  	return inst
    78  }
    79  
    80  // GetNewRewardAuthorityAccount gets the "newRewardAuthority" account.
    81  func (inst *SetRewardAuthorityBySuperAuthority) GetNewRewardAuthorityAccount() *ag_solanago.AccountMeta {
    82  	return inst.AccountMetaSlice.Get(3)
    83  }
    84  
    85  func (inst SetRewardAuthorityBySuperAuthority) Build() *Instruction {
    86  	return &Instruction{BaseVariant: ag_binary.BaseVariant{
    87  		Impl:   inst,
    88  		TypeID: Instruction_SetRewardAuthorityBySuperAuthority,
    89  	}}
    90  }
    91  
    92  // ValidateAndBuild validates the instruction parameters and accounts;
    93  // if there is a validation error, it returns the error.
    94  // Otherwise, it builds and returns the instruction.
    95  func (inst SetRewardAuthorityBySuperAuthority) ValidateAndBuild() (*Instruction, error) {
    96  	if err := inst.Validate(); err != nil {
    97  		return nil, err
    98  	}
    99  	return inst.Build(), nil
   100  }
   101  
   102  func (inst *SetRewardAuthorityBySuperAuthority) Validate() error {
   103  	// Check whether all (required) parameters are set:
   104  	{
   105  		if inst.RewardIndex == nil {
   106  			return errors.New("RewardIndex parameter is not set")
   107  		}
   108  	}
   109  
   110  	// Check whether all (required) accounts are set:
   111  	{
   112  		if inst.AccountMetaSlice[0] == nil {
   113  			return errors.New("accounts.WhirlpoolsConfig is not set")
   114  		}
   115  		if inst.AccountMetaSlice[1] == nil {
   116  			return errors.New("accounts.Whirlpool is not set")
   117  		}
   118  		if inst.AccountMetaSlice[2] == nil {
   119  			return errors.New("accounts.RewardEmissionsSuperAuthority is not set")
   120  		}
   121  		if inst.AccountMetaSlice[3] == nil {
   122  			return errors.New("accounts.NewRewardAuthority is not set")
   123  		}
   124  	}
   125  	return nil
   126  }
   127  
   128  func (inst *SetRewardAuthorityBySuperAuthority) EncodeToTree(parent ag_treeout.Branches) {
   129  	parent.Child(ag_format.Program(ProgramName, ProgramID)).
   130  		//
   131  		ParentFunc(func(programBranch ag_treeout.Branches) {
   132  			programBranch.Child(ag_format.Instruction("SetRewardAuthorityBySuperAuthority")).
   133  				//
   134  				ParentFunc(func(instructionBranch ag_treeout.Branches) {
   135  
   136  					// Parameters of the instruction:
   137  					instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) {
   138  						paramsBranch.Child(ag_format.Param("RewardIndex", *inst.RewardIndex))
   139  					})
   140  
   141  					// Accounts of the instruction:
   142  					instructionBranch.Child("Accounts[len=4]").ParentFunc(func(accountsBranch ag_treeout.Branches) {
   143  						accountsBranch.Child(ag_format.Meta("             whirlpoolsConfig", inst.AccountMetaSlice.Get(0)))
   144  						accountsBranch.Child(ag_format.Meta("                    whirlpool", inst.AccountMetaSlice.Get(1)))
   145  						accountsBranch.Child(ag_format.Meta("rewardEmissionsSuperAuthority", inst.AccountMetaSlice.Get(2)))
   146  						accountsBranch.Child(ag_format.Meta("           newRewardAuthority", inst.AccountMetaSlice.Get(3)))
   147  					})
   148  				})
   149  		})
   150  }
   151  
   152  func (obj SetRewardAuthorityBySuperAuthority) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) {
   153  	// Serialize `RewardIndex` param:
   154  	err = encoder.Encode(obj.RewardIndex)
   155  	if err != nil {
   156  		return err
   157  	}
   158  	return nil
   159  }
   160  func (obj *SetRewardAuthorityBySuperAuthority) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) {
   161  	// Deserialize `RewardIndex`:
   162  	err = decoder.Decode(&obj.RewardIndex)
   163  	if err != nil {
   164  		return err
   165  	}
   166  	return nil
   167  }
   168  
   169  // NewSetRewardAuthorityBySuperAuthorityInstruction declares a new SetRewardAuthorityBySuperAuthority instruction with the provided parameters and accounts.
   170  func NewSetRewardAuthorityBySuperAuthorityInstruction(
   171  	// Parameters:
   172  	rewardIndex uint8,
   173  	// Accounts:
   174  	whirlpoolsConfig ag_solanago.PublicKey,
   175  	whirlpool ag_solanago.PublicKey,
   176  	rewardEmissionsSuperAuthority ag_solanago.PublicKey,
   177  	newRewardAuthority ag_solanago.PublicKey) *SetRewardAuthorityBySuperAuthority {
   178  	return NewSetRewardAuthorityBySuperAuthorityInstructionBuilder().
   179  		SetRewardIndex(rewardIndex).
   180  		SetWhirlpoolsConfigAccount(whirlpoolsConfig).
   181  		SetWhirlpoolAccount(whirlpool).
   182  		SetRewardEmissionsSuperAuthorityAccount(rewardEmissionsSuperAuthority).
   183  		SetNewRewardAuthorityAccount(newRewardAuthority)
   184  }