git.delta.rocks / unique-network / refs/commits / 85f3ef2e0166

difftreelog

move types and interfaces to types.ts

Max Andreev2022-08-24parent: #a36e310.patch.diff
in: master

3 files changed

addedtests/src/util/playgrounds/types.tsdiffbeforeafterboth

no changes

modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
33
4import {mnemonicGenerate} from '@polkadot/util-crypto';4import {mnemonicGenerate} from '@polkadot/util-crypto';
5import {UniqueHelper} from './unique';5import {UniqueHelper} from './unique';
6import {IKeyringPair} from '@polkadot/types/types';
7import {ApiPromise, WsProvider} from '@polkadot/api';6import {ApiPromise, WsProvider} from '@polkadot/api';
8import * as defs from '../../interfaces/definitions';7import * as defs from '../../interfaces/definitions';
8import { TSigner } from './types';
99
1010
11export class DevUniqueHelper extends UniqueHelper {11export class DevUniqueHelper extends UniqueHelper {
69 * @returns array of newly created accounts69 * @returns array of newly created accounts
70 * @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor); 70 * @example const [acc1, acc2, acc3] = await createAccounts([0n, 10n, 20n], donor);
71 */71 */
72 creteAccounts = async (balances: bigint[], donor: IKeyringPair): Promise<IKeyringPair[]> => {72 creteAccounts = async (balances: bigint[], donor: TSigner): Promise<TSigner[]> => {
73 let nonce = await this.helper.chain.getNonce(donor.address);73 let nonce = await this.helper.chain.getNonce(donor.address);
74 const tokenNominal = this.helper.balance.getOneTokenNominal();74 const tokenNominal = this.helper.balance.getOneTokenNominal();
75 const transactions = [];75 const transactions = [];
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
9import {ApiInterfaceEvents} from '@polkadot/api/types';9import {ApiInterfaceEvents} from '@polkadot/api/types';
10import {IKeyringPair} from '@polkadot/types/types';10import {IKeyringPair} from '@polkadot/types/types';
11import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm} from '@polkadot/util-crypto';11import {encodeAddress, decodeAddress, keccakAsHex, evmToAddress, addressToEvm} from '@polkadot/util-crypto';
12import { ICrossAccountIdLower, ICrossAccountId, TUniqueNetworks, IApiListeners, TApiAllowedListeners, TSigner, TSubstrateAccount, ICollectionLimits, ICollectionPermissions, INestingPermissions, IProperty, ITokenPropertyPermission, ICollectionCreationOptions, IToken, IChainProperties, TEthereumAccount } from './types';
1213
1314
14const crossAccountIdFromLower = (lowerAddress: ICrossAccountIdLower): ICrossAccountId => {15const crossAccountIdFromLower = (lowerAddress: ICrossAccountIdLower): ICrossAccountId => {
82 events?: any;83 events?: any;
83}84}
84
85interface IApiListeners {
86 connected?: (...args: any[]) => any;
87 disconnected?: (...args: any[]) => any;
88 error?: (...args: any[]) => any;
89 ready?: (...args: any[]) => any;
90 decorated?: (...args: any[]) => any;
91}
92
93interface ICrossAccountId {
94 Substrate?: TSubstrateAccount;
95 Ethereum?: TEthereumAccount;
96}
97
98interface ICrossAccountIdLower {
99 substrate?: TSubstrateAccount;
100 ethereum?: TEthereumAccount;
101}
102
103interface ICollectionLimits {
104 accountTokenOwnershipLimit?: number | null;
105 sponsoredDataSize?: number | null;
106 sponsoredDataRateLimit?: {blocks: number} | {sponsoringDisabled: null} | null;
107 tokenLimit?: number | null;
108 sponsorTransferTimeout?: number | null;
109 sponsorApproveTimeout?: number | null;
110 ownerCanTransfer?: boolean | null;
111 ownerCanDestroy?: boolean | null;
112 transfersEnabled?: boolean | null;
113}
114
115interface INestingPermissions {
116 tokenOwner?: boolean;
117 collectionAdmin?: boolean;
118 restricted?: number[] | null;
119}
120
121interface ICollectionPermissions {
122 access?: 'Normal' | 'AllowList';
123 mintMode?: boolean;
124 nesting?: INestingPermissions;
125}
126
127interface IProperty {
128 key: string;
129 value: string;
130}
131
132interface ITokenPropertyPermission {
133 key: string;
134 permission: {
135 mutable: boolean;
136 tokenOwner: boolean;
137 collectionAdmin: boolean;
138 }
139}
140
141interface IToken {
142 collectionId: number;
143 tokenId: number;
144}
145
146interface ICollectionCreationOptions {
147 name: string | number[];
148 description: string | number[];
149 tokenPrefix: string | number[];
150 mode?: {
151 nft?: null;
152 refungible?: null;
153 fungible?: number;
154 }
155 permissions?: ICollectionPermissions;
156 properties?: IProperty[];
157 tokenPropertyPermissions?: ITokenPropertyPermission[];
158 limits?: ICollectionLimits;
159 pendingSponsor?: TSubstrateAccount;
160}
161
162interface IChainProperties {
163 ss58Format: number;
164 tokenDecimals: number[];
165 tokenSymbol: string[]
166}
167
168type TSubstrateAccount = string;
169type TEthereumAccount = string;
170type TApiAllowedListeners = 'connected' | 'disconnected' | 'error' | 'ready' | 'decorated';
171type TUniqueNetworks = 'opal' | 'quartz' | 'unique';
172type TSigner = IKeyringPair; // | 'string'
17385
174class UniqueUtil {86class UniqueUtil {
175 static transactionStatus = {87 static transactionStatus = {