From ea6854b7af949685a1cec9c5b190793fd72c26f4 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 --- .../framework/aptos-framework/doc/coin.md | 23 ++++++++++++++++++- .../aptos-framework/doc/fungible_asset.md | 4 ++-- .../aptos-framework/sources/coin.move | 2 +- .../sources/fungible_asset.move | 4 ++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/aptos-move/framework/aptos-framework/doc/coin.md b/aptos-move/framework/aptos-framework/doc/coin.md index c5ff5884262a77..07e97171f99b19 100644 --- a/aptos-move/framework/aptos-framework/doc/coin.md +++ b/aptos-move/framework/aptos-framework/doc/coin.md @@ -1440,7 +1440,7 @@ Create APT pairing by passing AptosCoin. }; primary_fungible_store::create_primary_store_enabled_fungible_asset( &metadata_object_cref, - option::map(coin_supply<CoinType>(), |_| MAX_U128), + option::none(), name<CoinType>(), symbol<CoinType>(), decimals<CoinType>(), @@ -4595,6 +4595,27 @@ The creator of CoinType must be @aptos_framework. +Make sure name and symbol are legal length. +Only the creator of CoinType can initialize. + + + + + +
schema InitializeInternalSchema<CoinType> {
+    account: signer;
+    name: vector<u8>;
+    symbol: vector<u8>;
+    let account_addr = signer::address_of(account);
+    let coin_address = type_info::type_of<CoinType>().account_address;
+    aborts_if coin_address != account_addr;
+    aborts_if exists<CoinInfo<CoinType>>(account_addr);
+    aborts_if len(name) > MAX_COIN_NAME_LENGTH;
+    aborts_if len(symbol) > MAX_COIN_SYMBOL_LENGTH;
+}
+
+ + 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..c57c49a0832610 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(),
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);