SPLTokenProgram.reallocate constructor

SPLTokenProgram.reallocate({
  1. required SPLTokenReallocateLayout layout,
  2. required SolAddress account,
  3. required SolAddress payer,
  4. required SolAddress owner,
  5. SolAddress programId = SPLTokenProgramConst.token2022ProgramId,
  6. List<SolAddress> multiSigners = const [],
})

Check to see if a token account is large enough for a list of ExtensionTypes, and if not, use reallocation to increase the data size.

Implementation

factory SPLTokenProgram.reallocate({
  required SPLTokenReallocateLayout layout,

  /// The account to reallocate.
  required SolAddress account,

  /// The payer account to fund reallocation
  required SolAddress payer,

  ///  The account's owner.
  required SolAddress owner,
  SolAddress programId = SPLTokenProgramConst.token2022ProgramId,

  /// Multisignature owner
  List<SolAddress> multiSigners = const [],
}) {
  if (programId == SPLTokenProgramConst.tokenProgramId) {
    throw const MessageException("Token program does not support extensions");
  }
  return SPLTokenProgram(
      layout: layout,
      keys: SPLTokenUtils.buildKeys(keys: [
        account.toWritable(),
        payer.toSignerAndWritable(),
        SystemProgramConst.programId.toReadOnly(),
      ], owner: owner, multiSigners: multiSigners),
      programId: programId);
}