difftreelog
fix eslint
in: master
33 files changed
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -33,7 +33,7 @@
transferFromExpectSuccess,
transferFromExpectFail,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
chai.use(chaiAsPromised);
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -26,7 +26,7 @@
setCollectionLimitsExpectSuccess,
isTokenExists,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
import chai from 'chai';
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -34,7 +34,7 @@
getCreatedCollectionCount,
UNIQUE,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
tests/src/createItem.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {default as usingApi, executeTransaction} from './substrate/substrate-api';18import chai from 'chai';19import {IKeyringPair} from '@polkadot/types/types';20import {21 createCollectionExpectSuccess,22 createItemExpectSuccess,23 addCollectionAdminExpectSuccess,24 createCollectionWithPropsExpectSuccess,25 createItemWithPropsExpectSuccess,26 createItemWithPropsExpectFailure,27 createCollection,28 transferExpectSuccess,29 itApi,30 normalizeAccountId,31 getCreateItemResult,32 requirePallets,33 Pallets34} from './util/helpers';3536const expect = chai.expect;37let alice: IKeyringPair;38let bob: IKeyringPair;3940describe('integration test: ext. ():', () => {41 before(async () => {42 await usingApi(async (api, privateKeyWrapper) => {43 alice = privateKeyWrapper('//Alice');44 bob = privateKeyWrapper('//Bob');45 });46 });4748 it('Create new item in NFT collection', async () => {49 const createMode = 'NFT';50 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});51 await createItemExpectSuccess(alice, newCollectionID, createMode);52 });53 it('Create new item in Fungible collection', async () => {54 const createMode = 'Fungible';55 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});56 await createItemExpectSuccess(alice, newCollectionID, createMode);57 });58 itApi('Check events on create new item in Fungible collection', async ({api}) => {59 const createMode = 'Fungible';60 61 const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;62 63 const to = normalizeAccountId(alice);64 {65 const createData = {fungible: {value: 100}};66 const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);67 const events = await executeTransaction(api, alice, tx);68 const result = getCreateItemResult(events);69 expect(result.amount).to.be.equal(100);70 expect(result.collectionId).to.be.equal(newCollectionID);71 expect(result.recipient).to.be.deep.equal(to);72 }73 {74 const createData = {fungible: {value: 50}};75 const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);76 const events = await executeTransaction(api, alice, tx);77 const result = getCreateItemResult(events);78 expect(result.amount).to.be.equal(50);79 expect(result.collectionId).to.be.equal(newCollectionID);80 expect(result.recipient).to.be.deep.equal(to);81 }8283 });84 it('Create new item in ReFungible collection', async function() {85 await requirePallets(this, [Pallets.ReFungible]);8687 const createMode = 'ReFungible';88 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});89 await createItemExpectSuccess(alice, newCollectionID, createMode);90 });91 it('Create new item in NFT collection with collection admin permissions', async () => {92 const createMode = 'NFT';93 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});94 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);95 await createItemExpectSuccess(bob, newCollectionID, createMode);96 });97 it('Create new item in Fungible collection with collection admin permissions', async () => {98 const createMode = 'Fungible';99 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});100 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);101 await createItemExpectSuccess(bob, newCollectionID, createMode);102 });103 it('Create new item in ReFungible collection with collection admin permissions', async function() {104 await requirePallets(this, [Pallets.ReFungible]);105106 const createMode = 'ReFungible';107 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});108 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);109 await createItemExpectSuccess(bob, newCollectionID, createMode);110 });111112 it('Set property Admin', async () => {113 const createMode = 'NFT';114 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 115 propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});116 117 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);118 });119120 it('Set property AdminConst', async () => {121 const createMode = 'NFT';122 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 123 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});124 125 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);126 });127128 it('Set property itemOwnerOrAdmin', async () => {129 const createMode = 'NFT';130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},131 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});132 133 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);134 });135136 it('Check total pieces of Fungible token', async () => {137 await usingApi(async api => {138 const createMode = 'Fungible';139 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});140 const amountPieces = 10n;141 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);142 {143 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);144 expect(totalPieces.isSome).to.be.true;145 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);146 }147148 await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);149 {150 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);151 expect(totalPieces.isSome).to.be.true;152 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);153 }154155 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;156 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);157 });158 });159160 it('Check total pieces of NFT token', async () => {161 await usingApi(async api => {162 const createMode = 'NFT';163 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});164 const amountPieces = 1n;165 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);166 {167 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);168 expect(totalPieces.isSome).to.be.true;169 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);170 }171172 await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);173 {174 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);175 expect(totalPieces.isSome).to.be.true;176 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);177 }178179 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;180 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);181 });182 });183184 it('Check total pieces of ReFungible token', async function() {185 await requirePallets(this, [Pallets.ReFungible]);186187 await usingApi(async api => {188 const createMode = 'ReFungible';189 const createCollectionResult = await createCollection(api, alice, {mode: {type: createMode}});190 const collectionId = createCollectionResult.collectionId;191 const amountPieces = 100n;192 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);193 {194 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);195 expect(totalPieces.isSome).to.be.true;196 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);197 }198199 await transferExpectSuccess(collectionId, tokenId, bob, alice, 60n, createMode);200 {201 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);202 expect(totalPieces.isSome).to.be.true;203 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);204 }205206 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;207 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);208 });209 });210});211212describe('Negative integration test: ext. createItem():', () => {213 before(async () => {214 await usingApi(async (api, privateKeyWrapper) => {215 alice = privateKeyWrapper('//Alice');216 bob = privateKeyWrapper('//Bob');217 });218 });219220 it('Regular user cannot create new item in NFT collection', async () => {221 const createMode = 'NFT';222 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});223 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;224 });225 it('Regular user cannot create new item in Fungible collection', async () => {226 const createMode = 'Fungible';227 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});228 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;229 });230 it('Regular user cannot create new item in ReFungible collection', async function() {231 await requirePallets(this, [Pallets.ReFungible]);232233 const createMode = 'ReFungible';234 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});235 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;236 });237238 it('No editing rights', async () => {239 await usingApi(async () => {240 const createMode = 'NFT';241 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 242 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});243 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);244245 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);246 });247 });248249 it('User doesnt have editing rights', async () => {250 await usingApi(async () => {251 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});252 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);253 });254 });255256 it('Adding property without access rights', async () => {257 await usingApi(async () => {258 const newCollectionID = await createCollectionWithPropsExpectSuccess();259 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);260261 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);262 });263 });264265 it('Adding more than 64 prps', async () => {266 await usingApi(async () => {267 const prps = [];268269 for (let i = 0; i < 65; i++) {270 prps.push({key: `key${i}`, value: `value${i}`});271 }272273 const newCollectionID = await createCollectionWithPropsExpectSuccess();274 275 await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);276 });277 });278279 it('Trying to add bigger property than allowed', async () => {280 await usingApi(async () => {281 const newCollectionID = await createCollectionWithPropsExpectSuccess();282 283 await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);284 });285 });286287 it('Check total pieces for invalid Fungible token', async () => {288 await usingApi(async api => {289 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});290 const collectionId = createCollectionResult.collectionId;291 const invalidTokenId = 1000_000;292 293 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;294 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);295 });296 });297298 it('Check total pieces for invalid NFT token', async () => {299 await usingApi(async api => {300 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'NFT'}});301 const collectionId = createCollectionResult.collectionId;302 const invalidTokenId = 1000_000;303 304 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;305 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);306 });307 });308309 it('Check total pieces for invalid Refungible token', async function() {310 await requirePallets(this, [Pallets.ReFungible]);311312 await usingApi(async api => {313 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});314 const collectionId = createCollectionResult.collectionId;315 const invalidTokenId = 1000_000;316 317 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;318 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);319 });320 });321});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {default as usingApi, executeTransaction} from './substrate/substrate-api';18import chai from 'chai';19import {IKeyringPair} from '@polkadot/types/types';20import {21 createCollectionExpectSuccess,22 createItemExpectSuccess,23 addCollectionAdminExpectSuccess,24 createCollectionWithPropsExpectSuccess,25 createItemWithPropsExpectSuccess,26 createItemWithPropsExpectFailure,27 createCollection,28 transferExpectSuccess,29 itApi,30 normalizeAccountId,31 getCreateItemResult,32 requirePallets,33 Pallets,34} from './util/helpers';3536const expect = chai.expect;37let alice: IKeyringPair;38let bob: IKeyringPair;3940describe('integration test: ext. ():', () => {41 before(async () => {42 await usingApi(async (api, privateKeyWrapper) => {43 alice = privateKeyWrapper('//Alice');44 bob = privateKeyWrapper('//Bob');45 });46 });4748 it('Create new item in NFT collection', async () => {49 const createMode = 'NFT';50 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});51 await createItemExpectSuccess(alice, newCollectionID, createMode);52 });53 it('Create new item in Fungible collection', async () => {54 const createMode = 'Fungible';55 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});56 await createItemExpectSuccess(alice, newCollectionID, createMode);57 });58 itApi('Check events on create new item in Fungible collection', async ({api}) => {59 const createMode = 'Fungible';60 61 const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;62 63 const to = normalizeAccountId(alice);64 {65 const createData = {fungible: {value: 100}};66 const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);67 const events = await executeTransaction(api, alice, tx);68 const result = getCreateItemResult(events);69 expect(result.amount).to.be.equal(100);70 expect(result.collectionId).to.be.equal(newCollectionID);71 expect(result.recipient).to.be.deep.equal(to);72 }73 {74 const createData = {fungible: {value: 50}};75 const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);76 const events = await executeTransaction(api, alice, tx);77 const result = getCreateItemResult(events);78 expect(result.amount).to.be.equal(50);79 expect(result.collectionId).to.be.equal(newCollectionID);80 expect(result.recipient).to.be.deep.equal(to);81 }8283 });84 it('Create new item in ReFungible collection', async function() {85 await requirePallets(this, [Pallets.ReFungible]);8687 const createMode = 'ReFungible';88 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});89 await createItemExpectSuccess(alice, newCollectionID, createMode);90 });91 it('Create new item in NFT collection with collection admin permissions', async () => {92 const createMode = 'NFT';93 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});94 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);95 await createItemExpectSuccess(bob, newCollectionID, createMode);96 });97 it('Create new item in Fungible collection with collection admin permissions', async () => {98 const createMode = 'Fungible';99 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});100 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);101 await createItemExpectSuccess(bob, newCollectionID, createMode);102 });103 it('Create new item in ReFungible collection with collection admin permissions', async function() {104 await requirePallets(this, [Pallets.ReFungible]);105106 const createMode = 'ReFungible';107 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});108 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);109 await createItemExpectSuccess(bob, newCollectionID, createMode);110 });111112 it('Set property Admin', async () => {113 const createMode = 'NFT';114 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 115 propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});116 117 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);118 });119120 it('Set property AdminConst', async () => {121 const createMode = 'NFT';122 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 123 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});124 125 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);126 });127128 it('Set property itemOwnerOrAdmin', async () => {129 const createMode = 'NFT';130 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},131 propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});132 133 await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);134 });135136 it('Check total pieces of Fungible token', async () => {137 await usingApi(async api => {138 const createMode = 'Fungible';139 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});140 const amountPieces = 10n;141 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);142 {143 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);144 expect(totalPieces.isSome).to.be.true;145 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);146 }147148 await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);149 {150 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);151 expect(totalPieces.isSome).to.be.true;152 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);153 }154155 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;156 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);157 });158 });159160 it('Check total pieces of NFT token', async () => {161 await usingApi(async api => {162 const createMode = 'NFT';163 const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});164 const amountPieces = 1n;165 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);166 {167 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);168 expect(totalPieces.isSome).to.be.true;169 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);170 }171172 await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);173 {174 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);175 expect(totalPieces.isSome).to.be.true;176 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);177 }178179 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;180 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);181 });182 });183184 it('Check total pieces of ReFungible token', async function() {185 await requirePallets(this, [Pallets.ReFungible]);186187 await usingApi(async api => {188 const createMode = 'ReFungible';189 const createCollectionResult = await createCollection(api, alice, {mode: {type: createMode}});190 const collectionId = createCollectionResult.collectionId;191 const amountPieces = 100n;192 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);193 {194 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);195 expect(totalPieces.isSome).to.be.true;196 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);197 }198199 await transferExpectSuccess(collectionId, tokenId, bob, alice, 60n, createMode);200 {201 const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);202 expect(totalPieces.isSome).to.be.true;203 expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);204 }205206 const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;207 expect(totalPieces.toBigInt()).to.be.eq(amountPieces);208 });209 });210});211212describe('Negative integration test: ext. createItem():', () => {213 before(async () => {214 await usingApi(async (api, privateKeyWrapper) => {215 alice = privateKeyWrapper('//Alice');216 bob = privateKeyWrapper('//Bob');217 });218 });219220 it('Regular user cannot create new item in NFT collection', async () => {221 const createMode = 'NFT';222 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});223 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;224 });225 it('Regular user cannot create new item in Fungible collection', async () => {226 const createMode = 'Fungible';227 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});228 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;229 });230 it('Regular user cannot create new item in ReFungible collection', async function() {231 await requirePallets(this, [Pallets.ReFungible]);232233 const createMode = 'ReFungible';234 const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});235 await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;236 });237238 it('No editing rights', async () => {239 await usingApi(async () => {240 const createMode = 'NFT';241 const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 242 propPerm: [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});243 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);244245 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);246 });247 });248249 it('User doesnt have editing rights', async () => {250 await usingApi(async () => {251 const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});252 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);253 });254 });255256 it('Adding property without access rights', async () => {257 await usingApi(async () => {258 const newCollectionID = await createCollectionWithPropsExpectSuccess();259 await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);260261 await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);262 });263 });264265 it('Adding more than 64 prps', async () => {266 await usingApi(async () => {267 const prps = [];268269 for (let i = 0; i < 65; i++) {270 prps.push({key: `key${i}`, value: `value${i}`});271 }272273 const newCollectionID = await createCollectionWithPropsExpectSuccess();274 275 await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);276 });277 });278279 it('Trying to add bigger property than allowed', async () => {280 await usingApi(async () => {281 const newCollectionID = await createCollectionWithPropsExpectSuccess();282 283 await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);284 });285 });286287 it('Check total pieces for invalid Fungible token', async () => {288 await usingApi(async api => {289 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});290 const collectionId = createCollectionResult.collectionId;291 const invalidTokenId = 1000_000;292 293 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;294 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);295 });296 });297298 it('Check total pieces for invalid NFT token', async () => {299 await usingApi(async api => {300 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'NFT'}});301 const collectionId = createCollectionResult.collectionId;302 const invalidTokenId = 1000_000;303 304 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;305 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);306 });307 });308309 it('Check total pieces for invalid Refungible token', async function() {310 await requirePallets(this, [Pallets.ReFungible]);311312 await usingApi(async api => {313 const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});314 const collectionId = createCollectionResult.collectionId;315 const invalidTokenId = 1000_000;316 317 expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;318 expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);319 });320 });321});tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -35,7 +35,7 @@
getTokenProperties,
requirePallets,
Pallets,
- checkPalletsPresence
+ checkPalletsPresence,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -416,7 +416,7 @@
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- let types = ['NFT', 'Fungible'];
+ const types = ['NFT', 'Fungible'];
if (await checkPalletsPresence([Pallets.ReFungible])) {
types.push('ReFungible');
tests/src/destroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -26,7 +26,7 @@
getCreatedCollectionCount,
createItemExpectSuccess,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
chai.use(chaiAsPromised);
tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -28,7 +28,7 @@
getFreeBalance,
waitNewBlocks, burnItemExpectSuccess,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
import {expect} from 'chai';
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -18,7 +18,7 @@
transferFromExpectSuccess,
setCollectionLimitsExpectSuccess,
requirePallets,
- Pallets
+ Pallets,
} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -9,7 +9,7 @@
getCreateCollectionResult,
transferExpectSuccess,
requirePallets,
- Pallets
+ Pallets,
} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
import {tokenIdToAddress} from '../eth/util/helpers';
tests/src/nesting/unnest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/unnest.test.ts
+++ b/tests/src/nesting/unnest.test.ts
@@ -11,7 +11,7 @@
transferExpectSuccess,
transferFromExpectSuccess,
requirePallets,
- Pallets
+ Pallets,
} from '../util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
tests/src/nextSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/nextSponsoring.test.ts
+++ b/tests/src/nextSponsoring.test.ts
@@ -28,7 +28,7 @@
normalizeAccountId,
getNextSponsored,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
chai.use(chaiAsPromised);
tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -38,7 +38,7 @@
getDestroyItemsResult,
getModuleNames,
Pallets,
- requirePallets
+ requirePallets,
} from './util/helpers';
import chai from 'chai';
tests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/acceptNft.test.ts
+++ b/tests/src/rmrk/acceptNft.test.ts
@@ -8,7 +8,7 @@
} from './util/tx';
import {NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
describe('integration test: accept NFT', () => {
let api: any;
tests/src/rmrk/addResource.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/addResource.test.ts
+++ b/tests/src/rmrk/addResource.test.ts
@@ -12,7 +12,7 @@
addNftComposableResource,
} from './util/tx';
import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
describe('integration test: add NFT resource', () => {
const Alice = '//Alice';
tests/src/rmrk/addTheme.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/addTheme.test.ts
+++ b/tests/src/rmrk/addTheme.test.ts
@@ -3,7 +3,7 @@
import {createBase, addTheme} from './util/tx';
import {expectTxFailure} from './util/helpers';
import {getThemeNames} from './util/fetch';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
describe('integration test: add Theme to Base', () => {
let api: any;
tests/src/rmrk/burnNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/burnNft.test.ts
+++ b/tests/src/rmrk/burnNft.test.ts
@@ -5,7 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
tests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/changeCollectionIssuer.test.ts
+++ b/tests/src/rmrk/changeCollectionIssuer.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {
changeIssuer,
tests/src/rmrk/createBase.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/createBase.test.ts
+++ b/tests/src/rmrk/createBase.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {createCollection, createBase} from './util/tx';
describe('integration test: create new Base', () => {
tests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/deleteCollection.test.ts
+++ b/tests/src/rmrk/deleteCollection.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, deleteCollection} from './util/tx';
tests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/getOwnedNfts.test.ts
+++ b/tests/src/rmrk/getOwnedNfts.test.ts
@@ -1,6 +1,6 @@
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {getOwnedNfts} from './util/fetch';
import {mintNft, createCollection} from './util/tx';
tests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/lockCollection.test.ts
+++ b/tests/src/rmrk/lockCollection.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, lockCollection, mintNft} from './util/tx';
tests/src/rmrk/mintNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/mintNft.test.ts
+++ b/tests/src/rmrk/mintNft.test.ts
@@ -1,6 +1,6 @@
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {getNft} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {createCollection, mintNft} from './util/tx';
tests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/rejectNft.test.ts
+++ b/tests/src/rmrk/rejectNft.test.ts
@@ -8,7 +8,7 @@
} from './util/tx';
import {getChildren, NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
describe('integration test: reject NFT', () => {
let api: any;
tests/src/rmrk/removeResource.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/removeResource.test.ts
+++ b/tests/src/rmrk/removeResource.test.ts
@@ -1,7 +1,7 @@
import {expect} from 'chai';
import privateKey from '../substrate/privateKey';
import {executeTransaction, getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {getNft, NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {
tests/src/rmrk/sendNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/sendNft.test.ts
+++ b/tests/src/rmrk/sendNft.test.ts
@@ -3,7 +3,7 @@
import {createCollection, mintNft, sendNft} from './util/tx';
import {NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
describe('integration test: send NFT', () => {
let api: any;
tests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setCollectionProperty.test.ts
+++ b/tests/src/rmrk/setCollectionProperty.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, setPropertyCollection} from './util/tx';
tests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setEquippableList.test.ts
+++ b/tests/src/rmrk/setEquippableList.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, createBase, setEquippableList} from './util/tx';
tests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setNftProperty.test.ts
+++ b/tests/src/rmrk/setNftProperty.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';
tests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setResourcePriorities.test.ts
+++ b/tests/src/rmrk/setResourcePriorities.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { requirePallets, Pallets } from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {mintNft, createCollection, setResourcePriorities} from './util/tx';
tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -24,7 +24,7 @@
addCollectionAdminExpectSuccess,
getCreatedCollectionCount,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
import {IKeyringPair} from '@polkadot/types/types';
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -42,7 +42,7 @@
subToEth,
itWeb3,
} from './eth/util/helpers';
-import { request } from 'https';
+import {request} from 'https';
let alice: IKeyringPair;
let bob: IKeyringPair;
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -32,7 +32,7 @@
setCollectionLimitsExpectSuccess,
getCreatedCollectionCount,
requirePallets,
- Pallets
+ Pallets,
} from './util/helpers';
chai.use(chaiAsPromised);
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -28,7 +28,7 @@
import {hexToStr, strToUTF16, utf16ToStr} from './util';
import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';
import {UpDataStructsTokenChild} from '../interfaces';
-import { Context } from 'mocha';
+import {Context} from 'mocha';
chai.use(chaiAsPromised);
const expect = chai.expect;