Skip to content

Commit f9037e6

Browse files
authored
Merge pull request #8 from paritytech/mh-queryInfo-nonce
Extrinsic queryInfo, account nonce
2 parents 9b6a269 + b13c760 commit f9037e6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polkadot-rpc-proxy",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

src/ApiHandler.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ export default class ApiHandler {
4949
});
5050

5151
const defaultSuccess = typeof events === 'string' ? events : false;
52-
const extrinsics = block.extrinsics.map((extrinsic) => {
52+
const queryInfo = await Promise.all(block.extrinsics.map((extrinsic) => {
53+
return api.rpc.payment.queryInfo(extrinsic.toHex(), hash);
54+
}));
55+
const extrinsics = block.extrinsics.map((extrinsic, idx) => {
5356
const { method, nonce, signature, signer, isSigned, tip, args } = extrinsic;
5457
const hash = u8aToHex(blake2AsU8a(extrinsic.toU8a(), 256));
58+
const info = queryInfo[idx];
5559

5660
return {
5761
method: `${method.sectionName}.${method.methodName}`,
@@ -60,6 +64,7 @@ export default class ApiHandler {
6064
args,
6165
tip,
6266
hash,
67+
info,
6368
events: [] as SantiziedEvent[],
6469
success: defaultSuccess,
6570
};
@@ -105,19 +110,20 @@ export default class ApiHandler {
105110
async fetchBalance(hash: BlockHash, address: string) {
106111
const { api } = this;
107112

108-
const [header, free, reserved, locks] = await Promise.all([
113+
const [header, free, reserved, locks, nonce] = await Promise.all([
109114
api.rpc.chain.getHeader(hash),
110115
api.query.balances.freeBalance.at(hash, address),
111116
api.query.balances.reservedBalance.at(hash, address),
112117
api.query.balances.locks.at(hash, address),
118+
api.query.system.accountNonce.at(hash, address),
113119
]);
114120

115121
const at = {
116122
hash,
117123
height: header.number,
118124
};
119125

120-
return { at, free, reserved, locks };
126+
return { at, nonce, free, reserved, locks };
121127
}
122128

123129
async fetchEvents(hash: BlockHash): Promise<EventRecord[] | string> {

0 commit comments

Comments
 (0)