difftreelog
feat calculatePovInfo playgrnd method
in: master
3 files changed
tests/src/util/playgrounds/types.tsdiffbeforeafterboth--- 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,
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.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);