authorizeChecked static method
TransactionInstruction
authorizeChecked({
- required Pubkey stakeAccount,
- required Pubkey authority,
- required Pubkey? custodian,
- required Pubkey newAuthority,
- required StakeAuthorize authorityType,
Authorize a key to manage stake or withdrawal.
This instruction behaves like Authorize
with the additional requirement that the new stake
or withdraw authority must also be a signer.
Keys:
[w]
stakeAccount
- Stake account to be updated.[s]
authority
- The stake or withdraw authority.[s]
newAuthority
- The new stake or withdraw authority.[s]
custodian
- Lockup authority if updating StakeAuthorize.withdrawer before lockup expiration.
Implementation
static TransactionInstruction authorizeChecked({
// Keys
required final Pubkey stakeAccount,
required final Pubkey authority,
required final Pubkey? custodian,
// Data
required final Pubkey newAuthority,
required final StakeAuthorize authorityType,
}) {
// 0. `[w]` Stake account to be updated
// 1. `[]` Clock sysvar
// 2. `[s]` The stake or withdraw authority
// 3. `[s]` [newAuthority] - 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(sysvarClockPubkey),
AccountMeta.signer(authority),
AccountMeta.signer(newAuthority),
if (custodian != null)
AccountMeta.signer(custodian)
];
final List<Iterable<u8>> data = [
borsh.enumeration(StakeAuthorize.values).encode(authorityType), [0,0,0], // padding
];
return _instance.createTransactionIntruction(
StakeInstruction.authorizeChecked,
keys: keys,
data: data,
);
}