SPLToken2022ExtensionsProgram.withdrawWithheldTokensFromAccounts constructor

SPLToken2022ExtensionsProgram.withdrawWithheldTokensFromAccounts({
  1. required SolAddress mint,
  2. required SolAddress destination,
  3. required SolAddress authority,
  4. required List<SolAddress> sources,
  5. SolAddress programId = SPLTokenProgramConst.token2022ProgramId,
  6. List<SolAddress> multiSigners = const [],
})

Transfer all withheld tokens to an account. Signed by the mint's withdraw withheld tokens authority.

Implementation

factory SPLToken2022ExtensionsProgram.withdrawWithheldTokensFromAccounts(
    {
    /// The token mint.
    required SolAddress mint,

    /// The fee receiver account.
    required SolAddress destination,

    /// The mint's withdraw withheld authority.
    required SolAddress authority,

    /// The source accounts to withdraw from.
    required List<SolAddress> sources,
    SolAddress programId = SPLTokenProgramConst.token2022ProgramId,
    List<SolAddress> multiSigners = const []}) {
  if (programId == SPLTokenProgramConst.tokenProgramId) {
    throw const MessageException("Token program does not support extensions");
  }
  return SPLToken2022ExtensionsProgram(
      keys: [
        ...SPLTokenUtils.buildKeys(
            keys: [mint.toWritable(), destination.toWritable()],
            owner: authority,
            multiSigners: multiSigners),
        ...sources.map((e) => e.toWritable())
      ],
      programId: programId,
      layout: SPLToken2022WithdrawWithheldTokensFromAccountsLayout(
          numTokenAccounts: sources.length));
}