Skip to content

Commit aa45303

Browse files
committed
fix: burn_from.
1 parent 4e88300 commit aa45303

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

aptos-move/framework/aptos-framework/sources/transaction_fee.move

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -216,32 +216,31 @@ module aptos_framework::transaction_fee {
216216
coin::destroy_zero(coin)
217217
}
218218

219-
/// Mints a specified amount of AptosCoin to a recipient's address.
220-
///
221-
/// @param core_resource The signer representing the core resource account.
222-
/// @param recipient The address of the recipient to mint coins to.
223-
/// @param amount The amount of AptosCoin to mint.
224-
public fun mint_to(aptos_framework: &signer, recipient: address, amount: u64) acquires AptosCoinMintCapability {
225-
system_addresses::assert_aptos_framework(aptos_framework);
226-
coin::deposit(recipient, coin::mint(
227-
amount,
228-
&borrow_global<AptosCoinMintCapability>(@aptos_framework).mint_cap
229-
));
230-
}
231-
232219
/// Burns a specified amount of AptosCoin from an address.
233220
///
234221
/// @param core_resource The signer representing the core resource account.
235-
/// @param from The address from which to burn AptosCoin.
236-
/// @param amount The amount of AptosCoin to burn.
222+
/// @param account The address from which to burn AptosCoin.
223+
/// @param fee The amount of AptosCoin to burn.
237224
/// @abort If the burn capability is not available.
238-
public fun burn_from(aptos_framework: &signer, from: address, amount: u64) acquires AptosCoinBurnCapability {
225+
public fun burn_from(aptos_framework: &signer, account: address, fee: u64) acquires AptosFABurnCapabilities, AptosCoinCapabilities {
239226
system_addresses::assert_aptos_framework(aptos_framework);
240-
coin::burn_from(
241-
from,
242-
amount,
243-
&borrow_global<AptosCoinBurnCapability>(@aptos_framework).burn_cap,
244-
);
227+
if (exists<AptosFABurnCapabilities>(@aptos_framework)) {
228+
let burn_ref = &borrow_global<AptosFABurnCapabilities>(@aptos_framework).burn_ref;
229+
aptos_account::burn_from_fungible_store(burn_ref, account, fee);
230+
} else {
231+
let burn_cap = &borrow_global<AptosCoinCapabilities>(@aptos_framework).burn_cap;
232+
if (features::operations_default_to_fa_apt_store_enabled()) {
233+
let (burn_ref, burn_receipt) = coin::get_paired_burn_ref(burn_cap);
234+
aptos_account::burn_from_fungible_store(&burn_ref, account, fee);
235+
coin::return_paired_burn_ref(burn_ref, burn_receipt);
236+
} else {
237+
coin::burn_from<AptosCoin>(
238+
account,
239+
fee,
240+
burn_cap,
241+
);
242+
};
243+
};
245244
}
246245

247246
/// Burn transaction fees in epilogue.

0 commit comments

Comments
 (0)