git.delta.rocks / unique-network / refs/commits / 698c51fd21a7

difftreelog

fix move RMRK needed parts of deprecated helpers

Daniel Shiposha2022-10-11parent: #681fe40.patch.diff
in: master

20 files changed

modifiedtests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth
7 acceptNft,7 acceptNft,
8} from './util/tx';8} from './util/tx';
9import {NftIdTuple} from './util/fetch';9import {NftIdTuple} from './util/fetch';
10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';10import {isNftChildOfAnother, expectTxFailure, requirePallets, Pallets} from './util/helpers';
11import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
1211
13describe('integration test: accept NFT', () => {12describe('integration test: accept NFT', () => {
14 let api: any;13 let api: any;
modifiedtests/src/rmrk/addResource.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import {NftIdTuple} from './util/fetch';3import {NftIdTuple} from './util/fetch';
4import {expectTxFailure, getResourceById} from './util/helpers';4import {expectTxFailure, getResourceById, requirePallets, Pallets} from './util/helpers';
5import {5import {
6 addNftBasicResource,6 addNftBasicResource,
7 acceptNftResource,7 acceptNftResource,
12 addNftComposableResource,12 addNftComposableResource,
13} from './util/tx';13} from './util/tx';
14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';
15import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
1615
17describe('integration test: add NFT resource', () => {16describe('integration test: add NFT resource', () => {
18 const Alice = '//Alice';17 const Alice = '//Alice';
modifiedtests/src/rmrk/addTheme.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import {createBase, addTheme} from './util/tx';3import {createBase, addTheme} from './util/tx';
4import {expectTxFailure} from './util/helpers';4import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
5import {getThemeNames} from './util/fetch';5import {getThemeNames} from './util/fetch';
6import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
76
8describe('integration test: add Theme to Base', () => {7describe('integration test: add Theme to Base', () => {
9 let api: any;8 let api: any;
modifiedtests/src/rmrk/burnNft.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {expectTxFailure} from './util/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {NftIdTuple, getChildren} from './util/fetch';3import {NftIdTuple, getChildren} from './util/fetch';
4import {burnNft, createCollection, sendNft, mintNft} from './util/tx';4import {burnNft, createCollection, sendNft, mintNft} from './util/tx';
55
6import chai from 'chai';6import chai from 'chai';
7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';
8import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
98
10chai.use(chaiAsPromised);9chai.use(chaiAsPromised);
11const expect = chai.expect;10const expect = chai.expect;
modifiedtests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {expectTxFailure} from './util/helpers';
4import {3import {
5 changeIssuer,4 changeIssuer,
6 createCollection,5 createCollection,
modifiedtests/src/rmrk/createBase.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {requirePallets, Pallets} from './util/helpers';
3import {createCollection, createBase} from './util/tx';3import {createCollection, createBase} from './util/tx';
44
5describe('integration test: create new Base', () => {5describe('integration test: create new Base', () => {
modifiedtests/src/rmrk/createCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {requirePallets, Pallets} from './util/helpers';
3import {createCollection} from './util/tx';3import {createCollection} from './util/tx';
44
5describe('Integration test: create new collection', () => {5describe('Integration test: create new collection', () => {
modifiedtests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {expectTxFailure} from './util/helpers';
4import {createCollection, deleteCollection} from './util/tx';3import {createCollection, deleteCollection} from './util/tx';
54
6describe('integration test: delete collection', () => {5describe('integration test: delete collection', () => {
modifiedtests/src/rmrk/equipNft.test.tsdiffbeforeafterboth
1import {ApiPromise} from '@polkadot/api';1import {ApiPromise} from '@polkadot/api';
2import {expect} from 'chai';2import {expect} from 'chai';
3import {getApiConnection} from '../substrate/substrate-api';3import {getApiConnection} from '../substrate/substrate-api';
4import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
5import {getNft, getParts, NftIdTuple} from './util/fetch';4import {getNft, getParts, NftIdTuple} from './util/fetch';
6import {expectTxFailure} from './util/helpers';5import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
7import {6import {
8 addNftComposableResource,7 addNftComposableResource,
9 addNftSlotResource,8 addNftSlotResource,
modifiedtests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {requirePallets, Pallets} from './util/helpers';
4import {getOwnedNfts} from './util/fetch';4import {getOwnedNfts} from './util/fetch';
5import {mintNft, createCollection} from './util/tx';5import {mintNft, createCollection} from './util/tx';
66
modifiedtests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {expectTxFailure} from './util/helpers';
4import {createCollection, lockCollection, mintNft} from './util/tx';3import {createCollection, lockCollection, mintNft} from './util/tx';
54
6describe('integration test: lock collection', () => {5describe('integration test: lock collection', () => {
modifiedtests/src/rmrk/mintNft.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
4import {getNft} from './util/fetch';3import {getNft} from './util/fetch';
5import {expectTxFailure} from './util/helpers';4import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
6import {createCollection, mintNft} from './util/tx';5import {createCollection, mintNft} from './util/tx';
76
8describe('integration test: mint new NFT', () => {7describe('integration test: mint new NFT', () => {
modifiedtests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth
7 rejectNft,7 rejectNft,
8} from './util/tx';8} from './util/tx';
9import {getChildren, NftIdTuple} from './util/fetch';9import {getChildren, NftIdTuple} from './util/fetch';
10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';10import {isNftChildOfAnother, expectTxFailure, requirePallets, Pallets} from './util/helpers';
11import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
1211
13describe('integration test: reject NFT', () => {12describe('integration test: reject NFT', () => {
14 let api: any;13 let api: any;
modifiedtests/src/rmrk/removeResource.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import privateKey from '../substrate/privateKey';2import privateKey from '../substrate/privateKey';
3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';
4import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
5import {getNft, NftIdTuple} from './util/fetch';4import {getNft, NftIdTuple} from './util/fetch';
6import {expectTxFailure} from './util/helpers';5import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
7import {6import {
8 acceptNft, acceptResourceRemoval, addNftBasicResource,7 acceptNft, acceptResourceRemoval, addNftBasicResource,
9 createBase,8 createBase,
modifiedtests/src/rmrk/sendNft.test.tsdiffbeforeafterboth
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import {createCollection, mintNft, sendNft} from './util/tx';3import {createCollection, mintNft, sendNft} from './util/tx';
4import {NftIdTuple} from './util/fetch';4import {NftIdTuple} from './util/fetch';
5import {isNftChildOfAnother, expectTxFailure} from './util/helpers';5import {isNftChildOfAnother, expectTxFailure, requirePallets, Pallets} from './util/helpers';
6import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
76
8describe('integration test: send NFT', () => {7describe('integration test: send NFT', () => {
9 let api: any;8 let api: any;
modifiedtests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {expectTxFailure} from './util/helpers';
4import {createCollection, setPropertyCollection} from './util/tx';3import {createCollection, setPropertyCollection} from './util/tx';
54
6describe('integration test: set collection property', () => {5describe('integration test: set collection property', () => {
modifiedtests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {expectTxFailure} from './util/helpers';
4import {createCollection, createBase, setEquippableList} from './util/tx';3import {createCollection, createBase, setEquippableList} from './util/tx';
54
6describe("integration test: set slot's Equippable List", () => {5describe("integration test: set slot's Equippable List", () => {
modifiedtests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';
3import {NftIdTuple} from './util/fetch';2import {NftIdTuple} from './util/fetch';
4import {expectTxFailure} from './util/helpers';3import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
5import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';4import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';
65
7describe('integration test: set NFT property', () => {6describe('integration test: set NFT property', () => {
modifiedtests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';
3import {expectTxFailure} from './util/helpers';
4import {mintNft, createCollection, setResourcePriorities} from './util/tx';3import {mintNft, createCollection, setResourcePriorities} from './util/tx';
54
6describe('integration test: set NFT resource priorities', () => {5describe('integration test: set NFT resource priorities', () => {
modifiedtests/src/rmrk/util/helpers.tsdiffbeforeafterboth
10import {NftIdTuple, getChildren, getOwnedNfts, getCollectionProperties, getNftProperties, getResources} from './fetch';10import {NftIdTuple, getChildren, getOwnedNfts, getCollectionProperties, getNftProperties, getResources} from './fetch';
11import chaiAsPromised from 'chai-as-promised';11import chaiAsPromised from 'chai-as-promised';
12import chai from 'chai';12import chai from 'chai';
13import {getApiConnection} from '../../substrate/substrate-api';
14import {Context} from 'mocha';
1315
14chai.use(chaiAsPromised);16chai.use(chaiAsPromised);
15const expect = chai.expect;17const expect = chai.expect;
19 successData: T | null;21 successData: T | null;
20}22}
23
24export enum Pallets {
25 Inflation = 'inflation',
26 RmrkCore = 'rmrkcore',
27 RmrkEquip = 'rmrkequip',
28 ReFungible = 'refungible',
29 Fungible = 'fungible',
30 NFT = 'nonfungible',
31 Scheduler = 'scheduler',
32 AppPromotion = 'apppromotion',
33}
34
35let modulesNames: any;
36export function getModuleNames(api: ApiPromise): string[] {
37 if (typeof modulesNames === 'undefined')
38 modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());
39 return modulesNames;
40}
41
42export async function missingRequiredPallets(requiredPallets: string[]): Promise<string[]> {
43 const api = await getApiConnection();
44 const pallets = getModuleNames(api);
45
46 return requiredPallets.filter(p => !pallets.includes(p));
47}
48
49export async function requirePallets(mocha: Context, requiredPallets: string[]) {
50 const missingPallets = await missingRequiredPallets(requiredPallets);
51
52 if (missingPallets.length > 0) {
53 const skippingTestMsg = `\tSkipping test "${mocha.test?.title}".`;
54 const missingPalletsMsg = `\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;
55 const skipMsg = `${skippingTestMsg}\n${missingPalletsMsg}`;
56
57 console.error('\x1b[38:5:208m%s\x1b[0m', skipMsg);
58
59 mocha.skip();
60 }
61}
2162
22export function makeNftOwner(api: ApiPromise, owner: string | NftIdTuple): NftOwner {63export function makeNftOwner(api: ApiPromise, owner: string | NftIdTuple): NftOwner {
23 const isNftSending = (typeof owner !== 'string');64 const isNftSending = (typeof owner !== 'string');