--- a/tests/package.json +++ b/tests/package.json @@ -40,7 +40,6 @@ "testMigrationStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts", "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts", "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts", - "testSetVariableMetaData": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetaData.test.ts", "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts", "testSetCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionSponsor.test.ts", "testConfirmSponsorship": "mocha --timeout 9999999 -r ts-node/register ./**/confirmSponsorship.test.ts", --- a/tests/src/contracts.test.ts +++ b/tests/src/contracts.test.ts @@ -111,7 +111,7 @@ await addToAllowListExpectSuccess(alice, collectionId, contract.address); await addToAllowListExpectSuccess(alice, collectionId, bob.address); - const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, {Nft: {const_data: '0x010203', variable_data: '0x020304'}}); + const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, {Nft: {const_data: '0x010203'}}); const events = await submitTransactionAsync(alice, transferTx); const result = getGenericResult(events); expect(result.success).to.be.true; @@ -121,7 +121,6 @@ { owner: bob.address, constData: '0x010203', - variableData: '0x020304', }, ]); }); @@ -140,9 +139,9 @@ await addToAllowListExpectSuccess(alice, collectionId, bob.address); const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [ - {Nft: {const_data: '0x010203', variable_data: '0x020304'}}, - {Nft: {const_data: '0x010204', variable_data: '0x020305'}}, - {Nft: {const_data: '0x010205', variable_data: '0x020306'}}, + {Nft: {const_data: '0x010203'}}, + {Nft: {const_data: '0x010204'}}, + {Nft: {const_data: '0x010205'}}, ]); const events = await submitTransactionAsync(alice, transferTx); const result = getGenericResult(events); @@ -155,17 +154,14 @@ { Owner: bob.address, ConstData: '0x010203', - VariableData: '0x020304', }, { Owner: bob.address, ConstData: '0x010204', - VariableData: '0x020305', }, { Owner: bob.address, ConstData: '0x010205', - VariableData: '0x020306', }, ]); }); @@ -208,24 +204,6 @@ const token: any = (await api.query.unique.nftItemList(collectionId, tokenId) as any).unwrap(); expect(token.owner.toString()).to.be.equal(charlie.address); - }); - }); - - it('SetVariableMetaData CE', async () => { - await usingApi(async api => { - const alice = privateKey('//Alice'); - - const collectionId = await createCollectionExpectSuccess(); - const [contract] = await deployTransferContract(api); - const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString()); - - const transferTx = contract.tx.setVariableMetaData(value, gasLimit, collectionId, tokenId, '0x121314'); - const events = await submitTransactionAsync(alice, transferTx); - const result = getGenericResult(events); - expect(result.success).to.be.true; - - const token: any = (await api.query.unique.nftItemList(collectionId, tokenId) as any).unwrap(); - expect(token.variableData.toString()).to.be.equal('0x121314'); }); }); --- a/tests/src/createMultipleItems.test.ts +++ b/tests/src/createMultipleItems.test.ts @@ -30,7 +30,6 @@ getBalance, getTokenOwner, getLastTokenId, - getVariableMetadata, getConstMetadata, getCreatedCollectionCount, createCollectionWithPropsExpectSuccess, @@ -47,9 +46,9 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); const alice = privateKey('//Alice'); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); await submitTransactionAsync(alice, createMultipleItemsTx); @@ -63,10 +62,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); @@ -97,9 +92,9 @@ expect(itemsListIndexBefore).to.be.equal(0); const alice = privateKey('//Alice'); const args = [ - {ReFungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}}, - {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}}, - {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}}, + {ReFungible: {const_data: [0x31], pieces: 1}}, + {ReFungible: {const_data: [0x32], pieces: 1}}, + {ReFungible: {const_data: [0x33], pieces: 1}}, ]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); @@ -114,10 +109,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); @@ -130,8 +121,8 @@ tokenLimit: 2, }); const args = [ - {NFT: {const_data: 'A', variable_data: 'A'}}, - {NFT: {const_data: 'B', variable_data: 'B'}}, + {NFT: {const_data: 'A'}}, + {NFT: {const_data: 'B'}}, ]; const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); const events = await submitTransactionAsync(alice, createMultipleItemsTx); @@ -146,9 +137,10 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); const alice = privateKey('//Alice'); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; + const bob = privateKey('//Bob'); + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); await submitTransactionAsync(alice, createMultipleItemsTx); @@ -156,9 +148,9 @@ expect(itemsListIndexAfter).to.be.equal(3); await expect(executeTransaction( - api, - alice, - api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]), + api, + alice, + api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]), )).to.not.be.rejected; expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address)); @@ -168,10 +160,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); @@ -181,9 +169,10 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); const alice = privateKey('//Alice'); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; + const bob = privateKey('//Bob'); + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); await submitTransactionAsync(alice, createMultipleItemsTx); @@ -191,9 +180,9 @@ expect(itemsListIndexAfter).to.be.equal(3); await expect(executeTransaction( - api, - alice, - api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]), + api, + alice, + api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]), )).to.not.be.rejected; expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address)); @@ -203,10 +192,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); @@ -216,9 +201,10 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); const alice = privateKey('//Alice'); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; + const bob = privateKey('//Bob'); + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); await submitTransactionAsync(alice, createMultipleItemsTx); @@ -226,9 +212,9 @@ expect(itemsListIndexAfter).to.be.equal(3); await expect(executeTransaction( - api, - alice, - api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]), + api, + alice, + api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]), )).to.not.be.rejected; expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address)); @@ -238,10 +224,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); }); @@ -264,9 +246,9 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(bob.address), args); await submitTransactionAsync(bob, createMultipleItemsTx); @@ -280,10 +262,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); @@ -314,9 +292,9 @@ expect(itemsListIndexBefore).to.be.equal(0); await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); const args = [ - {ReFungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}}, - {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}}, - {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}}, + {ReFungible: {const_data: [0x31], pieces: 1}}, + {ReFungible: {const_data: [0x32], pieces: 1}}, + {ReFungible: {const_data: [0x33], pieces: 1}}, ]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(bob.address), args); @@ -331,10 +309,6 @@ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); - - expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]); - expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]); - expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]); }); }); }); @@ -356,9 +330,9 @@ const collectionId = await createCollectionExpectSuccess(); const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected; @@ -387,9 +361,9 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); const args = [ - {ReFungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}}, - {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}}, - {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}}, + {ReFungible: {const_data: [0x31], pieces: 1}}, + {ReFungible: {const_data: [0x32], pieces: 1}}, + {ReFungible: {const_data: [0x33], pieces: 1}}, ]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); @@ -412,9 +386,9 @@ const collectionId = await createCollectionExpectSuccess(); const alice = privateKey('//Alice'); const args = [ - {NFT: {const_data: 'A'.repeat(2049), variable_data: 'A'.repeat(2049)}}, - {NFT: {const_data: 'B'.repeat(2049), variable_data: 'B'.repeat(2049)}}, - {NFT: {const_data: 'C'.repeat(2049), variable_data: 'C'.repeat(2049)}}, + {NFT: {const_data: 'A'.repeat(2049)}}, + {NFT: {const_data: 'B'.repeat(2049)}}, + {NFT: {const_data: 'C'.repeat(2049)}}, ]; const createMultipleItemsTx = api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); @@ -424,9 +398,9 @@ const collectionIdReFungible = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}}); const argsReFungible = [ - {ReFungible: ['1'.repeat(2049), '1'.repeat(2049), 10]}, - {ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10]}, - {ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10]}, + {ReFungible: ['1'.repeat(2049), 10]}, + {ReFungible: ['2'.repeat(2049), 10]}, + {ReFungible: ['3'.repeat(2049), 10]}, ]; const createMultipleItemsTxFungible = api.tx.unique .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible); @@ -449,9 +423,8 @@ await usingApi(async (api: ApiPromise) => { const collectionId = await createCollectionExpectSuccess(); const args = [ - {NFT: {const_data: 'A', variable_data: 'A'}}, - {NFT: {const_data: 'B', variable_data: 'B'.repeat(2049)}}, - {NFT: {const_data: 'C'.repeat(2049), variable_data: 'C'}}, + {NFT: {const_data: 'A'}}, + {NFT: {const_data: 'B'.repeat(2049)}}, ]; const createMultipleItemsTx = await api.tx.unique .createMultipleItems(collectionId, normalizeAccountId(alice.address), args); @@ -467,8 +440,8 @@ tokenLimit: 1, }); const args = [ - {NFT: {const_data: 'A', variable_data: 'A'}}, - {NFT: {const_data: 'B', variable_data: 'B'}}, + {NFT: {const_data: 'A'}}, + {NFT: {const_data: 'B'}}, ]; const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected; @@ -482,10 +455,10 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; - + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; + const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); const events = await submitTransactionAsync(alice, createMultipleItemsTx); @@ -493,9 +466,9 @@ for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), )).to.be.rejected; } @@ -510,10 +483,10 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; - + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; + const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); const events = await submitTransactionAsync(alice, createMultipleItemsTx); @@ -521,9 +494,9 @@ for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), )).to.be.rejected; } }); @@ -535,10 +508,10 @@ const itemsListIndexBefore = await getLastTokenId(api, collectionId); await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); expect(itemsListIndexBefore).to.be.equal(0); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; - + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; + const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); const events = await submitTransactionAsync(alice, createMultipleItemsTx); @@ -546,9 +519,9 @@ for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), )).to.be.rejected; } }); @@ -562,28 +535,28 @@ expect(itemsListIndexBefore).to.be.equal(0); await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; - + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; + const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); const events = await submitTransactionAsync(alice, createMultipleItemsTx); const result = getCreateItemsResult(events); - + const prps = []; - + for (let i = 0; i < 65; i++) { prps.push({key: `key${i}`, value: `value${i}`}); } await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/); - + for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps), )).to.be.rejected; } }); @@ -595,10 +568,10 @@ propPerm: [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]}); const itemsListIndexBefore = await getLastTokenId(api, collectionId); expect(itemsListIndexBefore).to.be.equal(0); - const args = [{Nft: {const_data: '0x31', variable_data: '0x31'}}, - {Nft: {const_data: '0x32', variable_data: '0x32'}}, - {Nft: {const_data: '0x33', variable_data: '0x33'}}]; - + const args = [{Nft: {const_data: '0x31'}}, + {Nft: {const_data: '0x32'}}, + {Nft: {const_data: '0x33'}}]; + const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args); const events = await submitTransactionAsync(alice, createMultipleItemsTx); @@ -609,9 +582,9 @@ for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]), )).to.be.rejected; } }); --- a/tests/src/createMultipleItemsEx.test.ts +++ b/tests/src/createMultipleItemsEx.test.ts @@ -30,15 +30,12 @@ { owner: {substrate: alice.address}, constData: '0x0000', - variableData: '0x1111', }, { owner: {substrate: bob.address}, constData: '0x2222', - variableData: '0x3333', }, { owner: {substrate: charlie.address}, constData: '0x4444', - variableData: '0x5555', }, ]; @@ -61,22 +58,19 @@ { owner: {substrate: alice.address}, constData: '0x0000', - variableData: '0x1111', }, { owner: {substrate: bob.address}, constData: '0x2222', - variableData: '0x3333', }, { owner: {substrate: charlie.address}, constData: '0x4444', - variableData: '0x5555', }, ]; await expect(executeTransaction( - api, - alice, - api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]), + api, + alice, + api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]), )).to.not.be.rejected; await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, { @@ -98,28 +92,25 @@ { owner: {substrate: alice.address}, constData: '0x0000', - variableData: '0x1111', }, { owner: {substrate: bob.address}, constData: '0x2222', - variableData: '0x3333', }, { owner: {substrate: charlie.address}, constData: '0x4444', - variableData: '0x5555', }, ]; await expect(executeTransaction( - api, - alice, - api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]), + api, + alice, + api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]), )).to.not.be.rejected; await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, { NFT: data, })); - + const tokens = await api.query.nonfungible.tokenData.entries(collection); const json = tokens.map(([, token]) => token.toJSON()); expect(json).to.be.deep.equal(data); @@ -136,28 +127,25 @@ { owner: {substrate: alice.address}, constData: '0x0000', - variableData: '0x1111', }, { owner: {substrate: bob.address}, constData: '0x2222', - variableData: '0x3333', }, { owner: {substrate: charlie.address}, constData: '0x4444', - variableData: '0x5555', }, ]; await expect(executeTransaction( - api, - alice, - api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]), + api, + alice, + api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]), )).to.not.be.rejected; await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, { NFT: data, })); - + const tokens = await api.query.nonfungible.tokenData.entries(collection); const json = tokens.map(([, token]) => token.toJSON()); expect(json).to.be.deep.equal(data); @@ -184,15 +172,15 @@ const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data}); await executeTransaction(api, alice, tx); - + const events = await submitTransactionAsync(alice, tx); const result = getCreateItemsResult(events); - + for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), )).to.be.rejected; } }); @@ -218,15 +206,15 @@ const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data}); await executeTransaction(api, alice, tx); - + const events = await submitTransactionAsync(alice, tx); const result = getCreateItemsResult(events); - + for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), )).to.be.rejected; } }); @@ -251,15 +239,15 @@ const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data}); await executeTransaction(api, alice, tx); - + const events = await submitTransactionAsync(alice, tx); const result = getCreateItemsResult(events); - + for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]), )).to.be.rejected; } }); @@ -284,24 +272,24 @@ const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data}); await executeTransaction(api, alice, tx); - + const events = await submitTransactionAsync(alice, tx); const result = getCreateItemsResult(events); const prps = []; - + for (let i = 0; i < 65; i++) { prps.push({key: `key${i}`, value: `value${i}`}); } await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/); - + for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps), )).to.be.rejected; } }); @@ -326,7 +314,7 @@ const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data}); await executeTransaction(api, alice, tx); - + const events = await submitTransactionAsync(alice, tx); const result = getCreateItemsResult(events); @@ -334,12 +322,12 @@ await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.NoSpaceForProperty/); - + for (const elem of result) { await expect(executeTransaction( - api, - bob, - api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps), + api, + bob, + api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps), )).to.be.rejected; } }); @@ -355,15 +343,12 @@ { owner: {substrate: alice.address}, constData: '0x0000', - variableData: '0x1111', }, { owner: {substrate: bob.address}, constData: '0x2222', - variableData: '0x3333', }, { owner: {substrate: charlie.address}, constData: '0x4444', - variableData: '0x5555', }, ]; @@ -386,15 +371,12 @@ { owner: {substrate: alice.address}, constData: '0x0000', - variableData: '0x1111', }, { owner: {substrate: bob.address}, constData: '0x2222', - variableData: '0x3333', }, { owner: {substrate: charlie.address}, constData: '0x4444', - variableData: '0x5555', }, ]; --- a/tests/src/eth/api/UniqueFungible.sol +++ b/tests/src/eth/api/UniqueFungible.sol @@ -22,6 +22,21 @@ ); } +// Selector: 56fd500b +interface CollectionProperties is Dummy, ERC165 { + // Selector: setProperty(string,string) 62d9491f + function setProperty(string memory key, string memory value) external; + + // Selector: deleteProperty(string) 34241914 + function deleteProperty(string memory key) external; +} + +// Selector: 79cc6790 +interface ERC20UniqueExtensions is Dummy, ERC165 { + // Selector: burnFrom(address,uint256) 79cc6790 + function burnFrom(address from, uint256 amount) external returns (bool); +} + // Selector: 942e8b22 interface ERC20 is Dummy, ERC165, ERC20Events { // Selector: name() 06fdde03 @@ -59,4 +74,10 @@ returns (uint256); } -interface UniqueFungible is Dummy, ERC165, ERC20 {} +interface UniqueFungible is + Dummy, + ERC165, + ERC20, + ERC20UniqueExtensions, + CollectionProperties +{} --- a/tests/src/eth/api/UniqueNFT.sol +++ b/tests/src/eth/api/UniqueNFT.sol @@ -48,6 +48,15 @@ function burn(uint256 tokenId) external; } +// Selector: 56fd500b +interface CollectionProperties is Dummy, ERC165 { + // Selector: setProperty(string,string) 62d9491f + function setProperty(string memory key, string memory value) external; + + // Selector: deleteProperty(string) 34241914 + function deleteProperty(string memory key) external; +} + // Selector: 58800161 interface ERC721 is Dummy, ERC165, ERC721Events { // Selector: balanceOf(address) 70a08231 @@ -162,7 +171,7 @@ function totalSupply() external view returns (uint256); } -// Selector: e562194d +// Selector: d74d154f interface ERC721UniqueExtensions is Dummy, ERC165 { // Selector: transfer(address,uint256) a9059cbb function transfer(address to, uint256 tokenId) external; @@ -173,15 +182,6 @@ // Selector: nextTokenId() 75794a3c function nextTokenId() external view returns (uint256); - // Selector: setVariableMetadata(uint256,bytes) d4eac26d - function setVariableMetadata(uint256 tokenId, bytes memory data) external; - - // Selector: getVariableMetadata(uint256) e6c5ce6f - function getVariableMetadata(uint256 tokenId) - external - view - returns (bytes memory); - // Selector: mintBulk(address,uint256[]) 44a9945e function mintBulk(address to, uint256[] memory tokenIds) external @@ -201,5 +201,6 @@ ERC721Enumerable, ERC721UniqueExtensions, ERC721Mintable, - ERC721Burnable + ERC721Burnable, + CollectionProperties {} --- a/tests/src/eth/base.test.ts +++ b/tests/src/eth/base.test.ts @@ -79,7 +79,7 @@ minter = createEthAccount(web3); }); }); - + itWeb3('interfaceID == 0xffffffff always false', async ({web3}) => { expect(await contract(web3).methods.supportsInterface('0xffffffff').call()).to.be.false; }); @@ -101,7 +101,7 @@ }); itWeb3('ERC721UniqueExtensions support', async ({web3}) => { - expect(await contract(web3).methods.supportsInterface('0xe562194d').call()).to.be.true; + expect(await contract(web3).methods.supportsInterface('0xd74d154f').call()).to.be.true; }); itWeb3('ERC721Burnable support', async ({web3}) => { --- a/tests/src/eth/nonFungible.test.ts +++ b/tests/src/eth/nonFungible.test.ts @@ -15,7 +15,7 @@ // along with Unique Network. If not, see . import privateKey from '../substrate/privateKey'; -import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, setVariableMetaDataExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE, setMetadataUpdatePermissionFlagExpectSuccess} from '../util/helpers'; +import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE, setMetadataUpdatePermissionFlagExpectSuccess} from '../util/helpers'; import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers'; import nonFungibleAbi from './nonFungibleAbi.json'; import {expect} from 'chai'; @@ -331,41 +331,6 @@ const balance = await contract.methods.balanceOf(receiver).call(); expect(+balance).to.equal(1); } - }); - - itWeb3('Can perform getVariableMetadata', async ({web3, api}) => { - const collection = await createCollectionExpectSuccess({ - mode: {type: 'NFT'}, - }); - const alice = privateKey('//Alice'); - - const owner = await createEthAccountWithBalance(api, web3); - - const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner}); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, collection, 'Admin'); - await setVariableMetaDataExpectSuccess(alice, collection, item, [1, 2, 3]); - - const address = collectionIdToAddress(collection); - const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS}); - - expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203'); - }); - - itWeb3('Can perform setVariableMetadata', async ({web3, api}) => { - const collection = await createCollectionExpectSuccess({ - mode: {type: 'NFT'}, - }); - const alice = privateKey('//Alice'); - - const owner = await createEthAccountWithBalance(api, web3); - - const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner}); - - const address = collectionIdToAddress(collection); - const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS}); - - expect(await contract.methods.setVariableMetadata(item, '0x010203').send({from: owner})); - expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203'); }); }); --- a/tests/src/eth/proxy/UniqueNFTProxy.abi +++ b/tests/src/eth/proxy/UniqueNFTProxy.abi @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"_proxied","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[],"name":"MintingFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"approved","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"finishMinting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getVariableMetadata","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"mintBulk","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"uint256","name":"field_0","type":"uint256"},{"internalType":"string","name":"field_1","type":"string"}],"internalType":"struct Tuple0[]","name":"tokens","type":"tuple[]"}],"name":"mintBulkWithTokenURI","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"tokenUri","type":"string"}],"name":"mintWithTokenURI","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintingFinished","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFromWithData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setVariableMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"interfaceId","type":"uint32"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"inputs":[{"internalType":"address","name":"_proxied","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[],"name":"MintingFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"approved","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"key","type":"string"}],"name":"deleteProperty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"finishMinting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"mintBulk","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"uint256","name":"field_0","type":"uint256"},{"internalType":"string","name":"field_1","type":"string"}],"internalType":"struct Tuple0[]","name":"tokens","type":"tuple[]"}],"name":"mintBulkWithTokenURI","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"tokenUri","type":"string"}],"name":"mintWithTokenURI","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintingFinished","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFromWithData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"name":"setProperty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file --- a/tests/src/eth/proxy/UniqueNFTProxy.bin +++ b/tests/src/eth/proxy/UniqueNFTProxy.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5060405161168d38038061168d83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b6115fa806100936000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c806350bb4e7f116100f9578063a22cb46511610097578063d4eac26d11610071578063d4eac26d1461036b578063e6c5ce6f1461037e578063e985e9c514610391578063f4f4b500146103a457600080fd5b8063a22cb46514610332578063a9059cbb14610345578063c87b56dd1461035857600080fd5b806370a08231116100d357806370a082311461030757806375794a3c1461031a5780637d64bcb41461032257806395d89b411461032a57600080fd5b806350bb4e7f146102ce57806360a11672146102e15780636352211e146102f457600080fd5b80632f745c591161016657806342842e0e1161014057806342842e0e1461028257806342966c681461029557806344a9945e146102a85780634f6ccce7146102bb57600080fd5b80632f745c5914610249578063365430061461025c57806340c10f191461026f57600080fd5b806305d2035b146101ae57806306fdde03146101cb578063081812fc146101e0578063095ea7b31461020b57806318160ddd1461022057806323b872dd14610236575b600080fd5b6101b66103b7565b60405190151581526020015b60405180910390f35b6101d3610443565b6040516101c2919061148a565b6101f36101ee366004611277565b6104c3565b6040516001600160a01b0390911681526020016101c2565b61021e61021936600461118c565b610547565b005b6102286105b2565b6040519081526020016101c2565b61021e610244366004610eff565b610639565b61022861025736600461118c565b6106ad565b6101b661026a366004610fac565b610739565b6101b661027d36600461118c565b6107be565b61021e610290366004610eff565b6107f8565b61021e6102a3366004611277565b610839565b6101b66102b63660046110b1565b61089a565b6102286102c9366004611277565b6108cd565b6101b66102dc3660046111b8565b61094b565b61021e6102ef366004610f40565b6109da565b6101f3610302366004611277565b610a49565b610228610315366004610e8c565b610a7b565b610228610aae565b6101b6610afd565b6101d3610b62565b61021e61034036600461115e565b610ba6565b61021e61035336600461118c565b610be0565b6101d3610366366004611277565b610c19565b61021e6103793660046112a9565b610c9b565b6101d361038c366004611277565b610ccd565b6101f361039f366004610ec6565b610cff565b6101b66103b23660046112f0565b610d85565b60008060009054906101000a90046001600160a01b03166001600160a01b03166305d2035b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561040657600080fd5b505afa15801561041a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043e9190611211565b905090565b60008054604080516306fdde0360e01b815290516060936001600160a01b03909316926306fdde039260048082019391829003018186803b15801561048757600080fd5b505afa15801561049b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261043e919081019061122e565b6000805460405163020604bf60e21b8152600481018490526001600160a01b039091169063081812fc906024015b60206040518083038186803b15801561050957600080fd5b505afa15801561051d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105419190610ea9565b92915050565b60005460405163095ea7b360e01b81526001600160a01b038481166004830152602482018490529091169063095ea7b3906044015b600060405180830381600087803b15801561059657600080fd5b505af11580156105aa573d6000803e3d6000fd5b505050505050565b60008060009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561060157600080fd5b505afa158015610615573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043e9190611290565b6000546040516323b872dd60e01b81526001600160a01b038581166004830152848116602483015260448201849052909116906323b872dd906064015b600060405180830381600087803b15801561069057600080fd5b505af11580156106a4573d6000803e3d6000fd5b50505050505050565b60008054604051632f745c5960e01b81526001600160a01b0385811660048301526024820185905290911690632f745c599060440160206040518083038186803b1580156106fa57600080fd5b505afa15801561070e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107329190611290565b9392505050565b60008054604051631b2a180360e11b81526001600160a01b039091169063365430069061076c908690869060040161137f565b602060405180830381600087803b15801561078657600080fd5b505af115801561079a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107329190611211565b600080546040516340c10f1960e01b81526001600160a01b03858116600483015260248201859052909116906340c10f199060440161076c565b600054604051632142170760e11b81526001600160a01b038581166004830152848116602483015260448201849052909116906342842e0e90606401610676565b600054604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561087f57600080fd5b505af1158015610893573d6000803e3d6000fd5b5050505050565b60008054604051632254ca2f60e11b81526001600160a01b03909116906344a9945e9061076c9086908690600401611404565b60008054604051634f6ccce760e01b8152600481018490526001600160a01b0390911690634f6ccce7906024015b60206040518083038186803b15801561091357600080fd5b505afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105419190611290565b600080546040516350bb4e7f60e01b81526001600160a01b03909116906350bb4e7f906109809087908790879060040161145a565b602060405180830381600087803b15801561099a57600080fd5b505af11580156109ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d29190611211565b949350505050565b6000546040516330508b3960e11b81526001600160a01b03909116906360a1167290610a10908790879087908790600401611342565b600060405180830381600087803b158015610a2a57600080fd5b505af1158015610a3e573d6000803e3d6000fd5b505050505b50505050565b600080546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e906024016104f1565b600080546040516370a0823160e01b81526001600160a01b038481166004830152909116906370a08231906024016108fb565b60008060009054906101000a90046001600160a01b03166001600160a01b03166375794a3c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561060157600080fd5b60008060009054906101000a90046001600160a01b03166001600160a01b0316637d64bcb46040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610b4e57600080fd5b505af115801561041a573d6000803e3d6000fd5b60008054604080516395d89b4160e01b815290516060936001600160a01b03909316926395d89b419260048082019391829003018186803b15801561048757600080fd5b60005460405163a22cb46560e01b81526001600160a01b03848116600483015283151560248301529091169063a22cb4659060440161057c565b60005460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb9060440161057c565b60005460405163c87b56dd60e01b8152600481018390526060916001600160a01b03169063c87b56dd906024015b60006040518083038186803b158015610c5f57600080fd5b505afa158015610c73573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610541919081019061122e565b60005460405163d4eac26d60e01b81526001600160a01b039091169063d4eac26d9061057c908590859060040161149d565b60005460405163e6c5ce6f60e01b8152600481018390526060916001600160a01b03169063e6c5ce6f90602401610c47565b6000805460405163e985e9c560e01b81526001600160a01b03858116600483015284811660248301529091169063e985e9c59060440160206040518083038186803b158015610d4d57600080fd5b505afa158015610d61573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107329190610ea9565b6000805460405162f4f4b560e81b815263ffffffff841660048201526001600160a01b039091169063f4f4b5009060240160206040518083038186803b158015610dce57600080fd5b505afa158015610de2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105419190611211565b6000610e19610e1484611534565b6114df565b9050828152838383011115610e2d57600080fd5b61073283602083018461155c565b600082601f830112610e4c57600080fd5b8135610e5a610e1482611534565b818152846020838601011115610e6f57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215610e9e57600080fd5b81356107328161159e565b600060208284031215610ebb57600080fd5b81516107328161159e565b60008060408385031215610ed957600080fd5b8235610ee48161159e565b91506020830135610ef48161159e565b809150509250929050565b600080600060608486031215610f1457600080fd5b8335610f1f8161159e565b92506020840135610f2f8161159e565b929592945050506040919091013590565b60008060008060808587031215610f5657600080fd5b8435610f618161159e565b93506020850135610f718161159e565b925060408501359150606085013567ffffffffffffffff811115610f9457600080fd5b610fa087828801610e3b565b91505092959194509250565b60008060408385031215610fbf57600080fd5b8235610fca8161159e565b915060208381013567ffffffffffffffff80821115610fe857600080fd5b818601915086601f830112610ffc57600080fd5b813561100a610e1482611510565b8082825285820191508585018a878560051b880101111561102a57600080fd5b60005b848110156110a05781358681111561104457600080fd5b87016040818e03601f1901121561105a57600080fd5b6110626114b6565b89820135815260408201358881111561107a57600080fd5b6110888f8c83860101610e3b565b828c015250855250928701929087019060010161102d565b50979a909950975050505050505050565b600080604083850312156110c457600080fd5b82356110cf8161159e565b915060208381013567ffffffffffffffff8111156110ec57600080fd5b8401601f810186136110fd57600080fd5b803561110b610e1482611510565b80828252848201915084840189868560051b870101111561112b57600080fd5b600094505b8385101561114e578035835260019490940193918501918501611130565b5080955050505050509250929050565b6000806040838503121561117157600080fd5b823561117c8161159e565b91506020830135610ef4816115b6565b6000806040838503121561119f57600080fd5b82356111aa8161159e565b946020939093013593505050565b6000806000606084860312156111cd57600080fd5b83356111d88161159e565b925060208401359150604084013567ffffffffffffffff8111156111fb57600080fd5b61120786828701610e3b565b9150509250925092565b60006020828403121561122357600080fd5b8151610732816115b6565b60006020828403121561124057600080fd5b815167ffffffffffffffff81111561125757600080fd5b8201601f8101841361126857600080fd5b6109d284825160208401610e06565b60006020828403121561128957600080fd5b5035919050565b6000602082840312156112a257600080fd5b5051919050565b600080604083850312156112bc57600080fd5b82359150602083013567ffffffffffffffff8111156112da57600080fd5b6112e685828601610e3b565b9150509250929050565b60006020828403121561130257600080fd5b813563ffffffff8116811461073257600080fd5b6000815180845261132e81602086016020860161155c565b601f01601f19169290920160200192915050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061137590830184611316565b9695505050505050565b6001600160a01b0383168152604060208083018290528351828401819052600092916060600583901b860181019290860190878301865b828110156113f557888603605f190184528151805187528501518587018890526113e288880182611316565b96505092840192908401906001016113b6565b50939998505050505050505050565b6001600160a01b038316815260406020808301829052835191830182905260009184820191906060850190845b8181101561144d57845183529383019391830191600101611431565b5090979650505050505050565b60018060a01b03841681528260208201526060604082015260006114816060830184611316565b95945050505050565b6020815260006107326020830184611316565b8281526040602082015260006109d26040830184611316565b6040805190810167ffffffffffffffff811182821017156114d9576114d9611588565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561150857611508611588565b604052919050565b600067ffffffffffffffff82111561152a5761152a611588565b5060051b60200190565b600067ffffffffffffffff82111561154e5761154e611588565b50601f01601f191660200190565b60005b8381101561157757818101518382015260200161155f565b83811115610a435750506000910152565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146115b357600080fd5b50565b80151581146115b357600080fdfea2646970667358221220669a75a3efcdc6b60606caa5c7e41cab1d727e89a03fd231d1cda27f4de159a064736f6c63430008070033 \ No newline at end of file +608060405234801561001057600080fd5b506040516116bb3803806116bb83398101604081905261002f91610054565b600080546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b611628806100936000396000f3fe608060405234801561001057600080fd5b50600436106101c45760003560e01c80634f6ccce7116100f957806379cc679011610097578063a22cb46511610071578063a22cb46514610399578063a9059cbb146103ac578063c87b56dd146103bf578063e985e9c5146103d257600080fd5b806379cc6790146103765780637d64bcb41461038957806395d89b411461039157600080fd5b806362d9491f116100d357806362d9491f146103355780636352211e1461034857806370a082311461035b57806375794a3c1461036e57600080fd5b80634f6ccce7146102fc57806350bb4e7f1461030f57806360a116721461032257600080fd5b80632f745c591161016657806340c10f191161014057806340c10f19146102b057806342842e0e146102c357806342966c68146102d657806344a9945e146102e957600080fd5b80632f745c5914610277578063342419141461028a578063365430061461029d57600080fd5b8063081812fc116101a2578063081812fc1461020e578063095ea7b31461023957806318160ddd1461024e57806323b872dd1461026457600080fd5b806301ffc9a7146101c957806305d2035b146101f157806306fdde03146101f9575b600080fd5b6101dc6101d7366004610dca565b6103e5565b60405190151581526020015b60405180910390f35b6101dc610462565b6102016104df565b6040516101e89190610e4c565b61022161021c366004610e5f565b610550565b6040516001600160a01b0390911681526020016101e8565b61024c610247366004610e90565b6105bf565b005b61025661062a565b6040519081526020016101e8565b61024c610272366004610ebc565b6106a2565b610256610285366004610e90565b610716565b61024c610298366004610ff3565b610793565b6101dc6102ab36600461104c565b6107f8565b6101dc6102be366004610e90565b61086e565b61024c6102d1366004610ebc565b6108a8565b61024c6102e4366004610e5f565b6108e9565b6101dc6102f736600461114f565b61091a565b61025661030a366004610e5f565b61094d565b6101dc61031d3660046111f5565b6109bc565b61024c61033036600461124e565b610a3c565b61024c6103433660046112ce565b610aab565b610221610356366004610e5f565b610add565b610256610369366004611332565b610b0f565b610256610b42565b61024c610384366004610e90565b610b96565b6101dc610bcf565b610201610c25565b61024c6103a736600461135d565b610c6e565b61024c6103ba366004610e90565b610ca8565b6102016103cd366004610e5f565b610ce1565b6102216103e0366004611396565b610d53565b600080546040516301ffc9a760e01b81526001600160e01b0319841660048201526001600160a01b03909116906301ffc9a790602401602060405180830381865afa158015610438573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045c91906113c4565b92915050565b60008060009054906101000a90046001600160a01b03166001600160a01b03166305d2035b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104da91906113c4565b905090565b60008054604080516306fdde0360e01b815290516060936001600160a01b03909316926306fdde0392600480820193918290030181865afa158015610528573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104da91908101906113e1565b6000805460405163020604bf60e21b8152600481018490526001600160a01b039091169063081812fc906024015b602060405180830381865afa15801561059b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045c9190611458565b60005460405163095ea7b360e01b81526001600160a01b038481166004830152602482018490529091169063095ea7b3906044015b600060405180830381600087803b15801561060e57600080fd5b505af1158015610622573d6000803e3d6000fd5b505050505050565b60008060009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561067e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104da9190611475565b6000546040516323b872dd60e01b81526001600160a01b038581166004830152848116602483015260448201849052909116906323b872dd906064015b600060405180830381600087803b1580156106f957600080fd5b505af115801561070d573d6000803e3d6000fd5b50505050505050565b60008054604051632f745c5960e01b81526001600160a01b0385811660048301526024820185905290911690632f745c5990604401602060405180830381865afa158015610768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078c9190611475565b9392505050565b600054604051630d09064560e21b81526001600160a01b03909116906334241914906107c3908490600401610e4c565b600060405180830381600087803b1580156107dd57600080fd5b505af11580156107f1573d6000803e3d6000fd5b5050505050565b60008054604051631b2a180360e11b81526001600160a01b039091169063365430069061082b908690869060040161148e565b6020604051808303816000875af115801561084a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078c91906113c4565b600080546040516340c10f1960e01b81526001600160a01b03858116600483015260248201859052909116906340c10f199060440161082b565b600054604051632142170760e11b81526001600160a01b038581166004830152848116602483015260448201849052909116906342842e0e906064016106df565b600054604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c68906024016107c3565b60008054604051632254ca2f60e11b81526001600160a01b03909116906344a9945e9061082b9086908690600401611513565b60008054604051634f6ccce760e01b8152600481018490526001600160a01b0390911690634f6ccce7906024015b602060405180830381865afa158015610998573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045c9190611475565b600080546040516350bb4e7f60e01b81526001600160a01b03909116906350bb4e7f906109f190879087908790600401611569565b6020604051808303816000875af1158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3491906113c4565b949350505050565b6000546040516330508b3960e11b81526001600160a01b03909116906360a1167290610a72908790879087908790600401611590565b600060405180830381600087803b158015610a8c57600080fd5b505af1158015610aa0573d6000803e3d6000fd5b505050505b50505050565b6000546040516362d9491f60e01b81526001600160a01b03909116906362d9491f906105f490859085906004016115cd565b600080546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e9060240161057e565b600080546040516370a0823160e01b81526001600160a01b038481166004830152909116906370a082319060240161097b565b60008060009054906101000a90046001600160a01b03166001600160a01b03166375794a3c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561067e573d6000803e3d6000fd5b60005460405163079cc67960e41b81526001600160a01b03848116600483015260248201849052909116906379cc6790906044016105f4565b60008060009054906101000a90046001600160a01b03166001600160a01b0316637d64bcb46040518163ffffffff1660e01b81526004016020604051808303816000875af11580156104b6573d6000803e3d6000fd5b60008054604080516395d89b4160e01b815290516060936001600160a01b03909316926395d89b4192600480820193918290030181865afa158015610528573d6000803e3d6000fd5b60005460405163a22cb46560e01b81526001600160a01b03848116600483015283151560248301529091169063a22cb465906044016105f4565b60005460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016105f4565b60005460405163c87b56dd60e01b8152600481018390526060916001600160a01b03169063c87b56dd90602401600060405180830381865afa158015610d2b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261045c91908101906113e1565b6000805460405163e985e9c560e01b81526001600160a01b03858116600483015284811660248301529091169063e985e9c590604401602060405180830381865afa158015610da6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078c9190611458565b600060208284031215610ddc57600080fd5b81356001600160e01b03198116811461078c57600080fd5b60005b83811015610e0f578181015183820152602001610df7565b83811115610aa55750506000910152565b60008151808452610e38816020860160208601610df4565b601f01601f19169290920160200192915050565b60208152600061078c6020830184610e20565b600060208284031215610e7157600080fd5b5035919050565b6001600160a01b0381168114610e8d57600080fd5b50565b60008060408385031215610ea357600080fd5b8235610eae81610e78565b946020939093013593505050565b600080600060608486031215610ed157600080fd5b8335610edc81610e78565b92506020840135610eec81610e78565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610f3657610f36610efd565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610f6557610f65610efd565b604052919050565b600067ffffffffffffffff821115610f8757610f87610efd565b50601f01601f191660200190565b6000610fa8610fa384610f6d565b610f3c565b9050828152838383011115610fbc57600080fd5b828260208301376000602084830101529392505050565b600082601f830112610fe457600080fd5b61078c83833560208501610f95565b60006020828403121561100557600080fd5b813567ffffffffffffffff81111561101c57600080fd5b610a3484828501610fd3565b600067ffffffffffffffff82111561104257611042610efd565b5060051b60200190565b600080604080848603121561106057600080fd5b833561106b81610e78565b925060208481013567ffffffffffffffff8082111561108957600080fd5b818701915087601f83011261109d57600080fd5b81356110ab610fa382611028565b81815260059190911b8301840190848101908a8311156110ca57600080fd5b8585015b8381101561113d578035858111156110e65760008081fd5b8601808d03601f19018913156110fc5760008081fd5b611104610f13565b888201358152898201358781111561111c5760008081fd5b61112a8f8b83860101610fd3565b828b0152508452509186019186016110ce565b50809750505050505050509250929050565b6000806040838503121561116257600080fd5b823561116d81610e78565b915060208381013567ffffffffffffffff81111561118a57600080fd5b8401601f8101861361119b57600080fd5b80356111a9610fa382611028565b81815260059190911b820183019083810190888311156111c857600080fd5b928401925b828410156111e6578335825292840192908401906111cd565b80955050505050509250929050565b60008060006060848603121561120a57600080fd5b833561121581610e78565b925060208401359150604084013567ffffffffffffffff81111561123857600080fd5b61124486828701610fd3565b9150509250925092565b6000806000806080858703121561126457600080fd5b843561126f81610e78565b9350602085013561127f81610e78565b925060408501359150606085013567ffffffffffffffff8111156112a257600080fd5b8501601f810187136112b357600080fd5b6112c287823560208401610f95565b91505092959194509250565b600080604083850312156112e157600080fd5b823567ffffffffffffffff808211156112f957600080fd5b61130586838701610fd3565b9350602085013591508082111561131b57600080fd5b5061132885828601610fd3565b9150509250929050565b60006020828403121561134457600080fd5b813561078c81610e78565b8015158114610e8d57600080fd5b6000806040838503121561137057600080fd5b823561137b81610e78565b9150602083013561138b8161134f565b809150509250929050565b600080604083850312156113a957600080fd5b82356113b481610e78565b9150602083013561138b81610e78565b6000602082840312156113d657600080fd5b815161078c8161134f565b6000602082840312156113f357600080fd5b815167ffffffffffffffff81111561140a57600080fd5b8201601f8101841361141b57600080fd5b8051611429610fa382610f6d565b81815285602083850101111561143e57600080fd5b61144f826020830160208601610df4565b95945050505050565b60006020828403121561146a57600080fd5b815161078c81610e78565b60006020828403121561148757600080fd5b5051919050565b6001600160a01b0383168152604060208083018290528351828401819052600092916060600583901b860181019290860190878301865b8281101561150457888603605f190184528151805187528501518587018890526114f188880182610e20565b96505092840192908401906001016114c5565b50939998505050505050505050565b6001600160a01b038316815260406020808301829052835191830182905260009184820191906060850190845b8181101561155c57845183529383019391830191600101611540565b5090979650505050505050565b60018060a01b038416815282602082015260606040820152600061144f6060830184610e20565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906115c390830184610e20565b9695505050505050565b6040815260006115e06040830185610e20565b828103602084015261144f8185610e2056fea26469706673582212205bdf4275f4b714a1029ccfe77c0f9a0e20e121a932e1e5840cace97dfa886da964736f6c634300080d0033 \ No newline at end of file --- a/tests/src/eth/proxy/UniqueNFTProxy.sol +++ b/tests/src/eth/proxy/UniqueNFTProxy.sol @@ -148,29 +148,17 @@ return proxied.nextTokenId(); } - function supportsInterface(uint32 interfaceId) + function burnFrom(address from, uint256 tokenId) external override { + return proxied.burnFrom(from, tokenId); + } + + function supportsInterface(bytes4 interfaceId) external view override returns (bool) { return proxied.supportsInterface(interfaceId); - } - - function setVariableMetadata(uint256 tokenId, bytes memory data) - external - override - { - return proxied.setVariableMetadata(tokenId, data); - } - - function getVariableMetadata(uint256 tokenId) - external - view - override - returns (bytes memory) - { - return proxied.getVariableMetadata(tokenId); } function mintBulk(address to, uint256[] memory tokenIds) @@ -188,4 +176,12 @@ { return proxied.mintBulkWithTokenURI(to, tokens); } + + function setProperty(string memory key, string memory value) external override { + return proxied.setProperty(key, value); + } + + function deleteProperty(string memory key) external override { + return proxied.deleteProperty(key); + } } --- a/tests/src/eth/proxy/nonFungibleProxy.test.ts +++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts @@ -15,7 +15,7 @@ // along with Unique Network. If not, see . import privateKey from '../../substrate/privateKey'; -import {createCollectionExpectSuccess, createItemExpectSuccess, setVariableMetaDataExpectSuccess, setMetadataUpdatePermissionFlagExpectSuccess} from '../../util/helpers'; +import {createCollectionExpectSuccess, createItemExpectSuccess, setMetadataUpdatePermissionFlagExpectSuccess} from '../../util/helpers'; import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers'; import nonFungibleAbi from '../nonFungibleAbi.json'; import {expect} from 'chai'; @@ -333,36 +333,5 @@ const balance = await contract.methods.balanceOf(receiver).call(); expect(+balance).to.equal(1); } - }); - - itWeb3('Can perform getVariableMetadata', async ({web3, api}) => { - const collection = await createCollectionExpectSuccess({ - mode: {type: 'NFT'}, - }); - const alice = privateKey('//Alice'); - const caller = await createEthAccountWithBalance(api, web3); - - const address = collectionIdToAddress(collection); - const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS})); - const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address}); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, collection, 'Admin'); - await setVariableMetaDataExpectSuccess(alice, collection, item, [1, 2, 3]); - - expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203'); - }); - - itWeb3('Can perform setVariableMetadata', async ({web3, api}) => { - const collection = await createCollectionExpectSuccess({ - mode: {type: 'NFT'}, - }); - const alice = privateKey('//Alice'); - const caller = await createEthAccountWithBalance(api, web3); - - const address = collectionIdToAddress(collection); - const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS})); - const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address}); - - expect(await contract.methods.setVariableMetadata(item, '0x010203').send({from: caller})); - expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203'); }); }); --- a/tests/src/metadataUpdate.test.ts +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. -// This file is part of Unique Network. - -// Unique Network is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Unique Network is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Unique Network. If not, see . - -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import privateKey from './substrate/privateKey'; -import usingApi from './substrate/substrate-api'; -import { - createItemExpectSuccess, - createCollectionExpectSuccess, - enablePublicMintingExpectSuccess, - enableAllowListExpectSuccess, - setMetadataUpdatePermissionFlagExpectSuccess, - setVariableMetaDataExpectSuccess, - setMintPermissionExpectSuccess, - addToAllowListExpectSuccess, - addCollectionAdminExpectSuccess, - setVariableMetaDataExpectFailure, - setMetadataUpdatePermissionFlagExpectFailure, -} from './util/helpers'; - -chai.use(chaiAsPromised); - -describe('Metadata update permissions with ItemOwner flag', () => { - it('ItemOwner can set variable metadata with ItemOwner permission flag', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner'); - - await setVariableMetaDataExpectSuccess(alice, nftCollectionId, newNftTokenId, data); - }); - }); - - it('Admin can\'n set variable metadata with ItemOwner permission flag', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner'); - - await setMintPermissionExpectSuccess(alice, nftCollectionId, true); - await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address); - await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address); - - await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data); - }); - }); - - it('User can\'n set variable metadata with ItemOwner permission flag', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner'); - - await setMintPermissionExpectSuccess(alice, nftCollectionId, true); - await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data); - }); - }); -}); - -describe('Metadata update permissions with Admin flag', () => { - it('Admin can set variable metadata with Admin permission flag', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin'); - - await setMintPermissionExpectSuccess(alice, nftCollectionId, true); - await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address); - await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address); - - await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data); - }); - }); - - it('User can\'n can set variable metadata with Admin permission flag', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin'); - - await setMintPermissionExpectSuccess(alice, nftCollectionId, true); - await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address); - await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address); - - await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data); - }); - }); - - it('ItemOwner can\'n can set variable metadata with Admin permission flag', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - await enablePublicMintingExpectSuccess(alice, nftCollectionId); - await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address); - await enableAllowListExpectSuccess(alice, nftCollectionId); - const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin'); - - await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data); - }); - }); -}); - -describe('Metadata update permissions with None flag', () => { - it('Nobody can set variable metadata with None flag (Regular)', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None'); - - await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data); - }); - }); - - it('Nobody can set variable metadata with None flag (Admin)', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - const bob = privateKey('//Bob'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None'); - - await setMintPermissionExpectSuccess(alice, nftCollectionId, true); - await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address); - await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address); - - await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data); - }); - }); - - it('Nobody can set variable metadata with None flag (ItemOwner)', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - - const data = [1, 2, 254, 255]; - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None'); - - await setVariableMetaDataExpectFailure(alice, nftCollectionId, newNftTokenId, data); - }); - }); - - it('Nobody can set variable metadata flag after freeze', async () => { - await usingApi(async () => { - const alice = privateKey('//Alice'); - - // nft - const nftCollectionId = await createCollectionExpectSuccess(); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None'); - await setMetadataUpdatePermissionFlagExpectFailure(alice, nftCollectionId, 'Admin'); - }); - }); -}); --- a/tests/src/nesting/rules-smoke.test.ts +++ b/tests/src/nesting/rules-smoke.test.ts @@ -23,7 +23,7 @@ nestTarget = {Ethereum: tokenIdToAddress(collection, token)}; }); }); - + it('called for fungible', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'Fungible',decimalPoints:0}}); @@ -39,7 +39,7 @@ it('called for nonfungible', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {NFT: {ConstData: [], VariableData: {}}}))) + await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {NFT: {ConstData: []}}))) .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/); const token = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address}); @@ -51,7 +51,7 @@ it('called for refungible', async () => { await usingApi(async api => { const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}}); - await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {ReFungible: {ConstData: [], VariableData: {}}}))) + await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {ReFungible: {ConstData: []}}))) .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/); const token = await createItemExpectSuccess(alice, collection, 'ReFungible', {Substrate: alice.address}); @@ -60,4 +60,3 @@ }); }); }); - \ No newline at end of file --- a/tests/src/setVariableMetaData.test.ts +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. -// This file is part of Unique Network. - -// Unique Network is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Unique Network is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Unique Network. If not, see . - -import {IKeyringPair} from '@polkadot/types/types'; -import chai from 'chai'; -import chaiAsPromised from 'chai-as-promised'; -import privateKey from './substrate/privateKey'; -import usingApi from './substrate/substrate-api'; -import { - burnItemExpectSuccess, - createCollectionExpectSuccess, - createItemExpectSuccess, - destroyCollectionExpectSuccess, - findNotExistingCollection, - setVariableMetaDataExpectFailure, - setVariableMetaDataExpectSuccess, - addCollectionAdminExpectSuccess, - setMetadataUpdatePermissionFlagExpectSuccess, - getVariableMetadata, -} from './util/helpers'; - -chai.use(chaiAsPromised); -const expect = chai.expect; - -describe('Integration Test setVariableMetaData', () => { - const data = [1, 2, 254, 255]; - - let alice: IKeyringPair; - let collectionId: number; - let tokenId: number; - before(async () => { - await usingApi(async () => { - alice = privateKey('//Alice'); - collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT'); - }); - }); - - it('execute setVariableMetaData', async () => { - await setVariableMetaDataExpectSuccess(alice, collectionId, tokenId, data); - }); - - it('verify data was set', async () => { - await usingApi(async api => { - expect(await getVariableMetadata(api, collectionId, tokenId)).to.deep.equal(data); - }); - }); -}); - -describe('Integration Test collection admin setVariableMetaData', () => { - const data = [1, 2, 254, 255]; - - let alice: IKeyringPair; - let bob: IKeyringPair; - let collectionId: number; - let tokenId: number; - before(async () => { - await usingApi(async () => { - alice = privateKey('//Alice'); - bob = privateKey('//Bob'); - collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT'); - await setMetadataUpdatePermissionFlagExpectSuccess(alice, collectionId, 'Admin'); - await addCollectionAdminExpectSuccess(alice, collectionId, bob.address); - }); - }); - - it('execute setVariableMetaData', async () => { - await setVariableMetaDataExpectSuccess(bob, collectionId, tokenId, data); - }); - - it('verify data was set', async () => { - await usingApi(async api => { - expect(await getVariableMetadata(api, collectionId, tokenId)).to.deep.equal(data); - }); - }); -}); - -describe('Negative Integration Test setVariableMetaData', () => { - const data = [1]; - - let alice: IKeyringPair; - let bob: IKeyringPair; - - let validCollectionId: number; - let validTokenId: number; - - before(async () => { - await usingApi(async () => { - alice = privateKey('//Alice'); - bob = privateKey('//Bob'); - - validCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - validTokenId = await createItemExpectSuccess(alice, validCollectionId, 'NFT'); - }); - }); - - it('fails on not existing collection id', async () => { - await usingApi(async api => { - const nonExistingCollectionId = await findNotExistingCollection(api); - await setVariableMetaDataExpectFailure(alice, nonExistingCollectionId, 1, data); - }); - }); - it('fails on removed collection id', async () => { - const removedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - const removedCollectionTokenId = await createItemExpectSuccess(alice, removedCollectionId, 'NFT'); - - await destroyCollectionExpectSuccess(removedCollectionId); - await setVariableMetaDataExpectFailure(alice, removedCollectionId, removedCollectionTokenId, data); - }); - it('fails on removed token', async () => { - const removedTokenCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}}); - const removedTokenId = await createItemExpectSuccess(alice, removedTokenCollectionId, 'NFT'); - await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId); - - await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data); - }); - it('fails on not existing token', async () => { - const nonExistingTokenId = validTokenId + 1; - - await setVariableMetaDataExpectFailure(alice, validCollectionId, nonExistingTokenId, data); - }); - it('fails on too long data', async () => { - const tooLongData = new Array(4097).fill(0xff); - - await setVariableMetaDataExpectFailure(alice, validCollectionId, validTokenId, tooLongData); - }); - it('fails on fungible token', async () => { - const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}}); - const fungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible'); - - await setVariableMetaDataExpectFailure(alice, fungibleCollectionId, fungibleTokenId, data); - }); - it('fails on bad sender', async () => { - await setVariableMetaDataExpectFailure(bob, validCollectionId, validTokenId, data); - }); -}); --- a/tests/src/setVariableMetadataSponsoringRateLimit.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. -// This file is part of Unique Network. - -// Unique Network is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Unique Network is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Unique Network. If not, see . - -import {IKeyringPair} from '@polkadot/types/types'; -import {expect} from 'chai'; -import privateKey from './substrate/privateKey'; -import usingApi from './substrate/substrate-api'; -import { - confirmSponsorshipExpectSuccess, - createCollectionExpectSuccess, - createItemExpectSuccess, - findUnusedAddress, - getDetailedCollectionInfo, - setCollectionLimitsExpectSuccess, - setCollectionSponsorExpectSuccess, - setVariableMetaDataExpectFailure, - setVariableMetaDataExpectSuccess, -} from './util/helpers'; - -describe('Integration Test setVariableMetadataSponsoringRateLimit', () => { - let alice: IKeyringPair; - let userWithNoBalance: IKeyringPair; - - before(async () => { - await usingApi(async (api) => { - alice = privateKey('//Alice'); - userWithNoBalance = await findUnusedAddress(api); - }); - }); - - it('sponsored setVariableMetaData can be called twice with pause for free', async () => { - const collectionId = await createCollectionExpectSuccess(); - await setCollectionSponsorExpectSuccess(collectionId, alice.address); - await confirmSponsorshipExpectSuccess(collectionId); - await setCollectionLimitsExpectSuccess(alice, collectionId, { - sponsoredDataRateLimit: {Blocks: 0}, - }); - - const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address); - await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]); - await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]); - }); - - it('sponsored setVariableMetaData can\'t be called twice without pause for free', async () => { - const collectionId = await createCollectionExpectSuccess(); - await setCollectionSponsorExpectSuccess(collectionId, alice.address); - await confirmSponsorshipExpectSuccess(collectionId); - await setCollectionLimitsExpectSuccess(alice, collectionId, { - sponsoredDataRateLimit: {Blocks: 10}, - }); - - const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address); - await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1, 2, 3]); - await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2, 3]); - }); - - it('sponsored setVariableMetaData can\'t be called for free with variable metadata above collection limits', async () => { - const collectionId = await createCollectionExpectSuccess(); - await setCollectionSponsorExpectSuccess(collectionId, alice.address); - await confirmSponsorshipExpectSuccess(collectionId); - await setCollectionLimitsExpectSuccess(alice, collectionId, { - sponsoredDataRateLimit: {Blocks: 0}, - sponsoredDataSize: 1, - }); - const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address); - - await setVariableMetaDataExpectSuccess(userWithNoBalance, collectionId, itemId, [1]); - await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1, 2]); - }); - - it('Default value of rate limit does not sponsor setting variable metadata', async () => { - const collectionId = await createCollectionExpectSuccess(); - await setCollectionSponsorExpectSuccess(collectionId, alice.address); - await confirmSponsorshipExpectSuccess(collectionId); - - const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', userWithNoBalance.address); - await setVariableMetaDataExpectFailure(userWithNoBalance, collectionId, itemId, [1]); - }); - - it('sponsoring of data is disabled by default', async () => { - await usingApi(async api => { - const collectionId = await createCollectionExpectSuccess(); - - const collection = (await getDetailedCollectionInfo(api, collectionId))!; - // limit is none = default is used - expect(collection?.limits.sponsoredDataRateLimit.isNone); - }); - }); - - it('sponsoring can be disabled explicitly', async () => { - await usingApi(async api => { - const collectionId = await createCollectionExpectSuccess(); - - await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsoredDataRateLimit: {Blocks: 6}}); - { - const collection = (await getDetailedCollectionInfo(api, collectionId))!; - expect(collection?.limits.sponsoredDataRateLimit.unwrap().asBlocks.toNumber()).to.equal(6); - } - - await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsoredDataRateLimit: 'SponsoringDisabled'}); - { - const collection = (await getDetailedCollectionInfo(api, collectionId))!; - // disabled sponsoring = default value - expect(collection?.limits.sponsoredDataRateLimit.unwrap().isNone).to.true; - } - }); - }); -}); --- a/tests/src/util/helpers.ts +++ b/tests/src/util/helpers.ts @@ -142,7 +142,6 @@ export interface IReFungibleTokenDataType { owner: IReFungibleOwner[]; constData: number[]; - variableData: number[]; } export function uniqueEventMessage(events: EventRecord[]): IGetMessage { @@ -793,24 +792,7 @@ expect(result.success).to.be.false; }); } - -export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) { - await usingApi(async (api) => { - const tx = api.tx.unique.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex')); - const events = await submitTransactionAsync(sender, tx); - const result = getGenericResult(events); - expect(result.success).to.be.true; - }); -} - -export async function setVariableMetaDataExpectFailure(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) { - await usingApi(async (api) => { - const tx = api.tx.unique.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex')); - await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected; - }); -} - export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) { await usingApi(async (api) => { const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex')); @@ -1137,13 +1119,6 @@ collectionId: number, ): Promise { return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any; -} -export async function getVariableMetadata( - api: ApiPromise, - collectionId: number, - tokenId: number, -): Promise { - return [...(await api.rpc.unique.variableMetadata(collectionId, tokenId))]; } export async function getConstMetadata( api: ApiPromise, @@ -1182,10 +1157,10 @@ const createData = {fungible: {value: 10}}; tx = api.tx.unique.createItem(collectionId, to, createData as any); } else if (createMode === 'ReFungible') { - const createData = {refungible: {const_data: [], variable_data: [], pieces: 100}}; + const createData = {refungible: {const_data: [], pieces: 100}}; tx = api.tx.unique.createItem(collectionId, to, createData as any); } else { - const createData = {nft: {const_data: [], variable_data: []}}; + const createData = {nft: {const_data: []}}; tx = api.tx.unique.createItem(collectionId, to, createData as any); }