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

difftreelog

Merge pull request #103 from usetech-llc/feature/NFTPAR-303_itemCreated_event_recipient

Greg Zaitsev2021-02-17parents: #a09692c #cadb228.patch.diff
in: master
Add recipient field to ItemCreated event

4 files changed

modifieddoc/application_development.mddiffbeforeafterboth
--- a/doc/application_development.md
+++ b/doc/application_development.md
@@ -79,6 +79,7 @@
 ##### Events
 ItemCreated
 ItemId: Identifier of newly created NFT, which is unique within the Collection, so the NFT is uniquely identified with a pair of values: CollectionId and ItemId.
+Recipient: Address, owner of newly created item
 
 #### BurnItem
 
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -495,7 +495,9 @@
         /// * collection_id: Id of the collection where item was created.
         /// 
         /// * item_id: Id of an item. Unique within the collection.
-        ItemCreated(CollectionId, TokenId),
+        ///
+        /// * recipient: Owner of newly created item 
+        ItemCreated(CollectionId, TokenId, AccountId),
 
         /// Collection item was burned.
         /// 
@@ -1635,7 +1637,7 @@
         {
             CreateItemData::NFT(data) => {
                 let item = NftItemType {
-                    owner,
+                    owner: owner.clone(),
                     const_data: data.const_data,
                     variable_data: data.variable_data
                 };
@@ -1660,7 +1662,7 @@
         };
 
         // call event
-        Self::deposit_event(RawEvent::ItemCreated(collection_id, <ItemListIndex>::get(collection_id)));
+        Self::deposit_event(RawEvent::ItemCreated(collection_id, <ItemListIndex>::get(collection_id), owner));
 
         Ok(())
     }
modifiedtests/package.jsondiffbeforeafterboth
29 "testRemoveFromWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromWhiteList.test.ts",29 "testRemoveFromWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromWhiteList.test.ts",
30 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",30 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
31 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",31 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
32 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",
32 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",33 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",
33 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",34 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",
34 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",35 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -36,6 +36,7 @@
   success: boolean;
   collectionId: number;
   itemId: number;
+  recipient: string;
 }
 
 interface IReFungibleOwner {
@@ -94,6 +95,7 @@
   let success = false;
   let collectionId: number = 0;
   let itemId: number = 0;
+  let recipient: string = '';
   events.forEach(({ phase, event: { data, method, section } }) => {
     // console.log(`    ${phase}: ${section}.${method}:: ${data}`);
     if (method == 'ExtrinsicSuccess') {
@@ -101,12 +103,14 @@
     } else if ((section == 'nft') && (method == 'ItemCreated')) {
       collectionId = parseInt(data[0].toString());
       itemId = parseInt(data[1].toString());
+      recipient = data[2].toString();
     }
   });
   const result: CreateItemResult = {
     success,
     collectionId,
     itemId,
+    recipient,
   };
   return result;
 }
@@ -736,6 +740,7 @@
     }
     expect(collectionId).to.be.equal(result.collectionId);
     expect(BItemCount).to.be.equal(result.itemId);
+    expect(owner).to.be.equal(result.recipient);
     newItemId = result.itemId;
   });
   return newItemId;