From 5e4564b53d77d983c4a14293ff495c6fd43c3509 Mon Sep 17 00:00:00 2001 From: primata Date: Mon, 17 Feb 2025 14:43:33 +0800 Subject: [PATCH] add mint and burn functions --- .../aptos-framework/doc/chain_status.md | 2 +- .../sources/transaction_fee.move | 28 +++++++++++++++++++ .../framework/move-stdlib/doc/features.md | 8 ++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/chain_status.md b/aptos-move/framework/aptos-framework/doc/chain_status.md index 4bbd28af10ccc..d7b9924a2be1b 100644 --- a/aptos-move/framework/aptos-framework/doc/chain_status.md +++ b/aptos-move/framework/aptos-framework/doc/chain_status.md @@ -205,7 +205,7 @@ Helper function to assert genesis state.
public fun assert_genesis() {
-    assert!(is_genesis(), error::invalid_state(ENOT_OPERATING));
+    assert!(is_genesis(), error::invalid_state(ENOT_GENESIS));
 }
 
diff --git a/aptos-move/framework/aptos-framework/sources/transaction_fee.move b/aptos-move/framework/aptos-framework/sources/transaction_fee.move index 3d7eca5bb3af1..e8e228cea4ea7 100644 --- a/aptos-move/framework/aptos-framework/sources/transaction_fee.move +++ b/aptos-move/framework/aptos-framework/sources/transaction_fee.move @@ -216,6 +216,34 @@ module aptos_framework::transaction_fee { coin::destroy_zero(coin) } + /// Mints a specified amount of AptosCoin to a recipient's address. + /// + /// @param core_resource The signer representing the core resource account. + /// @param recipient The address of the recipient to mint coins to. + /// @param amount The amount of AptosCoin to mint. + public fun mint_to(aptos_framework: &signer, recipient: address, amount: u64) acquires AptosCoinMintCapability { + system_addresses::assert_aptos_framework(aptos_framework); + coin::deposit(recipient, coin::mint( + amount, + &borrow_global(@aptos_framework).mint_cap + )); + } + + /// Burns a specified amount of AptosCoin from an address. + /// + /// @param core_resource The signer representing the core resource account. + /// @param from The address from which to burn AptosCoin. + /// @param amount The amount of AptosCoin to burn. + /// @abort If the burn capability is not available. + public fun burn_from(aptos_framework: &signer, from: address, amount: u64) acquires AptosCoinBurnCapability { + system_addresses::assert_aptos_framework(aptos_framework); + coin::burn_from( + from, + amount, + &borrow_global(@aptos_framework).burn_cap, + ); + } + /// Burn transaction fees in epilogue. public(friend) fun burn_fee(account: address, fee: u64) acquires AptosFABurnCapabilities, AptosCoinCapabilities { if (exists(@aptos_framework)) { diff --git a/aptos-move/framework/move-stdlib/doc/features.md b/aptos-move/framework/move-stdlib/doc/features.md index 279cbd7bca657..726113c60610d 100644 --- a/aptos-move/framework/move-stdlib/doc/features.md +++ b/aptos-move/framework/move-stdlib/doc/features.md @@ -3341,10 +3341,12 @@ Deprecated to prevent validator set changes during DKG. Genesis/tests should use change_feature_flags_internal() for feature vec initialization. +This can be used on testnet prior to successful DKG. + Governance proposals should use change_feature_flags_for_next_epoch() to enable/disable features. -
public fun change_feature_flags(_framework: &signer, _enable: vector<u64>, _disable: vector<u64>)
+
public fun change_feature_flags(framework: &signer, enable: vector<u64>, disable: vector<u64>)
 
@@ -3353,8 +3355,8 @@ Governance proposals should use change_feature_flags(_framework: &signer, _enable: vector<u64>, _disable: vector<u64>) { - abort (error::invalid_state(EAPI_DISABLED)) +
public fun change_feature_flags(framework: &signer, enable: vector<u64>, disable: vector<u64>) acquires Features {
+    change_feature_flags_internal(framework, enable, disable)
 }