@acala-network/chopsticks 0.3.8 → 0.3.9

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.
@@ -35,7 +35,7 @@ export declare class Blockchain {
35
35
  setHead(block: Block): Promise<void>;
36
36
  submitExtrinsic(extrinsic: HexString): Promise<HexString>;
37
37
  newBlock(params?: BuildBlockParams): Promise<Block>;
38
- upcomingBlock(count?: number): Promise<Block>;
38
+ upcomingBlock(skipCount?: number): Promise<Block>;
39
39
  dryRunExtrinsic(extrinsic: HexString | {
40
40
  call: HexString;
41
41
  address: string;
@@ -119,8 +119,8 @@ class Blockchain {
119
119
  await this.#txpool.buildBlock(params);
120
120
  return this.#head;
121
121
  }
122
- async upcomingBlock(count = 1) {
123
- return this.#txpool.upcomingBlock(count);
122
+ async upcomingBlock(skipCount = 0) {
123
+ return this.#txpool.upcomingBlock(skipCount);
124
124
  }
125
125
  async dryRunExtrinsic(extrinsic, at) {
126
126
  await this.api.isReady;
@@ -27,5 +27,5 @@ export declare class TxPool {
27
27
  get pendingExtrinsics(): HexString[];
28
28
  submitExtrinsic(extrinsic: HexString): void;
29
29
  buildBlock(params?: BuildBlockParams): Promise<void>;
30
- upcomingBlock(count?: number): Promise<Block>;
30
+ upcomingBlock(skipCount?: number): Promise<Block>;
31
31
  }
@@ -19,11 +19,11 @@ class TxPool {
19
19
  #pool = [];
20
20
  #mode;
21
21
  #inherentProvider;
22
+ #last;
22
23
  #lastBuildBlockPromise = Promise.resolve();
23
- #last = new rxjs_1.ReplaySubject(1);
24
- #upcoming = this.#last.pipe((0, rxjs_1.share)());
25
24
  constructor(chain, inherentProvider, mode = BuildBlockMode.Batch) {
26
25
  this.#chain = chain;
26
+ this.#last = new rxjs_1.BehaviorSubject(chain.head);
27
27
  this.#mode = mode;
28
28
  this.#inherentProvider = inherentProvider;
29
29
  }
@@ -51,10 +51,10 @@ class TxPool {
51
51
  await this.#lastBuildBlockPromise;
52
52
  this.#last.next(this.#chain.head);
53
53
  }
54
- async upcomingBlock(count = 1) {
55
- if (count < 1)
56
- throw new Error('count needs to be greater than 0');
57
- return (0, rxjs_1.firstValueFrom)(this.#upcoming.pipe((0, operators_1.skip)(count - 1), (0, operators_1.first)()));
54
+ async upcomingBlock(skipCount = 0) {
55
+ if (skipCount < 0)
56
+ throw new Error('skipCount needs to be greater or equal to 0');
57
+ return (0, rxjs_1.firstValueFrom)(this.#last.pipe((0, operators_1.skip)(1 + skipCount), (0, operators_1.take)(1)));
58
58
  }
59
59
  async #buildBlock(wait, params) {
60
60
  await this.#chain.api.isReady;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Bryan Chen <xlchen1291@gmail.com>",