authorizeCheckedWithSeed static method

TransactionInstruction authorizeCheckedWithSeed({
  1. required Pubkey stakeAccount,
  2. required Pubkey authorityBase,
  3. required Pubkey? custodian,
  4. required Pubkey newAuthority,
  5. required StakeAuthorize authorityType,
  6. required String authoritySeed,
  7. required Pubkey authorityOwner,
})

Authorize a key to manage stake or withdrawal with a derived key.

This instruction behaves like AuthorizeWithSeed with the additional requirement that the new stake or withdraw authority must also be a signer.

Keys:

  • [w] Stake account to be updated
  • [s] Base key of stake or withdraw authority
  • [] Clock sysvar
  • [s] The new stake or withdraw authority
  • [s] Lockup authority if updating StakeAuthorize.withdrawer before lockup expiration.

Implementation

static TransactionInstruction authorizeCheckedWithSeed({
  // Keys
  required final Pubkey stakeAccount,
  required final Pubkey authorityBase,
  required final Pubkey? custodian,
  // Data
  required final Pubkey newAuthority,
  required final StakeAuthorize authorityType,
  required final String authoritySeed,
  required final Pubkey authorityOwner,
}) {
  // 0. `[w]` Stake account to be updated
  // 1. `[s]` Base key of stake or withdraw authority
  // 2. `[]` Clock sysvar
  // 3. `[s]` The new stake or withdraw authority
  // 4. `[s]` Lockup authority if updating StakeAuthorize.withdrawer before lockup expiration.
  final List<AccountMeta> keys = [
    AccountMeta.writable(stakeAccount),
    AccountMeta.signer(authorityBase),
    AccountMeta(sysvarClockPubkey),
    AccountMeta.signer(newAuthority),
    if (custodian != null) AccountMeta.signer(custodian),
  ];

  final List<Iterable<u8>> data = [
    borsh.enumeration(StakeAuthorize.values).encode(authorityType),
    [0, 0, 0], // padding
    borsh.rustString().encode(authoritySeed),
    borsh.pubkey.encode(authorityOwner.toBase58()),
  ];

  return _instance.createTransactionIntruction(
    StakeInstruction.authorizeCheckedWithSeed,
    keys: keys,
    data: data,
  );
}