@acala-network/chopsticks-core 0.10.0-1 → 0.10.0

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.
@@ -311,7 +311,7 @@ class StorageLayer {
311
311
  if (idx !== -1) {
312
312
  if (includeFirst) {
313
313
  const key = _class_private_field_get(this, _keys)[idx];
314
- if (key && key.startsWith(prefix)) {
314
+ if (key && key.startsWith(prefix) && key > startKey) {
315
315
  foundNextKey(key);
316
316
  }
317
317
  }
@@ -7,7 +7,9 @@ import type { Header } from '../../index.js';
7
7
  *
8
8
  * @return Block hash | hash[] | null
9
9
  */
10
- export declare const chain_getBlockHash: Handler<[number | number[] | null], HexString | (HexString | null)[] | null>;
10
+ export declare const chain_getBlockHash: Handler<[
11
+ number | HexString | number[] | HexString[] | null
12
+ ], HexString | (HexString | null)[] | null>;
11
13
  /**
12
14
  * @param context
13
15
  * @param params - [`blockhash`]
@@ -39,7 +41,7 @@ export declare const chain_getFinalizedHead: Handler<void, HexString>;
39
41
  export declare const chain_subscribeNewHead: Handler<void, string>;
40
42
  export declare const chain_subscribeFinalizedHeads: Handler<void, string>;
41
43
  export declare const chain_unsubscribeNewHead: Handler<[string], void>;
42
- export declare const chain_getHead: Handler<[number | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
44
+ export declare const chain_getHead: Handler<[number | `0x${string}` | `0x${string}`[] | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
43
45
  export declare const chain_subscribeNewHeads: Handler<void, string>;
44
46
  export declare const chain_unsubscribeNewHeads: Handler<[string], void>;
45
47
  export declare const chain_unsubscribeFinalizedHeads: Handler<[string], void>;
@@ -43,6 +43,7 @@ _export(exports, {
43
43
  return chain_unsubscribeNewHeads;
44
44
  }
45
45
  });
46
+ const _util = require("@polkadot/util");
46
47
  const _shared = require("../shared.js");
47
48
  const processHeader = ({ parentHash, number, stateRoot, extrinsicsRoot, digest })=>{
48
49
  return {
@@ -59,7 +60,7 @@ const chain_getBlockHash = async (context, [blockNumber])=>{
59
60
  const numbers = Array.isArray(blockNumber) ? blockNumber : [
60
61
  blockNumber
61
62
  ];
62
- const hashes = await Promise.all(numbers.map((n)=>context.chain.getBlockAt(n))).then((blocks)=>blocks.map((b)=>b?.hash || null));
63
+ const hashes = await Promise.all(numbers.map((n)=>(0, _util.isHex)(n, undefined, true) ? (0, _util.hexToNumber)(n) : n).map((n)=>context.chain.getBlockAt(n))).then((blocks)=>blocks.map((b)=>b?.hash || null));
63
64
  return Array.isArray(blockNumber) ? hashes : hashes[0];
64
65
  };
65
66
  const chain_getHeader = async (context, [hash])=>{
@@ -39,9 +39,10 @@ declare const handlers: {
39
39
  state_unsubscribeStorage: import("../shared.js").Handler<[string], void>;
40
40
  childstate_getStorage: import("../shared.js").Handler<[`0x${string}`, `0x${string}`, `0x${string}`], string | null>;
41
41
  childstate_getKeysPaged: import("../shared.js").Handler<[`0x${string}`, `0x${string}`, number, `0x${string}`, `0x${string}`], `0x${string}`[] | undefined>;
42
+ state_getStorageAt: import("../shared.js").Handler<[`0x${string}`, `0x${string}`], string | null>;
42
43
  payment_queryFeeDetails: import("../shared.js").Handler<[`0x${string}`, `0x${string}`], `0x${string}`>;
43
44
  payment_queryInfo: import("../shared.js").Handler<[`0x${string}`, `0x${string}`], `0x${string}`>;
44
- chain_getBlockHash: import("../shared.js").Handler<[number | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
45
+ chain_getBlockHash: import("../shared.js").Handler<[number | `0x${string}` | `0x${string}`[] | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
45
46
  chain_getHeader: import("../shared.js").Handler<[`0x${string}`], import("../../index.js").Header>;
46
47
  chain_getBlock: import("../shared.js").Handler<[`0x${string}`], {
47
48
  block: {
@@ -54,7 +55,7 @@ declare const handlers: {
54
55
  chain_subscribeNewHead: import("../shared.js").Handler<void, string>;
55
56
  chain_subscribeFinalizedHeads: import("../shared.js").Handler<void, string>;
56
57
  chain_unsubscribeNewHead: import("../shared.js").Handler<[string], void>;
57
- chain_getHead: import("../shared.js").Handler<[number | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
58
+ chain_getHead: import("../shared.js").Handler<[number | `0x${string}` | `0x${string}`[] | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
58
59
  chain_subscribeNewHeads: import("../shared.js").Handler<void, string>;
59
60
  chain_unsubscribeNewHeads: import("../shared.js").Handler<[string], void>;
60
61
  chain_unsubscribeFinalizedHeads: import("../shared.js").Handler<[string], void>;
@@ -95,3 +95,4 @@ export declare const childstate_getKeysPaged: Handler<[
95
95
  HexString,
96
96
  HexString
97
97
  ], HexString[] | undefined>;
98
+ export declare const state_getStorageAt: Handler<[`0x${string}`, `0x${string}`], string | null>;
@@ -30,6 +30,9 @@ _export(exports, {
30
30
  state_getStorage: function() {
31
31
  return state_getStorage;
32
32
  },
33
+ state_getStorageAt: function() {
34
+ return state_getStorageAt;
35
+ },
33
36
  state_queryStorageAt: function() {
34
37
  return state_queryStorageAt;
35
38
  },
@@ -165,3 +168,4 @@ const childstate_getKeysPaged = async (context, [child, prefix, pageSize, startK
165
168
  startKey: (0, _index.prefixedChildKey)(child, startKey)
166
169
  }).then((keys)=>keys.map(_index.stripChildPrefix));
167
170
  };
171
+ const state_getStorageAt = state_getStorage;
@@ -240,7 +240,7 @@ export class StorageLayer {
240
240
  if (idx !== -1) {
241
241
  if (includeFirst) {
242
242
  const key = this.#keys[idx];
243
- if (key && key.startsWith(prefix)) {
243
+ if (key && key.startsWith(prefix) && key > startKey) {
244
244
  foundNextKey(key);
245
245
  }
246
246
  }
@@ -7,7 +7,9 @@ import type { Header } from '../../index.js';
7
7
  *
8
8
  * @return Block hash | hash[] | null
9
9
  */
10
- export declare const chain_getBlockHash: Handler<[number | number[] | null], HexString | (HexString | null)[] | null>;
10
+ export declare const chain_getBlockHash: Handler<[
11
+ number | HexString | number[] | HexString[] | null
12
+ ], HexString | (HexString | null)[] | null>;
11
13
  /**
12
14
  * @param context
13
15
  * @param params - [`blockhash`]
@@ -39,7 +41,7 @@ export declare const chain_getFinalizedHead: Handler<void, HexString>;
39
41
  export declare const chain_subscribeNewHead: Handler<void, string>;
40
42
  export declare const chain_subscribeFinalizedHeads: Handler<void, string>;
41
43
  export declare const chain_unsubscribeNewHead: Handler<[string], void>;
42
- export declare const chain_getHead: Handler<[number | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
44
+ export declare const chain_getHead: Handler<[number | `0x${string}` | `0x${string}`[] | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
43
45
  export declare const chain_subscribeNewHeads: Handler<void, string>;
44
46
  export declare const chain_unsubscribeNewHeads: Handler<[string], void>;
45
47
  export declare const chain_unsubscribeFinalizedHeads: Handler<[string], void>;
@@ -1,3 +1,4 @@
1
+ import { hexToNumber, isHex } from '@polkadot/util';
1
2
  import { ResponseError } from '../shared.js';
2
3
  const processHeader = ({ parentHash, number, stateRoot, extrinsicsRoot, digest })=>{
3
4
  return {
@@ -19,7 +20,7 @@ const processHeader = ({ parentHash, number, stateRoot, extrinsicsRoot, digest }
19
20
  const numbers = Array.isArray(blockNumber) ? blockNumber : [
20
21
  blockNumber
21
22
  ];
22
- const hashes = await Promise.all(numbers.map((n)=>context.chain.getBlockAt(n))).then((blocks)=>blocks.map((b)=>b?.hash || null));
23
+ const hashes = await Promise.all(numbers.map((n)=>isHex(n, undefined, true) ? hexToNumber(n) : n).map((n)=>context.chain.getBlockAt(n))).then((blocks)=>blocks.map((b)=>b?.hash || null));
23
24
  return Array.isArray(blockNumber) ? hashes : hashes[0];
24
25
  };
25
26
  /**
@@ -39,9 +39,10 @@ declare const handlers: {
39
39
  state_unsubscribeStorage: import("../shared.js").Handler<[string], void>;
40
40
  childstate_getStorage: import("../shared.js").Handler<[`0x${string}`, `0x${string}`, `0x${string}`], string | null>;
41
41
  childstate_getKeysPaged: import("../shared.js").Handler<[`0x${string}`, `0x${string}`, number, `0x${string}`, `0x${string}`], `0x${string}`[] | undefined>;
42
+ state_getStorageAt: import("../shared.js").Handler<[`0x${string}`, `0x${string}`], string | null>;
42
43
  payment_queryFeeDetails: import("../shared.js").Handler<[`0x${string}`, `0x${string}`], `0x${string}`>;
43
44
  payment_queryInfo: import("../shared.js").Handler<[`0x${string}`, `0x${string}`], `0x${string}`>;
44
- chain_getBlockHash: import("../shared.js").Handler<[number | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
45
+ chain_getBlockHash: import("../shared.js").Handler<[number | `0x${string}` | `0x${string}`[] | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
45
46
  chain_getHeader: import("../shared.js").Handler<[`0x${string}`], import("../../index.js").Header>;
46
47
  chain_getBlock: import("../shared.js").Handler<[`0x${string}`], {
47
48
  block: {
@@ -54,7 +55,7 @@ declare const handlers: {
54
55
  chain_subscribeNewHead: import("../shared.js").Handler<void, string>;
55
56
  chain_subscribeFinalizedHeads: import("../shared.js").Handler<void, string>;
56
57
  chain_unsubscribeNewHead: import("../shared.js").Handler<[string], void>;
57
- chain_getHead: import("../shared.js").Handler<[number | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
58
+ chain_getHead: import("../shared.js").Handler<[number | `0x${string}` | `0x${string}`[] | number[] | null], `0x${string}` | (`0x${string}` | null)[] | null>;
58
59
  chain_subscribeNewHeads: import("../shared.js").Handler<void, string>;
59
60
  chain_unsubscribeNewHeads: import("../shared.js").Handler<[string], void>;
60
61
  chain_unsubscribeFinalizedHeads: import("../shared.js").Handler<[string], void>;
@@ -95,3 +95,4 @@ export declare const childstate_getKeysPaged: Handler<[
95
95
  HexString,
96
96
  HexString
97
97
  ], HexString[] | undefined>;
98
+ export declare const state_getStorageAt: Handler<[`0x${string}`, `0x${string}`], string | null>;
@@ -173,3 +173,4 @@ const logger = defaultLogger.child({
173
173
  startKey: prefixedChildKey(child, startKey)
174
174
  }).then((keys)=>keys.map(stripChildPrefix));
175
175
  };
176
+ export const state_getStorageAt = state_getStorage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-core",
3
- "version": "0.10.0-1",
3
+ "version": "0.10.0",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "docs:prep": "typedoc"
13
13
  },
14
14
  "dependencies": {
15
- "@acala-network/chopsticks-executor": "0.10.0-1",
15
+ "@acala-network/chopsticks-executor": "0.10.0",
16
16
  "@polkadot/rpc-provider": "^10.11.2",
17
17
  "@polkadot/types": "^10.11.2",
18
18
  "@polkadot/types-codec": "^10.11.2",