git.delta.rocks / unique-network / refs/commits / e4dd4c0eeff5

difftreelog

Merge pull request #133 from usetech-llc/feature/NFTPAR-196_sponsor_setVariableMetadata

Greg Zaitsev2021-03-22parents: #e72e7a9 #ff8c59d.patch.diff
in: master
Feature/nftpar 196 sponsor set variable metadata

3 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -174,7 +174,7 @@
     pub mint_mode: bool,
     pub offchain_schema: Vec<u8>,
     pub schema_version: SchemaVersion,
-    pub sponsorship: SponsorshipState<AccountId>,
+    pub sponsorship: SponsorshipState<T::AccountId>,
     pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions 
     pub variable_on_chain_schema: Vec<u8>, //
     pub const_on_chain_schema: Vec<u8>, //
@@ -1853,8 +1853,6 @@
     }
 
     fn create_item_no_validation(collection: &CollectionHandle<T>, owner: T::AccountId, data: CreateItemData) -> DispatchResult {
-        let collection_id = collection.id;
-
         match data
         {
             CreateItemData::NFT(data) => {
@@ -2622,10 +2620,7 @@
                 // sponsor timeout
                 let block_number = <system::Module<T>>::block_number() as T::BlockNumber;
 
-                let collection = <Collection<T>>::get(collection_id);
-
                 let limit = collection.limits.sponsor_transfer_timeout;
-                let mut sponsored = true;
                 if <CreateItemBasket<T>>::contains_key((collection_id, &who)) {
                     let last_tx_block = <CreateItemBasket<T>>::get((collection_id, &who));
                     let limit_time = last_tx_block + limit.into();
@@ -2636,9 +2631,7 @@
                 <CreateItemBasket<T>>::insert((collection_id, who.clone()), block_number);
 
                 // check free create limit
-                if (collection.limits.sponsored_data_size >= (_properties.len() as u32)) &&
-                   (sponsored)
-                {
+                if collection.limits.sponsored_data_size >= (_properties.len() as u32) {
                     collection.sponsorship.sponsor()
                         .cloned()
                 } else {
@@ -2747,7 +2740,7 @@
                 let collection = <CollectionById<T>>::get(collection_id)?;
 
                 if
-                    collection.sponsor_confirmed &&
+                    collection.sponsorship.confirmed() &&
                     // Can't sponsor fungible collection, this tx will be rejected
                     // as invalid
                     !matches!(collection.mode, CollectionMode::Fungible(_)) &&
@@ -2769,7 +2762,7 @@
                 if !sponsor_metadata_changes {
                     None
                 } else {
-                    Some(collection.sponsor)
+                    collection.sponsorship.sponsor().cloned()
                 }
             }
 
modifiedtests/src/rpc.load.tsdiffbeforeafterboth
--- a/tests/src/rpc.load.ts
+++ b/tests/src/rpc.load.ts
@@ -110,7 +110,7 @@
     });
   });
 
-  it.only('Smart Contract RPC Load Test', async () => {
+  it('Smart Contract RPC Load Test', async () => {
     await usingApi(async api => {
 
       // Deploy smart contract
modifiedtests/src/setVariableMetadataSponsoringRateLimit.test.tsdiffbeforeafterboth
68 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2]);68 await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2]);
69 });69 });
7070
71 it.only('Default value of rate limit does not sponsor setting variable metadata', async () => {71 it('Default value of rate limit does not sponsor setting variable metadata', async () => {
72 const collectionId = await createCollectionExpectSuccess();72 const collectionId = await createCollectionExpectSuccess();
73 await setCollectionSponsorExpectSuccess(collectionId, alice.address);73 await setCollectionSponsorExpectSuccess(collectionId, alice.address);
74 await confirmSponsorshipExpectSuccess(collectionId);74 await confirmSponsorshipExpectSuccess(collectionId);