Skip to content

Commit

Permalink
add mint and burn functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Primata committed Feb 17, 2025
1 parent 1b796d5 commit 5e4564b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-framework/doc/chain_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Helper function to assert genesis state.


<pre><code><b>public</b> <b>fun</b> <a href="chain_status.md#0x1_chain_status_assert_genesis">assert_genesis</a>() {
<b>assert</b>!(<a href="chain_status.md#0x1_chain_status_is_genesis">is_genesis</a>(), <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="chain_status.md#0x1_chain_status_ENOT_OPERATING">ENOT_OPERATING</a>));
<b>assert</b>!(<a href="chain_status.md#0x1_chain_status_is_genesis">is_genesis</a>(), <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="chain_status.md#0x1_chain_status_ENOT_GENESIS">ENOT_GENESIS</a>));
}
</code></pre>

Expand Down
28 changes: 28 additions & 0 deletions aptos-move/framework/aptos-framework/sources/transaction_fee.move
Original file line number Diff line number Diff line change
Expand Up @@ -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<AptosCoinMintCapability>(@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<AptosCoinBurnCapability>(@aptos_framework).burn_cap,
);
}

/// Burn transaction fees in epilogue.
public(friend) fun burn_fee(account: address, fee: u64) acquires AptosFABurnCapabilities, AptosCoinCapabilities {
if (exists<AptosFABurnCapabilities>(@aptos_framework)) {
Expand Down
8 changes: 5 additions & 3 deletions aptos-move/framework/move-stdlib/doc/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -3341,10 +3341,12 @@ Deprecated to prevent validator set changes during DKG.

Genesis/tests should use <code><a href="features.md#0x1_features_change_feature_flags_internal">change_feature_flags_internal</a>()</code> for feature vec initialization.

This can be used on testnet prior to successful DKG.

Governance proposals should use <code><a href="features.md#0x1_features_change_feature_flags_for_next_epoch">change_feature_flags_for_next_epoch</a>()</code> to enable/disable features.


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(_framework: &<a href="signer.md#0x1_signer">signer</a>, _enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, _disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;)
<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(framework: &<a href="signer.md#0x1_signer">signer</a>, enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;)
</code></pre>


Expand All @@ -3353,8 +3355,8 @@ Governance proposals should use <code><a href="features.md#0x1_features_change_f
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(_framework: &<a href="signer.md#0x1_signer">signer</a>, _enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, _disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;) {
<b>abort</b> (<a href="error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="features.md#0x1_features_EAPI_DISABLED">EAPI_DISABLED</a>))
<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_change_feature_flags">change_feature_flags</a>(framework: &<a href="signer.md#0x1_signer">signer</a>, enable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;, disable: <a href="vector.md#0x1_vector">vector</a>&lt;u64&gt;) <b>acquires</b> <a href="features.md#0x1_features_Features">Features</a> {
<a href="features.md#0x1_features_change_feature_flags_internal">change_feature_flags_internal</a>(framework, enable, disable)
}
</code></pre>

Expand Down

0 comments on commit 5e4564b

Please sign in to comment.