@acala-network/chopsticks 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,63 +1,87 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.author_pendingExtrinsics = exports.author_unwatchExtrinsic = exports.author_submitAndWatchExtrinsic = exports.author_submitExtrinsic = void 0;
3
4
  const chopsticks_core_1 = require("@acala-network/chopsticks-core");
4
5
  const shared_1 = require("../shared");
5
6
  const logger_1 = require("../../logger");
6
7
  const logger = logger_1.defaultLogger.child({ name: 'rpc-author' });
7
- const handlers = {
8
- author_submitExtrinsic: async (context, [extrinsic]) => {
9
- return context.chain.submitExtrinsic(extrinsic).catch((error) => {
10
- const code = error.isInvalid ? 1010 : 1011;
11
- throw new shared_1.ResponseError(code, error.toString());
12
- });
13
- },
14
- author_submitAndWatchExtrinsic: async (context, [extrinsic], { subscribe, unsubscribe }) => {
15
- let update = (_block) => { };
16
- const id = context.chain.headState.subscribeHead((block) => update(block));
17
- const callback = subscribe('author_extrinsicUpdate', id, () => context.chain.headState.unsubscribeHead(id));
18
- const onExtrinsicFail = ([failedExtrinsic, error]) => {
19
- if (failedExtrinsic === extrinsic) {
20
- callback(error.toJSON());
21
- done(id);
22
- }
23
- };
24
- context.chain.txPool.event.on(chopsticks_core_1.APPLY_EXTRINSIC_ERROR, onExtrinsicFail);
25
- const done = (id) => {
26
- context.chain.txPool.event.removeListener(chopsticks_core_1.APPLY_EXTRINSIC_ERROR, onExtrinsicFail);
27
- unsubscribe(id);
28
- };
29
- update = async (block) => {
30
- const extrisnics = await block.extrinsics;
31
- if (!extrisnics.includes(extrinsic))
32
- return;
33
- logger.debug({ block: block.hash }, 'author_extrinsicUpdate');
34
- callback({
35
- InBlock: block.hash,
36
- });
37
- callback({
38
- Finalized: block.hash,
39
- });
40
- done(id);
41
- };
42
- try {
43
- await context.chain.submitExtrinsic(extrinsic);
44
- callback({
45
- Ready: null,
46
- });
47
- }
48
- catch (error) {
49
- logger.error({ error }, 'ExtrinsicFailed');
50
- const code = error.isInvalid ? 1010 : 1011;
8
+ /**
9
+ * @param context
10
+ * @param params - [`extrinsic`]
11
+ *
12
+ * @return Hash
13
+ */
14
+ const author_submitExtrinsic = async (context, [extrinsic]) => {
15
+ return context.chain.submitExtrinsic(extrinsic).catch((error) => {
16
+ const code = error.isInvalid ? 1010 : 1011;
17
+ throw new shared_1.ResponseError(code, error.toString());
18
+ });
19
+ };
20
+ exports.author_submitExtrinsic = author_submitExtrinsic;
21
+ /**
22
+ * @param context
23
+ * @param params - [`extrinsic`]
24
+ * @param subscriptionManager
25
+ *
26
+ * @return subscription id
27
+ */
28
+ const author_submitAndWatchExtrinsic = async (context, [extrinsic], { subscribe, unsubscribe }) => {
29
+ let update = (_block) => { };
30
+ const id = context.chain.headState.subscribeHead((block) => update(block));
31
+ const callback = subscribe('author_extrinsicUpdate', id, () => context.chain.headState.unsubscribeHead(id));
32
+ const onExtrinsicFail = ([failedExtrinsic, error]) => {
33
+ if (failedExtrinsic === extrinsic) {
34
+ callback(error.toJSON());
51
35
  done(id);
52
- throw new shared_1.ResponseError(code, error.toString());
53
36
  }
54
- return id;
55
- },
56
- author_unwatchExtrinsic: async (_context, [subid], { unsubscribe }) => {
57
- unsubscribe(subid);
58
- },
59
- author_pendingExtrinsics: async (context) => {
60
- return context.chain.txPool.pendingExtrinsics;
61
- },
37
+ };
38
+ context.chain.txPool.event.on(chopsticks_core_1.APPLY_EXTRINSIC_ERROR, onExtrinsicFail);
39
+ const done = (id) => {
40
+ context.chain.txPool.event.removeListener(chopsticks_core_1.APPLY_EXTRINSIC_ERROR, onExtrinsicFail);
41
+ unsubscribe(id);
42
+ };
43
+ update = async (block) => {
44
+ const extrisnics = await block.extrinsics;
45
+ if (!extrisnics.includes(extrinsic))
46
+ return;
47
+ logger.debug({ block: block.hash }, 'author_extrinsicUpdate');
48
+ callback({
49
+ inBlock: block.hash,
50
+ });
51
+ callback({
52
+ finalized: block.hash,
53
+ });
54
+ done(id);
55
+ };
56
+ try {
57
+ await context.chain.submitExtrinsic(extrinsic);
58
+ callback({
59
+ ready: null,
60
+ });
61
+ }
62
+ catch (error) {
63
+ logger.error({ error }, 'ExtrinsicFailed');
64
+ const code = error.isInvalid ? 1010 : 1011;
65
+ done(id);
66
+ throw new shared_1.ResponseError(code, error.toString());
67
+ }
68
+ return id;
69
+ };
70
+ exports.author_submitAndWatchExtrinsic = author_submitAndWatchExtrinsic;
71
+ /**
72
+ * @param _context
73
+ * @param params - [`subid`]
74
+ */
75
+ const author_unwatchExtrinsic = async (_context, [subid], { unsubscribe }) => {
76
+ unsubscribe(subid);
77
+ };
78
+ exports.author_unwatchExtrinsic = author_unwatchExtrinsic;
79
+ /**
80
+ * Get pending extrinsics
81
+ *
82
+ * @return Array of pending extrinsics
83
+ */
84
+ const author_pendingExtrinsics = async (context) => {
85
+ return context.chain.txPool.pendingExtrinsics;
62
86
  };
63
- exports.default = handlers;
87
+ exports.author_pendingExtrinsics = author_pendingExtrinsics;
@@ -1,6 +1,44 @@
1
- declare const _default: {
2
- chain_subscribeNewHeads: import("../shared").Handler;
3
- chain_unsubscribeNewHeads: import("../shared").Handler;
4
- chain_unsubscribeFinalizedHeads: import("../shared").Handler;
5
- };
6
- export default _default;
1
+ import { Header } from '@polkadot/types/interfaces';
2
+ import { HexString } from '@polkadot/util/types';
3
+ import { Handler } from '../shared';
4
+ /**
5
+ * @param context
6
+ * @param params - [`blockNumber`]
7
+ *
8
+ * @return Block hash
9
+ */
10
+ export declare const chain_getBlockHash: Handler<[number], HexString>;
11
+ /**
12
+ * @param context
13
+ * @param params - [`blockhash`]
14
+ *
15
+ * @return Header - see `@polkadot/types/interfaces`
16
+ */
17
+ export declare const chain_getHeader: Handler<[HexString], Header>;
18
+ /**
19
+ * @param context
20
+ * @param params - [`blockhash`]
21
+ *
22
+ * @return Block header and extrinsics
23
+ */
24
+ export declare const chain_getBlock: Handler<[
25
+ HexString
26
+ ], {
27
+ block: {
28
+ header: Header;
29
+ extrinsics: HexString[];
30
+ };
31
+ justifications: null;
32
+ }>;
33
+ /**
34
+ * @param context
35
+ *
36
+ * @return head hash
37
+ */
38
+ export declare const chain_getFinalizedHead: Handler<void, HexString>;
39
+ export declare const chain_subscribeNewHead: Handler<void, string>;
40
+ export declare const chain_subscribeFinalizedHeads: Handler<void, string>;
41
+ export declare const chain_unsubscribeNewHead: Handler<[string], void>;
42
+ export declare const chain_subscribeNewHeads: Handler<void, string>;
43
+ export declare const chain_unsubscribeNewHeads: Handler<[string], void>;
44
+ export declare const chain_unsubscribeFinalizedHeads: Handler<[string], void>;
@@ -1,72 +1,95 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chain_unsubscribeFinalizedHeads = exports.chain_unsubscribeNewHeads = exports.chain_subscribeNewHeads = exports.chain_unsubscribeNewHead = exports.chain_subscribeFinalizedHeads = exports.chain_subscribeNewHead = exports.chain_getFinalizedHead = exports.chain_getBlock = exports.chain_getHeader = exports.chain_getBlockHash = void 0;
3
4
  const shared_1 = require("../shared");
4
5
  const processHeader = (header) => {
5
6
  const res = header.toJSON();
6
7
  res.number = '0x' + res.number.toString(16); // number is hex format
7
8
  return res;
8
9
  };
9
- const handlers = {
10
- chain_getBlockHash: async (context, [blockNumber]) => {
11
- const block = await context.chain.getBlockAt(blockNumber);
12
- if (!block) {
13
- throw new shared_1.ResponseError(1, `Block #${blockNumber} not found`);
14
- }
15
- return block.hash;
16
- },
17
- chain_getHeader: async (context, [hash]) => {
18
- const block = await context.chain.getBlock(hash);
19
- if (!block) {
20
- throw new shared_1.ResponseError(1, `Block ${hash} not found`);
21
- }
22
- return processHeader(await block.header);
23
- },
24
- chain_getBlock: async (context, [hash]) => {
25
- const block = await context.chain.getBlock(hash);
26
- if (!block) {
27
- throw new shared_1.ResponseError(1, `Block ${hash} not found`);
28
- }
29
- return {
30
- block: {
31
- header: await block.header,
32
- extrinsics: await block.extrinsics,
33
- },
34
- justifications: null,
35
- };
36
- },
37
- chain_getFinalizedHead: async (context) => {
38
- return context.chain.head.hash;
39
- },
40
- chain_subscribeNewHead: async (context, _params, { subscribe }) => {
41
- let update = () => { };
42
- const id = context.chain.headState.subscribeHead(() => update());
43
- const callback = subscribe('chain_newHead', id, () => context.chain.headState.unsubscribeHead(id));
44
- update = async () => {
45
- callback(processHeader(await context.chain.head.header));
46
- };
47
- update();
48
- return id;
49
- },
50
- chain_subscribeFinalizedHeads: async (context, _params, { subscribe }) => {
51
- let update = () => { };
52
- const id = context.chain.headState.subscribeHead(() => update());
53
- const callback = subscribe('chain_finalizedHead', id, () => context.chain.headState.unsubscribeHead(id));
54
- update = async () => {
55
- callback(processHeader(await context.chain.head.header));
56
- };
57
- update();
58
- return id;
59
- },
60
- chain_unsubscribeNewHead: async (_context, [subid], { unsubscribe }) => {
61
- unsubscribe(subid);
62
- },
10
+ /**
11
+ * @param context
12
+ * @param params - [`blockNumber`]
13
+ *
14
+ * @return Block hash
15
+ */
16
+ const chain_getBlockHash = async (context, [blockNumber]) => {
17
+ const block = await context.chain.getBlockAt(blockNumber);
18
+ if (!block) {
19
+ throw new shared_1.ResponseError(1, `Block #${blockNumber} not found`);
20
+ }
21
+ return block.hash;
63
22
  };
64
- const alias = {
65
- chain_subscribeNewHeads: handlers.chain_subscribeNewHead,
66
- chain_unsubscribeNewHeads: handlers.chain_unsubscribeNewHead,
67
- chain_unsubscribeFinalizedHeads: handlers.chain_unsubscribeNewHead,
23
+ exports.chain_getBlockHash = chain_getBlockHash;
24
+ /**
25
+ * @param context
26
+ * @param params - [`blockhash`]
27
+ *
28
+ * @return Header - see `@polkadot/types/interfaces`
29
+ */
30
+ const chain_getHeader = async (context, [hash]) => {
31
+ const block = await context.chain.getBlock(hash);
32
+ if (!block) {
33
+ throw new shared_1.ResponseError(1, `Block ${hash} not found`);
34
+ }
35
+ return processHeader(await block.header);
68
36
  };
69
- exports.default = {
70
- ...handlers,
71
- ...alias,
37
+ exports.chain_getHeader = chain_getHeader;
38
+ /**
39
+ * @param context
40
+ * @param params - [`blockhash`]
41
+ *
42
+ * @return Block header and extrinsics
43
+ */
44
+ const chain_getBlock = async (context, [hash]) => {
45
+ const block = await context.chain.getBlock(hash);
46
+ if (!block) {
47
+ throw new shared_1.ResponseError(1, `Block ${hash} not found`);
48
+ }
49
+ return {
50
+ block: {
51
+ header: await block.header,
52
+ extrinsics: await block.extrinsics,
53
+ },
54
+ justifications: null,
55
+ };
72
56
  };
57
+ exports.chain_getBlock = chain_getBlock;
58
+ /**
59
+ * @param context
60
+ *
61
+ * @return head hash
62
+ */
63
+ const chain_getFinalizedHead = async (context) => {
64
+ return context.chain.head.hash;
65
+ };
66
+ exports.chain_getFinalizedHead = chain_getFinalizedHead;
67
+ const chain_subscribeNewHead = async (context, _params, { subscribe }) => {
68
+ let update = () => { };
69
+ const id = context.chain.headState.subscribeHead(() => update());
70
+ const callback = subscribe('chain_newHead', id, () => context.chain.headState.unsubscribeHead(id));
71
+ update = async () => {
72
+ callback(processHeader(await context.chain.head.header));
73
+ };
74
+ update();
75
+ return id;
76
+ };
77
+ exports.chain_subscribeNewHead = chain_subscribeNewHead;
78
+ const chain_subscribeFinalizedHeads = async (context, _params, { subscribe }) => {
79
+ let update = () => { };
80
+ const id = context.chain.headState.subscribeHead(() => update());
81
+ const callback = subscribe('chain_finalizedHead', id, () => context.chain.headState.unsubscribeHead(id));
82
+ update = async () => {
83
+ callback(processHeader(await context.chain.head.header));
84
+ };
85
+ update();
86
+ return id;
87
+ };
88
+ exports.chain_subscribeFinalizedHeads = chain_subscribeFinalizedHeads;
89
+ const chain_unsubscribeNewHead = async (_context, [subid], { unsubscribe }) => {
90
+ unsubscribe(subid);
91
+ };
92
+ exports.chain_unsubscribeNewHead = chain_unsubscribeNewHead;
93
+ exports.chain_subscribeNewHeads = exports.chain_subscribeNewHead;
94
+ exports.chain_unsubscribeNewHeads = exports.chain_unsubscribeNewHead;
95
+ exports.chain_unsubscribeFinalizedHeads = exports.chain_unsubscribeNewHead;
@@ -1,3 +1,65 @@
1
- import { Handlers } from '../shared';
2
- declare const handlers: Handlers;
1
+ import * as AuthorRPC from './author';
2
+ import * as ChainRPC from './chain';
3
+ import * as PaymentRPC from './payment';
4
+ import * as StateRPC from './state';
5
+ import * as SystemRPC from './system';
6
+ export { AuthorRPC };
7
+ export { ChainRPC };
8
+ export { PaymentRPC };
9
+ export { StateRPC };
10
+ export { SystemRPC };
11
+ declare const handlers: {
12
+ system_localPeerId: () => Promise<string>;
13
+ system_nodeRoles: () => Promise<string[]>;
14
+ system_localListenAddresses: () => Promise<never[]>;
15
+ system_chain: import("../shared").Handler<void, string>;
16
+ system_properties: import("../shared").Handler<void, import("@acala-network/chopsticks-core").ChainProperties>;
17
+ system_name: import("../shared").Handler<void, string>;
18
+ system_version: import("../shared").Handler<void, string>;
19
+ system_chainType: import("../shared").Handler<void, string>;
20
+ system_health: () => Promise<{
21
+ peers: number;
22
+ isSyncing: boolean;
23
+ shouldHavePeers: boolean;
24
+ }>;
25
+ system_dryRun: import("../shared").Handler<[`0x${string}`, `0x${string}`], string>;
26
+ system_accountNextIndex: import("../shared").Handler<[`0x${string}`], number>;
27
+ state_getRuntimeVersion: import("../shared").Handler<[`0x${string}`], import("@acala-network/chopsticks-core").RuntimeVersion | undefined>;
28
+ state_getMetadata: import("../shared").Handler<[`0x${string}`], `0x${string}` | undefined>;
29
+ state_getStorage: import("../shared").Handler<[`0x${string}`, `0x${string}`], string | undefined>;
30
+ state_getKeysPaged: import("../shared").Handler<[string, number, string, `0x${string}`], string[] | undefined>;
31
+ state_queryStorageAt: import("../shared").Handler<[string[], `0x${string}`], [] | [{
32
+ block: `0x${string}`;
33
+ changes: (string | undefined)[][];
34
+ }]>;
35
+ state_call: import("../shared").Handler<[`0x${string}`, `0x${string}`, `0x${string}`], `0x${string}`>;
36
+ state_subscribeRuntimeVersion: import("../shared").Handler<[], string>;
37
+ state_unsubscribeRuntimeVersion: import("../shared").Handler<[`0x${string}`], void>;
38
+ state_subscribeStorage: import("../shared").Handler<[string[]], string>;
39
+ state_unsubscribeStorage: import("../shared").Handler<[string], void>;
40
+ childstate_getStorage: import("../shared").Handler<[`0x${string}`, `0x${string}`, `0x${string}`], string | undefined>;
41
+ childstate_getKeysPaged: import("../shared").Handler<[`0x${string}`, `0x${string}`, number, `0x${string}`, `0x${string}`], `0x${string}`[] | undefined>;
42
+ payment_queryFeeDetails: import("../shared").Handler<[`0x${string}`, `0x${string}`], `0x${string}`>;
43
+ payment_queryInfo: import("../shared").Handler<[`0x${string}`, `0x${string}`], `0x${string}`>;
44
+ chain_getBlockHash: import("../shared").Handler<[number], `0x${string}`>;
45
+ chain_getHeader: import("../shared").Handler<[`0x${string}`], import("@polkadot/types/interfaces").Header>;
46
+ chain_getBlock: import("../shared").Handler<[`0x${string}`], {
47
+ block: {
48
+ header: import("@polkadot/types/interfaces").Header;
49
+ extrinsics: `0x${string}`[];
50
+ };
51
+ justifications: null;
52
+ }>;
53
+ chain_getFinalizedHead: import("../shared").Handler<void, `0x${string}`>;
54
+ chain_subscribeNewHead: import("../shared").Handler<void, string>;
55
+ chain_subscribeFinalizedHeads: import("../shared").Handler<void, string>;
56
+ chain_unsubscribeNewHead: import("../shared").Handler<[string], void>;
57
+ chain_subscribeNewHeads: import("../shared").Handler<void, string>;
58
+ chain_unsubscribeNewHeads: import("../shared").Handler<[string], void>;
59
+ chain_unsubscribeFinalizedHeads: import("../shared").Handler<[string], void>;
60
+ author_submitExtrinsic: import("../shared").Handler<[`0x${string}`], `0x${string}`>;
61
+ author_submitAndWatchExtrinsic: import("../shared").Handler<[`0x${string}`], string>;
62
+ author_unwatchExtrinsic: import("../shared").Handler<[string], void>;
63
+ author_pendingExtrinsics: import("../shared").Handler<void, `0x${string}`[]>;
64
+ };
3
65
  export default handlers;
@@ -1,18 +1,44 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const author_1 = __importDefault(require("./author"));
7
- const chain_1 = __importDefault(require("./chain"));
8
- const payment_1 = __importDefault(require("./payment"));
9
- const state_1 = __importDefault(require("./state"));
10
- const system_1 = __importDefault(require("./system"));
26
+ exports.SystemRPC = exports.StateRPC = exports.PaymentRPC = exports.ChainRPC = exports.AuthorRPC = void 0;
27
+ const AuthorRPC = __importStar(require("./author"));
28
+ exports.AuthorRPC = AuthorRPC;
29
+ const ChainRPC = __importStar(require("./chain"));
30
+ exports.ChainRPC = ChainRPC;
31
+ const PaymentRPC = __importStar(require("./payment"));
32
+ exports.PaymentRPC = PaymentRPC;
33
+ const StateRPC = __importStar(require("./state"));
34
+ exports.StateRPC = StateRPC;
35
+ const SystemRPC = __importStar(require("./system"));
36
+ exports.SystemRPC = SystemRPC;
11
37
  const handlers = {
12
- ...author_1.default,
13
- ...chain_1.default,
14
- ...state_1.default,
15
- ...system_1.default,
16
- ...payment_1.default,
38
+ ...AuthorRPC,
39
+ ...ChainRPC,
40
+ ...PaymentRPC,
41
+ ...StateRPC,
42
+ ...SystemRPC,
17
43
  };
18
44
  exports.default = handlers;
@@ -1,3 +1,16 @@
1
- import { Handlers } from '../shared';
2
- declare const handlers: Handlers;
3
- export default handlers;
1
+ import { HexString } from '@polkadot/util/types';
2
+ import { Handler } from '../shared';
3
+ /**
4
+ * @param context
5
+ * @param params - [`extrinsic`, `blockhash`]
6
+ *
7
+ * @return result in hash
8
+ */
9
+ export declare const payment_queryFeeDetails: Handler<[HexString, HexString], HexString>;
10
+ /**
11
+ * @param context
12
+ * @param params - [`extrinsic`, `blockhash`]
13
+ *
14
+ * @return result in hash
15
+ */
16
+ export declare const payment_queryInfo: Handler<[HexString, HexString], HexString>;
@@ -1,33 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const shared_1 = require("../shared");
3
+ exports.payment_queryInfo = exports.payment_queryFeeDetails = void 0;
4
4
  const util_1 = require("@polkadot/util");
5
- const handlers = {
6
- payment_queryFeeDetails: async (context, [extrinsic, hash]) => {
7
- const block = await context.chain.getBlock(hash);
8
- if (!block) {
9
- throw new shared_1.ResponseError(1, `Block ${hash} not found`);
10
- }
11
- const registry = await block.registry;
12
- const tx = (0, util_1.hexToU8a)(extrinsic);
13
- const resp = await block.call('TransactionPaymentApi_query_fee_details', [
14
- registry.createType('Extrinsic', tx).toHex(),
15
- registry.createType('u32', tx.byteLength).toHex(),
16
- ]);
17
- return resp.result;
18
- },
19
- payment_queryInfo: async (context, [extrinsic, hash]) => {
20
- const block = await context.chain.getBlock(hash);
21
- if (!block) {
22
- throw new shared_1.ResponseError(1, `Block ${hash} not found`);
23
- }
24
- const registry = await block.registry;
25
- const tx = (0, util_1.hexToU8a)(extrinsic);
26
- const resp = await block.call('TransactionPaymentApi_query_info', [
27
- registry.createType('Extrinsic', tx).toHex(),
28
- registry.createType('u32', tx.byteLength).toHex(),
29
- ]);
30
- return resp.result;
31
- },
5
+ const shared_1 = require("../shared");
6
+ /**
7
+ * @param context
8
+ * @param params - [`extrinsic`, `blockhash`]
9
+ *
10
+ * @return result in hash
11
+ */
12
+ const payment_queryFeeDetails = async (context, [extrinsic, hash]) => {
13
+ const block = await context.chain.getBlock(hash);
14
+ if (!block) {
15
+ throw new shared_1.ResponseError(1, `Block ${hash} not found`);
16
+ }
17
+ const registry = await block.registry;
18
+ const tx = (0, util_1.hexToU8a)(extrinsic);
19
+ const resp = await block.call('TransactionPaymentApi_query_fee_details', [
20
+ registry.createType('Extrinsic', tx).toHex(),
21
+ registry.createType('u32', tx.byteLength).toHex(),
22
+ ]);
23
+ return resp.result;
24
+ };
25
+ exports.payment_queryFeeDetails = payment_queryFeeDetails;
26
+ /**
27
+ * @param context
28
+ * @param params - [`extrinsic`, `blockhash`]
29
+ *
30
+ * @return result in hash
31
+ */
32
+ const payment_queryInfo = async (context, [extrinsic, hash]) => {
33
+ const block = await context.chain.getBlock(hash);
34
+ if (!block) {
35
+ throw new shared_1.ResponseError(1, `Block ${hash} not found`);
36
+ }
37
+ const registry = await block.registry;
38
+ const tx = (0, util_1.hexToU8a)(extrinsic);
39
+ const resp = await block.call('TransactionPaymentApi_query_info', [
40
+ registry.createType('Extrinsic', tx).toHex(),
41
+ registry.createType('u32', tx.byteLength).toHex(),
42
+ ]);
43
+ return resp.result;
32
44
  };
33
- exports.default = handlers;
45
+ exports.payment_queryInfo = payment_queryInfo;