From 877dc5d9eb7cedc157bf122b028531d4a558e6a8 Mon Sep 17 00:00:00 2001 From: str-mv Date: Thu, 07 May 2020 13:28:22 +0000 Subject: [PATCH] Merge branch 'master' of https://github.com/usetech-llc/nft_parachain --- --- a/doc/demo_milestone1-2.md +++ b/doc/demo_milestone1-2.md @@ -30,23 +30,23 @@ Before we continue, we need to do some preparations in the UI: Add NFT Data types so that the UI knows how to decode them. Go to [Settings-Developer Tab](https://polkadot.js.org/apps/#/settings/developer) and add following types to the JSON object in there: ``` { - "Address": "AccountId", - "LookupSource": "AccountId", - "Weight": "u32", "NftItemType": { "Collection": "u64", "Owner": "AccountId", "Data": "Vec" }, "CollectionType": { + "Owner": "AccountId", "NextItemId": "u64", - "Owner": "AccountId", "CustomDataSize": "u32" - } + }, + "Address": "AccountId", + "LookupSource": "AccountId", + "Weight": "u32" } ``` -**Note: ** In the future we will likely switch to substrate "2.0.0-alpha.7", in which case Weight type should be `u64`. +**Note:** In the future we will likely switch to substrate "2.0.0-alpha.7", in which case Weight type should be `u64`. #### CreateCollection @@ -57,10 +57,10 @@ Also, read the state variable `nft`.`collection` with ID = 1 (Because everything in NFT Palette is numbered from 1, not from 0). You will see something like this: ``` -templateModule.collection: CollectionType +nft.collection: CollectionType { - NextItemId: 0, Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + NextItemId: 1, CustomDataSize: 1 } ``` @@ -70,10 +70,10 @@ Open extrinsics tab of the [standard UI](https://polkadot.js.org/apps/#/extrinsics). Select `nft` module and `changeCollectionOwner` method. First, try to execute it to change owner to BOB for collection 1 from some different account than ALICE - FERDIE to see that it is not possible because ALICE owns collection 1 and FERDIE is not allowed to give it to BOB. Second, select ALICE as transaction signer and run it again. This time the collection owner changes, which will be reflected if you read the state variable `nft`.`collection` with ID = 1: ``` -templateModule.collection: CollectionType +nft.collection: CollectionType { - NextItemId: 0, Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty, + NextItemId: 1, CustomDataSize: 1 } ``` @@ -123,7 +123,7 @@ Execute extrinsic `nft`.`createItem` from ALICE account. Set properties to `0x01`. Now if you read the chain state `nft`.`balance(, ALICE)`, it will be equal to 1. Also, you can read chain state `nft`.`itemList(, 1)`, and it will return data for the token 1: ``` -templateModule.itemList: NftItemType +nft.itemList: NftItemType { Collection: 1, Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, @@ -134,7 +134,7 @@ #### GetOwner Reading the ownership is done by reading chainstate `nft`.`itemList(, 1)`. One of the returned fields is Owner: ``` -templateModule.itemList: NftItemType +nft.itemList: NftItemType { Collection: 1, Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, @@ -145,7 +145,7 @@ #### Transfer Execute `nft`.`transfer` from ALICE address to transfer token 1 to BOB and check the ownership again: ``` -templateModule.itemList: NftItemType +nft.itemList: NftItemType { Collection: 1, Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty, @@ -159,7 +159,7 @@ Read the chain state `nft`.`balance` for ALICE address and see that she owns 1 token: ``` -templateModule.balance: u64 +nft.balance: u64 1 ``` @@ -167,7 +167,7 @@ Execute `nft`.`AddCollectionAdmin` from ALICE account and let CHARLIE be an admin. Now you can see that CHARLIE can transfer ALICE's token from ALICE's account to EVE and back. Also, you can read admin list from chain state and see that it is not empty: ``` -templateModule.adminList: Vec +nft.adminList: Vec [ 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y ] @@ -177,14 +177,14 @@ Execute `nft`.`RemoveCollectionAdmin` from ALICE account to remove CHARLIE from admins. Now you can see that CHARLIE cannot transfer ALICE's tokens anymore. If you read the chan state `nft`.`adminList`, the response will be empty: ``` -templateModule.adminList: Vec +nft.adminList: Vec [] ``` #### BurnItem Execute `nft`.`burnItem` from ALICE account to burn token 1, and then read the chain state `nft`.`itemList(, 1)`. This time the chain state returns default values in fields because token does not exist anymore. You can also check ALICE balance in chain state, now it is equal 0 again. ``` -templateModule.itemList: NftItemType +nft.itemList: NftItemType { Collection: 0, Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM, -- gitstuff