difftreelog
fix(tests) repair createMultipleItem + ..Ex, remove features made obsolete by properties
in: master
9 files changed
tests/src/contracts.test.tsdiffbeforeafterboth139 await addToAllowListExpectSuccess(alice, collectionId, bob.address);139 await addToAllowListExpectSuccess(alice, collectionId, bob.address);140140141 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [141 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [142 {Nft: {const_data: '0x010203'}},142 {NFT: {/*const_data: '0x010203'*/}},143 {Nft: {const_data: '0x010204'}},143 {NFT: {/*const_data: '0x010204'*/}},144 {Nft: {const_data: '0x010205'}},144 {NFT: {/*const_data: '0x010205'*/}},145 ]);145 ]);146 const events = await submitTransactionAsync(alice, transferTx);146 const events = await submitTransactionAsync(alice, transferTx);147 const result = getGenericResult(events);147 const result = getGenericResult(events);153 expect(tokensAfter).to.be.deep.equal([153 expect(tokensAfter).to.be.deep.equal([154 {154 {155 Owner: bob.address,155 Owner: bob.address,156 ConstData: '0x010203',156 //ConstData: '0x010203',157 },157 },158 {158 {159 Owner: bob.address,159 Owner: bob.address,160 ConstData: '0x010204',160 //ConstData: '0x010204',161 },161 },162 {162 {163 Owner: bob.address,163 Owner: bob.address,164 ConstData: '0x010205',164 //ConstData: '0x010205',165 },165 },166 ]);166 ]);167 });167 });tests/src/createCollection.test.tsdiffbeforeafterboth63 const bob = privateKey('//Bob');63 const bob = privateKey('//Bob');64 const tx = api.tx.unique.createCollectionEx({64 const tx = api.tx.unique.createCollectionEx({65 mode: {Fungible: 8},65 mode: {Fungible: 8},66 access: 'AllowList',66 //access: 'AllowList',67 name: [1],67 name: [1],68 description: [2],68 description: [2],69 tokenPrefix: '0x000000',69 tokenPrefix: '0x000000',70 offchainSchema: '0x111111',70 //offchainSchema: '0x111111',71 schemaVersion: 'Unique',71 //schemaVersion: 'Unique',72 pendingSponsor: bob.address,72 pendingSponsor: bob.address,73 limits: {73 limits: {74 accountTokenOwnershipLimit: 3,74 accountTokenOwnershipLimit: 3,75 },75 },76 constOnChainSchema: '0x333333',76 //constOnChainSchema: '0x333333',77 });77 });78 const events = await submitTransactionAsync(alice, tx);78 const events = await submitTransactionAsync(alice, tx);79 const result = getCreateCollectionResult(events);79 const result = getCreateCollectionResult(events);808081 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;81 const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;82 expect(collection.owner.toString()).to.equal(alice.address);82 expect(collection.owner.toString()).to.equal(alice.address);83 expect(collection.mode.asFungible.toNumber()).to.equal(8);83 expect(collection.mode.asFungible.toNumber()).to.equal(8);84 expect(collection.access.isAllowList).to.be.true;84 //expect(collection.access.isAllowList).to.be.true;85 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);85 expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);86 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);86 expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);87 expect(collection.tokenPrefix.toString()).to.equal('0x000000');87 expect(collection.tokenPrefix.toString()).to.equal('0x000000');88 expect(collection.offchainSchema.toString()).to.equal('0x111111');88 //expect(collection.offchainSchema.toString()).to.equal('0x111111');89 expect(collection.schemaVersion.isUnique).to.be.true;89 //expect(collection.schemaVersion.isUnique).to.be.true;90 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);90 expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);91 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);91 expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);92 expect(collection.constOnChainSchema.toString()).to.equal('0x333333');92 //expect(collection.constOnChainSchema.toString()).to.equal('0x333333');93 });93 });94 });94 });95});95});tests/src/createMultipleItems.test.tsdiffbeforeafterboth30 getBalance,30 getBalance,31 getTokenOwner,31 getTokenOwner,32 getLastTokenId,32 getLastTokenId,33 getConstMetadata,34 getCreatedCollectionCount,33 getCreatedCollectionCount,35 createCollectionWithPropsExpectSuccess,34 createCollectionWithPropsExpectSuccess,36 getCreateItemsResult,37 createMultipleItemsWithPropsExpectSuccess,35 createMultipleItemsWithPropsExpectSuccess,38 createMultipleItemsWithPropsExpectFailure,36 getTokenProperties,39} from './util/helpers';37} from './util/helpers';403841chai.use(chaiAsPromised);39chai.use(chaiAsPromised);42const expect = chai.expect;40const expect = chai.expect;434144describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {42describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {45 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {43 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {46 await usingApi(async (api: ApiPromise) => {44 await usingApi(async (api: ApiPromise) => {47 const collectionId = await createCollectionExpectSuccess();45 const collectionId = await createCollectionExpectSuccess();48 const itemsListIndexBefore = await getLastTokenId(api, collectionId);46 const itemsListIndexBefore = await getLastTokenId(api, collectionId);49 expect(itemsListIndexBefore).to.be.equal(0);47 expect(itemsListIndexBefore).to.be.equal(0);4850 const alice = privateKey('//Alice');49 const alice = privateKey('//Alice');51 const args = [{Nft: {const_data: '0x31'}},50 await submitTransactionAsync(51 alice, 52 api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}])53 );54 55 const args = [56 {NFT: {properties: [{key: 'data', value: '1'}]}},52 {Nft: {const_data: '0x32'}},57 {NFT: {properties: [{key: 'data', value: '2'}]}},53 {Nft: {const_data: '0x33'}}];58 {NFT: {properties: [{key: 'data', value: '3'}]}}59 ];54 const createMultipleItemsTx = api.tx.unique60 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);55 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);56 await submitTransactionAsync(alice, createMultipleItemsTx);61 await submitTransactionAsync(alice, createMultipleItemsTx);57 const itemsListIndexAfter = await getLastTokenId(api, collectionId);62 const itemsListIndexAfter = await getLastTokenId(api, collectionId);58 expect(itemsListIndexAfter).to.be.equal(3);63 expect(itemsListIndexAfter).to.be.equal(3);61 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));66 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));62 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));67 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));636864 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);69 expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('1');65 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);70 expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('2');66 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);71 expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('3');67 });72 });68 });73 });697470 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {75 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {71 await usingApi(async (api: ApiPromise) => {76 await usingApi(async (api: ApiPromise) => {72 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});77 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});73 const itemsListIndexBefore = await getLastTokenId(api, collectionId);78 const itemsListIndexBefore = await getLastTokenId(api, collectionId);87 });92 });88 });93 });899490 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {95 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {91 await usingApi(async (api: ApiPromise) => {96 await usingApi(async (api: ApiPromise) => {92 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});97 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});93 const itemsListIndexBefore = await getLastTokenId(api, collectionId);98 const itemsListIndexBefore = await getLastTokenId(api, collectionId);94 expect(itemsListIndexBefore).to.be.equal(0);99 expect(itemsListIndexBefore).to.be.equal(0);95 const alice = privateKey('//Alice');100 const alice = privateKey('//Alice');96 const args = [101 const args = [97 {ReFungible: {const_data: [0x31], pieces: 1}},102 {ReFungible: {pieces: 1}},98 {ReFungible: {const_data: [0x32], pieces: 1}},103 {ReFungible: {pieces: 2}},99 {ReFungible: {const_data: [0x33], pieces: 1}},104 {ReFungible: {pieces: 3}},100 ];105 ];101 const createMultipleItemsTx = api.tx.unique106 const createMultipleItemsTx = api.tx.unique102 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);107 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);105 expect(itemsListIndexAfter).to.be.equal(3);110 expect(itemsListIndexAfter).to.be.equal(3);106111107 expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);112 expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);108 expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(1n);113 expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(2n);109 expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(1n);114 expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(3n);110111 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);112 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);113 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);114 });115 });115 });116 });116117123 tokenLimit: 2,124 tokenLimit: 2,124 });125 });125 const args = [126 const args = [126 {NFT: {const_data: 'A'}},127 {NFT: {}},127 {NFT: {const_data: 'B'}},128 {NFT: {}},128 ];129 ];129 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);130 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);130 const events = await submitTransactionAsync(alice, createMultipleItemsTx);131 const events = await submitTransactionAsync(alice, createMultipleItemsTx);133 });134 });134 });135 });135136136 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {137 it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {137 await usingApi(async (api: ApiPromise) => {138 await usingApi(async (api: ApiPromise) => {138 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});139 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});139 const itemsListIndexBefore = await getLastTokenId(api, collectionId);140 const itemsListIndexBefore = await getLastTokenId(api, collectionId);140 expect(itemsListIndexBefore).to.be.equal(0);141 expect(itemsListIndexBefore).to.be.equal(0);141 const alice = privateKey('//Alice');142 const alice = privateKey('//Alice');142 const bob = privateKey('//Bob');143 const args = [143 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},144 {NFT: {properties: [{key: 'k', value: 'v1'}]}},144 {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},145 {NFT: {properties: [{key: 'k', value: 'v2'}]}},145 {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];146 {NFT: {properties: [{key: 'k', value: 'v3'}]}}147 ];146148147 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);149 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);148 const itemsListIndexAfter = await getLastTokenId(api, collectionId);150 const itemsListIndexAfter = await getLastTokenId(api, collectionId);152 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));154 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));153 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));155 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));154156155 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);157 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');156 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);158 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');157 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);159 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');158 });160 });159 });161 });160162161 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {163 it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {162 await usingApi(async (api: ApiPromise) => {164 await usingApi(async (api: ApiPromise) => {163 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});165 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});164 const itemsListIndexBefore = await getLastTokenId(api, collectionId);166 const itemsListIndexBefore = await getLastTokenId(api, collectionId);165 expect(itemsListIndexBefore).to.be.equal(0);167 expect(itemsListIndexBefore).to.be.equal(0);166 const alice = privateKey('//Alice');168 const alice = privateKey('//Alice');167 const bob = privateKey('//Bob');169 const bob = privateKey('//Bob');168 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);170 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);169 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},171 const args = [172 {NFT: {properties: [{key: 'k', value: 'v1'}]}},170 {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},173 {NFT: {properties: [{key: 'k', value: 'v2'}]}},171 {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];174 {NFT: {properties: [{key: 'k', value: 'v3'}]}}175 ];172176173 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);177 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);174 const itemsListIndexAfter = await getLastTokenId(api, collectionId);178 const itemsListIndexAfter = await getLastTokenId(api, collectionId);178 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));182 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));179 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));183 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));180184181 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);185 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');182 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);186 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');183 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);187 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');184 });188 });185 });189 });186190187 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {191 it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {188 await usingApi(async (api: ApiPromise) => {192 await usingApi(async (api: ApiPromise) => {189 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});193 const collectionId = await createCollectionWithPropsExpectSuccess(194 {propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}195 );190 const itemsListIndexBefore = await getLastTokenId(api, collectionId);196 const itemsListIndexBefore = await getLastTokenId(api, collectionId);191 expect(itemsListIndexBefore).to.be.equal(0);197 expect(itemsListIndexBefore).to.be.equal(0);192 const alice = privateKey('//Alice');198 const alice = privateKey('//Alice');193 const bob = privateKey('//Bob');199 const args = [194 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},200 {NFT: {properties: [{key: 'k', value: 'v1'}]}},195 {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},201 {NFT: {properties: [{key: 'k', value: 'v2'}]}},196 {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];202 {NFT: {properties: [{key: 'k', value: 'v3'}]}}203 ];197204198 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);205 await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);199 const itemsListIndexAfter = await getLastTokenId(api, collectionId);206 const itemsListIndexAfter = await getLastTokenId(api, collectionId);203 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));210 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));204 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));211 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));205212206 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);213 expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');207 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);214 expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');208 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);215 expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');209 });216 });210 });217 });211});218});212219213describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {220describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {214215 let alice: IKeyringPair;221 let alice: IKeyringPair;216 let bob: IKeyringPair;222 let bob: IKeyringPair;217223222 });228 });223 });229 });224230225 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {231 it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {226 await usingApi(async (api: ApiPromise) => {232 await usingApi(async (api: ApiPromise) => {227 const collectionId = await createCollectionExpectSuccess();233 const collectionId = await createCollectionWithPropsExpectSuccess(234 {propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}235 );228 const itemsListIndexBefore = await getLastTokenId(api, collectionId);236 const itemsListIndexBefore = await getLastTokenId(api, collectionId);229 expect(itemsListIndexBefore).to.be.equal(0);237 expect(itemsListIndexBefore).to.be.equal(0);230 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);238 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);231 const args = [{Nft: {const_data: '0x31'}},239 const args = [240 {NFT: {properties: [{key: 'data', value: 'v1'}]}},232 {Nft: {const_data: '0x32'}},241 {NFT: {properties: [{key: 'data', value: 'v2'}]}},233 {Nft: {const_data: '0x33'}}];242 {NFT: {properties: [{key: 'data', value: 'v3'}]}}243 ];234 const createMultipleItemsTx = api.tx.unique244 const createMultipleItemsTx = api.tx.unique235 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);245 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);236 await submitTransactionAsync(bob, createMultipleItemsTx);246 await submitTransactionAsync(bob, createMultipleItemsTx);241 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));251 expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));242 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));252 expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));243253244 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);254 expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('v1');245 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);255 expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('v2');246 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);256 expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('v3');247 });257 });248 });258 });249259250 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {260 it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {251 await usingApi(async (api: ApiPromise) => {261 await usingApi(async (api: ApiPromise) => {252 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});262 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});253 const itemsListIndexBefore = await getLastTokenId(api, collectionId);263 const itemsListIndexBefore = await getLastTokenId(api, collectionId);267 });277 });268 });278 });269279270 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {280 it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {271 await usingApi(async (api: ApiPromise) => {281 await usingApi(async (api: ApiPromise) => {272 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});282 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});273 const itemsListIndexBefore = await getLastTokenId(api, collectionId);283 const itemsListIndexBefore = await getLastTokenId(api, collectionId);274 expect(itemsListIndexBefore).to.be.equal(0);284 expect(itemsListIndexBefore).to.be.equal(0);275 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);285 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);276 const args = [286 const args = [277 {ReFungible: {const_data: [0x31], pieces: 1}},287 {ReFungible: {pieces: 1}},278 {ReFungible: {const_data: [0x32], pieces: 1}},288 {ReFungible: {pieces: 2}},279 {ReFungible: {const_data: [0x33], pieces: 1}},289 {ReFungible: {pieces: 3}},280 ];290 ];281 const createMultipleItemsTx = api.tx.unique291 const createMultipleItemsTx = api.tx.unique282 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);292 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);285 expect(itemsListIndexAfter).to.be.equal(3);295 expect(itemsListIndexAfter).to.be.equal(3);286296287 expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);297 expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);288 expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(1n);298 expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(2n);289 expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(1n);299 expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(3n);290291 expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);292 expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);293 expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);294 });300 });295 });301 });296});302});297303298describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {304describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {299300 let alice: IKeyringPair;305 let alice: IKeyringPair;301 let bob: IKeyringPair;306 let bob: IKeyringPair;302307312 const collectionId = await createCollectionExpectSuccess();317 const collectionId = await createCollectionExpectSuccess();313 const itemsListIndexBefore = await getLastTokenId(api, collectionId);318 const itemsListIndexBefore = await getLastTokenId(api, collectionId);314 expect(itemsListIndexBefore).to.be.equal(0);319 expect(itemsListIndexBefore).to.be.equal(0);315 const args = [{Nft: {const_data: '0x31'}},320 const args = [{NFT: {}},316 {Nft: {const_data: '0x32'}},321 {NFT: {}},317 {Nft: {const_data: '0x33'}}];322 {NFT: {}}];318 const createMultipleItemsTx = api.tx.unique323 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);319 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);320 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;324 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);321 });325 });322 });326 });323327331 {Fungible: {value: 2}},335 {Fungible: {value: 2}},332 {Fungible: {value: 3}},336 {Fungible: {value: 3}},333 ];337 ];334 const createMultipleItemsTx = api.tx.unique338 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);335 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);336 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;339 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);337 });340 });338 });341 });339342343 const itemsListIndexBefore = await getLastTokenId(api, collectionId);346 const itemsListIndexBefore = await getLastTokenId(api, collectionId);344 expect(itemsListIndexBefore).to.be.equal(0);347 expect(itemsListIndexBefore).to.be.equal(0);345 const args = [348 const args = [346 {ReFungible: {const_data: [0x31], pieces: 1}},349 {ReFungible: {pieces: 1}},347 {ReFungible: {const_data: [0x32], pieces: 1}},350 {ReFungible: {pieces: 1}},348 {ReFungible: {const_data: [0x33], pieces: 1}},351 {ReFungible: {pieces: 1}},349 ];352 ];350 const createMultipleItemsTx = api.tx.unique353 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);351 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);352 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;354 await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);353 });355 });354 });356 });355357356 it('Create token in not existing collection', async () => {358 it('Create token in not existing collection', async () => {357 await usingApi(async (api: ApiPromise) => {359 await usingApi(async (api: ApiPromise) => {358 const collectionId = await getCreatedCollectionCount(api) + 1;360 const collectionId = await getCreatedCollectionCount(api) + 1;359 const createMultipleItemsTx = api.tx.unique361 const createMultipleItemsTx = api.tx.unique.createMultipleItems(360 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);362 collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']363 );361 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;364 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);362 });365 });363 });366 });364367365 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {368 it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {366 await usingApi(async (api: ApiPromise) => {369 await usingApi(async (api: ApiPromise) => {367 // NFT370 // NFT368 const collectionId = await createCollectionExpectSuccess();371 const collectionId = await createCollectionWithPropsExpectSuccess({372 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]373 });369 const alice = privateKey('//Alice');374 const alice = privateKey('//Alice');370 const args = [375 const args = [371 {NFT: {const_data: 'A'.repeat(2049)}},376 {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},372 {NFT: {const_data: 'B'.repeat(2049)}},377 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},373 {NFT: {const_data: 'C'.repeat(2049)}},378 {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},374 ];379 ];375 const createMultipleItemsTx = api.tx.unique380 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);376 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);377 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;381 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;378382379 // ReFungible383 // ReFungible395 const collectionId = await createCollectionExpectSuccess();399 const collectionId = await createCollectionExpectSuccess();396 const createMultipleItemsTx = api.tx.unique400 const createMultipleItemsTx = api.tx.unique397 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);401 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);398 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;402 await expect(403 executeTransaction(api, alice, createMultipleItemsTx)404 ).to.be.rejectedWith(405 /nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/406 );399 // garbage collection :-D407 // garbage collection :-D // lol400 await destroyCollectionExpectSuccess(collectionId);408 await destroyCollectionExpectSuccess(collectionId);401 });409 });402 });410 });403411404 it('Create tokens with different data limits <> maximum data limit', async () => {412 it('Create tokens with different data limits <> maximum data limit', async () => {405 await usingApi(async (api: ApiPromise) => {413 await usingApi(async (api: ApiPromise) => {406 const collectionId = await createCollectionExpectSuccess();414 const collectionId = await createCollectionWithPropsExpectSuccess({415 propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]416 });407 const args = [417 const args = [408 {NFT: {const_data: 'A'}},418 {NFT: {properties: [{key: 'key', value: 'A'}]}},409 {NFT: {const_data: 'B'.repeat(2049)}},419 {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},410 ];420 ];411 const createMultipleItemsTx = await api.tx.unique421 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);412 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);413 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;422 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;414 });423 });415 });424 });416425417 it('Fails when minting tokens exceeds collectionLimits amount', async () => {426 it('Fails when minting tokens exceeds collectionLimits amount', async () => {418 await usingApi(async (api) => {427 await usingApi(async (api) => {419420 const collectionId = await createCollectionExpectSuccess();428 const collectionId = await createCollectionExpectSuccess();421 await setCollectionLimitsExpectSuccess(alice, collectionId, {429 await setCollectionLimitsExpectSuccess(alice, collectionId, {422 tokenLimit: 1,430 tokenLimit: 1,423 });431 });424 const args = [432 const args = [425 {NFT: {const_data: 'A'}},433 {NFT: {}},426 {NFT: {const_data: 'B'}},434 {NFT: {}},427 ];435 ];428 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);436 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);429 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;437 await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);430 });438 });431 });439 });432440433 it('No editing rights', async () => {434 await usingApi(async (api: ApiPromise) => {435 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],436 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: true}}]});437 const itemsListIndexBefore = await getLastTokenId(api, collectionId);438 expect(itemsListIndexBefore).to.be.equal(0);439 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);440 const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},441 {Nft: {const_data: '0x32'}},442 {Nft: {const_data: '0x33'}}];443444 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);445 });446 });447448 it('User doesnt have editing rights', async () => {441 it('User doesnt have editing rights', async () => {449 await usingApi(async (api: ApiPromise) => {442 await usingApi(async (api: ApiPromise) => {450 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],443 const collectionId = await createCollectionWithPropsExpectSuccess({451 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});444 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]445 });452 const itemsListIndexBefore = await getLastTokenId(api, collectionId);446 const itemsListIndexBefore = await getLastTokenId(api, collectionId);453 expect(itemsListIndexBefore).to.be.equal(0);447 expect(itemsListIndexBefore).to.be.equal(0);454 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);448 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);455 const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},449 const args = [450 {NFT: {properties: [{key: 'key1', value: 'v2'}]}},456 {Nft: {const_data: '0x32'}},451 {NFT: {}},457 {Nft: {const_data: '0x33'}}];452 {NFT: {}}453 ];458454459 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);455 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);456 await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);460 });457 });461 });458 });462459466 const itemsListIndexBefore = await getLastTokenId(api, collectionId);463 const itemsListIndexBefore = await getLastTokenId(api, collectionId);467 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);464 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);468 expect(itemsListIndexBefore).to.be.equal(0);465 expect(itemsListIndexBefore).to.be.equal(0);469 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v'}]}},466 const args = [{NFT: {properties: [{key: 'k', value: 'v'}]}},470 {Nft: {const_data: '0x32'}},467 {NFT: {}},471 {Nft: {const_data: '0x33'}}];468 {NFT: {}}];472469473 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);470 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);471 await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);474 });472 });475 });473 });476474477 it('Adding more than 64 prps', async () => {475 it('Adding more than 64 prps', async () => {478 await usingApi(async (api: ApiPromise) => {476 await usingApi(async (api: ApiPromise) => {479 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],477 const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];480 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});478 for (let i = 0; i < 65; i++) {479 propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});480 }481482 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});483484 const tx1 = api.tx.unique.setPropertyPermissions(collectionId, propPerms);485 await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);486481 const itemsListIndexBefore = await getLastTokenId(api, collectionId);487 const itemsListIndexBefore = await getLastTokenId(api, collectionId);482 expect(itemsListIndexBefore).to.be.equal(0);488 expect(itemsListIndexBefore).to.be.equal(0);488 prps.push({key: `key${i}`, value: `value${i}`});494 prps.push({key: `key${i}`, value: `value${i}`});489 }495 }490496491 const args = [{Nft: {const_data: '0x31', properties: prps}},497 const args = [498 {NFT: {properties: prps}},492 {Nft: {const_data: '0x32', properties: prps}},499 {NFT: {properties: prps}},493 {Nft: {const_data: '0x33', properties: prps}}];500 {NFT: {properties: prps}}501 ];494502495 createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);503 // there are no permissions, but will fail anyway because of too much weight for a block504 const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);;505 await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;496 });506 });497 });507 });498508499 it('Trying to add bigger property than allowed', async () => {509 it('Trying to add bigger property than allowed', async () => {500 await usingApi(async (api: ApiPromise) => {510 await usingApi(async (api: ApiPromise) => {501 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});511 const collectionId = await createCollectionWithPropsExpectSuccess({512 propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]513 });502 const itemsListIndexBefore = await getLastTokenId(api, collectionId);514 const itemsListIndexBefore = await getLastTokenId(api, collectionId);503 expect(itemsListIndexBefore).to.be.equal(0);515 expect(itemsListIndexBefore).to.be.equal(0);504 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},516 const args = [{NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},505 {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},517 {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},506 {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];518 {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];507519508 createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);520 const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);521 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);509 });522 });510 });523 });511});524});tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth29 const data = [29 const data = [30 {30 {31 owner: {substrate: alice.address},31 owner: {substrate: alice.address},32 constData: '0x0000',32 // constData: '0x0000',33 }, {33 }, {34 owner: {substrate: bob.address},34 owner: {substrate: bob.address},35 constData: '0x2222',35 // constData: '0x2222',36 }, {36 }, {37 owner: {substrate: charlie.address},37 owner: {substrate: charlie.address},38 constData: '0x4444',38 // constData: '0x4444',39 },39 },40 ];40 ];414157 const data = [57 const data = [58 {58 {59 owner: {substrate: alice.address},59 owner: {substrate: alice.address},60 constData: '0x1111',60 // constData: '0x1111',61 properties: [{key: 'k', value: 'v1'}],61 properties: [{key: 'k', value: 'v1'}],62 }, {62 }, {63 owner: {substrate: bob.address},63 owner: {substrate: bob.address},64 constData: '0x2222',64 // constData: '0x2222',65 properties: [{key: 'k', value: 'v2'}],65 properties: [{key: 'k', value: 'v2'}],66 }, {66 }, {67 owner: {substrate: charlie.address},67 owner: {substrate: charlie.address},68 constData: '0x4444',68 // constData: '0x4444',69 properties: [{key: 'k', value: 'v3'}],69 properties: [{key: 'k', value: 'v3'}],70 },70 },71 ];71 ];88 const data = [88 const data = [89 {89 {90 owner: {substrate: alice.address},90 owner: {substrate: alice.address},91 constData: '0x0000',91 // constData: '0x0000',92 properties: [{key: 'k', value: 'v1'}],92 properties: [{key: 'k', value: 'v1'}],93 }, {93 }, {94 owner: {substrate: bob.address},94 owner: {substrate: bob.address},95 constData: '0x2222',95 // constData: '0x2222',96 properties: [{key: 'k', value: 'v2'}],96 properties: [{key: 'k', value: 'v2'}],97 }, {97 }, {98 owner: {substrate: charlie.address},98 owner: {substrate: charlie.address},99 constData: '0x4444',99 // constData: '0x4444',100 properties: [{key: 'k', value: 'v3'}],100 properties: [{key: 'k', value: 'v3'}],101 },101 },102 ];102 ];119 const data = [119 const data = [120 {120 {121 owner: {substrate: alice.address},121 owner: {substrate: alice.address},122 constData: '0x0000',122 // constData: '0x0000',123 properties: [{key: 'k', value: 'v1'}],123 properties: [{key: 'k', value: 'v1'}],124 }, {124 }, {125 owner: {substrate: bob.address},125 owner: {substrate: bob.address},126 constData: '0x2222',126 // constData: '0x2222',127 properties: [{key: 'k', value: 'v2'}],127 properties: [{key: 'k', value: 'v2'}],128 }, {128 }, {129 owner: {substrate: charlie.address},129 owner: {substrate: charlie.address},130 constData: '0x4444',130 // constData: '0x4444',131 properties: [{key: 'k', value: 'v3'}],131 properties: [{key: 'k', value: 'v3'}],132 },132 },133 ];133 ];154 owner: {substrate: alice.address},154 owner: {substrate: alice.address},155 properties: [{key: 'key1', value: 'v2'}],155 properties: [{key: 'key1', value: 'v2'}],156 }, {156 }, {157 owner: {substrate: alice.address},157 owner: {substrate: bob.address},158 properties: [{key: 'key1', value: 'v2'}],158 properties: [{key: 'key1', value: 'v2'}],159 }, {159 }, {160 owner: {substrate: alice.address},160 owner: {substrate: charlie.address},161 properties: [{key: 'key1', value: 'v2'}],161 properties: [{key: 'key1', value: 'v2'}],162 },162 },163 ];163 ];164164165 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});165 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});166 // await executeTransaction(api, alice, tx);166 // await executeTransaction(api, alice, tx);167167168 //await submitTransactionExpectFailAsync(alice, tx);168 await submitTransactionExpectFailAsync(alice, tx);169 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);169 });170 });170 });171 });171172193 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});194 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});194 // await executeTransaction(api, alice, tx);195 // await executeTransaction(api, alice, tx);195196197 //await submitTransactionExpectFailAsync(alice, tx);196 await submitTransactionExpectFailAsync(alice, tx);198 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);197 });199 });198 });200 });199201219221220 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});222 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});221223222 await submitTransactionExpectFailAsync(alice, tx);224 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);225 //await submitTransactionExpectFailAsync(alice, tx);223 });226 });224 });227 });225228226 it('Adding more than 64 prps', async () => {229 it('Adding more than 64 properties', async () => {227 const prps = [{key: 'key', value: 'v'}];228 const propPerm = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];230 const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];229231230 for (let i = 0; i < 65; i++) {232 for (let i = 0; i < 65; i++) {231 prps.push({key: `key${i}`, value: `value${i}`});232 propPerm.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});233 propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});233 }234 }234235235 const collection = await createCollectionWithPropsExpectSuccess({propPerm: propPerm});236 const alice = privateKey('//Alice');236 const alice = privateKey('//Alice');237 const bob = privateKey('//Bob');237 const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});238 const charlie = privateKey('//Charlie');239 await addCollectionAdminExpectSuccess(alice, collection, bob.address);240 await usingApi(async (api) => {238 await usingApi(async (api) => {241 const data = [239 await expect(242 {243 owner: {substrate: alice.address},244 properties: prps,245 }, {246 owner: {substrate: alice.address},247 properties: prps,248 }, {249 owner: {substrate: alice.address},250 properties: prps,251 },252 ];253254 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});240 executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))255241 ).to.be.rejectedWith(/common\.PropertyLimitReached/);256 await submitTransactionExpectFailAsync(alice, tx);257 });242 });258 });243 });259244276261277 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});262 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});278263264 //await submitTransactionExpectFailAsync(alice, tx);279 await submitTransactionExpectFailAsync(alice, tx);265 await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);280 });266 });281 });267 });282268289 const data = [275 const data = [290 {276 {291 owner: {substrate: alice.address},277 owner: {substrate: alice.address},292 constData: '0x0000',278 // constData: '0x0000',293 }, {279 }, {294 owner: {substrate: bob.address},280 owner: {substrate: bob.address},295 constData: '0x2222',281 // constData: '0x2222',296 }, {282 }, {297 owner: {substrate: charlie.address},283 owner: {substrate: charlie.address},298 constData: '0x4444',284 // constData: '0x4444',299 },285 },300 ];286 ];301287317 const data = [303 const data = [318 {304 {319 owner: {substrate: alice.address},305 owner: {substrate: alice.address},320 constData: '0x0000',306 // constData: '0x0000',321 }, {307 }, {322 owner: {substrate: bob.address},308 owner: {substrate: bob.address},323 constData: '0x2222',309 // constData: '0x2222',324 }, {310 }, {325 owner: {substrate: charlie.address},311 owner: {substrate: charlie.address},326 constData: '0x4444',312 // constData: '0x4444',327 },313 },328 ];314 ];329315tests/src/nesting/properties.test.tsdiffbeforeafterboth792 ]), 792 ]), 793 )).to.be.rejectedWith(/common\.NoSpaceForProperty/);793 )).to.be.rejectedWith(/common\.NoSpaceForProperty/);794794795 expect((await api.rpc.unique.tokenProperties(collection, token, ['a_holy_book', 'young years'])).toJSON()).to.be.empty;795 expect((await api.rpc.unique.tokenProperties(collection, token, ['a_holy_book', 'young_years'])).toJSON()).to.be.empty;796 const propertiesMap = (await api.query.nonfungible.tokenProperties(collection, token)).toJSON();796 const propertiesMap = (await api.query.nonfungible.tokenProperties(collection, token)).toJSON();797 expect(propertiesMap.consumedSpace).to.be.equal(originalSpace);797 expect(propertiesMap.consumedSpace).to.be.equal(originalSpace);798 });798 });tests/src/setConstOnChainSchema.test.tsdiffbeforeafterbothno changes
tests/src/setOffchainSchema.test.tsdiffbeforeafterbothno changes
tests/src/setSchemaVersion.test.tsdiffbeforeafterbothno changes
tests/src/util/helpers.tsdiffbeforeafterboth27import privateKey from '../substrate/privateKey';27import privateKey from '../substrate/privateKey';28import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';28import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';29import {hexToStr, strToUTF16, utf16ToStr} from './util';29import {hexToStr, strToUTF16, utf16ToStr} from './util';30import {UpDataStructsRpcCollection, UpDataStructsCreateItemData} from '@polkadot/types/lookup';30import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';313132chai.use(chaiAsPromised);32chai.use(chaiAsPromised);33const expect = chai.expect;33const expect = chai.expect;141141142export interface IReFungibleTokenDataType {142export interface IReFungibleTokenDataType {143 owner: IReFungibleOwner[];143 owner: IReFungibleOwner[];144 constData: number[];145}144}146145147export function uniqueEventMessage(events: EventRecord[]): IGetMessage {146export function uniqueEventMessage(events: EventRecord[]): IGetMessage {784 });783 });785}784}786785787export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) {786/*export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) {788 await usingApi(async (api) => {787 await usingApi(async (api) => {789 const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));788 const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));790 const events = await submitTransactionAsync(sender, tx);789 const events = await submitTransactionAsync(sender, tx);791 const result = getGenericResult(events);790 const result = getGenericResult(events);792791793 expect(result.success).to.be.true;792 expect(result.success).to.be.true;794 });793 });795}794}796795797export async function setOffchainSchemaExpectFailure(sender: IKeyringPair, collectionId: number, data: number[]) {796export async function setOffchainSchemaExpectFailure(sender: IKeyringPair, collectionId: number, data: number[]) {798 await usingApi(async (api) => {797 await usingApi(async (api) => {799 const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));798 const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));800 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;799 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;801 });800 });802}801}*/803802804export interface CreateFungibleData {803export interface CreateFungibleData {805 readonly Value: bigint;804 readonly Value: bigint;1111): Promise<string[]> {1110): Promise<string[]> {1112 return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;1111 return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;1113}1112}1113/*export async function getConstMetadata(1114 api: ApiPromise,1115 collectionId: number,1116 tokenId: number,1117): Promise<number[]> {1118 return [...(await api.rpc.unique.constMetadata(collectionId, tokenId))];1119}*/1114export async function getConstMetadata(1120export async function getTokenProperties(1115 api: ApiPromise,1121 api: ApiPromise,1116 collectionId: number,1122 collectionId: number,1117 tokenId: number,1123 tokenId: number,1124 propertyKeys: string[],1118): Promise<number[]> {1125): Promise<UpDataStructsProperty[]> {1119 return [...(await api.rpc.unique.constMetadata(collectionId, tokenId))];1126 return (await api.rpc.unique.tokenProperties(collectionId, tokenId, propertyKeys)).toHuman() as any;1120}1127}112111281122export async function createFungibleItemExpectSuccess(1129export async function createFungibleItemExpectSuccess(1150 });1157 });1151}1158}11521153export async function createMultipleItemsWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1154 await usingApi(async (api) => {1155 const to = normalizeAccountId(owner);1156 const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);11571158 const events = await expect(await submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1159 const result = getCreateItemsResult(events);11601161 expect(result).to.be.equal(false);1162 });1163}116411591165export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1160export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1166 await usingApi(async (api) => {1161 await usingApi(async (api) => {1187 const createData = {fungible: {value: 10}};1182 const createData = {fungible: {value: 10}};1188 tx = api.tx.unique.createItem(collectionId, to, createData as any);1183 tx = api.tx.unique.createItem(collectionId, to, createData as any);1189 } else if (createMode === 'ReFungible') {1184 } else if (createMode === 'ReFungible') {1190 const createData = {refungible: {const_data: [], pieces: 100}};1185 const createData = {refungible: {pieces: 100}};1191 tx = api.tx.unique.createItem(collectionId, to, createData as any);1186 tx = api.tx.unique.createItem(collectionId, to, createData as any);1192 } else {1187 } else {1193 const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});1188 const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1194 tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);1189 tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);1195 }1190 }11961191122512201226 let tx;1221 let tx;1227 if (createMode === 'NFT') {1222 if (createMode === 'NFT') {1228 const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});1223 const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1229 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1224 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1230 } else {1225 } else {1231 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1226 tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1251 const createData = {fungible: {value: 10}};1246 const createData = {fungible: {value: 10}};1252 tx = api.tx.unique.createItem(collectionId, to, createData as any);1247 tx = api.tx.unique.createItem(collectionId, to, createData as any);1253 } else if (createMode === 'ReFungible') {1248 } else if (createMode === 'ReFungible') {1254 const createData = {refungible: {const_data: [], pieces: 100}};1249 const createData = {refungible: {pieces: 100}};1255 tx = api.tx.unique.createItem(collectionId, to, createData as any);1250 tx = api.tx.unique.createItem(collectionId, to, createData as any);1256 } else {1251 } else {1257 const createData = {nft: {const_data: []}};1252 const createData = {nft: {}};1258 tx = api.tx.unique.createItem(collectionId, to, createData as any);1253 tx = api.tx.unique.createItem(collectionId, to, createData as any);1259 }1254 }12601255