difftreelog
move types and interfaces to types.ts
in: master
3 files changed
tests/src/util/playgrounds/types.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import {IKeyringPair} from '@polkadot/types/types';56export interface IChainEvent {7 data: any;8 method: string;9 section: string;10}1112export interface ITransactionResult {13 status: 'Fail' | 'Success';14 result: {15 events: {16 event: IChainEvent17 }[];18 },19 moduleError?: string;20}2122export interface ILogger {23 log: (msg: any, level?: string) => void;24 level: {25 ERROR: 'ERROR';26 WARNING: 'WARNING';27 INFO: 'INFO';28 [key: string]: string;29 }30}3132export interface IUniqueHelperLog {33 executedAt: number;34 executionTime: number;35 type: 'extrinsic' | 'rpc';36 status: 'Fail' | 'Success';37 call: string;38 params: any[];39 moduleError?: string;40 events?: any;41}4243export interface IApiListeners {44 connected?: (...args: any[]) => any;45 disconnected?: (...args: any[]) => any;46 error?: (...args: any[]) => any;47 ready?: (...args: any[]) => any; 48 decorated?: (...args: any[]) => any;49}5051export interface ICrossAccountId {52 Substrate?: TSubstrateAccount;53 Ethereum?: TEthereumAccount;54}5556export interface ICrossAccountIdLower {57 substrate?: TSubstrateAccount;58 ethereum?: TEthereumAccount;59}6061export interface ICollectionLimits {62 accountTokenOwnershipLimit?: number | null;63 sponsoredDataSize?: number | null;64 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;65 tokenLimit?: number | null;66 sponsorTransferTimeout?: number | null;67 sponsorApproveTimeout?: number | null;68 ownerCanTransfer?: boolean | null;69 ownerCanDestroy?: boolean | null;70 transfersEnabled?: boolean | null;71}7273export interface INestingPermissions {74 tokenOwner?: boolean;75 collectionAdmin?: boolean;76 restricted?: number[] | null;77}7879export interface ICollectionPermissions {80 access?: 'Normal' | 'AllowList';81 mintMode?: boolean;82 nesting?: INestingPermissions;83}8485export interface IProperty {86 key: string;87 value: string;88}8990export interface ITokenPropertyPermission {91 key: string;92 permission: {93 mutable: boolean;94 tokenOwner: boolean;95 collectionAdmin: boolean;96 }97}9899export interface IToken {100 collectionId: number;101 tokenId: number;102}103104export interface ICollectionCreationOptions {105 name: string | number[];106 description: string | number[];107 tokenPrefix: string | number[];108 mode?: {109 nft?: null;110 refungible?: null;111 fungible?: number;112 }113 permissions?: ICollectionPermissions;114 properties?: IProperty[];115 tokenPropertyPermissions?: ITokenPropertyPermission[];116 limits?: ICollectionLimits;117 pendingSponsor?: TSubstrateAccount;118}119120export interface IChainProperties {121 ss58Format: number;122 tokenDecimals: number[];123 tokenSymbol: string[]124}125126export type TSubstrateAccount = string;127export type TEthereumAccount = string;128export type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';129export type TUniqueNetworks = 'opal' | 'quartz' | 'unique';130export type TSigner = IKeyringPair; // | 'string'tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -3,9 +3,9 @@
import {mnemonicGenerate} from '@polkadot/util-crypto';
import {UniqueHelper} from './unique';
-import {IKeyringPair} from '@polkadot/types/types';
import {ApiPromise, WsProvider} from '@polkadot/api';
import * as defs from '../../interfaces/definitions';
+import { TSigner } from './types';
export class DevUniqueHelper extends UniqueHelper {
@@ -69,7 +69,7 @@
* @returns array of newly created accounts
* @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor);
*/
- creteAccounts = async (balances: bigint[], donor: IKeyringPair): Promise<IKeyringPair[]> => {
+ creteAccounts = async (balances: bigint[], donor: TSigner): Promise<TSigner[]> => {
let nonce = await this.helper.chain.getNonce(donor.address);
const tokenNominal = this.helper.balance.getOneTokenNominal();
const transactions = [];
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -9,6 +9,7 @@
import {ApiInterfaceEvents} from '@polkadot/api/types';
import {IKeyringPair} from '@polkadot/types/types';
import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm} from '@polkadot/util-crypto';
+import { ICrossAccountIdLower, ICrossAccountId, TUniqueNetworks, IApiListeners, TApiAllowedListeners, TSigner, TSubstrateAccount, ICollectionLimits, ICollectionPermissions, INestingPermissions, IProperty, ITokenPropertyPermission, ICollectionCreationOptions, IToken, IChainProperties, TEthereumAccount } from './types';
const crossAccountIdFromLower = (lowerAddress: ICrossAccountIdLower): ICrossAccountId => {
@@ -80,96 +81,7 @@
params: any[];
moduleError?: string;
events?: any;
-}
-
-interface IApiListeners {
- connected?: (...args: any[]) => any;
- disconnected?: (...args: any[]) => any;
- error?: (...args: any[]) => any;
- ready?: (...args: any[]) => any;
- decorated?: (...args: any[]) => any;
-}
-
-interface ICrossAccountId {
- Substrate?: TSubstrateAccount;
- Ethereum?: TEthereumAccount;
-}
-
-interface ICrossAccountIdLower {
- substrate?: TSubstrateAccount;
- ethereum?: TEthereumAccount;
-}
-
-interface ICollectionLimits {
- accountTokenOwnershipLimit?: number | null;
- sponsoredDataSize?: number | null;
- sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;
- tokenLimit?: number | null;
- sponsorTransferTimeout?: number | null;
- sponsorApproveTimeout?: number | null;
- ownerCanTransfer?: boolean | null;
- ownerCanDestroy?: boolean | null;
- transfersEnabled?: boolean | null;
-}
-
-interface INestingPermissions {
- tokenOwner?: boolean;
- collectionAdmin?: boolean;
- restricted?: number[] | null;
-}
-
-interface ICollectionPermissions {
- access?: 'Normal' | 'AllowList';
- mintMode?: boolean;
- nesting?: INestingPermissions;
-}
-
-interface IProperty {
- key: string;
- value: string;
-}
-
-interface ITokenPropertyPermission {
- key: string;
- permission: {
- mutable: boolean;
- tokenOwner: boolean;
- collectionAdmin: boolean;
- }
}
-
-interface IToken {
- collectionId: number;
- tokenId: number;
-}
-
-interface ICollectionCreationOptions {
- name: string | number[];
- description: string | number[];
- tokenPrefix: string | number[];
- mode?: {
- nft?: null;
- refungible?: null;
- fungible?: number;
- }
- permissions?: ICollectionPermissions;
- properties?: IProperty[];
- tokenPropertyPermissions?: ITokenPropertyPermission[];
- limits?: ICollectionLimits;
- pendingSponsor?: TSubstrateAccount;
-}
-
-interface IChainProperties {
- ss58Format: number;
- tokenDecimals: number[];
- tokenSymbol: string[]
-}
-
-type TSubstrateAccount = string;
-type TEthereumAccount = string;
-type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';
-type TUniqueNetworks = 'opal' | 'quartz' | 'unique';
-type TSigner = IKeyringPair; // | 'string'
class UniqueUtil {
static transactionStatus = {