difftreelog
fix move RMRK needed parts of deprecated helpers
in: master
20 files changed
tests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth7 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';121113describe('integration test: accept NFT', () => {12describe('integration test: accept NFT', () => {14 let api: any;13 let api: any;tests/src/rmrk/addResource.test.tsdiffbeforeafterboth1import {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';161517describe('integration test: add NFT resource', () => {16describe('integration test: add NFT resource', () => {18 const Alice = '//Alice';17 const Alice = '//Alice';tests/src/rmrk/addTheme.test.tsdiffbeforeafterboth1import {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';768describe('integration test: add Theme to Base', () => {7describe('integration test: add Theme to Base', () => {9 let api: any;8 let api: any;tests/src/rmrk/burnNft.test.tsdiffbeforeafterboth1import {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';556import 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';9810chai.use(chaiAsPromised);9chai.use(chaiAsPromised);11const expect = chai.expect;10const expect = chai.expect;tests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth1import {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,tests/src/rmrk/createBase.test.tsdiffbeforeafterboth1import {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';445describe('integration test: create new Base', () => {5describe('integration test: create new Base', () => {tests/src/rmrk/createCollection.test.tsdiffbeforeafterboth1import {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';445describe('Integration test: create new collection', () => {5describe('Integration test: create new collection', () => {tests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth1import {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';546describe('integration test: delete collection', () => {5describe('integration test: delete collection', () => {tests/src/rmrk/equipNft.test.tsdiffbeforeafterboth1import {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,tests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth1import {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';66tests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth1import {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';546describe('integration test: lock collection', () => {5describe('integration test: lock collection', () => {tests/src/rmrk/mintNft.test.tsdiffbeforeafterboth1import {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';768describe('integration test: mint new NFT', () => {7describe('integration test: mint new NFT', () => {tests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth7 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';121113describe('integration test: reject NFT', () => {12describe('integration test: reject NFT', () => {14 let api: any;13 let api: any;tests/src/rmrk/removeResource.test.tsdiffbeforeafterboth1import {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,tests/src/rmrk/sendNft.test.tsdiffbeforeafterboth2import {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';768describe('integration test: send NFT', () => {7describe('integration test: send NFT', () => {9 let api: any;8 let api: any;tests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth1import {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';546describe('integration test: set collection property', () => {5describe('integration test: set collection property', () => {tests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth1import {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';546describe("integration test: set slot's Equippable List", () => {5describe("integration test: set slot's Equippable List", () => {tests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth1import {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';657describe('integration test: set NFT property', () => {6describe('integration test: set NFT property', () => {tests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth1import {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';546describe('integration test: set NFT resource priorities', () => {5describe('integration test: set NFT resource priorities', () => {tests/src/rmrk/util/helpers.tsdiffbeforeafterboth10import {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';131514chai.use(chaiAsPromised);16chai.use(chaiAsPromised);15const expect = chai.expect;17const expect = chai.expect;19 successData: T | null;21 successData: T | null;20}22}2324export 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}3435let 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}4142export async function missingRequiredPallets(requiredPallets: string[]): Promise<string[]> {43 const api = await getApiConnection();44 const pallets = getModuleNames(api);4546 return requiredPallets.filter(p => !pallets.includes(p));47}4849export async function requirePallets(mocha: Context, requiredPallets: string[]) {50 const missingPallets = await missingRequiredPallets(requiredPallets);5152 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}`;5657 console.error('\x1b[38:5:208m%s\x1b[0m', skipMsg);5859 mocha.skip();60 }61}216222export 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');