StakeInstruction.authorize constructor

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

Authorize a key to manage stake or withdrawal.

Implementation

factory StakeInstruction.authorize({
  required Ed25519HDPublicKey stake,
  required Ed25519HDPublicKey authority,
  required StakeAuthorize authorize,
  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),
        if (lockupAuthority != null)
          AccountMeta.readonly(pubKey: lockupAuthority, isSigner: true),
      ],
      data: ByteArray.merge([
        StakeProgram.authorizeInstructionIndex,
        authorize.serialize(),
      ]),
    );