From 57d7a68b436dc5bc3918f0229d4a94f07cee2fc4 Mon Sep 17 00:00:00 2001 From: Aaron Gao Date: Wed, 3 Jul 2024 19:27:11 +0100 Subject: [PATCH] [fix] make the max supply unlimited --- aptos-move/framework/aptos-framework/doc/fungible_asset.md | 4 ++-- aptos-move/framework/aptos-framework/sources/coin.move | 4 +++- .../framework/aptos-framework/sources/fungible_asset.move | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/fungible_asset.md b/aptos-move/framework/aptos-framework/doc/fungible_asset.md index 2c58cdd944dac4..f12ee14942b4f4 100644 --- a/aptos-move/framework/aptos-framework/doc/fungible_asset.md +++ b/aptos-move/framework/aptos-framework/doc/fungible_asset.md @@ -3321,12 +3321,12 @@ Destroy an empty fungible asset.
public(friend) fun deposit_internal(store_addr: address, fa: FungibleAsset) acquires FungibleStore, ConcurrentFungibleBalance {
     let FungibleAsset { metadata, amount } = fa;
-    if (amount == 0) return;
-
     assert!(exists<FungibleStore>(store_addr), error::not_found(EFUNGIBLE_STORE_EXISTENCE));
     let store = borrow_global_mut<FungibleStore>(store_addr);
     assert!(metadata == store.metadata, error::invalid_argument(EFUNGIBLE_ASSET_AND_STORE_MISMATCH));
 
+    if (amount == 0) return;
+
     if (store.balance == 0 && concurrent_fungible_balance_exists_inline(store_addr)) {
         let balance_resource = borrow_global_mut<ConcurrentFungibleBalance>(store_addr);
         aggregator_v2::add(&mut balance_resource.balance, amount);
diff --git a/aptos-move/framework/aptos-framework/sources/coin.move b/aptos-move/framework/aptos-framework/sources/coin.move
index 19a41f144b1f7b..5735bfb4e85044 100644
--- a/aptos-move/framework/aptos-framework/sources/coin.move
+++ b/aptos-move/framework/aptos-framework/sources/coin.move
@@ -328,7 +328,7 @@ module aptos_framework::coin {
                 };
             primary_fungible_store::create_primary_store_enabled_fungible_asset(
                 &metadata_object_cref,
-                option::map(coin_supply(), |_| MAX_U128),
+                option::none(),
                 name(),
                 symbol(),
                 decimals(),
@@ -2079,7 +2079,9 @@ module aptos_framework::coin {
         ensure_paired_metadata();
         let (mint_ref, mint_ref_receipt) = get_paired_mint_ref(&mint_cap);
         let (burn_ref, burn_ref_receipt) = get_paired_burn_ref(&burn_cap);
+        // make sure the minted amount is greater than current coin supply.
         let fungible_asset = fungible_asset::mint(&mint_ref, 50);
+        assert!(option::is_none(&fungible_asset::maximum(ensure_paired_metadata())), 0);
         assert!(supply() == option::some(150), 0);
         assert!(coin_supply() == option::some(100), 0);
         assert!(fungible_asset::supply(ensure_paired_metadata()) == option::some(50), 0);
diff --git a/aptos-move/framework/aptos-framework/sources/fungible_asset.move b/aptos-move/framework/aptos-framework/sources/fungible_asset.move
index 1b12cb49a2c61f..946d7b05eb415c 100644
--- a/aptos-move/framework/aptos-framework/sources/fungible_asset.move
+++ b/aptos-move/framework/aptos-framework/sources/fungible_asset.move
@@ -1011,12 +1011,12 @@ module aptos_framework::fungible_asset {
 
     public(friend) fun deposit_internal(store_addr: address, fa: FungibleAsset) acquires FungibleStore, ConcurrentFungibleBalance {
         let FungibleAsset { metadata, amount } = fa;
-        if (amount == 0) return;
-
         assert!(exists(store_addr), error::not_found(EFUNGIBLE_STORE_EXISTENCE));
         let store = borrow_global_mut(store_addr);
         assert!(metadata == store.metadata, error::invalid_argument(EFUNGIBLE_ASSET_AND_STORE_MISMATCH));
 
+        if (amount == 0) return;
+
         if (store.balance == 0 && concurrent_fungible_balance_exists_inline(store_addr)) {
             let balance_resource = borrow_global_mut(store_addr);
             aggregator_v2::add(&mut balance_resource.balance, amount);