diff --git a/build/StarcoinFramework/bytecode_modules/Genesis.mv b/build/StarcoinFramework/bytecode_modules/Genesis.mv index 31cd06ce..37dc35bc 100644 Binary files a/build/StarcoinFramework/bytecode_modules/Genesis.mv and b/build/StarcoinFramework/bytecode_modules/Genesis.mv differ diff --git a/build/StarcoinFramework/bytecode_modules/GenesisNFT.mv b/build/StarcoinFramework/bytecode_modules/GenesisNFT.mv index fef8e86d..48c1bbde 100644 Binary files a/build/StarcoinFramework/bytecode_modules/GenesisNFT.mv and b/build/StarcoinFramework/bytecode_modules/GenesisNFT.mv differ diff --git a/build/StarcoinFramework/bytecode_modules/MerkleNFTDistributor.mv b/build/StarcoinFramework/bytecode_modules/MerkleNFTDistributor.mv index b90835b1..c37a0416 100644 Binary files a/build/StarcoinFramework/bytecode_modules/MerkleNFTDistributor.mv and b/build/StarcoinFramework/bytecode_modules/MerkleNFTDistributor.mv differ diff --git a/build/StarcoinFramework/docs/Genesis.md b/build/StarcoinFramework/docs/Genesis.md index a0a80c29..638f9277 100644 --- a/build/StarcoinFramework/docs/Genesis.md +++ b/build/StarcoinFramework/docs/Genesis.md @@ -414,8 +414,6 @@ The module for init Genesis GenesisNFT::initialize(&genesis_account, merkle_root, 1639u64, image); }; Config::publish_new_config(&genesis_account, LanguageVersion::new(4)); - // upgrade genesis NFT - GenesisNFT::upgrade_to_nft_type_info_v2(&genesis_account); //v11 -> v12 Block::checkpoints_init(); diff --git a/build/StarcoinFramework/docs/MerkleNFT.md b/build/StarcoinFramework/docs/MerkleNFT.md index abb38d9d..93a2088b 100644 --- a/build/StarcoinFramework/docs/MerkleNFT.md +++ b/build/StarcoinFramework/docs/MerkleNFT.md @@ -8,6 +8,7 @@ - [Resource `MerkleNFTDistribution`](#0x1_MerkleNFTDistributor_MerkleNFTDistribution) - [Constants](#@Constants_0) - [Function `register`](#0x1_MerkleNFTDistributor_register) +- [Function `register_v2`](#0x1_MerkleNFTDistributor_register_v2) - [Function `mint_with_cap`](#0x1_MerkleNFTDistributor_mint_with_cap) - [Function `encode_leaf`](#0x1_MerkleNFTDistributor_encode_leaf) - [Function `set_minted_`](#0x1_MerkleNFTDistributor_set_minted_) @@ -96,6 +97,7 @@ ## Function `register` +Deprecated, use register_v2 instead.
public fun register<NFTMeta: copy, drop, store, Info: copy, drop, store>(signer: &signer, merkle_root: vector<u8>, leafs: u64, info: Info, meta: NFT::Metadata): NFT::MintCapability<NFTMeta>
@@ -107,7 +109,13 @@
 Implementation
 
 
