Skip to content

Commit

Permalink
feat: compile playgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Grigoriy Simonov committed Oct 22, 2023
1 parent 35c1755 commit d50ff3f
Show file tree
Hide file tree
Showing 176 changed files with 4,986 additions and 5,027 deletions.
4 changes: 3 additions & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"mocha": "^10.1.0",
"mochawesome": "^7.1.3",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"mocha": {
"timeout": 9999999,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/enableContractSponsoring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi from '../substrate/substrate-api';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/overflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi from '../substrate/substrate-api';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/removeFromContractAllowList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import usingApi from '../substrate/substrate-api';
import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from '../deprecated-helpers/contracthelpers';
import {addToContractAllowListExpectSuccess, isAllowlistedInContract, removeFromContractAllowListExpectFailure, removeFromContractAllowListExpectSuccess, toggleContractAllowlistExpectSuccess} from '../deprecated-helpers/helpers';
import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {expect} from 'chai';

// todo:playgrounds skipped again
Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/setChainLimits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import usingApi from '../substrate/substrate-api';
import {
createCollectionExpectSuccess,
Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/setContractSponsoringRateLimit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import usingApi from '../substrate/substrate-api';
import waitNewBlocks from '../substrate/wait-new-blocks';
import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from '../deprecated-helpers/contracthelpers';
Expand Down
4 changes: 2 additions & 2 deletions tests/src/.outdated/substrate/get-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import {ApiPromise} from '@polkadot/api';
import {AccountInfo} from '@polkadot/types/interfaces/system';
import promisifySubstrate from './promisify-substrate';
import {IKeyringPair} from '@polkadot/types/types';
import promisifySubstrate from './promisify-substrate.js';
import type {IKeyringPair} from '@polkadot/types/types';
import {submitTransactionAsync} from './substrate-api';
import {getGenericResult} from '../deprecated-helpers/helpers';
import {expect} from 'chai';
Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/substrate/privateKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {Keyring} from '@polkadot/api';
import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';

// WARNING: the WASM interface must be initialized before this function is called.
// Use either `usingApi`, or `cryptoWaitReady` for consistency.
Expand Down
18 changes: 9 additions & 9 deletions tests/src/.outdated/substrate/substrate-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {ApiPromise, WsProvider} from '@polkadot/api';
import {ApiOptions, ApiTypes, SubmittableExtrinsic} from '@polkadot/api/types';
import {ExtrinsicStatus} from '@polkadot/types/interfaces/author/types';
import {EventRecord} from '@polkadot/types/interfaces/system/types';
import {IKeyringPair} from '@polkadot/types/types';
import config from '../../config';
import type {ApiOptions, ApiTypes, SubmittableExtrinsic} from '@polkadot/api/types';
import type {ExtrinsicStatus} from '@polkadot/types/interfaces/author/types';
import type {EventRecord} from '@polkadot/types/interfaces/system/types';
import type {IKeyringPair} from '@polkadot/types/types';
import config from '../../config.js';
import '../../interfaces/augment-api-events';
import * as defs from '../../interfaces/definitions';
import privateKey from './privateKey';
import promisifySubstrate from './promisify-substrate';
import * as defs from '../../interfaces/definitions.js';
import privateKey from './privateKey.js';
import promisifySubstrate from './promisify-substrate.js';

import {SilentConsole} from '../../util/playgrounds/unique.dev';
import {SilentConsole} from '../../util/playgrounds/unique.dev.js';



Expand Down
2 changes: 1 addition & 1 deletion tests/src/.outdated/xcmTransfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import chaiAsPromised from 'chai-as-promised';

import {WsProvider} from '@polkadot/api';
import {ApiOptions} from '@polkadot/api/types';
import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
import {getGenericResult} from '../deprecated-helpers/helpers';
import waitNewBlocks from '../substrate/wait-new-blocks';
Expand Down
6 changes: 3 additions & 3 deletions tests/src/addCollectionAdmin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util';
import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from './util/index.js';
import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types.js';

describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
let donor: IKeyringPair;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/adminTransferAndBurn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util/index.js';

describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {
let alice: IKeyringPair;
Expand Down
7 changes: 4 additions & 3 deletions tests/src/allowLists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util';
import {ICollectionPermissions, NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util/index.js';
import type {ICollectionPermissions} from './util/playgrounds/types.js';
import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types.js';

describe('Integration Test ext. Allow list tests', () => {
let alice: IKeyringPair;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/apiConsts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {ApiPromise} from '@polkadot/api';
import {usingPlaygrounds, itSub, expect, COLLECTION_HELPER, CONTRACT_HELPER} from './util';
import {usingPlaygrounds, itSub, expect, COLLECTION_HELPER, CONTRACT_HELPER} from './util/index.js';


const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;
Expand Down
6 changes: 3 additions & 3 deletions tests/src/approve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import {expect, itSub, Pallets, usingPlaygrounds} from './util';
import {CrossAccountId} from './util/playgrounds/unique';
import type {IKeyringPair} from '@polkadot/types/types';
import {expect, itSub, Pallets, usingPlaygrounds} from './util/index.js';
import {CrossAccountId} from './util/playgrounds/unique.js';



Expand Down
17 changes: 8 additions & 9 deletions tests/src/benchmarks/mintFee/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';
import {usingEthPlaygrounds} from '../../eth/util/index.js';
import {EthUniqueHelper} from '../../eth/util/playgrounds/unique.dev.js';
import {readFile} from 'fs/promises';
import {
ICrossAccountId,
} from '../../util/playgrounds/types';
import {IKeyringPair} from '@polkadot/types/types';
import {UniqueNFTCollection} from '../../util/playgrounds/unique';
import type {ICrossAccountId} from '../../util/playgrounds/types.js';
import type {IKeyringPair} from '@polkadot/types/types';
import {UniqueNFTCollection} from '../../util/playgrounds/unique.js';
import {Contract} from 'web3-eth-contract';
import {createObjectCsvWriter} from 'csv-writer';
import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES} from '../utils/common';
import {makeNames} from '../../util';
import {ContractImports} from '../../eth/util/playgrounds/types';
import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES} from '../utils/common.js';
import {makeNames} from '../../util/index.js';
import type {ContractImports} from '../../eth/util/playgrounds/types.js';

const {dirname} = makeNames(import.meta.url);

Expand Down
3 changes: 1 addition & 2 deletions tests/src/benchmarks/nesting/ABIGEN/RMRKNestableMintable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import type { EventLog } from "web3-core";
import type { EventEmitter } from "events";
import type {
Callback,
PayableTransactionObject,
NonPayableTransactionObject,
BlockType,
ContractEventLog,
BaseContract,
} from "./types";
} from "./types.js";

export interface EventOptions {
filter?: object;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/benchmarks/nesting/ABIGEN/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { RMRKNestableMintable } from "./RMRKNestableMintable";
export type { RMRKNestableMintable } from "./RMRKNestableMintable.js";
13 changes: 7 additions & 6 deletions tests/src/benchmarks/nesting/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';
import {usingEthPlaygrounds} from '../../eth/util/index.js';
import {EthUniqueHelper} from '../../eth/util/playgrounds/unique.dev.js';
import {readFile} from 'fs/promises';
import {IKeyringPair} from '@polkadot/types/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
import {convertToTokens} from '../utils/common';
import {makeNames} from '../../util';
import {ContractImports} from '../../eth/util/playgrounds/types';
import {RMRKNestableMintable} from './ABIGEN';
import {convertToTokens} from '../utils/common.js';
import {makeNames} from '../../util/index.js';
import type {ContractImports} from '../../eth/util/playgrounds/types.js';
import type {RMRKNestableMintable} from './ABIGEN/index.js';

const {dirname} = makeNames(import.meta.url);

Expand Down
16 changes: 9 additions & 7 deletions tests/src/benchmarks/opsFee/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {EthUniqueHelper, usingEthPlaygrounds} from '../../eth/util';
import {usingEthPlaygrounds} from '../../eth/util/index.js';
import {EthUniqueHelper} from '../../eth/util/playgrounds/unique.dev.js';
import {readFile} from 'fs/promises';
import {CollectionLimitField, CreateCollectionData, TokenPermissionField} from '../../eth/util/playgrounds/types';
import {IKeyringPair} from '@polkadot/types/types';
import {UniqueFTCollection, UniqueNFTCollection} from '../../util/playgrounds/unique';
import {CollectionLimitField, CreateCollectionData, TokenPermissionField} from '../../eth/util/playgrounds/types.js';
import type {IKeyringPair} from '@polkadot/types/types';
import {UniqueFTCollection, UniqueNFTCollection} from '../../util/playgrounds/unique.js';
import {Contract} from 'web3-eth-contract';
import {createObjectCsvWriter} from 'csv-writer';
import {FunctionFeeVM, IFunctionFee} from '../utils/types';
import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES, SUBS_PROPERTIES} from '../utils/common';
import {makeNames} from '../../util';
import {FunctionFeeVM} from '../utils/types.js';
import type {IFunctionFee} from '../utils/types.js';
import {convertToTokens, createCollectionForBenchmarks, PERMISSIONS, PROPERTIES, SUBS_PROPERTIES} from '../utils/common.js';
import {makeNames} from '../../util/index.js';


const {dirname} = makeNames(import.meta.url);
Expand Down
8 changes: 4 additions & 4 deletions tests/src/benchmarks/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {EthUniqueHelper} from '../../eth/util';
import {ITokenPropertyPermission, TCollectionMode} from '../../util/playgrounds/types';
import {UniqueNFTCollection, UniqueRFTCollection} from '../../util/playgrounds/unique';
import {IKeyringPair} from '@polkadot/types/types';
import {EthUniqueHelper} from '../../eth/util/playgrounds/unique.dev.js';
import {UniqueNFTCollection, UniqueRFTCollection} from '../../util/playgrounds/unique.js';
import type {ITokenPropertyPermission, TCollectionMode} from '../../util/playgrounds/types.js';
import type {IKeyringPair} from '@polkadot/types/types';

export const PROPERTIES = Array(40)
.fill(0)
Expand Down
4 changes: 2 additions & 2 deletions tests/src/burnItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import {expect, itSub, usingPlaygrounds} from './util';
import type {IKeyringPair} from '@polkadot/types/types';
import {expect, itSub, usingPlaygrounds} from './util/index.js';


describe('integration test: ext. burnItem():', () => {
Expand Down
19 changes: 10 additions & 9 deletions tests/src/calibrate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {IKeyringPair} from '@polkadot/types/types';
import {usingEthPlaygrounds, EthUniqueHelper} from './eth/util';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingEthPlaygrounds} from './eth/util/index.js';
import {EthUniqueHelper} from './eth/util/playgrounds/unique.dev.js';

class Fract {
static ZERO = new Fract(0n);
Expand Down Expand Up @@ -174,14 +175,14 @@ function linearRegression(points: { x: Fract, y: Fract }[]) {

const hypothesisLinear = (a: Fract, b: Fract) => (x: Fract) => rpn(x, a, '*', b, '+');

function _error(points: { x: Fract, y: Fract }[], hypothesis: (a: Fract) => Fract) {
return points.map(p => {
const v = hypothesis(p.x);
const vv = p.y;
// function error(points: { x: Fract, y: Fract }[], hypothesis: (a: Fract) => Fract) {
// return points.map(p => {
// const v = hypothesis(p.x);
// const vv = p.y;

return rpn(v, vv, '-', 'dup', '*');
}).reduce((a, b) => a.plus(b), Fract.ZERO).sqrt().div(new Fract(BigInt(points.length)));
}
// return rpn(v, vv, '-', 'dup', '*');
// }).reduce((a, b) => a.plus(b), Fract.ZERO).sqrt().div(new Fract(BigInt(points.length)));
// }

async function calibrateWeightToFee(helper: EthUniqueHelper, privateKey: (account: string) => Promise<IKeyringPair>) {
const alice = await privateKey('//Alice');
Expand Down
4 changes: 2 additions & 2 deletions tests/src/calibrateApply.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {readFile, writeFile} from 'fs/promises';
import path from 'path';
import usingApi from './.outdated/substrate/substrate-api';
import {makeNames} from './util';
import usingApi from './.outdated/substrate/substrate-api.js';
import {makeNames} from './util/index.js';

const {dirname} = makeNames(import.meta.url);

Expand Down
6 changes: 3 additions & 3 deletions tests/src/change-collection-owner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util';
import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from './util/index.js';
import {NON_EXISTENT_COLLECTION_ID} from './util/playgrounds/types.js';

describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {
let alice: IKeyringPair;
Expand Down
6 changes: 3 additions & 3 deletions tests/src/check-event/burnItemEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from '../util';
import {IEvent} from '../util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, expect, itSub} from '../util/index.js';
import type {IEvent} from '../util/playgrounds/types.js';


describe('Burn Item event ', () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/src/check-event/createCollectionEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, itSub, expect} from '../util';
import {IEvent} from '../util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, itSub, expect} from '../util/index.js';
import type {IEvent} from '../util/playgrounds/types.js';

describe('Create collection event ', () => {
let alice: IKeyringPair;
Expand Down
6 changes: 3 additions & 3 deletions tests/src/check-event/createItemEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from '../util';
import {IEvent} from '../util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from '../util/index.js';
import type {IEvent} from '../util/playgrounds/types.js';

describe('Create Item event ', () => {
let alice: IKeyringPair;
Expand Down
6 changes: 3 additions & 3 deletions tests/src/check-event/createMultipleItemsEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, itSub, expect} from '../util';
import {IEvent} from '../util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, itSub, expect} from '../util/index.js';
import type {IEvent} from '../util/playgrounds/types.js';

describe('Create Multiple Items Event event ', () => {
let alice: IKeyringPair;
Expand Down
6 changes: 3 additions & 3 deletions tests/src/check-event/destroyCollectionEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.

// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from '../util';
import {IEvent} from '../util/playgrounds/types';
import type {IKeyringPair} from '@polkadot/types/types';
import {itSub, usingPlaygrounds, expect} from '../util/index.js';
import type {IEvent} from '../util/playgrounds/types.js';

describe('Destroy collection event ', () => {
let alice: IKeyringPair;
Expand Down
Loading

0 comments on commit d50ff3f

Please sign in to comment.