difftreelog
Merge pull request #632 from UniqueNetwork/tests/playgrounds-cleanup
in: master
Tests/playgrounds cleanup
69 files changed
tests/src/.outdated/addToContractAllowList.test.tsdiffbeforeafterboth17import chai from 'chai';17import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';18import chaiAsPromised from 'chai-as-promised';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';19import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';20import {20import {deployFlipper} from '../deprecated-helpers/contracthelpers';21 deployFlipper,22} from '../util/contracthelpers';23import {21import {getGenericResult} from '../deprecated-helpers/helpers';24 getGenericResult,25} from '../util/helpers';262227chai.use(chaiAsPromised);23chai.use(chaiAsPromised);28const expect = chai.expect;24const expect = chai.expect;tests/src/.outdated/contracts.test.tsdiffbeforeafterboth19import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';19import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';20import fs from 'fs';20import fs from 'fs';21import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';21import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';22import {22import {deployFlipper, getFlipValue, deployTransferContract} from '../deprecated-helpers/contracthelpers';23 deployFlipper,24 getFlipValue,25 deployTransferContract,26} from '../util/contracthelpers';272328import {24import {29 addToAllowListExpectSuccess,25 addToAllowListExpectSuccess,37 isAllowlisted,33 isAllowlisted,38 transferFromExpectSuccess,34 transferFromExpectSuccess,39 getTokenOwner,35 getTokenOwner,40} from '../util/helpers';36} from '../deprecated-helpers/helpers';4137423843chai.use(chaiAsPromised);39chai.use(chaiAsPromised);tests/src/.outdated/enableContractSponsoring.test.tsdiffbeforeafterboth18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import usingApi from '../substrate/substrate-api';20import usingApi from '../substrate/substrate-api';21import {deployFlipper, getFlipValue, toggleFlipValueExpectSuccess} from '../util/contracthelpers';21import {deployFlipper, getFlipValue, toggleFlipValueExpectSuccess} from '../deprecated-helpers/contracthelpers';22import {22import {23 enableContractSponsoringExpectFailure,23 enableContractSponsoringExpectFailure,24 enableContractSponsoringExpectSuccess,24 enableContractSponsoringExpectSuccess,25 findUnusedAddress,25 findUnusedAddress,26 setContractSponsoringRateLimitExpectSuccess,26 setContractSponsoringRateLimitExpectSuccess,27} from '../util/helpers';27} from '../deprecated-helpers/helpers';282829chai.use(chaiAsPromised);29chai.use(chaiAsPromised);30const expect = chai.expect;30const expect = chai.expect;tests/src/.outdated/eth/scheduling.test.tsdiffbeforeafterbothno changes
tests/src/.outdated/overflow.test.tsdiffbeforeafterboth18import chai from 'chai';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';19import chaiAsPromised from 'chai-as-promised';20import usingApi from '../substrate/substrate-api';20import usingApi from '../substrate/substrate-api';21import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from '../util/helpers';21import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from '../deprecated-helpers/helpers';222223chai.use(chaiAsPromised);23chai.use(chaiAsPromised);24const expect = chai.expect;24const expect = chai.expect;tests/src/.outdated/removeFromContractAllowList.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import usingApi from '../substrate/substrate-api';17import usingApi from '../substrate/substrate-api';18import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from '../util/contracthelpers';18import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from '../deprecated-helpers/contracthelpers';19import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from '../util/helpers';19import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from '../deprecated-helpers/helpers';20import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';21import {expect} from 'chai';21import {expect} from 'chai';2222tests/src/.outdated/scheduler.test.tsdiffbeforeafterboth39 getFreeBalance,39 getFreeBalance,40 confirmSponsorshipByKeyExpectSuccess,40 confirmSponsorshipByKeyExpectSuccess,41 scheduleExpectFailure,41 scheduleExpectFailure,42} from '../util/helpers';42} from '../deprecated-helpers/helpers';43import {IKeyringPair} from '@polkadot/types/types';43import {IKeyringPair} from '@polkadot/types/types';444445chai.use(chaiAsPromised);45chai.use(chaiAsPromised);tests/src/.outdated/setChainLimits.test.tsdiffbeforeafterboth21 addCollectionAdminExpectSuccess,21 addCollectionAdminExpectSuccess,22 setChainLimitsExpectFailure,22 setChainLimitsExpectFailure,23 IChainLimits,23 IChainLimits,24} from '../util/helpers';24} from '../deprecated-helpers/helpers';252526// todo:playgrounds skipped ~ postponed26// todo:playgrounds skipped ~ postponed27describe.skip('Negative Integration Test setChainLimits', () => {27describe.skip('Negative Integration Test setChainLimits', () => {tests/src/.outdated/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import usingApi from '../substrate/substrate-api';18import usingApi from '../substrate/substrate-api';19import waitNewBlocks from '../substrate/wait-new-blocks';19import waitNewBlocks from '../substrate/wait-new-blocks';20import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from '../util/contracthelpers';20import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from '../deprecated-helpers/contracthelpers';21import {21import {22 enableContractSponsoringExpectSuccess,22 enableContractSponsoringExpectSuccess,23 findUnusedAddress,23 findUnusedAddress,24 setContractSponsoringRateLimitExpectFailure,24 setContractSponsoringRateLimitExpectFailure,25 setContractSponsoringRateLimitExpectSuccess,25 setContractSponsoringRateLimitExpectSuccess,26} from '../util/helpers';26} from '../deprecated-helpers/helpers';272728// todo:playgrounds skipped~postponed test28// todo:playgrounds skipped~postponed test29describe.skip('Integration Test setContractSponsoringRateLimit', () => {29describe.skip('Integration Test setContractSponsoringRateLimit', () => {tests/src/.outdated/toggleContractAllowList.test.tsdiffbeforeafterboth20import {20import {21 deployFlipper,21 deployFlipper,22 getFlipValue,22 getFlipValue,23} from '../util/contracthelpers';23} from '../deprecated-helpers/contracthelpers';24import {24import {25 getGenericResult,25 getGenericResult,26} from '../util/helpers';26} from '../deprecated-helpers/helpers';272728chai.use(chaiAsPromised);28chai.use(chaiAsPromised);29const expect = chai.expect;29const expect = chai.expect;tests/src/.outdated/xcmTransfer.test.tsdiffbeforeafterboth21import {ApiOptions} from '@polkadot/api/types';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {getGenericResult} from '../util/helpers';24import {getGenericResult} from '../deprecated-helpers/helpers';25import waitNewBlocks from '../substrate/wait-new-blocks';25import waitNewBlocks from '../substrate/wait-new-blocks';26import getBalance from '../substrate/get-balance';26import getBalance from '../substrate/get-balance';2727tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth110 const [alice, ...accounts] = await helper.arrange.createAccounts([10n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], donor);110 const [alice, ...accounts] = await helper.arrange.createAccounts([10n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], donor);111 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});111 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});112112113 const chainAdminLimit = (helper.api!.consts.common.collectionAdminsLimit as any).toNumber();113 const chainAdminLimit = (helper.getApi().consts.common.collectionAdminsLimit as any).toNumber();114 expect(chainAdminLimit).to.be.equal(5);114 expect(chainAdminLimit).to.be.equal(5);115115116 for (let i = 0; i < chainAdminLimit; i++) {116 for (let i = 0; i < chainAdminLimit; i++) {tests/src/app-promotion.test.tsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import {18import {itSub, usingPlaygrounds, Pallets, requirePalletsOrSkip} from './util/playgrounds';19 normalizeAccountId,20 getModuleNames,21 Pallets,22} from './util/helpers';23import {itSub, usingPlaygrounds} from './util/playgrounds';24import {encodeAddress} from '@polkadot/util-crypto';19import {encodeAddress} from '@polkadot/util-crypto';25import {stringToU8a} from '@polkadot/util';20import {stringToU8a} from '@polkadot/util';26import {SponsoringMode} from './eth/util/helpers';27import {DevUniqueHelper} from './util/playgrounds/unique.dev';21import {DevUniqueHelper} from './util/playgrounds/unique.dev';28import {itEth, expect} from './eth/util/playgrounds';22import {itEth, expect, SponsoringMode} from './eth/util/playgrounds';292330let alice: IKeyringPair;24let alice: IKeyringPair;31let palletAdmin: IKeyringPair;25let palletAdmin: IKeyringPair;42describe('App promotion', () => {36describe('App promotion', () => {43 before(async function () {37 before(async function () {44 await usingPlaygrounds(async (helper, privateKey) => {38 await usingPlaygrounds(async (helper, privateKey) => {45 if (!getModuleNames(helper.api!).includes(Pallets.AppPromotion)) this.skip();39 requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);46 alice = privateKey('//Alice');40 alice = privateKey('//Alice');47 palletAdmin = privateKey('//Charlie'); // TODO use custom address41 palletAdmin = privateKey('//Charlie'); // TODO use custom address48 await helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));42 const api = helper.getApi();43 await helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));49 nominal = helper.balance.getOneTokenNominal();44 nominal = helper.balance.getOneTokenNominal();50 await helper.balance.transferToSubstrate(alice, palletAdmin.address, 1000n * nominal);45 await helper.balance.transferToSubstrate(alice, palletAdmin.address, 1000n * nominal);51 await helper.balance.transferToSubstrate(alice, palletAddress, 1000n * nominal);46 await helper.balance.transferToSubstrate(alice, palletAddress, 1000n * nominal);231 226 232 describe('admin adress', () => {227 describe('admin adress', () => {233 itSub('can be set by sudo only', async ({helper}) => {228 itSub('can be set by sudo only', async ({helper}) => {229 const api = helper.getApi();234 const nonAdmin = accounts.pop()!;230 const nonAdmin = accounts.pop()!;235 // nonAdmin can not set admin not from himself nor as a sudo231 // nonAdmin can not set admin not from himself nor as a sudo236 await expect(helper.signTransaction(nonAdmin, helper.api!.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address}))).to.be.rejected;232 await expect(helper.signTransaction(nonAdmin, api.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address}))).to.be.rejected;237 await expect(helper.signTransaction(nonAdmin, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address})))).to.be.rejected;233 await expect(helper.signTransaction(nonAdmin, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: nonAdmin.address})))).to.be.rejected;238 234 239 // Alice can235 // Alice can240 await expect(helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})))).to.be.fulfilled;236 await expect(helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})))).to.be.fulfilled;241 });237 });242 238 243 itSub('can be any valid CrossAccountId', async ({helper}) => {239 itSub('can be any valid CrossAccountId', async ({helper}) => {244 // We are not going to set an eth address as a sponsor,240 // We are not going to set an eth address as a sponsor,245 // but we do want to check, it doesn't break anything;241 // but we do want to check, it doesn't break anything;242 const api = helper.getApi();246 const account = accounts.pop()!;243 const account = accounts.pop()!;247 const ethAccount = helper.address.substrateToEth(account.address); 244 const ethAccount = helper.address.substrateToEth(account.address); 248 // Alice sets Ethereum address as a sudo. Then Substrate address back...245 // Alice sets Ethereum address as a sudo. Then Substrate address back...249 await expect(helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Ethereum: ethAccount})))).to.be.fulfilled;246 await expect(helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Ethereum: ethAccount})))).to.be.fulfilled;250 await expect(helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})))).to.be.fulfilled;247 await expect(helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})))).to.be.fulfilled;251 248 252 // ...It doesn't break anything;249 // ...It doesn't break anything;253 const collection = await helper.nft.mintCollection(account, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});250 const collection = await helper.nft.mintCollection(account, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});254 await expect(helper.signTransaction(account, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;251 await expect(helper.signTransaction(account, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;255 });252 });256 253 257 itSub('can be reassigned', async ({helper}) => {254 itSub('can be reassigned', async ({helper}) => {255 const api = helper.getApi();258 const [oldAdmin, newAdmin, collectionOwner] = [accounts.pop()!, accounts.pop()!, accounts.pop()!];256 const [oldAdmin, newAdmin, collectionOwner] = [accounts.pop()!, accounts.pop()!, accounts.pop()!];259 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});257 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});260 258 261 await expect(helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress(normalizeAccountId(oldAdmin))))).to.be.fulfilled;259 await expect(helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: oldAdmin.address})))).to.be.fulfilled;262 await expect(helper.signTransaction(alice, helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress(normalizeAccountId(newAdmin))))).to.be.fulfilled;260 await expect(helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: newAdmin.address})))).to.be.fulfilled;263 await expect(helper.signTransaction(oldAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;261 await expect(helper.signTransaction(oldAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;264 262 265 await expect(helper.signTransaction(newAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;263 await expect(helper.signTransaction(newAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;266 });264 });267 });265 });268 266 269 describe('collection sponsoring', () => {267 describe('collection sponsoring', () => {270 before(async function () {268 before(async function () {271 await usingPlaygrounds(async (helper) => {269 await usingPlaygrounds(async (helper) => {272 const tx = helper.api!.tx.sudo.sudo(helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address}));270 const api = helper.getApi();271 const tx = api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address}));273 await helper.signTransaction(alice, tx);272 await helper.signTransaction(alice, tx);274 });273 });275 });274 });276 275 277 itSub('should actually sponsor transactions', async ({helper}) => {276 itSub('should actually sponsor transactions', async ({helper}) => {277 const api = helper.getApi();278 const [collectionOwner, tokenSender, receiver] = [accounts.pop()!, accounts.pop()!, accounts.pop()!];278 const [collectionOwner, tokenSender, receiver] = [accounts.pop()!, accounts.pop()!, accounts.pop()!];279 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'Name', description: 'Description', tokenPrefix: 'Prefix', limits: {sponsorTransferTimeout: 0}});279 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'Name', description: 'Description', tokenPrefix: 'Prefix', limits: {sponsorTransferTimeout: 0}});280 const token = await collection.mintToken(collectionOwner, {Substrate: tokenSender.address});280 const token = await collection.mintToken(collectionOwner, {Substrate: tokenSender.address});281 await helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId));281 await helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId));282 const palletBalanceBefore = await helper.balance.getSubstrate(palletAddress);282 const palletBalanceBefore = await helper.balance.getSubstrate(palletAddress);283 283 284 await token.transfer(tokenSender, {Substrate: receiver.address});284 await token.transfer(tokenSender, {Substrate: receiver.address});291 });291 });292 292 293 itSub('can not be set by non admin', async ({helper}) => {293 itSub('can not be set by non admin', async ({helper}) => {294 const api = helper.getApi();294 const [collectionOwner, nonAdmin] = [accounts.pop()!, accounts.pop()!];295 const [collectionOwner, nonAdmin] = [accounts.pop()!, accounts.pop()!];295 296 296 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});297 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});297 298 298 await expect(helper.signTransaction(nonAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;299 await expect(helper.signTransaction(nonAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;299 expect((await collection.getData())?.raw.sponsorship).to.equal('Disabled');300 expect((await collection.getData())?.raw.sponsorship).to.equal('Disabled');300 });301 });301 302 302 itSub('should set pallet address as confirmed admin', async ({helper}) => {303 itSub('should set pallet address as confirmed admin', async ({helper}) => {304 const api = helper.getApi();303 const [collectionOwner, oldSponsor] = [accounts.pop()!, accounts.pop()!];305 const [collectionOwner, oldSponsor] = [accounts.pop()!, accounts.pop()!];304 306 305 // Can set sponsoring for collection without sponsor307 // Can set sponsoring for collection without sponsor306 const collectionWithoutSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'No-sponsor', description: 'New Collection', tokenPrefix: 'Promotion'});308 const collectionWithoutSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'No-sponsor', description: 'New Collection', tokenPrefix: 'Promotion'});307 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collectionWithoutSponsor.collectionId))).to.be.fulfilled;309 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionWithoutSponsor.collectionId))).to.be.fulfilled;308 expect((await collectionWithoutSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});310 expect((await collectionWithoutSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});309 311 310 // Can set sponsoring for collection with unconfirmed sponsor312 // Can set sponsoring for collection with unconfirmed sponsor311 const collectionWithUnconfirmedSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'Unconfirmed', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: oldSponsor.address});313 const collectionWithUnconfirmedSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'Unconfirmed', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: oldSponsor.address});312 expect((await collectionWithUnconfirmedSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Unconfirmed: oldSponsor.address});314 expect((await collectionWithUnconfirmedSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Unconfirmed: oldSponsor.address});313 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collectionWithUnconfirmedSponsor.collectionId))).to.be.fulfilled;315 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionWithUnconfirmedSponsor.collectionId))).to.be.fulfilled;314 expect((await collectionWithUnconfirmedSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});316 expect((await collectionWithUnconfirmedSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});315 317 316 // Can set sponsoring for collection with confirmed sponsor318 // Can set sponsoring for collection with confirmed sponsor317 const collectionWithConfirmedSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'Confirmed', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: oldSponsor.address});319 const collectionWithConfirmedSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'Confirmed', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: oldSponsor.address});318 await collectionWithConfirmedSponsor.confirmSponsorship(oldSponsor);320 await collectionWithConfirmedSponsor.confirmSponsorship(oldSponsor);319 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collectionWithConfirmedSponsor.collectionId))).to.be.fulfilled;321 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionWithConfirmedSponsor.collectionId))).to.be.fulfilled;320 expect((await collectionWithConfirmedSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});322 expect((await collectionWithConfirmedSponsor.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});321 });323 });322 324 323 itSub('can be overwritten by collection owner', async ({helper}) => { 325 itSub('can be overwritten by collection owner', async ({helper}) => { 326 const api = helper.getApi();324 const [collectionOwner, newSponsor] = [accounts.pop()!, accounts.pop()!];327 const [collectionOwner, newSponsor] = [accounts.pop()!, accounts.pop()!];325 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});328 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});326 const collectionId = collection.collectionId;329 const collectionId = collection.collectionId;327 330 328 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collectionId))).to.be.fulfilled;331 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionId))).to.be.fulfilled;329 332 330 // Collection limits still can be changed by the owner333 // Collection limits still can be changed by the owner331 expect(await collection.setLimits(collectionOwner, {sponsorTransferTimeout: 0})).to.be.true;334 expect(await collection.setLimits(collectionOwner, {sponsorTransferTimeout: 0})).to.be.true;338 });341 });339 342 340 itSub('should not overwrite collection limits set by the owner earlier', async ({helper}) => {343 itSub('should not overwrite collection limits set by the owner earlier', async ({helper}) => {344 const api = helper.getApi();341 const limits = {ownerCanDestroy: true, ownerCanTransfer: true, sponsorTransferTimeout: 0};345 const limits = {ownerCanDestroy: true, ownerCanTransfer: true, sponsorTransferTimeout: 0};342 const collectionWithLimits = await helper.nft.mintCollection(alice, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits});346 const collectionWithLimits = await helper.nft.mintCollection(alice, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits});343 347 344 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collectionWithLimits.collectionId))).to.be.fulfilled;348 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionWithLimits.collectionId))).to.be.fulfilled;345 expect((await collectionWithLimits.getData())?.raw.limits).to.be.deep.contain(limits);349 expect((await collectionWithLimits.getData())?.raw.limits).to.be.deep.contain(limits);346 });350 });347 351 348 itSub('should reject transaction if collection doesn\'t exist', async ({helper}) => {352 itSub('should reject transaction if collection doesn\'t exist', async ({helper}) => {353 const api = helper.getApi();349 const collectionOwner = accounts.pop()!;354 const collectionOwner = accounts.pop()!;350 355 351 // collection has never existed356 // collection has never existed352 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(999999999))).to.be.rejected;357 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(999999999))).to.be.rejected;353 // collection has been burned358 // collection has been burned354 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});359 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});355 await collection.burn(collectionOwner);360 await collection.burn(collectionOwner);356 361 357 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;362 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.rejected;358 });363 });359 });364 });360 365 361 describe('stopSponsoringCollection', () => {366 describe('stopSponsoringCollection', () => {362 itSub('can not be called by non-admin', async ({helper}) => { 367 itSub('can not be called by non-admin', async ({helper}) => {368 const api = helper.getApi();363 const [collectionOwner, nonAdmin] = [accounts.pop()!, accounts.pop()!];369 const [collectionOwner, nonAdmin] = [accounts.pop()!, accounts.pop()!];364 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});370 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});365 371 366 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;372 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;367 373 368 await expect(helper.signTransaction(nonAdmin, helper.api!.tx.appPromotion.stopSponsoringCollection(collection.collectionId))).to.be.rejected;374 await expect(helper.signTransaction(nonAdmin, api.tx.appPromotion.stopSponsoringCollection(collection.collectionId))).to.be.rejected;369 expect((await collection.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});375 expect((await collection.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: palletAddress});370 });376 });371 377 372 itSub('should set sponsoring as disabled', async ({helper}) => {378 itSub('should set sponsoring as disabled', async ({helper}) => {379 const api = helper.getApi();373 const [collectionOwner, recepient] = [accounts.pop()!, accounts.pop()!];380 const [collectionOwner, recepient] = [accounts.pop()!, accounts.pop()!];374 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits: {sponsorTransferTimeout: 0}});381 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits: {sponsorTransferTimeout: 0}});375 const token = await collection.mintToken(collectionOwner, {Substrate: collectionOwner.address});382 const token = await collection.mintToken(collectionOwner, {Substrate: collectionOwner.address});376 383 377 await helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorCollection(collection.collectionId));384 await helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId));378 await helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.stopSponsoringCollection(collection.collectionId));385 await helper.signTransaction(palletAdmin, api.tx.appPromotion.stopSponsoringCollection(collection.collectionId));379 386 380 expect((await collection.getData())?.raw.sponsorship).to.be.equal('Disabled');387 expect((await collection.getData())?.raw.sponsorship).to.be.equal('Disabled');381 388 387 });394 });388 395 389 itSub('should not affect collection which is not sponsored by pallete', async ({helper}) => {396 itSub('should not affect collection which is not sponsored by pallete', async ({helper}) => {397 const api = helper.getApi();390 const collectionOwner = accounts.pop()!;398 const collectionOwner = accounts.pop()!;391 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: collectionOwner.address});399 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: collectionOwner.address});392 await collection.confirmSponsorship(collectionOwner);400 await collection.confirmSponsorship(collectionOwner);393 401 394 await expect(helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.stopSponsoringCollection(collection.collectionId))).to.be.rejected;402 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.stopSponsoringCollection(collection.collectionId))).to.be.rejected;395 403 396 expect((await collection.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: collectionOwner.address});404 expect((await collection.getData())?.raw.sponsorship).to.be.deep.equal({Confirmed: collectionOwner.address});397 });405 });415 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address]);423 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address]);416 424 417 expect(await contractHelper.methods.hasSponsor(flipper.options.address).call()).to.be.true; 425 expect(await contractHelper.methods.hasSponsor(flipper.options.address).call()).to.be.true; 418 expect((await helper.api!.query.evmContractHelpers.owner(flipper.options.address)).toJSON()).to.be.equal(contractOwner); 426 expect((await helper.callRpc('api.query.evmContractHelpers.owner', [flipper.options.address])).toJSON()).to.be.equal(contractOwner); 419 expect((await helper.api!.query.evmContractHelpers.sponsoring(flipper.options.address)).toJSON()).to.deep.equal({427 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.deep.equal({420 confirmed: {428 confirmed: {421 substrate: palletAddress,429 substrate: palletAddress,422 },430 },431 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;439 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.fulfilled;432 440 433 // Contract is self sponsored441 // Contract is self sponsored434 expect((await helper.api!.query.evmContractHelpers.sponsoring(flipper.options.address)).toJSON()).to.be.deep.equal({442 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.be.deep.equal({435 confirmed: {443 confirmed: {436 ethereum: flipper.options.address.toLowerCase(),444 ethereum: flipper.options.address.toLowerCase(),437 },445 },462 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.not.rejected;470 await expect(contractHelper.methods.selfSponsoredEnable(flipper.options.address).send()).to.be.not.rejected;463 471 464 expect(await contractHelper.methods.hasSponsor(flipper.options.address).call()).to.be.true; 472 expect(await contractHelper.methods.hasSponsor(flipper.options.address).call()).to.be.true; 465 expect((await helper.api!.query.evmContractHelpers.owner(flipper.options.address)).toJSON()).to.be.equal(contractOwner); 473 expect((await helper.callRpc('api.query.evmContractHelpers.owner', [flipper.options.address])).toJSON()).to.be.equal(contractOwner); 466 expect((await helper.api!.query.evmContractHelpers.sponsoring(flipper.options.address)).toJSON()).to.deep.equal({474 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.deep.equal({467 confirmed: {475 confirmed: {468 ethereum: flipper.options.address.toLowerCase(),476 ethereum: flipper.options.address.toLowerCase(),469 },477 },482 await expect(helper.executeExtrinsic(nonAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true)).to.be.rejectedWith('appPromotion.NoPermission');490 await expect(helper.executeExtrinsic(nonAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true)).to.be.rejectedWith('appPromotion.NoPermission');483 491 484 // contract still self-sponsored 492 // contract still self-sponsored 485 expect((await helper.api!.query.evmContractHelpers.sponsoring(flipper.options.address)).toJSON()).to.deep.equal({493 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.deep.equal({486 confirmed: {494 confirmed: {487 ethereum: flipper.options.address.toLowerCase(),495 ethereum: flipper.options.address.toLowerCase(),488 },496 },505 await helper.eth.transferBalanceFromSubstrate(alice, flipper.options.address, 1000n); // transferBalanceToEth(api, alice, flipper.options.address, 1000n);513 await helper.eth.transferBalanceFromSubstrate(alice, flipper.options.address, 1000n); // transferBalanceToEth(api, alice, flipper.options.address, 1000n);506 514 507 // Set promotion to the Flipper515 // Set promotion to the Flipper508 await helper.signTransaction(palletAdmin, helper.api!.tx.appPromotion.sponsorContract(flipper.options.address));516 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.sponsorContract', [flipper.options.address], true);509 517 510 // Caller calls Flipper518 // Caller calls Flipper511 await flipper.methods.flip().send({from: caller});519 await flipper.methods.flip().send({from: caller});536 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.stopSponsoringContract', [flipper.options.address], true);544 await helper.executeExtrinsic(palletAdmin, 'api.tx.appPromotion.stopSponsoringContract', [flipper.options.address], true);537 545 538 expect(await contractHelper.methods.hasSponsor(flipper.options.address).call()).to.be.false; 546 expect(await contractHelper.methods.hasSponsor(flipper.options.address).call()).to.be.false; 539 expect((await helper.api!.query.evmContractHelpers.owner(flipper.options.address)).toJSON()).to.be.equal(contractOwner); 547 expect((await helper.callRpc('api.query.evmContractHelpers.owner', [flipper.options.address])).toJSON()).to.be.equal(contractOwner); 540 expect((await helper.api!.query.evmContractHelpers.sponsoring(flipper.options.address)).toJSON()).to.deep.equal({548 expect((await helper.callRpc('api.query.evmContractHelpers.sponsoring', [flipper.options.address])).toJSON()).to.deep.equal({541 disabled: null,549 disabled: null,542 });550 });543 551 717// Wait while promotion period less than specified block, to avoid boundary cases725// Wait while promotion period less than specified block, to avoid boundary cases718// 0 if this should be the beginning of the period.726// 0 if this should be the beginning of the period.719async function waitPromotionPeriodDoesntEnd(helper: DevUniqueHelper, waitBlockLessThan = LOCKING_PERIOD / 3n) {727async function waitPromotionPeriodDoesntEnd(helper: DevUniqueHelper, waitBlockLessThan = LOCKING_PERIOD / 3n) {720 const relayBlockNumber = (await helper.api!.query.parachainSystem.validationData()).value.relayParentNumber.toNumber(); // await helper.chain.getLatestBlockNumber();728 const relayBlockNumber = (await helper.callRpc('api.query.parachainSystem.validationData', [])).value.relayParentNumber.toNumber(); // await helper.chain.getLatestBlockNumber();721 const currentPeriodBlock = BigInt(relayBlockNumber) % LOCKING_PERIOD;729 const currentPeriodBlock = BigInt(relayBlockNumber) % LOCKING_PERIOD;722730723 if (currentPeriodBlock > waitBlockLessThan) {731 if (currentPeriodBlock > waitBlockLessThan) {tests/src/approve.test.tsdiffbeforeafterboth60 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});60 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});61 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});61 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});62 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;62 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;63 await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));63 await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));64 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;64 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;65 });65 });6666275 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});275 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});276 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});276 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});277 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;277 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;278 await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));278 await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));279 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;279 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;280 const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});280 const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});281 await expect(transferTokenFromTx()).to.be.rejected;281 await expect(transferTokenFromTx()).to.be.rejected;328 itSub('1 for NFT', async ({helper}) => {328 itSub('1 for NFT', async ({helper}) => {329 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});329 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});330 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});330 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});331 const approveTx = async () => helper.signTransaction(bob, helper.api?.tx.unique.approve({Substrate: charlie.address}, collectionId, tokenId, 2));331 const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));332 await expect(approveTx()).to.be.rejected;332 await expect(approveTx()).to.be.rejected;333 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;333 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;334 });334 });tests/src/block-production.test.tsdiffbeforeafterboth373738describe('Block Production smoke test', () => {38describe('Block Production smoke test', () => {39 itSub('Node produces new blocks', async ({helper}) => {39 itSub('Node produces new blocks', async ({helper}) => {40 const blocks: number[] | undefined = await getBlocks(helper.api!);40 const blocks: number[] | undefined = await getBlocks(helper.getApi());41 expect(blocks[0]).to.be.lessThan(blocks[1]);41 expect(blocks[0]).to.be.lessThan(blocks[1]);42 });42 });43});43});tests/src/calibrate.tsdiffbeforeafterboth1import {ApiPromise} from '@polkadot/api';2import {IKeyringPair} from '@polkadot/types/types';1import {IKeyringPair} from '@polkadot/types/types';3import Web3 from 'web3';24import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, recordEthFee, usingWeb3} from './eth/util/helpers';3import {usingEthPlaygrounds, EthUniqueHelper} from './eth/util/playgrounds';5import usingApi, {executeTransaction} from './substrate/substrate-api';46import {createCollectionExpectSuccess, createItemExpectSuccess, transferExpectSuccess, UNIQUE, waitNewBlocks} from './util/helpers';7import nonFungibleAbi from './eth/nonFungibleAbi.json';859function linearRegression(points: { x: bigint, y: bigint }[]) {6function linearRegression(points: { x: bigint, y: bigint }[]) {10 let sumxy = 0n;7 let sumxy = 0n;59 }).reduce((a, b) => a + b, 0n) / BigInt(points.length));56 }).reduce((a, b) => a + b, 0n) / BigInt(points.length));60}57}615862async function calibrateWeightToFee(api: ApiPromise, privateKey: (account: string) => IKeyringPair) {59async function calibrateWeightToFee(helper: EthUniqueHelper, privateKey: (account: string) => IKeyringPair) {63 const alice = privateKey('//Alice');60 const alice = privateKey('//Alice');64 const bob = privateKey('//Bob');61 const bob = privateKey('//Bob');65 const dataPoints = [];62 const dataPoints = [];666367 {64 {68 const collectionId = await createCollectionExpectSuccess();65 const collection = await helper.nft.mintCollection(alice, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});69 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');66 const token = await collection.mintToken(alice, {Substrate: alice.address});70 const aliceBalanceBefore = (await api.query.system.account(alice.address)).data.free.toBigInt();67 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);71 await transferExpectSuccess(collectionId, tokenId, alice, bob, 1, 'NFT');68 await token.transfer(alice, {Substrate: bob.address});72 const aliceBalanceAfter = (await api.query.system.account(alice.address)).data.free.toBigInt();69 const aliceBalanceAfter = await helper.balance.getSubstrate(alice.address);737074 console.log(`Original price: ${Number(aliceBalanceBefore - aliceBalanceAfter) / Number(UNIQUE)} UNQ`);71 console.log(`Original price: ${Number(aliceBalanceBefore - aliceBalanceAfter) / Number(helper.balance.getOneTokenNominal())} UNQ`);75 }72 }767374 const api = helper.getApi();77 const defaultCoeff = (api.consts.configuration.defaultWeightToFeeCoefficient as any).toBigInt();75 const defaultCoeff = (api.consts.configuration.defaultWeightToFeeCoefficient as any).toBigInt();78 for (let i = -5; i < 5; i++) {76 for (let i = -5; i < 5; i++) {79 await executeTransaction(api, alice, api.tx.sudo.sudo(api.tx.configuration.setWeightToFeeCoefficientOverride(defaultCoeff + defaultCoeff / 1000n * BigInt(i))));77 await helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.configuration.setWeightToFeeCoefficientOverride(defaultCoeff + defaultCoeff / 1000n * BigInt(i))));807881 const coefficient = (await api.query.configuration.weightToFeeCoefficientOverride() as any).toBigInt();79 const coefficient = (await api.query.configuration.weightToFeeCoefficientOverride() as any).toBigInt();82 const collectionId = await createCollectionExpectSuccess();80 const collection = await helper.nft.mintCollection(alice, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});83 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');81 const token = await collection.mintToken(alice, {Substrate: alice.address});848285 const aliceBalanceBefore = (await api.query.system.account(alice.address)).data.free.toBigInt();83 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);86 await transferExpectSuccess(collectionId, tokenId, alice, bob, 1, 'NFT');84 await token.transfer(alice, {Substrate: bob.address});87 const aliceBalanceAfter = (await api.query.system.account(alice.address)).data.free.toBigInt();85 const aliceBalanceAfter = await helper.balance.getSubstrate(alice.address);888689 const transferPrice = aliceBalanceBefore - aliceBalanceAfter;87 const transferPrice = aliceBalanceBefore - aliceBalanceAfter;9088949295 // console.log(`Error: ${error(dataPoints, x => a*x+b)}`);93 // console.log(`Error: ${error(dataPoints, x => a*x+b)}`);969497 const perfectValue = a * UNIQUE / 10n + b;95 const perfectValue = a * helper.balance.getOneTokenNominal() / 10n + b;98 await executeTransaction(api, alice, api.tx.sudo.sudo(api.tx.configuration.setWeightToFeeCoefficientOverride(perfectValue.toString())));96 await helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.configuration.setWeightToFeeCoefficientOverride(perfectValue.toString())));9997100 {98 {101 const collectionId = await createCollectionExpectSuccess();99 const collection = await helper.nft.mintCollection(alice, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});102 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');100 const token = await collection.mintToken(alice, {Substrate: alice.address});103 const aliceBalanceBefore = (await api.query.system.account(alice.address)).data.free.toBigInt();101 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);104 await transferExpectSuccess(collectionId, tokenId, alice, bob, 1, 'NFT');102 await token.transfer(alice, {Substrate: bob.address});105 const aliceBalanceAfter = (await api.query.system.account(alice.address)).data.free.toBigInt();103 const aliceBalanceAfter = await helper.balance.getSubstrate(alice.address);106104107 console.log(`Calibrated price: ${Number(aliceBalanceBefore - aliceBalanceAfter) / Number(UNIQUE)} UNQ`);105 console.log(`Calibrated price: ${Number(aliceBalanceBefore - aliceBalanceAfter) / Number(helper.balance.getOneTokenNominal())} UNQ`);108 }106 }109}107}110108111async function calibrateMinGasPrice(api: ApiPromise, web3: Web3, privateKey: (account: string) => IKeyringPair) {109async function calibrateMinGasPrice(helper: EthUniqueHelper, privateKey: (account: string) => IKeyringPair) {112 const alice = privateKey('//Alice');110 const alice = privateKey('//Alice');113 const caller = await createEthAccountWithBalance(api, web3, privateKey);111 const caller = await helper.eth.createAccountWithBalance(alice);114 const receiver = createEthAccount(web3);112 const receiver = helper.eth.createAccount();115 const dataPoints = [];113 const dataPoints = [];116114117 {115 {118 const collectionId = await createCollectionExpectSuccess();116 const collection = await helper.nft.mintCollection(alice, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});119 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Ethereum: caller});117 const token = await collection.mintToken(alice, {Ethereum: caller});120118121 const address = collectionIdToAddress(collectionId);119 const address = helper.ethAddress.fromCollectionId(collection.collectionId);122 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});120 const contract = helper.ethNativeContract.collection(address, 'nft', caller);123121124 const cost = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, tokenId).send(caller));122 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS}));125123126 console.log(`Original price: ${Number(cost) / Number(UNIQUE)} UNQ`);124 console.log(`Original price: ${Number(cost) / Number(helper.balance.getOneTokenNominal())} UNQ`);127 }125 }128126127 const api = helper.getApi();129 const defaultCoeff = (api.consts.configuration.defaultMinGasPrice as any).toBigInt();128 const defaultCoeff = (api.consts.configuration.defaultMinGasPrice as any).toBigInt();130 for (let i = -8; i < 8; i++) {129 for (let i = -8; i < 8; i++) {131 const gasPrice = defaultCoeff + defaultCoeff / 100000n * BigInt(i);130 const gasPrice = defaultCoeff + defaultCoeff / 100000n * BigInt(i);132 const gasPriceStr = '0x' + gasPrice.toString(16);131 const gasPriceStr = '0x' + gasPrice.toString(16);133 await executeTransaction(api, alice, api.tx.sudo.sudo(api.tx.configuration.setMinGasPriceOverride(gasPrice)));132 await helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.configuration.setMinGasPriceOverride(gasPrice)));134133135 const coefficient = (await api.query.configuration.minGasPriceOverride() as any).toBigInt();134 const coefficient = (await api.query.configuration.minGasPriceOverride() as any).toBigInt();136 const collectionId = await createCollectionExpectSuccess();135 const collection = await helper.nft.mintCollection(alice, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});137 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Ethereum: caller});136 const token = await collection.mintToken(alice, {Ethereum: caller});138137139 const address = collectionIdToAddress(collectionId);138 const address = helper.ethAddress.fromCollectionId(collection.collectionId);140 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, gasPrice: gasPriceStr, ...GAS_ARGS});139 const contract = helper.ethNativeContract.collection(address, 'nft', caller);141140142 const transferPrice = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, tokenId).send(caller));141 const transferPrice = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gasPrice: gasPriceStr, gas: helper.eth.DEFAULT_GAS}));143142144 dataPoints.push({x: transferPrice, y: coefficient});143 dataPoints.push({x: transferPrice, y: coefficient});145 }144 }149 // console.log(`Error: ${error(dataPoints, x => a*x+b)}`);148 // console.log(`Error: ${error(dataPoints, x => a*x+b)}`);150149151 // * 0.15 = * 10000 / 66666150 // * 0.15 = * 10000 / 66666152 const perfectValue = a * UNIQUE * 1000000n / 6666666n + b;151 const perfectValue = a * helper.balance.getOneTokenNominal() * 1000000n / 6666666n + b;153 await executeTransaction(api, alice, api.tx.sudo.sudo(api.tx.configuration.setMinGasPriceOverride(perfectValue.toString())));152 await helper.signTransaction(alice, api.tx.sudo.sudo(api.tx.configuration.setMinGasPriceOverride(perfectValue.toString())));154153155 {154 {156 const collectionId = await createCollectionExpectSuccess();155 const collection = await helper.nft.mintCollection(alice, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});157 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Ethereum: caller});156 const token = await collection.mintToken(alice, {Ethereum: caller});158157159 const address = collectionIdToAddress(collectionId);158 const address = helper.ethAddress.fromCollectionId(collection.collectionId);160 const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});159 const contract = helper.ethNativeContract.collection(address, 'nft', caller);161160162 const cost = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, tokenId).send(caller));161 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, token.tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS}));163162164 console.log(`Calibrated price: ${Number(cost) / Number(UNIQUE)} UNQ`);163 console.log(`Calibrated price: ${Number(cost) / Number(helper.balance.getOneTokenNominal())} UNQ`);165 }164 }166}165}167166168(async () => {167(async () => {169 await usingApi(async (api, privateKey) => {168 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {170 // Second run slightly reduces error sometimes, as price line is not actually straight, this is a curve169 // Second run slightly reduces error sometimes, as price line is not actually straight, this is a curve171170172 await calibrateWeightToFee(api, privateKey);171 await calibrateWeightToFee(helper, privateKey);173 await calibrateWeightToFee(api, privateKey);172 await calibrateWeightToFee(helper, privateKey);174173175 await usingWeb3(async web3 => {174 await calibrateMinGasPrice(helper, privateKey);176 await calibrateMinGasPrice(api, web3, privateKey);177 await calibrateMinGasPrice(api, web3, privateKey);178 });179180 await api.disconnect();175 await calibrateMinGasPrice(helper, privateKey);181 });176 });182})();177})();183178tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth178 tokenPrefix: 'COL',178 tokenPrefix: 'COL',179 }, 0);179 }, 0);180180181 const api = helper.api;182 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {181 await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx',[collection.collectionId, {183 Fungible: new Map([182 Fungible: new Map([184 [JSON.stringify({Substrate: alice.address}), 50],183 [JSON.stringify({Substrate: alice.address}), 50],185 [JSON.stringify({Substrate: bob.address}), 100],184 [JSON.stringify({Substrate: bob.address}), 100],186 ]),185 ]),187 }));186 }], true);188187189 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);188 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);190 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);189 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);200 ],199 ],201 });200 });202201203 const api = helper.api;204 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {202 await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx', [collection.collectionId, {205 RefungibleMultipleOwners: {203 RefungibleMultipleOwners: {206 users: new Map([204 users: new Map([207 [JSON.stringify({Substrate: alice.address}), 1],205 [JSON.stringify({Substrate: alice.address}), 1],211 {key: 'k', value: 'v'},209 {key: 'k', value: 'v'},212 ],210 ],213 },211 },214 }));212 }], true);215 const tokenId = await collection.getLastTokenId();213 const tokenId = await collection.getLastTokenId();216 expect(tokenId).to.be.equal(1);214 expect(tokenId).to.be.equal(1);217 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);215 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);228 ],226 ],229 });227 });230231 const api = helper.api;232228233 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {229 await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx', [collection.collectionId, {234 RefungibleMultipleItems: [230 RefungibleMultipleItems: [235 {231 {236 user: {Substrate: alice.address}, pieces: 1,232 user: {Substrate: alice.address}, pieces: 1,245 ],241 ],246 },242 },247 ],243 ],248 }));244 }], true);249245250 expect(await collection.getLastTokenId()).to.be.equal(2);246 expect(await collection.getLastTokenId()).to.be.equal(2);251 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);247 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);tests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth29/*eslint no-async-promise-executor: "off"*/29/*eslint no-async-promise-executor: "off"*/30function skipInflationBlock(api: ApiPromise): Promise<void> {30function skipInflationBlock(api: ApiPromise): Promise<void> {31 const promise = new Promise<void>(async (resolve) => {31 const promise = new Promise<void>(async (resolve) => {32 const blockInterval = (await api.consts.inflation.inflationBlockInterval).toNumber();32 const blockInterval = api.consts.inflation.inflationBlockInterval.toNumber();33 const unsubscribe = await api.rpc.chain.subscribeNewHeads(head => {33 const unsubscribe = await api.rpc.chain.subscribeNewHeads(head => {34 const currentBlock = head.number.toNumber();34 const currentBlock = head.number.toNumber();35 if (currentBlock % blockInterval < blockInterval - 10) {35 if (currentBlock % blockInterval < blockInterval - 10) {56 });56 });575758 itSub('Total issuance does not change', async ({helper}) => {58 itSub('Total issuance does not change', async ({helper}) => {59 const api = helper.api!;59 const api = helper.getApi();60 await skipInflationBlock(api);60 await skipInflationBlock(api);61 await helper.wait.newBlocks(1);61 await helper.wait.newBlocks(1);626263 const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();63 const totalBefore = (await helper.callRpc('api.query.balances.totalIssuance', [])).toBigInt();646465 await helper.balance.transferToSubstrate(alice, bob.address, 1n);65 await helper.balance.transferToSubstrate(alice, bob.address, 1n);666667 const totalAfter = (await api.query.balances.totalIssuance()).toBigInt();67 const totalAfter = (await helper.callRpc('api.query.balances.totalIssuance', [])).toBigInt();686869 expect(totalAfter).to.be.equal(totalBefore);69 expect(totalAfter).to.be.equal(totalBefore);70 });70 });717172 itSub('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async ({helper}) => {72 itSub('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async ({helper}) => {73 await skipInflationBlock(helper.api!);73 await skipInflationBlock(helper.getApi());74 await helper.wait.newBlocks(1);74 await helper.wait.newBlocks(1);757576 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);76 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);89 });89 });909091 itSub('Treasury balance increased by failed tx fee', async ({helper}) => {91 itSub('Treasury balance increased by failed tx fee', async ({helper}) => {92 const api = helper.api!;92 const api = helper.getApi();93 await helper.wait.newBlocks(1);93 await helper.wait.newBlocks(1);949495 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);95 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);107 });107 });108108109 itSub('NFT Transactions also send fees to Treasury', async ({helper}) => {109 itSub('NFT Transactions also send fees to Treasury', async ({helper}) => {110 await skipInflationBlock(helper.api!);110 await skipInflationBlock(helper.getApi());111 await helper.wait.newBlocks(1);111 await helper.wait.newBlocks(1);112112113 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);113 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);125125126 itSub('Fees are sane', async ({helper}) => {126 itSub('Fees are sane', async ({helper}) => {127 const unique = helper.balance.getOneTokenNominal();127 const unique = helper.balance.getOneTokenNominal();128 await skipInflationBlock(helper.api!);128 await skipInflationBlock(helper.getApi());129 await helper.wait.newBlocks(1);129 await helper.wait.newBlocks(1);130130131 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);131 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);140 });140 });141141142 itSub('NFT Transfer fee is close to 0.1 Unique', async ({helper}) => {142 itSub('NFT Transfer fee is close to 0.1 Unique', async ({helper}) => {143 await skipInflationBlock(helper.api!);143 await skipInflationBlock(helper.getApi());144 await helper.wait.newBlocks(1);144 await helper.wait.newBlocks(1);145145146 const collection = await helper.nft.mintCollection(alice, {146 const collection = await helper.nft.mintCollection(alice, {tests/src/deprecated-helpers/contracthelpers.tsdiffbeforeafterbothno changes
tests/src/deprecated-helpers/eth/helpers.d.tsdiffbeforeafterbothno changes
tests/src/deprecated-helpers/eth/helpers.tsdiffbeforeafterbothno changes
tests/src/deprecated-helpers/helpers.tsdiffbeforeafterbothno changes
tests/src/deprecated-helpers/util.tsdiffbeforeafterbothno changes
tests/src/eth/base.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {18 ethBalanceViaSub,19 GAS_ARGS,20 recordEthFee,21} from './util/helpers';22import {Contract} from 'web3-eth-contract';17import {Contract} from 'web3-eth-contract';231824import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';37 const deployer = await helper.eth.createAccountWithBalance(donor);33 const deployer = await helper.eth.createAccountWithBalance(donor);38 const flipper = await helper.eth.deployFlipper(deployer);34 const flipper = await helper.eth.deployFlipper(deployer);393540 const cost = await recordEthFee(helper.api!, deployer, () => flipper.methods.flip().send({from: deployer}));36 const cost = await helper.eth.calculateFee({Ethereum: deployer}, () => flipper.methods.flip().send({from: deployer}));41 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;37 expect(cost < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;42 });38 });433944 itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {40 itEth('Balance transfer fee is less than 0.2 UNQ', async ({helper}) => {45 const userA = await helper.eth.createAccountWithBalance(donor);41 const userA = await helper.eth.createAccountWithBalance(donor);46 const userB = helper.eth.createAccount();42 const userB = helper.eth.createAccount();47 const cost = await recordEthFee(helper.api!, userA, () => helper.web3!.eth.sendTransaction({from: userA, to: userB, value: '1000000', ...GAS_ARGS}));43 const cost = await helper.eth.calculateFee({Ethereum: userA}, () => helper.getWeb3().eth.sendTransaction({from: userA, to: userB, value: '1000000', gas: helper.eth.DEFAULT_GAS}));48 const balanceB = await ethBalanceViaSub(helper.api!, userB);44 const balanceB = await helper.balance.getEthereum(userB);49 expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;45 expect(cost - balanceB < BigInt(0.2 * Number(helper.balance.getOneTokenNominal()))).to.be.true;50 });46 });514760 const address = helper.ethAddress.fromCollectionId(collection.collectionId);56 const address = helper.ethAddress.fromCollectionId(collection.collectionId);61 const contract = helper.ethNativeContract.collection(address, 'nft', caller);57 const contract = helper.ethNativeContract.collection(address, 'nft', caller);625863 const cost = await recordEthFee(helper.api!, caller, () => contract.methods.transfer(receiver, tokenId).send(caller));59 const cost = await helper.eth.calculateFee({Ethereum: caller}, () => contract.methods.transfer(receiver, tokenId).send(caller));646065 const fee = Number(cost) / Number(helper.balance.getOneTokenNominal());61 const fee = Number(cost) / Number(helper.balance.getOneTokenNominal());66 const expectedFee = 0.15;62 const expectedFee = 0.15;tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth17import {evmToAddress} from '@polkadot/util-crypto';17import {evmToAddress} from '@polkadot/util-crypto';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';19import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';20import {UNIQUE} from '../util/helpers';20212122describe('Create NFT collection from EVM', () => {22describe('Create NFT collection from EVM', () => {23 let donor: IKeyringPair;23 let donor: IKeyringPair;656566 await collectionHelpers.methods66 await collectionHelpers.methods67 .createNonfungibleCollection('A', 'A', 'A')67 .createNonfungibleCollection('A', 'A', 'A')68 .send({value: Number(2n * UNIQUE)});68 .send({value: Number(2n * helper.balance.getOneTokenNominal())});69 69 70 expect(await collectionHelpers.methods70 expect(await collectionHelpers.methods71 .isCollectionExist(expectedCollectionAddress)71 .isCollectionExist(expectedCollectionAddress)147147148describe('(!negative tests!) Create NFT collection from EVM', () => {148describe('(!negative tests!) Create NFT collection from EVM', () => {149 let donor: IKeyringPair;149 let donor: IKeyringPair;150 let nominal: bigint;150151151 before(async function() {152 before(async function() {152 await usingEthPlaygrounds(async (_helper, privateKey) => {153 await usingEthPlaygrounds(async (helper, privateKey) => {153 donor = privateKey('//Alice');154 donor = privateKey('//Alice');155 nominal = helper.balance.getOneTokenNominal();154 });156 });155 });157 });156158165167166 await expect(collectionHelper.methods168 await expect(collectionHelper.methods167 .createNonfungibleCollection(collectionName, description, tokenPrefix)169 .createNonfungibleCollection(collectionName, description, tokenPrefix)168 .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);170 .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);169 171 170 }172 }171 {173 {175 const tokenPrefix = 'A';177 const tokenPrefix = 'A';176 await expect(collectionHelper.methods178 await expect(collectionHelper.methods177 .createNonfungibleCollection(collectionName, description, tokenPrefix)179 .createNonfungibleCollection(collectionName, description, tokenPrefix)178 .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);180 .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);179 }181 }180 {182 {181 const MAX_TOKEN_PREFIX_LENGTH = 16;183 const MAX_TOKEN_PREFIX_LENGTH = 16;184 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);186 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);185 await expect(collectionHelper.methods187 await expect(collectionHelper.methods186 .createNonfungibleCollection(collectionName, description, tokenPrefix)188 .createNonfungibleCollection(collectionName, description, tokenPrefix)187 .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);189 .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);188 }190 }189 });191 });190 192 193 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);195 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);194 await expect(collectionHelper.methods196 await expect(collectionHelper.methods195 .createNonfungibleCollection('Peasantry', 'absolutely anything', 'CVE')197 .createNonfungibleCollection('Peasantry', 'absolutely anything', 'CVE')196 .call({value: Number(1n * UNIQUE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');198 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');197 });199 });198200199 itEth('(!negative test!) Check owner', async ({helper}) => {201 itEth('(!negative test!) Check owner', async ({helper}) => {tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {Pallets, requirePalletsOrSkip} from '../util/playgrounds';19import {Pallets, requirePalletsOrSkip} from '../util/playgrounds';20import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';20import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';21import {UNIQUE} from '../util/helpers';21222223describe('Create RFT collection from EVM', () => {23describe('Create RFT collection from EVM', () => {24 let donor: IKeyringPair;24 let donor: IKeyringPair;666667 await collectionHelpers.methods67 await collectionHelpers.methods68 .createRFTCollection('A', 'A', 'A')68 .createRFTCollection('A', 'A', 'A')69 .send({value: Number(2n * UNIQUE)});69 .send({value: Number(2n * helper.balance.getOneTokenNominal())});70 70 71 expect(await collectionHelpers.methods71 expect(await collectionHelpers.methods72 .isCollectionExist(expectedCollectionAddress)72 .isCollectionExist(expectedCollectionAddress)148148149describe('(!negative tests!) Create RFT collection from EVM', () => {149describe('(!negative tests!) Create RFT collection from EVM', () => {150 let donor: IKeyringPair;150 let donor: IKeyringPair;151 let nominal: bigint;151152152 before(async function() {153 before(async function() {153 await usingEthPlaygrounds(async (helper, privateKey) => {154 await usingEthPlaygrounds(async (helper, privateKey) => {154 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);155 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);155 donor = privateKey('//Alice');156 donor = privateKey('//Alice');157 nominal = helper.balance.getOneTokenNominal();156 });158 });157 });159 });158160167169168 await expect(collectionHelper.methods170 await expect(collectionHelper.methods169 .createRFTCollection(collectionName, description, tokenPrefix)171 .createRFTCollection(collectionName, description, tokenPrefix)170 .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);172 .call({value: Number(2n * nominal)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);171 }173 }172 {174 {173 const MAX_DESCRIPTION_LENGTH = 256;175 const MAX_DESCRIPTION_LENGTH = 256;176 const tokenPrefix = 'A';178 const tokenPrefix = 'A';177 await expect(collectionHelper.methods179 await expect(collectionHelper.methods178 .createRFTCollection(collectionName, description, tokenPrefix)180 .createRFTCollection(collectionName, description, tokenPrefix)179 .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);181 .call({value: Number(2n * nominal)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);180 }182 }181 {183 {182 const MAX_TOKEN_PREFIX_LENGTH = 16;184 const MAX_TOKEN_PREFIX_LENGTH = 16;185 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);187 const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);186 await expect(collectionHelper.methods188 await expect(collectionHelper.methods187 .createRFTCollection(collectionName, description, tokenPrefix)189 .createRFTCollection(collectionName, description, tokenPrefix)188 .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);190 .call({value: Number(2n * nominal)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);189 }191 }190 });192 });191 193 194 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);196 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);195 await expect(collectionHelper.methods197 await expect(collectionHelper.methods196 .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')198 .createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')197 .call({value: Number(1n * UNIQUE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');199 .call({value: Number(1n * nominal)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');198 });200 });199201200 itEth('(!negative test!) Check owner', async ({helper}) => {202 itEth('(!negative test!) Check owner', async ({helper}) => {tests/src/eth/nonFungible.test.tsdiffbeforeafterboth17import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';17import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import {Contract} from 'web3-eth-contract';19import {Contract} from 'web3-eth-contract';20import {UNIQUE} from '../util/helpers';20212122describe('NFT: Information getting', () => {22describe('NFT: Information getting', () => {23 let donor: IKeyringPair;23 let donor: IKeyringPair;84 const receiver = helper.eth.createAccount();84 const receiver = helper.eth.createAccount();858586 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);86 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);87 let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});87 let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * helper.balance.getOneTokenNominal())});88 const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);88 const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);89 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);89 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);90 90 tests/src/eth/proxy/fungibleProxy.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {GAS_ARGS, normalizeEvents} from '../util/helpers';18import {expect} from 'chai';17import {expect} from 'chai';19import {readFile} from 'fs/promises';18import {readFile} from 'fs/promises';20import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';26 const web3 = helper.getWeb3();25 const web3 = helper.getWeb3();27 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueFungibleProxy.abi`)).toString()), undefined, {26 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueFungibleProxy.abi`)).toString()), undefined, {28 from: owner,27 from: owner,29 ...GAS_ARGS,28 gas: helper.eth.DEFAULT_GAS,30 });29 });31 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueFungibleProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});30 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueFungibleProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});32 return proxy;31 return proxy;949395 {94 {96 const result = await contract.methods.approve(spender, 100).send({from: caller});95 const result = await contract.methods.approve(spender, 100).send({from: caller});97 const events = normalizeEvents(result.events);96 const events = helper.eth.normalizeEvents(result.events);989799 expect(events).to.be.deep.equal([98 expect(events).to.be.deep.equal([100 {99 {131130132 {131 {133 const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: caller});132 const result = await contract.methods.transferFrom(owner, receiver, 49).send({from: caller});134 const events = normalizeEvents(result.events);133 const events = helper.eth.normalizeEvents(result.events);135 expect(events).to.be.deep.equal([134 expect(events).to.be.deep.equal([136 {135 {137 address,136 address,177176178 {177 {179 const result = await contract.methods.transfer(receiver, 50).send({from: caller});178 const result = await contract.methods.transfer(receiver, 50).send({from: caller});180 const events = normalizeEvents(result.events);179 const events = helper.eth.normalizeEvents(result.events);181 expect(events).to.be.deep.equal([180 expect(events).to.be.deep.equal([182 {181 {183 address,182 address,tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617import {GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';18import {expect} from 'chai';19import {readFile} from 'fs/promises';17import {readFile} from 'fs/promises';20import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';21import {EthUniqueHelper, itEth, usingEthPlaygrounds} from '../util/playgrounds';19import {EthUniqueHelper, itEth, usingEthPlaygrounds, expect} from '../util/playgrounds';20222123async function proxyWrap(helper: EthUniqueHelper, wrapped: any, donor: IKeyringPair) {22async function proxyWrap(helper: EthUniqueHelper, wrapped: any, donor: IKeyringPair) {24 // Proxy owner has no special privilegies, we don't need to reuse them23 // Proxy owner has no special privilegies, we don't need to reuse them25 const owner = await helper.eth.createAccountWithBalance(donor);24 const owner = await helper.eth.createAccountWithBalance(donor);26 const web3 = helper.getWeb3();25 const web3 = helper.getWeb3();27 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {26 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {28 from: owner,27 from: owner,29 ...GAS_ARGS,28 gas: helper.eth.DEFAULT_GAS,30 });29 });31 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});30 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});32 return proxy;31 return proxy;119 nextTokenId,118 nextTokenId,120 'Test URI',119 'Test URI',121 ).send({from: caller});120 ).send({from: caller});122 const events = normalizeEvents(result.events);121 const events = helper.eth.normalizeEvents(result.events);123 events[0].address = events[0].address.toLocaleLowerCase();122 events[0].address = events[0].address.toLocaleLowerCase();124123125 expect(events).to.be.deep.equal([124 expect(events).to.be.deep.equal([139 });138 });140139141 //TODO: CORE-302 add eth methods140 //TODO: CORE-302 add eth methods142 itWeb3.skip('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {141 itEth.skip('Can perform mintBulk()', async ({helper}) => {143 /*142 const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});144 const collection = await createCollectionExpectSuccess({143145 mode: {type: 'NFT'},144 const caller = await helper.eth.createAccountWithBalance(donor, 30n);146 });145 const receiver = helper.eth.createAccount();147 const alice = privateKeyWrapper('//Alice');146148147 const address = helper.ethAddress.fromCollectionId(collection.collectionId);149 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);148 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);150 const receiver = createEthAccount(web3);149 const contract = await proxyWrap(helper, evmCollection, donor);151150 await collection.addAdmin(donor, {Ethereum: contract.options.address});152 const address = collectionIdToAddress(collection);151153 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}), privateKeyWrapper);152 {154 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});153 const nextTokenId = await contract.methods.nextTokenId().call();155 await submitTransactionAsync(alice, changeAdminTx);154 expect(nextTokenId).to.be.equal('1');156155 const result = await contract.methods.mintBulkWithTokenURI(157 {156 receiver,158 const nextTokenId = await contract.methods.nextTokenId().call();157 [159 expect(nextTokenId).to.be.equal('1');158 [nextTokenId, 'Test URI 0'],160 const result = await contract.methods.mintBulkWithTokenURI(159 [+nextTokenId + 1, 'Test URI 1'],161 receiver,160 [+nextTokenId + 2, 'Test URI 2'],162 [161 ],163 [nextTokenId, 'Test URI 0'],162 ).send({from: caller});164 [+nextTokenId + 1, 'Test URI 1'],163 const events = helper.eth.normalizeEvents(result.events);165 [+nextTokenId + 2, 'Test URI 2'],164166 ],165 expect(events).to.be.deep.equal([167 ).send({from: caller});166 {168 const events = normalizeEvents(result.events);167 address,169168 event: 'Transfer',170 expect(events).to.be.deep.equal([169 args: {171 {170 from: '0x0000000000000000000000000000000000000000',172 address,171 to: receiver,173 event: 'Transfer',172 tokenId: nextTokenId,174 args: {173 },175 from: '0x0000000000000000000000000000000000000000',174 },176 to: receiver,175 {177 tokenId: nextTokenId,176 address,178 },177 event: 'Transfer',179 },178 args: {180 {179 from: '0x0000000000000000000000000000000000000000',181 address,180 to: receiver,182 event: 'Transfer',181 tokenId: String(+nextTokenId + 1),183 args: {182 },184 from: '0x0000000000000000000000000000000000000000',183 },185 to: receiver,184 {186 tokenId: String(+nextTokenId + 1),185 address,187 },186 event: 'Transfer',188 },187 args: {189 {188 from: '0x0000000000000000000000000000000000000000',190 address,189 to: receiver,191 event: 'Transfer',190 tokenId: String(+nextTokenId + 2),192 args: {191 },193 from: '0x0000000000000000000000000000000000000000',192 },194 to: receiver,193 ]);195 tokenId: String(+nextTokenId + 2),194196 },195 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');197 },196 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');198 ]);197 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');199200 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');201 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');202 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');203 }204 */205 });198 }199 });206200207 itEth('Can perform burn()', async ({helper}) => {201 itEth('Can perform burn()', async ({helper}) => {208 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});202 const collection = await helper.nft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});216210217 {211 {218 const result = await contract.methods.burn(tokenId).send({from: caller});212 const result = await contract.methods.burn(tokenId).send({from: caller});219 const events = normalizeEvents(result.events);213 const events = helper.eth.normalizeEvents(result.events);220214221 expect(events).to.be.deep.equal([215 expect(events).to.be.deep.equal([222 {216 {243 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});237 const {tokenId} = await collection.mintToken(alice, {Ethereum: contract.options.address});244238245 {239 {246 const result = await contract.methods.approve(spender, tokenId).send({from: caller, ...GAS_ARGS});240 const result = await contract.methods.approve(spender, tokenId).send({from: caller, gas: helper.eth.DEFAULT_GAS});247 const events = normalizeEvents(result.events);241 const events = helper.eth.normalizeEvents(result.events);248242249 expect(events).to.be.deep.equal([243 expect(events).to.be.deep.equal([250 {244 {276270277 {271 {278 const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});272 const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});279 const events = normalizeEvents(result.events);273 const events = helper.eth.normalizeEvents(result.events);280 expect(events).to.be.deep.equal([274 expect(events).to.be.deep.equal([281 {275 {282 address,276 address,313307314 {308 {315 const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});309 const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});316 const events = normalizeEvents(result.events);310 const events = helper.eth.normalizeEvents(result.events);317 expect(events).to.be.deep.equal([311 expect(events).to.be.deep.equal([318 {312 {319 address,313 address,tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth18import {EthUniqueHelper, expect, itEth, usingEthPlaygrounds} from './util/playgrounds';18import {EthUniqueHelper, expect, itEth, usingEthPlaygrounds} from './util/playgrounds';19import {IKeyringPair} from '@polkadot/types/types';19import {IKeyringPair} from '@polkadot/types/types';20import {Contract} from 'web3-eth-contract';20import {Contract} from 'web3-eth-contract';21import {UNIQUE} from '../util/helpers';21222223describe('Refungible token: Information getting', () => {23describe('Refungible token: Information getting', () => {24 let donor: IKeyringPair;24 let donor: IKeyringPair;81 const receiver = helper.eth.createAccount();81 const receiver = helper.eth.createAccount();828283 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);83 const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);84 let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});84 let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * helper.balance.getOneTokenNominal())});85 const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);85 const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);86 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);86 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);87 87 tests/src/eth/scheduling.test.tsdiffbeforeafterbothno changes
tests/src/eth/util/helpers.d.tsdiffbeforeafterbothno changes
tests/src/eth/util/helpers.tsdiffbeforeafterbothno changes
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth27import refungibleAbi from '../../reFungibleAbi.json';27import refungibleAbi from '../../reFungibleAbi.json';28import refungibleTokenAbi from '../../reFungibleTokenAbi.json';28import refungibleTokenAbi from '../../reFungibleTokenAbi.json';29import contractHelpersAbi from './../contractHelpersAbi.json';29import contractHelpersAbi from './../contractHelpersAbi.json';30import {TEthereumAccount} from '../../../util/playgrounds/types';30import {ICrossAccountId, TEthereumAccount} from '../../../util/playgrounds/types';313132class EthGroupBase {32class EthGroupBase {33 helper: EthUniqueHelper;33 helper: EthUniqueHelper;280 });280 });281 }281 }282283 async calculateFee(address: ICrossAccountId, code: () => Promise<any>): Promise<bigint> {284 const wrappedCode = async () => {285 await code();286 // In dev mode, the transaction might not finish processing in time287 await this.helper.wait.newBlocks(1);288 };289 return await this.helper.arrange.calculcateFee(address, wrappedCode);290 }282} 291} 283292284class EthAddressGroup extends EthGroupBase {293class EthAddressGroup extends EthGroupBase {tests/src/inflation.test.tsdiffbeforeafterboth40 const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);40 const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);41 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;41 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;424243 const blockInterval = (helper.api!.consts.inflation.inflationBlockInterval as any).toBigInt();43 const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();44 const totalIssuanceStart = ((await helper.api!.query.inflation.startingYearTotalIssuance()) as any).toBigInt();44 const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();45 const blockInflation = (await helper.api!.query.inflation.blockInflation() as any).toBigInt();45 const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();464647 const YEAR = 5259600n; // 6-second block. Blocks in one year47 const YEAR = 5259600n; // 6-second block. Blocks in one year48 // const YEAR = 2629800n; // 12-second block. Blocks in one year48 // const YEAR = 2629800n; // 12-second block. Blocks in one yeartests/src/nesting/properties.test.tsdiffbeforeafterboth276 276 277 itSub('Reads access rights to properties of a collection', async ({helper}) => {277 itSub('Reads access rights to properties of a collection', async ({helper}) => {278 const collection = await helper.nft.mintCollection(alice);278 const collection = await helper.nft.mintCollection(alice);279 const propertyRights = (await helper.api!.query.common.collectionPropertyPermissions(collection.collectionId)).toJSON();279 const propertyRights = (await helper.callRpc('api.query.common.collectionPropertyPermissions', [collection.collectionId])).toJSON();280 expect(propertyRights).to.be.empty;280 expect(propertyRights).to.be.empty;281 });281 });282 282 817 ).to.be.fulfilled;817 ).to.be.fulfilled;818 }818 }819819820 const originalSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 820 const originalSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 821 return originalSpace;821 return originalSpace;822 }822 }823823840 ).to.be.rejectedWith(/common\.NoPermission/);840 ).to.be.rejectedWith(/common\.NoPermission/);841 }841 }842842843 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 843 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 844 expect(consumedSpace).to.be.equal(originalSpace);844 expect(consumedSpace).to.be.equal(originalSpace);845 }845 }846846875 ).to.be.rejectedWith(/common\.NoPermission/);875 ).to.be.rejectedWith(/common\.NoPermission/);876 }876 }877 877 878 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 878 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 879 expect(consumedSpace).to.be.equal(originalSpace);879 expect(consumedSpace).to.be.equal(originalSpace);880 }880 }881881911911912 expect(await token.getProperties(['non-existent', 'now-existent'])).to.be.empty;912 expect(await token.getProperties(['non-existent', 'now-existent'])).to.be.empty;913 913 914 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 914 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 915 expect(consumedSpace).to.be.equal(originalSpace);915 expect(consumedSpace).to.be.equal(originalSpace);916 }916 }917917951 ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);951 ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);952 952 953 expect(await token.getProperties(['a_holy_book', 'young_years'])).to.be.empty;953 expect(await token.getProperties(['a_holy_book', 'young_years'])).to.be.empty;954 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 954 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 955 expect(consumedSpace).to.be.equal(originalSpace);955 expect(consumedSpace).to.be.equal(originalSpace);956 }956 }957957tests/src/pallet-presence.test.tsdiffbeforeafterboth59describe('Pallet presence', () => {59describe('Pallet presence', () => {60 before(async () => {60 before(async () => {61 await usingPlaygrounds(async helper => {61 await usingPlaygrounds(async helper => {62 const chain = await helper.api!.rpc.system.chain();62 const chain = await helper.callRpc('api.rpc.system.chain', []);636364 const refungible = 'refungible';64 const refungible = 'refungible';65 const scheduler = 'scheduler';65 const scheduler = 'scheduler';tests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth8} 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} from './util/helpers';11import {requirePallets, Pallets} from '../util/helpers';11import {requirePallets, Pallets} from '../deprecated-helpers/helpers';121213describe('integration test: accept NFT', () => {13describe('integration test: accept NFT', () => {14 let api: any;14 let api: any;tests/src/rmrk/addResource.test.tsdiffbeforeafterboth12 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 '../util/helpers';15import {requirePallets, Pallets} from '../deprecated-helpers/helpers';161617describe('integration test: add NFT resource', () => {17describe('integration test: add NFT resource', () => {18 const Alice = '//Alice';18 const Alice = '//Alice';tests/src/rmrk/addTheme.test.tsdiffbeforeafterboth3import {createBase, addTheme} from './util/tx';3import {createBase, addTheme} from './util/tx';4import {expectTxFailure} from './util/helpers';4import {expectTxFailure} from './util/helpers';5import {getThemeNames} from './util/fetch';5import {getThemeNames} from './util/fetch';6import {requirePallets, Pallets} from '../util/helpers';6import {requirePallets, Pallets} from '../deprecated-helpers/helpers';778describe('integration test: add Theme to Base', () => {8describe('integration test: add Theme to Base', () => {9 let api: any;9 let api: any;tests/src/rmrk/burnNft.test.tsdiffbeforeafterboth556import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import {requirePallets, Pallets} from '../util/helpers';8import {requirePallets, Pallets} from '../deprecated-helpers/helpers';9910chai.use(chaiAsPromised);10chai.use(chaiAsPromised);11const expect = chai.expect;11const expect = chai.expect;tests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';4import {4import {5 changeIssuer,5 changeIssuer,tests/src/rmrk/createBase.test.tsdiffbeforeafterboth1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/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 '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/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 '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';4import {createCollection, deleteCollection} from './util/tx';4import {createCollection, deleteCollection} from './util/tx';55tests/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 '../util/helpers';4import {requirePallets, Pallets} from '../deprecated-helpers/helpers';5import {getNft, getParts, NftIdTuple} from './util/fetch';5import {getNft, getParts, NftIdTuple} from './util/fetch';6import {expectTxFailure} from './util/helpers';6import {expectTxFailure} from './util/helpers';7import {7import {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 '../util/helpers';3import {requirePallets, Pallets} from '../deprecated-helpers/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 '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';4import {createCollection, lockCollection, mintNft} from './util/tx';4import {createCollection, lockCollection, mintNft} from './util/tx';55tests/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 '../util/helpers';3import {requirePallets, Pallets} from '../deprecated-helpers/helpers';4import {getNft} from './util/fetch';4import {getNft} from './util/fetch';5import {expectTxFailure} from './util/helpers';5import {expectTxFailure} from './util/helpers';6import {createCollection, mintNft} from './util/tx';6import {createCollection, mintNft} from './util/tx';tests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth8} 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} from './util/helpers';11import {requirePallets, Pallets} from '../util/helpers';11import {requirePallets, Pallets} from '../deprecated-helpers/helpers';121213describe('integration test: reject NFT', () => {13describe('integration test: reject NFT', () => {14 let api: any;14 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 '../util/helpers';4import {requirePallets, Pallets} from '../deprecated-helpers/helpers';5import {getNft, NftIdTuple} from './util/fetch';5import {getNft, NftIdTuple} from './util/fetch';6import {expectTxFailure} from './util/helpers';6import {expectTxFailure} from './util/helpers';7import {7import {tests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth9 requirePallets,9 requirePallets,10 normalizeAccountId,10 normalizeAccountId,11 Pallets,11 Pallets,12} from '../util/helpers';12} from '../deprecated-helpers/helpers';13import {IKeyringPair} from '@polkadot/types/types';13import {IKeyringPair} from '@polkadot/types/types';14import {ApiPromise} from '@polkadot/api';14import {ApiPromise} from '@polkadot/api';15import {it} from 'mocha';15import {it} from 'mocha';tests/src/rmrk/sendNft.test.tsdiffbeforeafterboth3import {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} from './util/helpers';6import {requirePallets, Pallets} from '../util/helpers';6import {requirePallets, Pallets} from '../deprecated-helpers/helpers';778describe('integration test: send NFT', () => {8describe('integration test: send NFT', () => {9 let api: any;9 let api: any;tests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';4import {createCollection, setPropertyCollection} from './util/tx';4import {createCollection, setPropertyCollection} from './util/tx';55tests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';4import {createCollection, createBase, setEquippableList} from './util/tx';4import {createCollection, createBase, setEquippableList} from './util/tx';55tests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {NftIdTuple} from './util/fetch';3import {NftIdTuple} from './util/fetch';4import {expectTxFailure} from './util/helpers';4import {expectTxFailure} from './util/helpers';5import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';5import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';tests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';2import {requirePallets, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../deprecated-helpers/helpers';3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';4import {mintNft, createCollection, setResourcePriorities} from './util/tx';4import {mintNft, createCollection, setResourcePriorities} from './util/tx';55tests/src/substrate/get-balance.tsdiffbeforeafterboth19import promisifySubstrate from './promisify-substrate';19import promisifySubstrate from './promisify-substrate';20import {IKeyringPair} from '@polkadot/types/types';20import {IKeyringPair} from '@polkadot/types/types';21import {submitTransactionAsync} from './substrate-api';21import {submitTransactionAsync} from './substrate-api';22import {getGenericResult} from '../util/helpers';22import {getGenericResult} from '../deprecated-helpers/helpers';23import {expect} from 'chai';23import {expect} from 'chai';242425export default async function getBalance(api: ApiPromise, accounts: string[]): Promise<Array<bigint>> {25export default async function getBalance(api: ApiPromise, accounts: string[]): Promise<Array<bigint>> {tests/src/transfer.nload.tsdiffbeforeafterboth18import {IKeyringPair} from '@polkadot/types/types';18import {IKeyringPair} from '@polkadot/types/types';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';20import waitNewBlocks from './substrate/wait-new-blocks';20import waitNewBlocks from './substrate/wait-new-blocks';21import {findUnusedAddresses} from './util/helpers';22import * as cluster from 'cluster';21import * as cluster from 'cluster';23import os from 'os';22import os from 'os';2324async function findUnusedAddress(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, seedAddition = ''): Promise<IKeyringPair> {25 let bal = 0n;26 let unused;27 do {28 const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000)) + seedAddition;29 unused = privateKeyWrapper(`//${randomSeed}`);30 bal = (await api.query.system.account(unused.address)).data.free.toBigInt();31 } while (bal !== 0n);32 return unused;33}3435function findUnusedAddresses(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, amount: number): Promise<IKeyringPair[]> {36 return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, privateKeyWrapper, '_' + Date.now())));37}243825// Innacurate transfer fee39// Innacurate transfer fee26const FEE = 10n ** 8n;40const FEE = 10n ** 8n;tests/src/tx-version-presence.test.tsdiffbeforeafterboth22describe('TxVersion is present', () => {22describe('TxVersion is present', () => {23 before(async () => {23 before(async () => {24 await usingPlaygrounds(async helper => {24 await usingPlaygrounds(async helper => {25 metadata = await helper.api!.rpc.state.getMetadata();25 metadata = await helper.callRpc('api.rpc.state.getMetadata', []);26 });26 });27 });27 });2828tests/src/util/contracthelpers.tsdiffbeforeafterbothno changes
tests/src/util/helpers.tsdiffbeforeafterbothno changes
tests/src/util/playgrounds/index.tsdiffbeforeafterboth38 Fungible = 'fungible',38 Fungible = 'fungible',39 NFT = 'nonfungible',39 NFT = 'nonfungible',40 Scheduler = 'scheduler',40 Scheduler = 'scheduler',41 AppPromotion = 'apppromotion',41}42}424343export function requirePalletsOrSkip(test: Context, helper: DevUniqueHelper, requiredPallets: string[]) {44export function requirePalletsOrSkip(test: Context, helper: DevUniqueHelper, requiredPallets: string[]) {tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth215 };215 };216216217 isDevNode = async () => {217 isDevNode = async () => {218 const block1 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(1));218 const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]);219 const block2 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(2));219 const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]);220 const findCreationDate = async (block: any) => {220 const findCreationDate = async (block: any) => {221 const humanBlock = block.toHuman();221 const humanBlock = block.toHuman();222 let date;222 let date;259 async newBlocks(blocksCount = 1): Promise<void> {259 async newBlocks(blocksCount = 1): Promise<void> {260 // eslint-disable-next-line no-async-promise-executor260 // eslint-disable-next-line no-async-promise-executor261 const promise = new Promise<void>(async (resolve) => {261 const promise = new Promise<void>(async (resolve) => {262 const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(() => {262 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {263 if (blocksCount > 0) {263 if (blocksCount > 0) {264 blocksCount--;264 blocksCount--;265 } else {265 } else {274 async forParachainBlockNumber(blockNumber: bigint) {274 async forParachainBlockNumber(blockNumber: bigint) {275 // eslint-disable-next-line no-async-promise-executor275 // eslint-disable-next-line no-async-promise-executor276 return new Promise<void>(async (resolve) => {276 return new Promise<void>(async (resolve) => {277 const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(async (data: any) => {277 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {278 if (data.number.toNumber() >= blockNumber) {278 if (data.number.toNumber() >= blockNumber) {279 unsubscribe();279 unsubscribe();280 resolve();280 resolve();286 async forRelayBlockNumber(blockNumber: bigint) {286 async forRelayBlockNumber(blockNumber: bigint) {287 // eslint-disable-next-line no-async-promise-executor287 // eslint-disable-next-line no-async-promise-executor288 return new Promise<void>(async (resolve) => {288 return new Promise<void>(async (resolve) => {289 const unsubscribe = await this.helper.api!.query.parachainSystem.validationData(async (data: any) => {289 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {290 if (data.value.relayParentNumber.toNumber() >= blockNumber) {290 if (data.value.relayParentNumber.toNumber() >= blockNumber) {291 // @ts-ignore291 // @ts-ignore292 unsubscribe();292 unsubscribe();tests/src/util/playgrounds/unique.tsdiffbeforeafterboth330 this.chainLog = [];330 this.chainLog = [];331 }331 }332333 getApi(): ApiPromise {334 if(this.api === null) throw Error('API not initialized');335 return this.api;336 }332337333 clearChainLog(): void {338 clearChainLog(): void {334 this.chainLog = [];339 this.chainLog = [];1986 * @returns ss58Format, token decimals, and token symbol1991 * @returns ss58Format, token decimals, and token symbol1987 */1992 */1988 getChainProperties(): IChainProperties {1993 getChainProperties(): IChainProperties {1989 const properties = (this.helper.api as any).registry.getChainProperties().toJSON();1994 const properties = (this.helper.getApi() as any).registry.getChainProperties().toJSON();1990 return {1995 return {1991 ss58Format: properties.ss58Format.toJSON(),1996 ss58Format: properties.ss58Format.toJSON(),1992 tokenDecimals: properties.tokenDecimals.toJSON(),1997 tokenDecimals: properties.tokenDecimals.toJSON(),2029 * @returns number, account's nonce2034 * @returns number, account's nonce2030 */2035 */2031 async getNonce(address: TSubstrateAccount): Promise<number> {2036 async getNonce(address: TSubstrateAccount): Promise<number> {2032 return (await (this.helper.api as any).query.system.account(address)).nonce.toNumber();2037 return (await this.helper.callRpc('api.query.system.account', [address])).nonce.toNumber();2033 }2038 }2034}2039}20352040tests/src/util/util.tsdiffbeforeafterbothno changes
tests/src/xcm/xcmOpal.test.tsdiffbeforeafterboth21import {ApiOptions} from '@polkadot/api/types';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {executeTransaction} from './../substrate/substrate-api';23import usingApi, {executeTransaction} from './../substrate/substrate-api';24import {bigIntToDecimals, describe_xcm, getGenericResult, paraSiblingSovereignAccount} from './../util/helpers';24import {bigIntToDecimals, describe_xcm, getGenericResult, paraSiblingSovereignAccount, normalizeAccountId} from './../deprecated-helpers/helpers';25import waitNewBlocks from './../substrate/wait-new-blocks';25import waitNewBlocks from './../substrate/wait-new-blocks';26import {normalizeAccountId} from './../util/helpers';27import getBalance from './../substrate/get-balance';26import getBalance from './../substrate/get-balance';28272928tests/src/xcm/xcmQuartz.test.tsdiffbeforeafterboth21import {ApiOptions} from '@polkadot/api/types';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../util/helpers';24import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../deprecated-helpers/helpers';25import {MultiLocation} from '@polkadot/types/interfaces';25import {MultiLocation} from '@polkadot/types/interfaces';26import {blake2AsHex} from '@polkadot/util-crypto';26import {blake2AsHex} from '@polkadot/util-crypto';27import waitNewBlocks from '../substrate/wait-new-blocks';27import waitNewBlocks from '../substrate/wait-new-blocks';tests/src/xcm/xcmUnique.test.tsdiffbeforeafterboth21import {ApiOptions} from '@polkadot/api/types';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';23import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';24import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../util/helpers';24import {getGenericResult, generateKeyringPair, waitEvent, describe_xcm, bigIntToDecimals} from '../deprecated-helpers/helpers';25import {MultiLocation} from '@polkadot/types/interfaces';25import {MultiLocation} from '@polkadot/types/interfaces';26import {blake2AsHex} from '@polkadot/util-crypto';26import {blake2AsHex} from '@polkadot/util-crypto';27import waitNewBlocks from '../substrate/wait-new-blocks';27import waitNewBlocks from '../substrate/wait-new-blocks';