difftreelog
fix properties have been moved in creation functions
in: master
5 files changed
tests/src/createItem.test.tsdiffbeforeafterboth24 addCollectionAdminExpectSuccess,24 addCollectionAdminExpectSuccess,25 createCollectionWithPropsExpectSuccess,25 createCollectionWithPropsExpectSuccess,26 createItemWithPropsExpectSuccess,26 createItemWithPropsExpectSuccess,27 createItemWithPropsExpectFailure,27} from './util/helpers';28} from './util/helpers';282929const expect = chai.expect;30const expect = chai.expect;129 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 130 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});131 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});131132 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');133 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);132 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);134133135 await expect(executeTransaction(134 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);136 api, 137 alice, 138 api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]), 139 )).to.be.rejected;140 });135 });141 });136 });142137143 it('User doesnt have editing rights', async () => {138 it('User doesnt have editing rights', async () => {144 await usingApi(async api => {139 await usingApi(async api => {145 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});140 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});146 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');147148 await expect(executeTransaction(141 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);149 api, 150 bob, 151 api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]), 152 )).to.be.rejected;153 });142 });154 });143 });155144156 it('Adding property without access rights', async () => {145 it('Adding property without access rights', async () => {157 await usingApi(async api => {146 await usingApi(async api => {158 const createMode = 'NFT';159 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});147 const newCollectionID = await createCollectionWithPropsExpectSuccess();160161 const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');162 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);148 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);163 149164 await expect(executeTransaction(150 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);165 api, 166 bob, 167 api.tx.unique.setTokenProperties(newCollectionID, token, [{key: 'key1', value: 'v2'}]), 168 )).to.be.rejected;169 });151 });170 });152 });171153172 it('Adding more than 64 prps', async () => {154 it('Adding more than 64 prps', async () => {173 await usingApi(async api => {155 await usingApi(async api => {174 const createMode = 'NFT';175176 const prps = [];156 const prps = [];177157178 for (let i = 0; i < 65; i++) {158 for (let i = 0; i < 65; i++) {179 prps.push({key: `key${i}`, value: `value${i}`});159 prps.push({key: `key${i}`, value: `value${i}`});180 }160 }181161182 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});162 const newCollectionID = await createCollectionWithPropsExpectSuccess();183 163 184 await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(newCollectionID, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);164 createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);185 });165 });186 });166 });187167188 it('Trying to add bigger property than allowed', async () => {168 it('Trying to add bigger property than allowed', async () => {189 await usingApi(async api => {169 await usingApi(async api => {190 const createMode = 'NFT';191 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});170 const newCollectionID = await createCollectionWithPropsExpectSuccess();192 171 193 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/);172 createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);194 });173 });195 });174 });196});175});tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -34,7 +34,8 @@
getCreatedCollectionCount,
createCollectionWithPropsExpectSuccess,
getCreateItemsResult,
- createMultipleItemsWithPropsExpectSuccess
+ createMultipleItemsWithPropsExpectSuccess,
+ createMultipleItemsWithPropsExpectFailure,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -432,79 +433,44 @@
it('No editing rights', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
- propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
+ propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: true}}]});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- const args = [{Nft: {const_data: '0x31'}},
+ const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},
{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);
-
- 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 expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
+ await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);
});
});
it('User doesnt have editing rights', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
- propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
+ propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
- const args = [{Nft: {const_data: '0x31'}},
+ const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},
{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);
-
- 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 createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);
});
});
it('Adding property without access rights', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});
+ const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
expect(itemsListIndexBefore).to.be.equal(0);
- const args = [{Nft: {const_data: '0x31'}},
+ const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v'}]}},
{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);
-
- 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 createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);
});
});
@@ -515,15 +481,6 @@
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-
- 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 = [];
@@ -531,43 +488,24 @@
prps.push({key: `key${i}`, value: `value${i}`});
}
- await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);
+ const args = [{Nft: {const_data: '0x31', properties: prps}},
+ {Nft: {const_data: '0x32', properties: prps}},
+ {Nft: {const_data: '0x33', properties: prps}}];
- for (const elem of result) {
- await expect(executeTransaction(
- api,
- bob,
- api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),
- )).to.be.rejected;
- }
+ createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);
});
});
it('Trying to add bigger property than allowed', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
- propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
+ const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
const itemsListIndexBefore = await getLastTokenId(api, collectionId);
expect(itemsListIndexBefore).to.be.equal(0);
- 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);
-
-
- 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/);
+ const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},
+ {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},
+ {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];
- 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)}]),
- )).to.be.rejected;
- }
+ createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);
});
});
});
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) => {