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.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.tsdiffbeforeafterboth161617import {expect} from 'chai';17import {expect} from 'chai';18import privateKey from './substrate/privateKey';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';19import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';212122describe('createMultipleItemsEx', () => {22describe('createMultipleItemsEx', () => {48 });48 });49 });49 });505051 it.only('createMultipleItemsEx with property Admin', async () => {51 it('createMultipleItemsEx with property Admin', async () => {52 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});52 const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});53 const alice = privateKey('//Alice');53 const alice = privateKey('//Alice');54 const bob = privateKey('//Bob');54 const bob = privateKey('//Bob');152 const data = [152 const data = [153 {153 {154 owner: {substrate: alice.address},154 owner: {substrate: alice.address},155 properties: [{key: 'key1', value: 'v2'}],155 }, {156 }, {156 owner: {substrate: bob.address},157 owner: {substrate: alice.address},158 properties: [{key: 'key1', value: 'v2'}],157 }, {159 }, {158 owner: {substrate: charlie.address},160 owner: {substrate: alice.address},161 properties: [{key: 'key1', value: 'v2'}],159 },162 },160 ];163 ];161164162 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});165 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});163 await executeTransaction(api, alice, tx);166 // await executeTransaction(api, alice, tx);164167165 const events = await submitTransactionAsync(alice, tx);168 await submitTransactionExpectFailAsync(alice, tx);166 const result = getCreateItemsResult(events);167168 for (const elem of result) {169 await expect(executeTransaction(170 api,171 bob,172 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),173 )).to.be.rejected;174 }175 });169 });176 });170 });177171186 const data = [180 const data = [187 {181 {188 owner: {substrate: alice.address},182 owner: {substrate: alice.address},183 properties: [{key: 'key1', value: 'v2'}],189 }, {184 }, {190 owner: {substrate: bob.address},185 owner: {substrate: alice.address},186 properties: [{key: 'key1', value: 'v2'}],191 }, {187 }, {192 owner: {substrate: charlie.address},188 owner: {substrate: alice.address},189 properties: [{key: 'key1', value: 'v2'}],193 },190 },194 ];191 ];195192196 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});193 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});197 await executeTransaction(api, alice, tx);194 // await executeTransaction(api, alice, tx);198195199 const events = await submitTransactionAsync(alice, tx);196 await submitTransactionExpectFailAsync(alice, tx);200 const result = getCreateItemsResult(events);201202 for (const elem of result) {203 await expect(executeTransaction(204 api,205 bob,206 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),207 )).to.be.rejected;208 }209 });197 });210 });198 });211199219 const data = [207 const data = [220 {208 {221 owner: {substrate: alice.address},209 owner: {substrate: alice.address},210 properties: [{key: 'key1', value: 'v2'}],222 }, {211 }, {223 owner: {substrate: bob.address},212 owner: {substrate: bob.address},213 properties: [{key: 'key1', value: 'v2'}],224 }, {214 }, {225 owner: {substrate: charlie.address},215 owner: {substrate: charlie.address},216 properties: [{key: 'key1', value: 'v2'}],226 },217 },227 ];218 ];228219229 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});220 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});230 await executeTransaction(api, alice, tx);231221232 const events = await submitTransactionAsync(alice, tx);222 await submitTransactionExpectFailAsync(alice, tx);233 const result = getCreateItemsResult(events);234235 for (const elem of result) {236 await expect(executeTransaction(237 api,238 bob,239 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),240 )).to.be.rejected;241 }242 });223 });243 });224 });244225245 it('Adding more than 64 prps', async () => {226 it('Adding more than 64 prps', async () => {246 const collection = await createCollectionWithPropsExpectSuccess();227 const prps = [{key: 'key', value: 'v'}];228 const propPerm = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];229230 for (let i = 0; i < 65; i++) {231 prps.push({key: `key${i}`, value: `value${i}`});232 propPerm.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});233 }234235 const collection = await createCollectionWithPropsExpectSuccess({propPerm: propPerm});247 const alice = privateKey('//Alice');236 const alice = privateKey('//Alice');248 const bob = privateKey('//Bob');237 const bob = privateKey('//Bob');249 const charlie = privateKey('//Charlie');238 const charlie = privateKey('//Charlie');252 const data = [241 const data = [253 {242 {254 owner: {substrate: alice.address},243 owner: {substrate: alice.address},244 properties: prps,255 }, {245 }, {256 owner: {substrate: bob.address},246 owner: {substrate: alice.address},247 properties: prps,257 }, {248 }, {258 owner: {substrate: charlie.address},249 owner: {substrate: alice.address},250 properties: prps,259 },251 },260 ];252 ];261253262 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});254 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});263 await executeTransaction(api, alice, tx);264255265 const events = await submitTransactionAsync(alice, tx);256 await submitTransactionExpectFailAsync(alice, tx);266 const result = getCreateItemsResult(events);267268 const prps = [];269270 for (let i = 0; i < 65; i++) {271 prps.push({key: `key${i}`, value: `value${i}`});272 }273274 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);275276277 for (const elem of result) {278 await expect(executeTransaction(279 api,280 bob,281 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),282 )).to.be.rejected;283 }284 });257 });285 });258 });286259287 it('Trying to add bigger property than allowed', async () => {260 it('Trying to add bigger property than allowed', async () => {288 const collection = await createCollectionWithPropsExpectSuccess();261 const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});289 const alice = privateKey('//Alice');262 const alice = privateKey('//Alice');290 const bob = privateKey('//Bob');263 const bob = privateKey('//Bob');291 const charlie = privateKey('//Charlie');264 const charlie = privateKey('//Charlie');292 await addCollectionAdminExpectSuccess(alice, collection, bob.address);265 await addCollectionAdminExpectSuccess(alice, collection, bob.address);293 await usingApi(async (api) => {266 await usingApi(async (api) => {294 const data = [267 const data = [295 {268 {296 owner: {substrate: alice.address},269 owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],297 }, {270 }, {298 owner: {substrate: bob.address},271 owner: {substrate: bob.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],299 }, {272 }, {300 owner: {substrate: charlie.address},273 owner: {substrate: charlie.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],301 },274 },302 ];275 ];303276304 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});277 const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});305 await executeTransaction(api, alice, tx);306278307 const events = await submitTransactionAsync(alice, tx);279 await submitTransactionExpectFailAsync(alice, tx);308 const result = getCreateItemsResult(events);309310 const prps = [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}];311312 await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collection, prps))).to.be.rejectedWith(/common\.NoSpaceForProperty/);313314315 for (const elem of result) {316 await expect(executeTransaction(317 api,318 bob,319 api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),320 )).to.be.rejected;321 }322 });280 });323 });281 });324282tests/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) => {