difftreelog
fix properties have been moved in creation functions
in: master
5 files changed
tests/src/createItem.test.tsdiffbeforeafterboth--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -24,6 +24,7 @@
addCollectionAdminExpectSuccess,
createCollectionWithPropsExpectSuccess,
createItemWithPropsExpectSuccess,
+ createItemWithPropsExpectFailure,
} from './util/helpers';
const expect = chai.expect;
@@ -128,69 +129,47 @@
const createMode = 'NFT';
const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},
propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
-
- const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
- await expect(executeTransaction(
- api,
- alice,
- api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]),
- )).to.be.rejected;
+ await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);
});
});
it('User doesnt have editing rights', async () => {
await usingApi(async api => {
const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
- const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
-
- await expect(executeTransaction(
- api,
- bob,
- api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]),
- )).to.be.rejected;
+ await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);
});
});
it('Adding property without access rights', async () => {
await usingApi(async api => {
- const createMode = 'NFT';
- const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
-
- const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
+ const newCollectionID = await createCollectionWithPropsExpectSuccess();
await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
-
- await expect(executeTransaction(
- api,
- bob,
- api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]),
- )).to.be.rejected;
+
+ await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);
});
});
it('Adding more than 64 prps', async () => {
await usingApi(async api => {
- const createMode = 'NFT';
-
const prps = [];
for (let i = 0; i < 65; i++) {
prps.push({key: `key${i}`, value: `value${i}`});
}
- const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
+ const newCollectionID = await createCollectionWithPropsExpectSuccess();
- await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(newCollectionID, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);
+ createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);
});
});
it('Trying to add bigger property than allowed', async () => {
await usingApi(async api => {
- const createMode = 'NFT';
- const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
+ const newCollectionID = await createCollectionWithPropsExpectSuccess();
- await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(newCollectionID, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]))).to.be.rejectedWith(/common\.NoSpaceForProperty/);
+ createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);
});
});
});
tests/src/createMultipleItems.test.tsdiffbeforeafterboth34 getCreatedCollectionCount,34 getCreatedCollectionCount,35 createCollectionWithPropsExpectSuccess,35 createCollectionWithPropsExpectSuccess,36 getCreateItemsResult,36 getCreateItemsResult,37 createMultipleItemsWithPropsExpectSuccess37 createMultipleItemsWithPropsExpectSuccess,38 createMultipleItemsWithPropsExpectFailure,38} from './util/helpers';39} from './util/helpers';394040chai.use(chaiAsPromised);41chai.use(chaiAsPromised);432 it('No editing rights', async () => {433 it('No editing rights', async () => {433 await usingApi(async (api: ApiPromise) => {434 await usingApi(async (api: ApiPromise) => {434 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],435 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],435 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});436 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: true}}]});436 const itemsListIndexBefore = await getLastTokenId(api, collectionId);437 const itemsListIndexBefore = await getLastTokenId(api, collectionId);437 expect(itemsListIndexBefore).to.be.equal(0);438 expect(itemsListIndexBefore).to.be.equal(0);438 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);439 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);439 const args = [{Nft: {const_data: '0x31'}},440 const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},440 {Nft: {const_data: '0x32'}},441 {Nft: {const_data: '0x32'}},441 {Nft: {const_data: '0x33'}}];442 {Nft: {const_data: '0x33'}}];442443443 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);444445 const events = await submitTransactionAsync(alice, createMultipleItemsTx);446 const result = getCreateItemsResult(events);447448 for (const elem of result) {449 await expect(executeTransaction(444 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);450 api,451 bob,452 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),453 )).to.be.rejected;454 }455456 // await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;457 });445 });458 });446 });459447460 it('User doesnt have editing rights', async () => {448 it('User doesnt have editing rights', async () => {461 await usingApi(async (api: ApiPromise) => {449 await usingApi(async (api: ApiPromise) => {462 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],450 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],463 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});451 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});464 const itemsListIndexBefore = await getLastTokenId(api, collectionId);452 const itemsListIndexBefore = await getLastTokenId(api, collectionId);465 expect(itemsListIndexBefore).to.be.equal(0);453 expect(itemsListIndexBefore).to.be.equal(0);466 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);454 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);467 const args = [{Nft: {const_data: '0x31'}},455 const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},468 {Nft: {const_data: '0x32'}},456 {Nft: {const_data: '0x32'}},469 {Nft: {const_data: '0x33'}}];457 {Nft: {const_data: '0x33'}}];470458471 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);472473 const events = await submitTransactionAsync(alice, createMultipleItemsTx);474 const result = getCreateItemsResult(events);475476 for (const elem of result) {477 await expect(executeTransaction(459 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);478 api,479 bob,480 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),481 )).to.be.rejected;482 }483 });460 });484 });461 });485462486 it('Adding property without access rights', async () => {463 it('Adding property without access rights', async () => {487 await usingApi(async (api: ApiPromise) => {464 await usingApi(async (api: ApiPromise) => {488 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});465 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});489 const itemsListIndexBefore = await getLastTokenId(api, collectionId);466 const itemsListIndexBefore = await getLastTokenId(api, collectionId);490 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);467 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);491 expect(itemsListIndexBefore).to.be.equal(0);468 expect(itemsListIndexBefore).to.be.equal(0);492 const args = [{Nft: {const_data: '0x31'}},469 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v'}]}},493 {Nft: {const_data: '0x32'}},470 {Nft: {const_data: '0x32'}},494 {Nft: {const_data: '0x33'}}];471 {Nft: {const_data: '0x33'}}];495472496 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);497498 const events = await submitTransactionAsync(alice, createMultipleItemsTx);499 const result = getCreateItemsResult(events);500501 for (const elem of result) {502 await expect(executeTransaction(473 await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);503 api,504 bob,505 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),506 )).to.be.rejected;507 }508 });474 });509 });475 });510476516 expect(itemsListIndexBefore).to.be.equal(0);482 expect(itemsListIndexBefore).to.be.equal(0);517 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);483 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);518519 const args = [{Nft: {const_data: '0x31'}},520 {Nft: {const_data: '0x32'}},521 {Nft: {const_data: '0x33'}}];522523 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);524 const events = await submitTransactionAsync(alice, createMultipleItemsTx);525526 const result = getCreateItemsResult(events);527484528 const prps = [];485 const prps = [];529486530 for (let i = 0; i < 65; i++) {487 for (let i = 0; i < 65; i++) {531 prps.push({key: `key${i}`, value: `value${i}`});488 prps.push({key: `key${i}`, value: `value${i}`});532 }489 }533490534 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);491 const args = [{Nft: {const_data: '0x31', properties: prps}},535492 {Nft: {const_data: '0x32', properties: prps}},536 for (const elem of result) {493 {Nft: {const_data: '0x33', properties: prps}}];494537 await expect(executeTransaction(495 createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);538 api,539 bob,540 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),541 )).to.be.rejected;542 }543 });496 });544 });497 });545498546 it('Trying to add bigger property than allowed', async () => {499 it('Trying to add bigger property than allowed', async () => {547 await usingApi(async (api: ApiPromise) => {500 await usingApi(async (api: ApiPromise) => {548 const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],501 const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});549 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});550 const itemsListIndexBefore = await getLastTokenId(api, collectionId);502 const itemsListIndexBefore = await getLastTokenId(api, collectionId);551 expect(itemsListIndexBefore).to.be.equal(0);503 expect(itemsListIndexBefore).to.be.equal(0);552 const args = [{Nft: {const_data: '0x31'}},504 const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},553 {Nft: {const_data: '0x32'}},554 {Nft: {const_data: '0x33'}}];555556 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);557558 const events = await submitTransactionAsync(alice, createMultipleItemsTx);559 const result = getCreateItemsResult(events);560561562 await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(collectionId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]))).to.be.rejectedWith(/common\.NoSpaceForProperty/);505 {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},563506 {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];564 for (const elem of result) {507565 await expect(executeTransaction(508 createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);566 api,567 bob,568 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]),569 )).to.be.rejected;570 }571 });509 });572 });510 });573});511});tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -16,7 +16,7 @@
import {expect} from 'chai';
import privateKey from './substrate/privateKey';
-import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';
+import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';
describe('createMultipleItemsEx', () => {
@@ -48,7 +48,7 @@
});
});
- it.only('createMultipleItemsEx with property Admin', async () => {
+ it('createMultipleItemsEx with property Admin', async () => {
const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
@@ -152,26 +152,20 @@
const data = [
{
owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
}, {
- owner: {substrate: bob.address},
+ owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
}, {
- owner: {substrate: charlie.address},
+ owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
},
];
const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});
- await executeTransaction(api, alice, tx);
-
- const events = await submitTransactionAsync(alice, tx);
- const result = getCreateItemsResult(events);
+ // await executeTransaction(api, alice, tx);
- for (const elem of result) {
- await expect(executeTransaction(
- api,
- bob,
- api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),
- )).to.be.rejected;
- }
+ await submitTransactionExpectFailAsync(alice, tx);
});
});
@@ -186,26 +180,20 @@
const data = [
{
owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
}, {
- owner: {substrate: bob.address},
+ owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
}, {
- owner: {substrate: charlie.address},
+ owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
},
];
const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});
- await executeTransaction(api, alice, tx);
-
- const events = await submitTransactionAsync(alice, tx);
- const result = getCreateItemsResult(events);
+ // await executeTransaction(api, alice, tx);
- for (const elem of result) {
- await expect(executeTransaction(
- api,
- bob,
- api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),
- )).to.be.rejected;
- }
+ await submitTransactionExpectFailAsync(alice, tx);
});
});
@@ -219,31 +207,32 @@
const data = [
{
owner: {substrate: alice.address},
+ properties: [{key: 'key1', value: 'v2'}],
}, {
owner: {substrate: bob.address},
+ properties: [{key: 'key1', value: 'v2'}],
}, {
owner: {substrate: charlie.address},
+ properties: [{key: 'key1', value: 'v2'}],
},
];
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'}]),
- )).to.be.rejected;
- }
+ await submitTransactionExpectFailAsync(alice, tx);
});
});
it('Adding more than 64 prps', async () => {
- const collection = await createCollectionWithPropsExpectSuccess();
+ const prps = [{key: 'key', value: 'v'}];
+ const propPerm = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];
+
+ for (let i = 0; i < 65; i++) {
+ prps.push({key: `key${i}`, value: `value${i}`});
+ propPerm.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});
+ }
+
+ const collection = await createCollectionWithPropsExpectSuccess({propPerm: propPerm});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
@@ -252,40 +241,24 @@
const data = [
{
owner: {substrate: alice.address},
+ properties: prps,
}, {
- owner: {substrate: bob.address},
+ owner: {substrate: alice.address},
+ properties: prps,
}, {
- owner: {substrate: charlie.address},
+ owner: {substrate: alice.address},
+ properties: prps,
},
];
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),
- )).to.be.rejected;
- }
+ await submitTransactionExpectFailAsync(alice, tx);
});
});
it('Trying to add bigger property than allowed', async () => {
- const collection = await createCollectionWithPropsExpectSuccess();
+ const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
@@ -293,32 +266,17 @@
await usingApi(async (api) => {
const data = [
{
- owner: {substrate: alice.address},
+ owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],
}, {
- owner: {substrate: bob.address},
+ owner: {substrate: bob.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],
}, {
- owner: {substrate: charlie.address},
+ owner: {substrate: charlie.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],
},
];
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 = [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}];
-
- 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),
- )).to.be.rejected;
- }
+ await submitTransactionExpectFailAsync(alice, tx);
});
});
tests/src/interfaces/rmrk/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/rmrk/definitions.ts
+++ b/tests/src/interfaces/rmrk/definitions.ts
@@ -24,92 +24,92 @@
const atParam = {name: 'at', type: 'Hash', isOptional: true};
const fn = (description: string, params: RpcParam[], type: string) => ({
- description,
- params: [...params, atParam],
- type,
+ description,
+ params: [...params, atParam],
+ type,
});
export default {
- types,
- rpc: {
- lastCollectionIdx: fn('Get the latest created collection id', [], 'u32'),
- collectionById: fn('Get collection by id', [{name: 'id', type: 'u32'}], 'Option<RmrkTypesCollectionInfo>'),
- nftById: fn(
- 'Get NFT by collection id and NFT id',
- [
- {name: 'collectionId', type: 'u32'},
- {name: 'nftId', type: 'u32'},
- ],
- 'Option<RmrkTypesNftInfo>'
- ),
- accountTokens: fn(
- 'Get tokens owned by an account in a collection',
- [
- {name: 'accountId', type: 'AccountId32'},
- {name: 'collectionId', type: 'u32'}
- ],
- 'Vec<u32>'
- ),
- nftChildren: fn(
- 'Get NFT children',
- [
- {name: 'collectionId', type: 'u32'},
- {name: 'nftId', type: 'u32'},
- ],
- 'Vec<RmrkTypesNftChild>'
- ),
- collectionProperties: fn(
- 'Get collection properties',
- [{name: 'collectionId', type: 'u32'}],
- 'Vec<RmrkTypesPropertyInfo>'
- ),
- nftProperties: fn(
- 'Get NFT properties',
- [
- {name: 'collectionId', type: 'u32'},
- {name: 'nftId', type: 'u32'}
- ],
- 'Vec<RmrkTypesPropertyInfo>'
- ),
- nftResources: fn(
- 'Get NFT resources',
- [
- {name: 'collectionId', type: 'u32'},
- {name: 'nftId', type: 'u32'}
- ],
- 'Vec<RmrkTypesResourceInfo>'
- ),
- nftResourcePriorities: fn(
- 'Get NFT resource priorities',
- [
- {name: 'collectionId', type: 'u32'},
- {name: 'nftId', type: 'u32'}
- ],
- 'Vec<Bytes>'
- ),
- base: fn(
- 'Get base info',
- [{name: 'baseId', type: 'u32'}],
- 'Option<RmrkTypesBaseInfo>'
- ),
- baseParts: fn(
- 'Get all Base\'s parts',
- [{name: 'baseId', type: 'u32'}],
- 'Vec<RmrkTypesPartType>'
- ),
- themeNames: fn(
- 'Get Base\'s theme names',
- [{name: 'baseId', type: 'u32'}],
- 'Vec<Bytes>'
- ),
- themes: fn(
- 'Get Theme\'s keys values',
- [
- {name: 'baseId', type: 'u32'},
- {name: 'themeName', type: 'String'},
- {name: 'keys', type: 'Option<Vec<String>>'}
- ],
- 'Option<RmrkTypesTheme>'
- )
- }
+ types,
+ rpc: {
+ lastCollectionIdx: fn('Get the latest created collection id', [], 'u32'),
+ collectionById: fn('Get collection by id', [{name: 'id', type: 'u32'}], 'Option<RmrkTypesCollectionInfo>'),
+ nftById: fn(
+ 'Get NFT by collection id and NFT id',
+ [
+ {name: 'collectionId', type: 'u32'},
+ {name: 'nftId', type: 'u32'},
+ ],
+ 'Option<RmrkTypesNftInfo>',
+ ),
+ accountTokens: fn(
+ 'Get tokens owned by an account in a collection',
+ [
+ {name: 'accountId', type: 'AccountId32'},
+ {name: 'collectionId', type: 'u32'},
+ ],
+ 'Vec<u32>',
+ ),
+ nftChildren: fn(
+ 'Get NFT children',
+ [
+ {name: 'collectionId', type: 'u32'},
+ {name: 'nftId', type: 'u32'},
+ ],
+ 'Vec<RmrkTypesNftChild>',
+ ),
+ collectionProperties: fn(
+ 'Get collection properties',
+ [{name: 'collectionId', type: 'u32'}],
+ 'Vec<RmrkTypesPropertyInfo>',
+ ),
+ nftProperties: fn(
+ 'Get NFT properties',
+ [
+ {name: 'collectionId', type: 'u32'},
+ {name: 'nftId', type: 'u32'},
+ ],
+ 'Vec<RmrkTypesPropertyInfo>',
+ ),
+ nftResources: fn(
+ 'Get NFT resources',
+ [
+ {name: 'collectionId', type: 'u32'},
+ {name: 'nftId', type: 'u32'},
+ ],
+ 'Vec<RmrkTypesResourceInfo>',
+ ),
+ nftResourcePriorities: fn(
+ 'Get NFT resource priorities',
+ [
+ {name: 'collectionId', type: 'u32'},
+ {name: 'nftId', type: 'u32'},
+ ],
+ 'Vec<Bytes>',
+ ),
+ base: fn(
+ 'Get base info',
+ [{name: 'baseId', type: 'u32'}],
+ 'Option<RmrkTypesBaseInfo>',
+ ),
+ baseParts: fn(
+ 'Get all Base\'s parts',
+ [{name: 'baseId', type: 'u32'}],
+ 'Vec<RmrkTypesPartType>',
+ ),
+ themeNames: fn(
+ 'Get Base\'s theme names',
+ [{name: 'baseId', type: 'u32'}],
+ 'Vec<Bytes>',
+ ),
+ themes: fn(
+ 'Get Theme\'s keys values',
+ [
+ {name: 'baseId', type: 'u32'},
+ {name: 'themeName', type: 'String'},
+ {name: 'keys', type: 'Option<Vec<String>>'},
+ ],
+ 'Option<RmrkTypesTheme>',
+ ),
+ },
};
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -1135,7 +1135,32 @@
const events = await submitTransactionAsync(sender, tx);
const result = getCreateItemsResult(events);
- for (let res of result) {
+ for (const res of result) {
+ expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;
+ }
+ });
+}
+
+export async function createMultipleItemsWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {
+ await usingApi(async (api) => {
+ const to = normalizeAccountId(owner);
+ const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);
+
+ const events = await expect(await submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
+ const result = getCreateItemsResult(events);
+
+ expect(result).to.be.equal(false);
+ });
+}
+
+export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {
+ await usingApi(async (api) => {
+ const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);
+
+ const events = await submitTransactionAsync(sender, tx);
+ const result = getCreateItemsResult(events);
+
+ for (const res of result) {
expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;
}
});
@@ -1156,7 +1181,7 @@
const createData = {refungible: {const_data: [], pieces: 100}};
tx = api.tx.unique.createItem(collectionId, to, createData as any);
} else {
- const data = api.createType('UpDataStructsCreateItemData', { NFT: { constData: 'test', properties: props}});
+ const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});
tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);
}
@@ -1186,6 +1211,25 @@
return newItemId;
}
+export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {
+ await usingApi(async (api) => {
+
+ let tx;
+ if (createMode === 'NFT') {
+ const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});
+ tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);
+ } else {
+ tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);
+ }
+
+
+ const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
+ const result = getCreateItemResult(events);
+
+ expect(result.success).to.be.false;
+ });
+}
+
export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {
let newItemId = 0;
await usingApi(async (api) => {