authorizeCheckedWithSeed static method
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,
);
}