StakeInstruction.authorizeChecked constructor

StakeInstruction.authorizeChecked({
  1. required Ed25519HDPublicKey stake,
  2. required Ed25519HDPublicKey authority,
  3. required StakeAuthorize stakeAuthorize,
  4. Ed25519HDPublicKey? lockupAuthority,
})

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.

Implementation

factory StakeInstruction.authorizeChecked({
  required Ed25519HDPublicKey stake,
  required Ed25519HDPublicKey authority,
  required StakeAuthorize stakeAuthorize,
  Ed25519HDPublicKey? lockupAuthority,
}) =>
    StakeInstruction._(
      accounts: [
        AccountMeta.writeable(pubKey: stake, isSigner: false),
        AccountMeta.readonly(
          pubKey: Ed25519HDPublicKey.fromBase58(Sysvar.clock),
          isSigner: false,
        ),
        AccountMeta.readonly(pubKey: authority, isSigner: true),
        AccountMeta.readonly(pubKey: stakeAuthorize.pubKey, isSigner: true),
        if (lockupAuthority != null)
          AccountMeta.readonly(pubKey: lockupAuthority, isSigner: true),
      ],
      data: ByteArray.merge([
        StakeProgram.authorizeCheckedInstructionIndex,
        stakeAuthorize.serialize(),
      ]),
    );