--- a/tests/src/util/playgrounds/types.ts +++ b/tests/src/util/playgrounds/types.ts @@ -171,6 +171,14 @@ amount: bigint, } +export interface IPovInfo { + proofSize: number, + compactProofSize: number, + compressedProofSize: number, + results: any[], + kv: any, +} + export interface ISchedulerOptions { scheduledId?: string, priority?: number, --- a/tests/src/util/playgrounds/unique.dev.ts +++ b/tests/src/util/playgrounds/unique.dev.ts @@ -8,10 +8,11 @@ import * as defs from '../../interfaces/definitions'; import {IKeyringPair} from '@polkadot/types/types'; import {EventRecord} from '@polkadot/types/interfaces'; -import {ICrossAccountId, TSigner} from './types'; +import {ICrossAccountId, IPovInfo, TSigner} from './types'; import {FrameSystemEventRecord} from '@polkadot/types/lookup'; import {VoidFn} from '@polkadot/api/types'; import {Pallets} from '..'; +import {spawnSync} from 'child_process'; export class SilentLogger { log(_msg: any, _level: any): void { } @@ -322,6 +323,34 @@ return balance; } + async calculatePoVInfo(txs: any[]): Promise { + const rawPovInfo = await this.helper.callRpc('api.rpc.unique.estimateExtrinsicPoV', [txs]); + + const kvJson: {[key: string]: string} = {}; + + for (const kv of rawPovInfo.keyValues) { + kvJson[kv.key.toHex()] = kv.value.toHex(); + } + + const kvStr = JSON.stringify(kvJson); + + const chainql = spawnSync( + 'chainql', + [ + `--tla-code=data=${kvStr}`, + '-e', 'function(data) cql.dump(cql.chain("wss://ws-opal.unique.network:443").latest._meta, data, {omit_empty:true})', + ], + ); + + return { + proofSize: rawPovInfo.proofSize.toNumber(), + compactProofSize: rawPovInfo.compactProofSize.toNumber(), + compressedProofSize: rawPovInfo.compressedProofSize.toNumber(), + results: rawPovInfo.results, + kv: JSON.parse(chainql.stdout.toString()), + }; + } + calculatePalletAddress(palletId: any) { const address = stringToU8a(('modl' + palletId).padEnd(32, '\0')); return encodeAddress(address, this.helper.chain.getChainProperties().ss58Format); --- a/tests/src/util/playgrounds/unique.ts +++ b/tests/src/util/playgrounds/unique.ts @@ -586,6 +586,20 @@ }); } + async signTransactionWithoutSending(signer: TSigner, tx: any) { + const api = this.getApi(); + const signingInfo = await api.derive.tx.signingInfo(signer.address); + + tx.sign(signer, { + blockHash: api.genesisHash, + genesisHash: api.genesisHash, + runtimeVersion: api.runtimeVersion, + nonce: signingInfo.nonce, + }); + + return tx.toHex(); + } + async getPaymentInfo(signer: TSigner, tx: any, len: number | null) { const api = this.getApi(); const signingInfo = await api.derive.tx.signingInfo(signer.address);