difftreelog
feat calculatePovInfo playgrnd method
in: master
3 files changed
tests/src/util/playgrounds/types.tsdiffbeforeafterboth171 amount: bigint,171 amount: bigint,172}172}173174export interface IPovInfo {175 proofSize: number,176 compactProofSize: number,177 compressedProofSize: number,178 results: any[],179 kv: any,180}173181174export interface ISchedulerOptions {182export interface ISchedulerOptions {175 scheduledId?: string,183 scheduledId?: string,tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth8import * as defs from '../../interfaces/definitions';8import * as defs from '../../interfaces/definitions';9import {IKeyringPair} from '@polkadot/types/types';9import {IKeyringPair} from '@polkadot/types/types';10import {EventRecord} from '@polkadot/types/interfaces';10import {EventRecord} from '@polkadot/types/interfaces';11import {ICrossAccountId, TSigner} from './types';11import {ICrossAccountId, IPovInfo, TSigner} from './types';12import {FrameSystemEventRecord} from '@polkadot/types/lookup';12import {FrameSystemEventRecord} from '@polkadot/types/lookup';13import {VoidFn} from '@polkadot/api/types';13import {VoidFn} from '@polkadot/api/types';14import {Pallets} from '..';14import {Pallets} from '..';15import {spawnSync} from 'child_process';151616export class SilentLogger {17export class SilentLogger {17 log(_msg: any, _level: any): void { }18 log(_msg: any, _level: any): void { }322 return balance;323 return balance;323 }324 }325326 async calculatePoVInfo(txs: any[]): Promise<IPovInfo> {327 const rawPovInfo = await this.helper.callRpc('api.rpc.unique.estimateExtrinsicPoV', [txs]);328329 const kvJson: {[key: string]: string} = {};330331 for (const kv of rawPovInfo.keyValues) {332 kvJson[kv.key.toHex()] = kv.value.toHex();333 }334335 const kvStr = JSON.stringify(kvJson);336337 const chainql = spawnSync(338 'chainql', 339 [340 `--tla-code=data=${kvStr}`,341 '-e', 'function(data) cql.dump(cql.chain("wss://ws-opal.unique.network:443").latest._meta, data, {omit_empty:true})',342 ],343 );344345 return {346 proofSize: rawPovInfo.proofSize.toNumber(),347 compactProofSize: rawPovInfo.compactProofSize.toNumber(),348 compressedProofSize: rawPovInfo.compressedProofSize.toNumber(),349 results: rawPovInfo.results,350 kv: JSON.parse(chainql.stdout.toString()),351 };352 }324353325 calculatePalletAddress(palletId: any) {354 calculatePalletAddress(palletId: any) {326 const address = stringToU8a(('modl' + palletId).padEnd(32, '\0'));355 const address = stringToU8a(('modl' + palletId).padEnd(32, '\0'));tests/src/util/playgrounds/unique.tsdiffbeforeafterboth586 });586 });587 }587 }588589 async signTransactionWithoutSending(signer: TSigner, tx: any) {590 const api = this.getApi();591 const signingInfo = await api.derive.tx.signingInfo(signer.address);592593 tx.sign(signer, {594 blockHash: api.genesisHash,595 genesisHash: api.genesisHash,596 runtimeVersion: api.runtimeVersion,597 nonce: signingInfo.nonce,598 });599600 return tx.toHex();601 }588602589 async getPaymentInfo(signer: TSigner, tx: any, len: number | null) {603 async getPaymentInfo(signer: TSigner, tx: any, len: number | null) {590 const api = this.getApi();604 const api = this.getApi();