From c0e5e7725f2a3c33e5df9e79772e58e996118a0f Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 25 Nov 2022 10:54:12 +0000 Subject: [PATCH] fix: separate povinfo RPC --- --- a/client/rpc/src/pov_estimate.rs +++ b/client/rpc/src/pov_estimate.rs @@ -122,7 +122,7 @@ #[rpc(server)] #[async_trait] pub trait PovEstimateApi { - #[method(name = "unique_estimateExtrinsicPoV")] + #[method(name = "povinfo_estimateExtrinsicPoV")] fn estimate_extrinsic_pov( &self, encoded_xts: Vec, --- a/tests/src/interfaces/augment-api-rpc.ts +++ b/tests/src/interfaces/augment-api-rpc.ts @@ -436,6 +436,12 @@ **/ queryInfo: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable>; }; + povinfo: { + /** + * Estimate PoV size of encoded signed extrinsics + **/ + estimateExtrinsicPoV: AugmentedRpc<(encodedXt: Vec | (Bytes | string | Uint8Array)[], at?: Hash | string | Uint8Array) => Observable>; + }; rmrk: { /** * Get tokens owned by an account in a collection @@ -725,10 +731,6 @@ * Get effective collection limits **/ effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable>>; - /** - * Estimate PoV size of an encoded extrinsic - **/ - estimateExtrinsicPoV: AugmentedRpc<(encodedXt: Vec | (Bytes | string | Uint8Array)[], at?: Hash | string | Uint8Array) => Observable>; /** * Get the last token ID created in a collection **/ --- a/tests/src/interfaces/definitions.ts +++ b/tests/src/interfaces/definitions.ts @@ -17,4 +17,5 @@ export {default as unique} from './unique/definitions'; export {default as appPromotion} from './appPromotion/definitions'; export {default as rmrk} from './rmrk/definitions'; -export {default as default} from './default/definitions'; \ No newline at end of file +export {default as povinfo} from './povinfo/definitions'; +export {default as default} from './default/definitions'; --- /dev/null +++ b/tests/src/interfaces/povinfo/definitions.ts @@ -0,0 +1,40 @@ +// Copyright 2019-2022 Unique Network (Gibraltar) Ltd. +// This file is part of Unique Network. + +// Unique Network is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Unique Network is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Unique Network. If not, see . + +type RpcParam = { + name: string; + type: string; + isOptional?: true; +}; + +const atParam = {name: 'at', type: 'Hash', isOptional: true}; + +const fun = (description: string, params: RpcParam[], type: string) => ({ + description, + params: [...params, atParam], + type, +}); + +export default { + types: {}, + rpc: { + estimateExtrinsicPoV: fun( + 'Estimate PoV size of encoded signed extrinsics', + [{name: 'encodedXt', type: 'Vec'}], + 'UpPovEstimateRpcPovInfo', + ), + }, +}; --- /dev/null +++ b/tests/src/interfaces/povinfo/index.ts @@ -0,0 +1,4 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +export * from './types'; --- /dev/null +++ b/tests/src/interfaces/povinfo/types.ts @@ -0,0 +1,4 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +export type PHANTOM_POVINFO = 'povinfo'; --- a/tests/src/interfaces/types.ts +++ b/tests/src/interfaces/types.ts @@ -4,4 +4,5 @@ export * from './unique/types'; export * from './appPromotion/types'; export * from './rmrk/types'; +export * from './povinfo/types'; export * from './default/types'; --- a/tests/src/util/playgrounds/unique.dev.ts +++ b/tests/src/util/playgrounds/unique.dev.ts @@ -99,6 +99,7 @@ rpc: { unique: defs.unique.rpc, appPromotion: defs.appPromotion.rpc, + povinfo: defs.povinfo.rpc, rmrk: defs.rmrk.rpc, eth: { feeHistory: { @@ -324,7 +325,7 @@ } async calculatePoVInfo(txs: any[]): Promise { - const rawPovInfo = await this.helper.callRpc('api.rpc.unique.estimateExtrinsicPoV', [txs]); + const rawPovInfo = await this.helper.callRpc('api.rpc.povinfo.estimateExtrinsicPoV', [txs]); const kvJson: {[key: string]: string} = {}; @@ -342,6 +343,10 @@ ], ); + if (!chainql.stdout) { + throw Error('unable to get an output from the `chainql`'); + } + return { proofSize: rawPovInfo.proofSize.toNumber(), compactProofSize: rawPovInfo.compactProofSize.toNumber(), -- gitstuff