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.tsdiffbeforeafterboth--- 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<IPovInfo> {
+ 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);
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- 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);