pub fn encode_cancel_burn_with_amount_script_function(
    token: TypeTag,
    preburn_address: AccountAddress,
    amount: u64
) -> TransactionPayload
Expand description

Summary

Cancels and returns the coins held in the preburn area under preburn_address, which are equal to the amount specified in the transaction. Finds the first preburn resource with the matching amount and returns the funds to the preburn_address’s balance. Can only be successfully sent by an account with Treasury Compliance role.

Technical Description

Cancels and returns all coins held in the Diem::Preburn<Token> resource under the preburn_address and return the funds to the preburn_address account’s DiemAccount::Balance<Token>. The transaction must be sent by an account with a Diem::BurnCapability<Token> resource published under it. The account at preburn_address must have a Diem::Preburn<Token> resource published under it, and its value must be nonzero. The transaction removes the entire balance held in the Diem::Preburn<Token> resource, and returns it back to the account’s DiemAccount::Balance<Token> under preburn_address. Due to this, the account at preburn_address must already have a balance in the Token currency published before this script is called otherwise the transaction will fail.

Events

The successful execution of this transaction will emit:

  • A Diem::CancelBurnEvent on the event handle held in the Diem::CurrencyInfo<Token> resource’s burn_events published under 0xA550C18.
  • A DiemAccount::ReceivedPaymentEvent on the preburn_address’s DiemAccount::DiemAccount received_events event handle with both the payer and payee being preburn_address.

Parameters

NameTypeDescription
TokenTypeThe Move type for the Token currenty that burning is being cancelled for. Token must be an already-registered currency on-chain.
accountsignerThe signer of the sending account of this transaction, must have a burn capability for Token published under it.
preburn_addressaddressThe address where the coins to-be-burned are currently held.
amountu64The amount to be cancelled.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::REQUIRES_CAPABILITYDiem::EBURN_CAPABILITYThe sending account does not have a Diem::BurnCapability<Token> published under it.
Errors::INVALID_STATEDiem::EPREBURN_NOT_FOUNDThe Diem::PreburnQueue<Token> resource under preburn_address does not contain a preburn request with a value matching amount.
Errors::NOT_PUBLISHEDDiem::EPREBURN_QUEUEThe account at preburn_address does not have a Diem::PreburnQueue<Token> resource published under it.
Errors::NOT_PUBLISHEDDiem::ECURRENCY_INFOThe specified Token is not a registered currency on-chain.
Errors::INVALID_ARGUMENTDiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPEThe account at preburn_address doesn’t have a balance resource for Token.
Errors::LIMIT_EXCEEDEDDiemAccount::EDEPOSIT_EXCEEDS_LIMITSThe depositing of the funds held in the prebun area would exceed the account’s account limits.
Errors::INVALID_STATEDualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SETThe account does not have a compliance key set on it but dual attestion checking was performed.
  • TreasuryComplianceScripts::burn_txn_fees
  • TreasuryComplianceScripts::burn_with_amount
  • TreasuryComplianceScripts::preburn