difftreelog
Merge branch 'master' of https://github.com/usetech-llc/nft_parachain
in: master
1 file changed
doc/demo_milestone1-2.mddiffbeforeafterboth30Before 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:30Before 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:31```31```32{32{33 "Address": "AccountId",34 "LookupSource": "AccountId",35 "Weight": "u32", 36 "NftItemType": {33 "NftItemType": {37 "Collection": "u64",34 "Collection": "u64",38 "Owner": "AccountId",35 "Owner": "AccountId",39 "Data": "Vec<u8>"36 "Data": "Vec<u8>"40 },37 },41 "CollectionType": {38 "CollectionType": {42 "NextItemId": "u64",43 "Owner": "AccountId",39 "Owner": "AccountId",40 "NextItemId": "u64",44 "CustomDataSize": "u32"41 "CustomDataSize": "u32"45 }42 },43 "Address": "AccountId",44 "LookupSource": "AccountId",45 "Weight": "u32"46}46}47```47```484849**Note: ** In the future we will likely switch to substrate "2.0.0-alpha.7", in which case Weight type should be `u64`.49**Note:** In the future we will likely switch to substrate "2.0.0-alpha.7", in which case Weight type should be `u64`.505051#### CreateCollection51#### CreateCollection525257Also, 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:57Also, 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:585859```59```60templateModule.collection: CollectionType60nft.collection: CollectionType61{61{62 NextItemId: 0,63 Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,62 Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,63 NextItemId: 1,64 CustomDataSize: 164 CustomDataSize: 165}65}66```66```70Open 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:70Open 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:717172```72```73templateModule.collection: CollectionType73nft.collection: CollectionType74{74{75 NextItemId: 0,76 Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,75 Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,76 NextItemId: 1,77 CustomDataSize: 177 CustomDataSize: 178}78}79```79```123Execute extrinsic `nft`.`createItem` from ALICE account. Set properties to `0x01`. Now if you read the chain state `nft`.`balance(<Collection ID>, ALICE)`, it will be equal to 1. Also, you can read chain state `nft`.`itemList(<Collection ID>, 1)`, and it will return data for the token 1:123Execute extrinsic `nft`.`createItem` from ALICE account. Set properties to `0x01`. Now if you read the chain state `nft`.`balance(<Collection ID>, ALICE)`, it will be equal to 1. Also, you can read chain state `nft`.`itemList(<Collection ID>, 1)`, and it will return data for the token 1:124124125```125```126templateModule.itemList: NftItemType126nft.itemList: NftItemType127{127{128 Collection: 1,128 Collection: 1,129 Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,129 Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,134#### GetOwner134#### GetOwner135Reading the ownership is done by reading chainstate `nft`.`itemList(<Collection ID>, 1)`. One of the returned fields is Owner:135Reading the ownership is done by reading chainstate `nft`.`itemList(<Collection ID>, 1)`. One of the returned fields is Owner:136```136```137templateModule.itemList: NftItemType137nft.itemList: NftItemType138{138{139 Collection: 1,139 Collection: 1,140 Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,140 Owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,145#### Transfer145#### Transfer146Execute `nft`.`transfer` from ALICE address to transfer token 1 to BOB and check the ownership again:146Execute `nft`.`transfer` from ALICE address to transfer token 1 to BOB and check the ownership again:147```147```148templateModule.itemList: NftItemType148nft.itemList: NftItemType149{149{150 Collection: 1,150 Collection: 1,151 Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,151 Owner: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,159159160Read the chain state `nft`.`balance` for ALICE address and see that she owns 1 token:160Read the chain state `nft`.`balance` for ALICE address and see that she owns 1 token:161```161```162templateModule.balance: u64162nft.balance: u6416311631164```164```165165166#### AddCollectionAdmin166#### AddCollectionAdmin167Execute `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:167Execute `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:168168169```169```170templateModule.adminList: Vec<AccountId>170nft.adminList: Vec<AccountId>171[171[172 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y172 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y173]173]177Execute `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:177Execute `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:178178179```179```180templateModule.adminList: Vec<AccountId>180nft.adminList: Vec<AccountId>181[]181[]182```182```183183184#### BurnItem184#### BurnItem185Execute `nft`.`burnItem` from ALICE account to burn token 1, and then read the chain state `nft`.`itemList(<Collection ID>, 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.185Execute `nft`.`burnItem` from ALICE account to burn token 1, and then read the chain state `nft`.`itemList(<Collection ID>, 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.186```186```187templateModule.itemList: NftItemType187nft.itemList: NftItemType188{188{189 Collection: 0,189 Collection: 0,190 Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,190 Owner: 5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM,