git.delta.rocks / unique-network / refs/commits / 47f1fe8177c4

difftreelog

fix eslint errors in playgrounds

Maksandre2022-08-08parent: #d944b14.patch.diff
in: master

2 files changed

modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/index.ts
+++ b/tests/src/util/playgrounds/index.ts
@@ -1,18 +1,18 @@
-import { IKeyringPair } from '@polkadot/types/types';
-import { UniqueHelper } from './unique';
+import {IKeyringPair} from '@polkadot/types/types';
+import {UniqueHelper} from './unique';
 import config from '../../config';
 import '../../interfaces/augment-api-events';
 import * as defs from '../../interfaces/definitions';
-import { ApiPromise, WsProvider } from '@polkadot/api';
+import {ApiPromise, WsProvider} from '@polkadot/api';
 
 
 class SilentLogger {
   log(msg: any, level: any): void {}
   level = {
-    ERROR: 'ERROR' as 'ERROR',
-    WARNING: 'WARNING' as 'WARNING',
-    INFO: 'INFO' as 'INFO'
-  }
+    ERROR: 'ERROR' as const,
+    WARNING: 'WARNING' as const,
+    INFO: 'INFO' as const,
+  };
 }
 
 
@@ -87,4 +87,4 @@
     console.log = consoleLog;
     console.warn = consoleWarn;
   }
-}
\ No newline at end of file
+};
\ No newline at end of file
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
11/* eslint-disable @typescript-eslint/no-var-requires */
2/* eslint-disable function-call-argument-newline */
3/* eslint-disable no-prototype-builtins */
4
2import { ApiPromise, WsProvider, Keyring } from '@polkadot/api';5import {ApiPromise, WsProvider, Keyring} from '@polkadot/api';
3import { ApiInterfaceEvents } from '@polkadot/api/types';6import {ApiInterfaceEvents} from '@polkadot/api/types';
69
710
8const crossAccountIdFromLower = (lowerAddress: ICrossAccountIdLower): ICrossAccountId => {11const crossAccountIdFromLower = (lowerAddress: ICrossAccountIdLower): ICrossAccountId => {
9 let address = {} as ICrossAccountId;12 const address = {} as ICrossAccountId;
10 if(lowerAddress.substrate) address.Substrate = lowerAddress.substrate;13 if(lowerAddress.substrate) address.Substrate = lowerAddress.substrate;
11 if(lowerAddress.ethereum) address.Ethereum = lowerAddress.ethereum;14 if(lowerAddress.ethereum) address.Ethereum = lowerAddress.ethereum;
12 return address;15 return address;
13}16};
1417
1518
16const nesting = {19const nesting = {
2124
22 address = address.toLowerCase().replace(/^0x/i,'');25 address = address.toLowerCase().replace(/^0x/i,'');
23 const addressHash = keccakAsHex(address).replace(/^0x/i,'');26 const addressHash = keccakAsHex(address).replace(/^0x/i,'');
24 let checksumAddress = ['0x'];27 const checksumAddress = ['0x'];
2528
26 for (let i = 0; i < address.length; i++ ) {29 for (let i = 0; i < address.length; i++) {
27 // If ith character is 8 to f then make it uppercase30 // If ith character is 8 to f then make it uppercase
37 return this.toChecksumAddress(40 return this.toChecksumAddress(`0xf8238ccfff8ed887463fd5e0${collectionId.toString(16).padStart(8, '0')}${tokenId.toString(16).padStart(8, '0')}`);
38 `0xf8238ccfff8ed887463fd5e0${collectionId.toString(16).padStart(8, '0')}${tokenId.toString(16).padStart(8, '0')}`
39 );
40 }41 },
41};42};
4243
4344
172 NOT_READY: 'NotReady',173 NOT_READY: 'NotReady',
173 FAIL: 'Fail',174 FAIL: 'Fail',
174 SUCCESS: 'Success'175 SUCCESS: 'Success',
175 }176 };
176177
177 static chainLogType = {178 static chainLogType = {
178 EXTRINSIC: 'extrinsic',179 EXTRINSIC: 'extrinsic',
179 RPC: 'rpc'180 RPC: 'rpc',
180 }181 };
181182
182 static getNestingTokenAddress(collectionId: number, tokenId: number) {183 static getNestingTokenAddress(collectionId: number, tokenId: number) {
183 return nesting.tokenIdToAddress(collectionId, tokenId);184 return nesting.tokenIdToAddress(collectionId, tokenId);
227 });228 });
228229
229 if (collectionId === null) {230 if (collectionId === null) {
230 throw Error(`No CollectionCreated event for ${label}`)231 throw Error(`No CollectionCreated event for ${label}`);
231 }232 }
232233
233 return collectionId;234 return collectionId;
237 if (creationResult.status !== this.transactionStatus.SUCCESS) {238 if (creationResult.status !== this.transactionStatus.SUCCESS) {
238 throw Error(`Unable to create tokens for ${label}`);239 throw Error(`Unable to create tokens for ${label}`);
239 }240 }
240 let success = false, tokens = [] as any;241 let success = false;
242 const tokens = [] as any;
241 creationResult.result.events.forEach(({event: {data, method, section}}) => {243 creationResult.result.events.forEach(({event: {data, method, section}}) => {
242 if (method === 'ExtrinsicSuccess') {244 if (method === 'ExtrinsicSuccess') {
243 success = true;245 success = true;
256 if (burnResult.status !== this.transactionStatus.SUCCESS) {258 if (burnResult.status !== this.transactionStatus.SUCCESS) {
257 throw Error(`Unable to burn tokens for ${label}`);259 throw Error(`Unable to burn tokens for ${label}`);
258 }260 }
259 let success = false, tokens = [] as any;261 let success = false;
262 const tokens = [] as any;
260 burnResult.result.events.forEach(({event: {data, method, section}}) => {263 burnResult.result.events.forEach(({event: {data, method, section}}) => {
261 if (method === 'ExtrinsicSuccess') {264 if (method === 'ExtrinsicSuccess') {
262 success = true;265 success = true;
288 static isTokenTransferSuccess(events: {event: IChainEvent}[], collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount=1n) {291 static isTokenTransferSuccess(events: {event: IChainEvent}[], collectionId: number, tokenId: number, fromAddressObj: ICrossAccountId, toAddressObj: ICrossAccountId, amount=1n) {
289 const normalizeAddress = (address: string | ICrossAccountId) => {292 const normalizeAddress = (address: string | ICrossAccountId) => {
290 if(typeof address === 'string') return address;293 if(typeof address === 'string') return address;
291 let obj = {} as any;294 const obj = {} as any;
292 Object.keys(address).forEach(k => {295 Object.keys(address).forEach(k => {
293 obj[k.toLocaleLowerCase()] = address[k as 'Substrate' | 'Ethereum'];296 obj[k.toLocaleLowerCase()] = address[k as 'Substrate' | 'Ethereum'];
294 });297 });
295 if(obj.substrate) return {Substrate: this.normalizeSubstrateAddress(obj.substrate)};298 if(obj.substrate) return {Substrate: this.normalizeSubstrateAddress(obj.substrate)};
296 if(obj.ethereum) return {Ethereum: obj.ethereum.toLocaleLowerCase()};299 if(obj.ethereum) return {Ethereum: obj.ethereum.toLocaleLowerCase()};
297 return address;300 return address;
298 }301 };
299 let transfer = {collectionId: null, tokenId: null, from: null, to: null, amount: 1} as any;302 let transfer = {collectionId: null, tokenId: null, from: null, to: null, amount: 1} as any;
300 events.forEach(({event: {data, method, section}}) => {303 events.forEach(({event: {data, method, section}}) => {
301 if ((section === 'common') && (method === 'Transfer')) {304 if ((section === 'common') && (method === 'Transfer')) {
302 let hData = (data as any).toJSON();305 const hData = (data as any).toJSON();
303 transfer = {306 transfer = {
304 collectionId: hData[0],307 collectionId: hData[0],
305 tokenId: hData[1],308 tokenId: hData[1],
361 }364 }
362365
363 static async detectNetwork(api: ApiPromise): Promise<TUniqueNetworks> {366 static async detectNetwork(api: ApiPromise): Promise<TUniqueNetworks> {
364 let spec = (await api.query.system.lastRuntimeUpgrade()).toJSON() as any;367 const spec = (await api.query.system.lastRuntimeUpgrade()).toJSON() as any;
365 if(['quartz', 'unique'].indexOf(spec.specName) > -1) return spec.specName;368 if(['quartz', 'unique'].indexOf(spec.specName) > -1) return spec.specName;
366 return 'opal';369 return 'opal';
367 }370 }
368371
369 static async detectNetworkByWsEndpoint(wsEndpoint: string): Promise<TUniqueNetworks> {372 static async detectNetworkByWsEndpoint(wsEndpoint: string): Promise<TUniqueNetworks> {
370 let api = new ApiPromise({provider: new WsProvider(wsEndpoint)});373 const api = new ApiPromise({provider: new WsProvider(wsEndpoint)});
371 await api.isReady;374 await api.isReady;
372375
373 const network = await this.detectNetwork(api);376 const network = await this.detectNetwork(api);
392 unique: {395 unique: {
393 unique: require('@unique-nft/unique-mainnet-types/definitions').unique.rpc396 unique: require('@unique-nft/unique-mainnet-types/definitions').unique.rpc,
394 }397 },
395 }398 };
396 if(!supportedRPC.hasOwnProperty(network)) network = await this.detectNetworkByWsEndpoint(wsEndpoint);399 if(!supportedRPC.hasOwnProperty(network)) network = await this.detectNetworkByWsEndpoint(wsEndpoint);
397 const rpc = supportedRPC[network];400 const rpc = supportedRPC[network];
398401
404 await api.isReadyOrError;407 await api.isReadyOrError;
405408
406 if (typeof listeners === 'undefined') listeners = {};409 if (typeof listeners === 'undefined') listeners = {};
407 for (let event of ['connected', 'disconnected', 'error', 'ready', 'decorated']) {410 for (const event of ['connected', 'disconnected', 'error', 'ready', 'decorated']) {
408 if (!listeners.hasOwnProperty(event) || typeof listeners[event as TApiAllowedListeners] === 'undefined') continue;411 if (!listeners.hasOwnProperty(event) || typeof listeners[event as TApiAllowedListeners] === 'undefined') continue;
409 api.on(event as ApiInterfaceEvents, listeners[event as TApiAllowedListeners] as (...args: any[]) => any);412 api.on(event as ApiInterfaceEvents, listeners[event as TApiAllowedListeners] as (...args: any[]) => any);
410 }413 }
437 const sign = (callback: any) => {440 const sign = (callback: any) => {
438 if(options !== null) return transaction.signAndSend(sender, options, callback);441 if(options !== null) return transaction.signAndSend(sender, options, callback);
439 return transaction.signAndSend(sender, callback);442 return transaction.signAndSend(sender, callback);
440 }443 };
441 return new Promise(async (resolve, reject) => {444 return new Promise(async (resolve, reject) => {
442 try {445 try {
443 let unsub = await sign((result: any) => {446 const unsub = await sign((result: any) => {
444 const status = this.getTransactionStatus(result);447 const status = this.getTransactionStatus(result);
445448
446 if (status === this.transactionStatus.SUCCESS) {449 if (status === this.transactionStatus.SUCCESS) {
479 constructApiCall(apiCall: string, params: any[]) {482 constructApiCall(apiCall: string, params: any[]) {
480 if(!apiCall.startsWith('api.')) throw Error(`Invalid api call: ${apiCall}`);483 if(!apiCall.startsWith('api.')) throw Error(`Invalid api call: ${apiCall}`);
481 let call = this.api as any;484 let call = this.api as any;
482 for(let part of apiCall.slice(4).split('.')) {485 for(const part of apiCall.slice(4).split('.')) {
483 call = call[part];486 call = call[part];
484 }487 }
485 return call(...params);488 return call(...params);
503506
504 const endTime = (new Date()).getTime();507 const endTime = (new Date()).getTime();
505508
506 let log = {509 const log = {
507 executedAt: endTime,510 executedAt: endTime,
508 executionTime: endTime - startTime,511 executionTime: endTime - startTime,
509 type: this.chainLogType.EXTRINSIC,512 type: this.chainLogType.EXTRINSIC,
527 if(!rpc.startsWith('api.rpc.') && !rpc.startsWith('api.query.')) throw Error(`${rpc} is not RPC call`);530 if(!rpc.startsWith('api.rpc.') && !rpc.startsWith('api.query.')) throw Error(`${rpc} is not RPC call`);
528531
529 const startTime = (new Date()).getTime();532 const startTime = (new Date()).getTime();
530 let result, log = {533 let result;
534 let error = null;
535 const log = {
531 type: this.chainLogType.RPC,536 type: this.chainLogType.RPC,
532 call: rpc,537 call: rpc,
533 params538 params,
534 } as IUniqueHelperLog, error = null;539 } as IUniqueHelperLog;
535540
536 try {541 try {
537 result = await this.constructApiCall(rpc, params);542 result = await this.constructApiCall(rpc, params);
607 raw: any612 raw: any
608 } | null> {613 } | null> {
609 const collection = await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId]);614 const collection = await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId]);
610 let humanCollection = collection.toHuman(), collectionData = {615 const humanCollection = collection.toHuman(), collectionData = {
611 id: collectionId, name: null, description: null, tokensCount: 0, admins: [],616 id: collectionId, name: null, description: null, tokensCount: 0, admins: [],
612 raw: humanCollection617 raw: humanCollection,
613 } as any, jsonCollection = collection.toJSON();618 } as any, jsonCollection = collection.toJSON();
614 if (humanCollection === null) return null;619 if (humanCollection === null) return null;
615 collectionData.raw.limits = jsonCollection.limits;620 collectionData.raw.limits = jsonCollection.limits;
616 collectionData.raw.permissions = jsonCollection.permissions;621 collectionData.raw.permissions = jsonCollection.permissions;
617 collectionData.normalizedOwner = this.helper.address.normalizeSubstrate(collectionData.raw.owner);622 collectionData.normalizedOwner = this.helper.address.normalizeSubstrate(collectionData.raw.owner);
618 for (let key of ['name', 'description']) {623 for (const key of ['name', 'description']) {
619 collectionData[key] = this.helper.util.vec2str(humanCollection[key]);624 collectionData[key] = this.helper.util.vec2str(humanCollection[key]);
620 }625 }
621626
632 * @returns array of administrators637 * @returns array of administrators
633 */638 */
634 async getAdmins(collectionId: number): Promise<ICrossAccountId[]> {639 async getAdmins(collectionId: number): Promise<ICrossAccountId[]> {
635 let normalized = [];640 const normalized = [];
636 for(let admin of (await this.helper.callRpc('api.rpc.unique.adminlist', [collectionId])).toHuman()) {641 for(const admin of (await this.helper.callRpc('api.rpc.unique.adminlist', [collectionId])).toHuman()) {
637 if(admin.Substrate) normalized.push({Substrate: this.helper.address.normalizeSubstrate(admin.Substrate)});642 if(admin.Substrate) normalized.push({Substrate: this.helper.address.normalizeSubstrate(admin.Substrate)});
638 else normalized.push(admin);643 else normalized.push(admin);
639 }644 }
938 }943 }
939944
940 async isTokenExists(collectionId: number, tokenId: number): Promise<boolean> {945 async isTokenExists(collectionId: number, tokenId: number): Promise<boolean> {
941 return (await this.helper.callRpc('api.rpc.unique.tokenExists', [collectionId, tokenId])).toJSON()946 return (await this.helper.callRpc('api.rpc.unique.tokenExists', [collectionId, tokenId])).toJSON();
942 }947 }
943}948}
944949
945class NFTnRFT extends CollectionGroup {950class NFTnRFT extends CollectionGroup {
946 async getTokensByAddress(collectionId: number, addressObj: ICrossAccountId): Promise<number[]> {951 async getTokensByAddress(collectionId: number, addressObj: ICrossAccountId): Promise<number[]> {
947 return (await this.helper.callRpc('api.rpc.unique.accountTokens', [collectionId, addressObj])).toJSON()952 return (await this.helper.callRpc('api.rpc.unique.accountTokens', [collectionId, addressObj])).toJSON();
948 }953 }
949954
950 async getToken(collectionId: number, tokenId: number, blockHashAt?: string, propertyKeys?: string[]): Promise<{955 async getToken(collectionId: number, tokenId: number, blockHashAt?: string, propertyKeys?: string[]): Promise<{
958 }963 }
959 else {964 else {
960 if(typeof propertyKeys === 'undefined') {965 if(typeof propertyKeys === 'undefined') {
961 let collection = (await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId])).toHuman();966 const collection = (await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId])).toHuman();
962 if(!collection) return null;967 if(!collection) return null;
963 propertyKeys = collection.tokenPropertyPermissions.map((x: ITokenPropertyPermission) => x.key);968 propertyKeys = collection.tokenPropertyPermissions.map((x: ITokenPropertyPermission) => x.key);
964 }969 }
965 tokenData = await this.helper.callRpc('api.rpc.unique.tokenData', [collectionId, tokenId, propertyKeys, blockHashAt]);970 tokenData = await this.helper.callRpc('api.rpc.unique.tokenData', [collectionId, tokenId, propertyKeys, blockHashAt]);
966 }971 }
967 tokenData = tokenData.toHuman();972 tokenData = tokenData.toHuman();
968 if (tokenData === null || tokenData.owner === null) return null;973 if (tokenData === null || tokenData.owner === null) return null;
969 let owner = {} as any;974 const owner = {} as any;
970 for (let key of Object.keys(tokenData.owner)) {975 for (const key of Object.keys(tokenData.owner)) {
971 owner[key.toLocaleLowerCase()] = key.toLocaleLowerCase() === 'substrate' ? this.helper.address.normalizeSubstrate(tokenData.owner[key]) : tokenData.owner[key];976 owner[key.toLocaleLowerCase()] = key.toLocaleLowerCase() === 'substrate' ? this.helper.address.normalizeSubstrate(tokenData.owner[key]) : tokenData.owner[key];
972 }977 }
973 tokenData.normalizedOwner = crossAccountIdFromLower(owner);978 tokenData.normalizedOwner = crossAccountIdFromLower(owner);
1010 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT', errorLabel = 'Unable to mint collection'): Promise<UniqueCollectionBase> {1015 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, mode: 'NFT' | 'RFT', errorLabel = 'Unable to mint collection'): Promise<UniqueCollectionBase> {
1011 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object1016 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object
1012 collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};1017 collectionOptions.mode = (mode === 'NFT') ? {nft: null} : {refungible: null};
1013 for (let key of ['name', 'description', 'tokenPrefix']) {1018 for (const key of ['name', 'description', 'tokenPrefix']) {
1014 if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);1019 if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);
1015 }1020 }
1016 const creationResult = await this.helper.executeExtrinsic(1021 const creationResult = await this.helper.executeExtrinsic(
11421147
1143 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {properties?: IProperty[]}[], label?: string): Promise<UniqueNFTToken[]> {1148 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {properties?: IProperty[]}[], label?: string): Promise<UniqueNFTToken[]> {
1144 if(typeof label === 'undefined') label = `collection #${collectionId}`;1149 if(typeof label === 'undefined') label = `collection #${collectionId}`;
1145 let rawTokens = [];1150 const rawTokens = [];
1146 for (let token of tokens) {1151 for (const token of tokens) {
1147 let raw = {NFT: {properties: token.properties}};1152 const raw = {NFT: {properties: token.properties}};
1148 rawTokens.push(raw);1153 rawTokens.push(raw);
1149 }1154 }
1150 const creationResult = await this.helper.executeExtrinsic(1155 const creationResult = await this.helper.executeExtrinsic(
12271232
1228 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {pieces: bigint, properties?: IProperty[]}[], label?: string): Promise<UniqueRFTToken[]> {1233 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {pieces: bigint, properties?: IProperty[]}[], label?: string): Promise<UniqueRFTToken[]> {
1229 if(typeof label === 'undefined') label = `collection #${collectionId}`;1234 if(typeof label === 'undefined') label = `collection #${collectionId}`;
1230 let rawTokens = [];1235 const rawTokens = [];
1231 for (let token of tokens) {1236 for (const token of tokens) {
1232 let raw = {ReFungible: {pieces: token.pieces, properties: token.properties}};1237 const raw = {ReFungible: {pieces: token.pieces, properties: token.properties}};
1233 rawTokens.push(raw);1238 rawTokens.push(raw);
1234 }1239 }
1235 const creationResult = await this.helper.executeExtrinsic(1240 const creationResult = await this.helper.executeExtrinsic(
1272 return new UniqueFTCollection(collectionId, this.helper);1277 return new UniqueFTCollection(collectionId, this.helper);
1273 }1278 }
12741279
1275 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, decimalPoints: number = 0, errorLabel = 'Unable to mint collection'): Promise<UniqueFTCollection> {1280 async mintCollection(signer: TSigner, collectionOptions: ICollectionCreationOptions, decimalPoints = 0, errorLabel = 'Unable to mint collection'): Promise<UniqueFTCollection> {
1276 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object1281 collectionOptions = JSON.parse(JSON.stringify(collectionOptions)) as ICollectionCreationOptions; // Clone object
1277 if(collectionOptions.tokenPropertyPermissions) throw Error('Fungible collections has no tokenPropertyPermissions');1282 if(collectionOptions.tokenPropertyPermissions) throw Error('Fungible collections has no tokenPropertyPermissions');
1278 collectionOptions.mode = {fungible: decimalPoints};1283 collectionOptions.mode = {fungible: decimalPoints};
1279 for (let key of ['name', 'description', 'tokenPrefix']) {1284 for (const key of ['name', 'description', 'tokenPrefix']) {
1280 if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);1285 if (typeof collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] === 'string') collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] = this.helper.util.str2vec(collectionOptions[key as 'name' | 'description' | 'tokenPrefix'] as string);
1281 }1286 }
1282 const creationResult = await this.helper.executeExtrinsic(1287 const creationResult = await this.helper.executeExtrinsic(
13031308
1304 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {value: bigint}[], label?: string): Promise<boolean> {1309 async mintMultipleTokensWithOneOwner(signer: TSigner, collectionId: number, owner: ICrossAccountId, tokens: {value: bigint}[], label?: string): Promise<boolean> {
1305 if(typeof label === 'undefined') label = `collection #${collectionId}`;1310 if(typeof label === 'undefined') label = `collection #${collectionId}`;
1306 let rawTokens = [];1311 const rawTokens = [];
1307 for (let token of tokens) {1312 for (const token of tokens) {
1308 let raw = {Fungible: {Value: token.value}};1313 const raw = {Fungible: {Value: token.value}};
1309 rawTokens.push(raw);1314 rawTokens.push(raw);
1310 }1315 }
1311 const creationResult = await this.helper.executeExtrinsic(1316 const creationResult = await this.helper.executeExtrinsic(
1421 }1426 }
14221427
1423 async normalizeSubstrateToChainFormat(address: TSubstrateAccount): Promise<TSubstrateAccount> {1428 async normalizeSubstrateToChainFormat(address: TSubstrateAccount): Promise<TSubstrateAccount> {
1424 let info = this.helper.chain.getChainProperties();1429 const info = this.helper.chain.getChainProperties();
1425 return encodeAddress(decodeAddress(address), info.ss58Format);1430 return encodeAddress(decodeAddress(address), info.ss58Format);
1426 }1431 }
14271432
1428 async ethToSubstrate(ethAddress: TEthereumAccount, toChainFormat=false): Promise<TSubstrateAccount> {1433 async ethToSubstrate(ethAddress: TEthereumAccount, toChainFormat=false): Promise<TSubstrateAccount> {
1429 if(!toChainFormat) return evmToAddress(ethAddress);1434 if(!toChainFormat) return evmToAddress(ethAddress);
1430 let info = this.helper.chain.getChainProperties();1435 const info = this.helper.chain.getChainProperties();
1431 return evmToAddress(ethAddress, info.ss58Format);1436 return evmToAddress(ethAddress, info.ss58Format);
1432 }1437 }
14331438