-
public fun register<NFTMeta: copy + store + drop, Info: copy + store + drop>(signer: &signer, merkle_root: vector<u8>, leafs: u64, info: Info, meta: Metadata): MintCapability<NFTMeta> {
+
public fun register<NFTMeta: copy + store + drop, Info: copy + store + drop>(
+    signer: &signer,
+    merkle_root: vector<u8>,
+    leafs: u64,
+    info: Info,
+    meta: Metadata
+): MintCapability<NFTMeta> {
     let bitmap_count = leafs / 128;
     if (bitmap_count * 128 < leafs) {
         bitmap_count = bitmap_count + 1;
@@ -130,6 +138,46 @@
 
 
 
+
+
+
+
+## Function `register_v2`
+
+
+
+
public fun register_v2<NFTMeta: copy, drop, store>(signer: &signer, merkle_root: vector<u8>, leafs: u64, meta: NFT::Metadata): NFT::MintCapability<NFTMeta>
+
+ + + +
+Implementation + + +
public fun register_v2<NFTMeta: copy + store + drop>(signer: &signer, merkle_root: vector<u8>, leafs: u64, meta: Metadata): MintCapability<NFTMeta> {
+    let bitmap_count = leafs / 128;
+    if (bitmap_count * 128 < leafs) {
+        bitmap_count = bitmap_count + 1;
+    };
+    let claimed_bitmap = Vector::empty();
+    let j = 0;
+    while (j < bitmap_count) {
+        Vector::push_back( &mut claimed_bitmap, 0u128);
+        j = j + 1;
+    };
+    let distribution = MerkleNFTDistribution<NFTMeta>{
+        merkle_root,
+        claimed_bitmap
+    };
+    NFT::register_v2<NFTMeta>(signer, meta);
+    move_to(signer, distribution);
+    NFT::remove_mint_capability<NFTMeta>(signer)
+}
+
+ + +
diff --git a/build/StarcoinFramework/source_maps/Genesis.mvsm b/build/StarcoinFramework/source_maps/Genesis.mvsm index 40576903..5295f7ad 100644 Binary files a/build/StarcoinFramework/source_maps/Genesis.mvsm and b/build/StarcoinFramework/source_maps/Genesis.mvsm differ diff --git a/build/StarcoinFramework/source_maps/GenesisNFT.mvsm b/build/StarcoinFramework/source_maps/GenesisNFT.mvsm index 12e69f07..14a6f17f 100644 Binary files a/build/StarcoinFramework/source_maps/GenesisNFT.mvsm and b/build/StarcoinFramework/source_maps/GenesisNFT.mvsm differ diff --git a/build/StarcoinFramework/source_maps/GenesisNFTScripts.mvsm b/build/StarcoinFramework/source_maps/GenesisNFTScripts.mvsm index 2ea1c9cb..d11198e8 100644 Binary files a/build/StarcoinFramework/source_maps/GenesisNFTScripts.mvsm and b/build/StarcoinFramework/source_maps/GenesisNFTScripts.mvsm differ diff --git a/build/StarcoinFramework/source_maps/MerkleNFTDistributor.mvsm b/build/StarcoinFramework/source_maps/MerkleNFTDistributor.mvsm index 5b196958..eb54fa0f 100644 Binary files a/build/StarcoinFramework/source_maps/MerkleNFTDistributor.mvsm and b/build/StarcoinFramework/source_maps/MerkleNFTDistributor.mvsm differ diff --git a/build/StarcoinFramework/source_maps/MerkleProof.mvsm b/build/StarcoinFramework/source_maps/MerkleProof.mvsm index c9a44b97..234610da 100644 Binary files a/build/StarcoinFramework/source_maps/MerkleProof.mvsm and b/build/StarcoinFramework/source_maps/MerkleProof.mvsm differ diff --git a/sources/Genesis.move b/sources/Genesis.move index 5b159b57..a704645e 100644 --- a/sources/Genesis.move +++ b/sources/Genesis.move @@ -349,8 +349,6 @@ module StarcoinFramework::Genesis { GenesisNFT::initialize(&genesis_account, merkle_root, 1639u64, image); }; Config::publish_new_config(&genesis_account, LanguageVersion::new(4)); - // upgrade genesis NFT - GenesisNFT::upgrade_to_nft_type_info_v2(&genesis_account); //v11 -> v12 Block::checkpoints_init(); diff --git a/sources/GenesisNFT.move b/sources/GenesisNFT.move index 0a11d29b..6e86a397 100644 --- a/sources/GenesisNFT.move +++ b/sources/GenesisNFT.move @@ -24,8 +24,7 @@ module StarcoinFramework::GenesisNFT { public fun initialize(sender: &signer, merkle_root: vector, leafs: u64, image: vector){ CoreAddresses::assert_genesis_address(sender); let metadata = NFT::new_meta_with_image(b"StarcoinGenesisNFT", image, b"The starcoin genesis NFT"); - let nft_info = GenesisNFTInfo{merkle_root: *&merkle_root, total_supply: leafs}; - let cap = MerkleNFTDistributor::register(sender, merkle_root, leafs, nft_info, metadata); + let cap = MerkleNFTDistributor::register_v2(sender, merkle_root, leafs, metadata); move_to(sender, GenesisNFTMintCapability{cap}); } diff --git a/sources/MerkleNFT.move b/sources/MerkleNFT.move index 36da5d84..959a8b3b 100644 --- a/sources/MerkleNFT.move +++ b/sources/MerkleNFT.move @@ -47,7 +47,14 @@ module StarcoinFramework::MerkleNFTDistributor { claimed_bitmap: vector, } - public fun register(signer: &signer, merkle_root: vector, leafs: u64, info: Info, meta: Metadata): MintCapability { + /// Deprecated, use `register_v2` instead. + public fun register( + signer: &signer, + merkle_root: vector, + leafs: u64, + info: Info, + meta: Metadata + ): MintCapability { let bitmap_count = leafs / 128; if (bitmap_count * 128 < leafs) { bitmap_count = bitmap_count + 1; @@ -67,6 +74,26 @@ module StarcoinFramework::MerkleNFTDistributor { NFT::remove_mint_capability(signer) } + public fun register_v2(signer: &signer, merkle_root: vector, leafs: u64, meta: Metadata): MintCapability { + let bitmap_count = leafs / 128; + if (bitmap_count * 128 < leafs) { + bitmap_count = bitmap_count + 1; + }; + let claimed_bitmap = Vector::empty(); + let j = 0; + while (j < bitmap_count) { + Vector::push_back( &mut claimed_bitmap, 0u128); + j = j + 1; + }; + let distribution = MerkleNFTDistribution{ + merkle_root, + claimed_bitmap + }; + NFT::register_v2(signer, meta); + move_to(signer, distribution); + NFT::remove_mint_capability(signer) + } + public fun mint_with_cap(sender: &signer, cap:&mut MintCapability, creator: address, index: u64, base_meta: Metadata, type_meta: NFTMeta, body: NFTBody, merkle_proof:vector>): NFT acquires MerkleNFTDistribution { let addr = Signer::address_of(sender);