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.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
pallets/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.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -29,6 +29,7 @@
"testRemoveFromWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromWhiteList.test.ts",
"testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
"testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
+ "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",
"testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",
"testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",
"testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",
tests/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;