difftreelog
Merge pull request #103 from usetech-llc/feature/NFTPAR-303_itemCreated_event_recipient
in: master
Add recipient field to ItemCreated event
4 files changed
doc/application_development.mddiffbeforeafterboth79##### Events79##### Events80ItemCreated80ItemCreated81ItemId: 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.81ItemId: 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.82Recipient: Address, owner of newly created item828383#### BurnItem84#### BurnItem8485pallets/nft/src/lib.rsdiffbeforeafterboth495 /// * collection_id: Id of the collection where item was created.495 /// * collection_id: Id of the collection where item was created.496 /// 496 /// 497 /// * item_id: Id of an item. Unique within the collection.497 /// * item_id: Id of an item. Unique within the collection.498 ///499 /// * recipient: Owner of newly created item 498 ItemCreated(CollectionId, TokenId),500 ItemCreated(CollectionId, TokenId, AccountId),499501500 /// Collection item was burned.502 /// Collection item was burned.501 /// 503 /// 1635 {1637 {1636 CreateItemData::NFT(data) => {1638 CreateItemData::NFT(data) => {1637 let item = NftItemType {1639 let item = NftItemType {1638 owner,1640 owner: owner.clone(),1639 const_data: data.const_data,1641 const_data: data.const_data,1640 variable_data: data.variable_data1642 variable_data: data.variable_data1641 };1643 };1660 };1662 };166116631662 // call event1664 // call event1663 Self::deposit_event(RawEvent::ItemCreated(collection_id, <ItemListIndex>::get(collection_id)));1665 Self::deposit_event(RawEvent::ItemCreated(collection_id, <ItemListIndex>::get(collection_id), owner));166416661665 Ok(())1667 Ok(())1666 }1668 }tests/package.jsondiffbeforeafterboth29 "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",tests/src/util/helpers.tsdiffbeforeafterboth36 success: boolean;36 success: boolean;37 collectionId: number;37 collectionId: number;38 itemId: number;38 itemId: number;39 recipient: string;39}40}404141interface IReFungibleOwner {42interface IReFungibleOwner {94 let success = false;95 let success = false;95 let collectionId: number = 0;96 let collectionId: number = 0;96 let itemId: number = 0;97 let itemId: number = 0;98 let recipient: string = '';97 events.forEach(({ phase, event: { data, method, section } }) => {99 events.forEach(({ phase, event: { data, method, section } }) => {98 // console.log(` ${phase}: ${section}.${method}:: ${data}`);100 // console.log(` ${phase}: ${section}.${method}:: ${data}`);99 if (method == 'ExtrinsicSuccess') {101 if (method == 'ExtrinsicSuccess') {100 success = true;102 success = true;101 } else if ((section == 'nft') && (method == 'ItemCreated')) {103 } else if ((section == 'nft') && (method == 'ItemCreated')) {102 collectionId = parseInt(data[0].toString());104 collectionId = parseInt(data[0].toString());103 itemId = parseInt(data[1].toString());105 itemId = parseInt(data[1].toString());106 recipient = data[2].toString();104 }107 }105 });108 });106 const result: CreateItemResult = {109 const result: CreateItemResult = {107 success,110 success,108 collectionId,111 collectionId,109 itemId,112 itemId,113 recipient,110 };114 };111 return result;115 return result;112}116}736 }740 }737 expect(collectionId).to.be.equal(result.collectionId);741 expect(collectionId).to.be.equal(result.collectionId);738 expect(BItemCount).to.be.equal(result.itemId);742 expect(BItemCount).to.be.equal(result.itemId);743 expect(owner).to.be.equal(result.recipient);739 newItemId = result.itemId;744 newItemId = result.itemId;740 });745 });741 return newItemId;746 return newItemId;