git.delta.rocks / unique-network / refs/commits / c0e5e7725f2a

difftreelog

fix separate povinfo RPC

Daniel Shiposha2022-11-25parent: #52ec20b.patch.diff
in: master

8 files changed

modifiedclient/rpc/src/pov_estimate.rsdiffbeforeafterboth
--- 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<BlockHash> {
-	#[method(name = "unique_estimateExtrinsicPoV")]
+	#[method(name = "povinfo_estimateExtrinsicPoV")]
 	fn estimate_extrinsic_pov(
 		&self,
 		encoded_xts: Vec<Bytes>,
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
--- 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<RuntimeDispatchInfoV1>>;
     };
+    povinfo: {
+      /**
+       * Estimate PoV size of encoded signed extrinsics
+       **/
+      estimateExtrinsicPoV: AugmentedRpc<(encodedXt: Vec<Bytes> | (Bytes | string | Uint8Array)[], at?: Hash | string | Uint8Array) => Observable<UpPovEstimateRpcPovInfo>>;
+    };
     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<Option<UpDataStructsCollectionLimits>>>;
-      /**
-       * Estimate PoV size of an encoded extrinsic
-       **/
-      estimateExtrinsicPoV: AugmentedRpc<(encodedXt: Vec<Bytes> | (Bytes | string | Uint8Array)[], at?: Hash | string | Uint8Array) => Observable<UpPovEstimateRpcPovInfo>>;
       /**
        * Get the last token ID created in a collection
        **/
modifiedtests/src/interfaces/definitions.tsdiffbeforeafterboth
--- 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';
addedtests/src/interfaces/povinfo/definitions.tsdiffbeforeafterboth
--- /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 <http://www.gnu.org/licenses/>.
+
+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<Bytes>'}],
+      'UpPovEstimateRpcPovInfo',
+    ),
+  },
+};
addedtests/src/interfaces/povinfo/index.tsdiffbeforeafterboth
--- /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';
addedtests/src/interfaces/povinfo/types.tsdiffbeforeafterboth

no changes

modifiedtests/src/interfaces/types.tsdiffbeforeafterboth
--- 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';
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- 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<IPovInfo> {
-    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(),