@across-protocol/sdk 3.1.35 → 3.2.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.
Files changed (100) hide show
  1. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +4 -4
  2. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +1 -2
  3. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  4. package/dist/cjs/clients/HubPoolClient.d.ts +7 -4
  5. package/dist/cjs/clients/HubPoolClient.js +37 -25
  6. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  7. package/dist/cjs/clients/SpokePoolClient.d.ts +7 -5
  8. package/dist/cjs/clients/SpokePoolClient.js +53 -90
  9. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  10. package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +4 -3
  11. package/dist/cjs/clients/mocks/MockConfigStoreClient.js +27 -44
  12. package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
  13. package/dist/cjs/clients/mocks/MockEvents.d.ts +5 -5
  14. package/dist/cjs/clients/mocks/MockEvents.js +7 -44
  15. package/dist/cjs/clients/mocks/MockEvents.js.map +1 -1
  16. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +5 -5
  17. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  18. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +9 -19
  19. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +22 -96
  20. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  21. package/dist/cjs/contracts/utils.d.ts +1 -1
  22. package/dist/cjs/contracts/utils.js.map +1 -1
  23. package/dist/cjs/gasPriceOracle/adapters/polygon.js +30 -7
  24. package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
  25. package/dist/cjs/interfaces/Common.d.ts +7 -0
  26. package/dist/cjs/priceClient/adapters/baseAdapter.js +11 -9
  27. package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -1
  28. package/dist/cjs/utils/EventUtils.d.ts +7 -4
  29. package/dist/cjs/utils/EventUtils.js +9 -5
  30. package/dist/cjs/utils/EventUtils.js.map +1 -1
  31. package/dist/cjs/utils/JSONUtils.js +1 -1
  32. package/dist/cjs/utils/JSONUtils.js.map +1 -1
  33. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +4 -4
  34. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +2 -3
  35. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  36. package/dist/esm/clients/HubPoolClient.d.ts +19 -4
  37. package/dist/esm/clients/HubPoolClient.js +51 -27
  38. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  39. package/dist/esm/clients/SpokePoolClient.d.ts +13 -12
  40. package/dist/esm/clients/SpokePoolClient.js +61 -104
  41. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  42. package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +4 -3
  43. package/dist/esm/clients/mocks/MockConfigStoreClient.js +33 -47
  44. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  45. package/dist/esm/clients/mocks/MockEvents.d.ts +5 -5
  46. package/dist/esm/clients/mocks/MockEvents.js +9 -50
  47. package/dist/esm/clients/mocks/MockEvents.js.map +1 -1
  48. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +5 -5
  49. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  50. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +9 -19
  51. package/dist/esm/clients/mocks/MockSpokePoolClient.js +30 -100
  52. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  53. package/dist/esm/contracts/utils.d.ts +1 -1
  54. package/dist/esm/contracts/utils.js.map +1 -1
  55. package/dist/esm/gasPriceOracle/adapters/polygon.js +31 -10
  56. package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
  57. package/dist/esm/interfaces/Common.d.ts +7 -0
  58. package/dist/esm/priceClient/adapters/baseAdapter.js +11 -9
  59. package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -1
  60. package/dist/esm/utils/EventUtils.d.ts +7 -4
  61. package/dist/esm/utils/EventUtils.js +7 -4
  62. package/dist/esm/utils/EventUtils.js.map +1 -1
  63. package/dist/esm/utils/JSONUtils.js +1 -1
  64. package/dist/esm/utils/JSONUtils.js.map +1 -1
  65. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +4 -4
  66. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  67. package/dist/types/clients/HubPoolClient.d.ts +19 -4
  68. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  69. package/dist/types/clients/SpokePoolClient.d.ts +13 -12
  70. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  71. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +4 -3
  72. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
  73. package/dist/types/clients/mocks/MockEvents.d.ts +5 -5
  74. package/dist/types/clients/mocks/MockEvents.d.ts.map +1 -1
  75. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +5 -5
  76. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  77. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +9 -19
  78. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  79. package/dist/types/contracts/utils.d.ts +1 -1
  80. package/dist/types/contracts/utils.d.ts.map +1 -1
  81. package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
  82. package/dist/types/interfaces/Common.d.ts +7 -0
  83. package/dist/types/interfaces/Common.d.ts.map +1 -1
  84. package/dist/types/priceClient/adapters/baseAdapter.d.ts.map +1 -1
  85. package/dist/types/utils/EventUtils.d.ts +7 -4
  86. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  87. package/package.json +3 -2
  88. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +9 -10
  89. package/src/clients/HubPoolClient.ts +34 -24
  90. package/src/clients/SpokePoolClient.ts +55 -74
  91. package/src/clients/mocks/MockConfigStoreClient.ts +11 -11
  92. package/src/clients/mocks/MockEvents.ts +15 -65
  93. package/src/clients/mocks/MockHubPoolClient.ts +6 -6
  94. package/src/clients/mocks/MockSpokePoolClient.ts +26 -59
  95. package/src/contracts/utils.ts +2 -1
  96. package/src/gasPriceOracle/adapters/polygon.ts +19 -8
  97. package/src/interfaces/Common.ts +7 -0
  98. package/src/priceClient/adapters/baseAdapter.ts +1 -0
  99. package/src/utils/EventUtils.ts +12 -7
  100. package/src/utils/JSONUtils.ts +1 -1
@@ -1,13 +1,12 @@
1
1
  import assert from "assert";
2
- import { Contract, Event, providers } from "ethers";
2
+ import { Contract } from "ethers";
3
3
  import { random } from "lodash";
4
4
  import winston from "winston";
5
5
  import { ZERO_ADDRESS } from "../../constants";
6
6
  import {
7
+ Log,
7
8
  DepositWithBlock,
8
9
  FillType,
9
- V3FundsDepositedEvent,
10
- RealizedLpFee,
11
10
  RelayerRefundExecutionWithBlock,
12
11
  SlowFillRequestWithBlock,
13
12
  Fill,
@@ -15,25 +14,20 @@ import {
15
14
  SlowFillLeaf,
16
15
  SpeedUp,
17
16
  } from "../../interfaces";
18
- import { BigNumber, bnZero, toBN, toBNWei, forEachAsync, getCurrentTime, randomAddress } from "../../utils";
17
+ import { toBN, toBNWei, getCurrentTime, randomAddress } from "../../utils";
19
18
  import { SpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
20
19
  import { HubPoolClient } from "../HubPoolClient";
21
20
  import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
22
21
  import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
23
22
 
24
- type Block = providers.Block;
25
-
26
- // This class replaces internal SpokePoolClient functionality, enabling the
27
- // user to bypass on-chain queries and inject ethers Event objects directly.
23
+ // This class replaces internal SpokePoolClient functionality, enabling
24
+ // the user to bypass on-chain queries and inject Log objects directly.
28
25
  export class MockSpokePoolClient extends SpokePoolClient {
29
26
  public eventManager: EventManager;
30
- private realizedLpFeePct: BigNumber = bnZero;
31
- private realizedLpFeePctOverride = false;
32
27
  private destinationTokenForChainOverride: Record<number, string> = {};
33
28
  // Allow tester to set the numberOfDeposits() returned by SpokePool at a block height.
34
29
  public depositIdAtBlock: number[] = [];
35
30
  public numberOfDeposits = 0;
36
- public blocks: Record<number, Block> = {};
37
31
 
38
32
  constructor(
39
33
  logger: winston.Logger,
@@ -47,36 +41,10 @@ export class MockSpokePoolClient extends SpokePoolClient {
47
41
  this.eventManager = getEventManager(chainId, this.eventSignatures, deploymentBlock);
48
42
  }
49
43
 
50
- setDefaultRealizedLpFeePct(fee: BigNumber): void {
51
- this.realizedLpFeePct = fee;
52
- this.realizedLpFeePctOverride = true;
53
- }
54
-
55
44
  setConfigStoreClient(configStore?: AcrossConfigStoreClient): void {
56
45
  this.configStoreClient = configStore;
57
46
  }
58
47
 
59
- clearDefaultRealizedLpFeePct(): void {
60
- this.realizedLpFeePctOverride = false;
61
- }
62
-
63
- async computeRealizedLpFeePct(depositEvent: V3FundsDepositedEvent) {
64
- const { realizedLpFeePct, realizedLpFeePctOverride } = this;
65
- const { blockNumber: quoteBlock } = depositEvent;
66
- return realizedLpFeePctOverride
67
- ? { realizedLpFeePct, quoteBlock }
68
- : await super.computeRealizedLpFeePct(depositEvent);
69
- }
70
-
71
- async batchComputeRealizedLpFeePct(depositEvents: V3FundsDepositedEvent[]): Promise<RealizedLpFee[]> {
72
- const { realizedLpFeePct, realizedLpFeePctOverride } = this;
73
- return realizedLpFeePctOverride
74
- ? depositEvents.map(({ blockNumber: quoteBlock }) => {
75
- return { realizedLpFeePct, quoteBlock };
76
- })
77
- : await super.batchComputeRealizedLpFeePct(depositEvents);
78
- }
79
-
80
48
  setDestinationTokenForChain(chainId: number, token: string): void {
81
49
  this.destinationTokenForChainOverride[chainId] = token;
82
50
  }
@@ -107,33 +75,32 @@ export class MockSpokePoolClient extends SpokePoolClient {
107
75
  return Promise.resolve(this.depositIdAtBlock[blockTag]);
108
76
  }
109
77
 
110
- async _update(eventsToQuery: string[]): Promise<SpokePoolUpdate> {
78
+ _update(eventsToQuery: string[]): Promise<SpokePoolUpdate> {
111
79
  // Generate new "on chain" responses.
112
80
  const latestBlockSearched = this.eventManager.blockNumber;
113
81
  const currentTime = getCurrentTime();
114
82
 
115
- const blocks: { [blockNumber: number]: Block } = {};
116
-
117
83
  // Ensure an array for every requested event exists, in the requested order.
118
84
  // All requested event types must be populated in the array (even if empty).
119
- const events: Event[][] = eventsToQuery.map(() => []);
120
- await forEachAsync(this.eventManager.getEvents().flat(), async (event) => {
121
- const idx = eventsToQuery.indexOf(event.event as string);
122
- if (idx !== -1) {
123
- events[idx].push(event);
124
- blocks[event.blockNumber] = await event.getBlock();
125
- }
126
- });
127
- this.blocks = blocks;
85
+ const events: Log[][] = eventsToQuery.map(() => []);
86
+ this.eventManager
87
+ .getEvents()
88
+ .flat()
89
+ .forEach((event) => {
90
+ const idx = eventsToQuery.indexOf(event.event);
91
+ if (idx !== -1) {
92
+ events[idx].push(event);
93
+ }
94
+ });
128
95
 
129
96
  // Update latestDepositIdQueried.
130
97
  const idx = eventsToQuery.indexOf("V3FundsDeposited");
131
98
  const latestDepositId = (events[idx] ?? []).reduce(
132
- (depositId, event) => Math.max(depositId, event.args?.["depositId"] ?? 0),
99
+ (depositId, event) => Math.max(depositId, (event.args["depositId"] ?? 0) as number),
133
100
  this.latestDepositIdQueried
134
101
  );
135
102
 
136
- return {
103
+ return Promise.resolve({
137
104
  success: true,
138
105
  firstDepositId: 0,
139
106
  latestDepositId,
@@ -141,7 +108,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
141
108
  oldestTime: 0,
142
109
  events,
143
110
  searchEndBlock: this.eventSearchConfig.toBlock || latestBlockSearched,
144
- };
111
+ });
145
112
  }
146
113
 
147
114
  // Event signatures. Not strictly required, but they make generated events more recognisable.
@@ -151,7 +118,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
151
118
  FundsDeposited: "uint256,uint256,uint256,int64,uint32,uint32,address,address,address,bytes",
152
119
  };
153
120
 
154
- depositV3(deposit: DepositWithBlock): Event {
121
+ depositV3(deposit: DepositWithBlock): Log {
155
122
  const event = "V3FundsDeposited";
156
123
 
157
124
  const { blockNumber, transactionIndex } = deposit;
@@ -197,7 +164,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
197
164
  });
198
165
  }
199
166
 
200
- fillV3Relay(fill: FillWithBlock): Event {
167
+ fillV3Relay(fill: FillWithBlock): Log {
201
168
  const event = "FilledV3Relay";
202
169
 
203
170
  const { blockNumber, transactionIndex } = fill;
@@ -247,7 +214,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
247
214
  });
248
215
  }
249
216
 
250
- speedUpV3Deposit(speedUp: SpeedUp): Event {
217
+ speedUpV3Deposit(speedUp: SpeedUp): Log {
251
218
  const event = "RequestedSpeedUpV3Deposit";
252
219
  const topics = [speedUp.depositId, speedUp.depositor];
253
220
  const args = { ...speedUp };
@@ -260,7 +227,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
260
227
  });
261
228
  }
262
229
 
263
- requestV3SlowFill(request: SlowFillRequestWithBlock): Event {
230
+ requestV3SlowFill(request: SlowFillRequestWithBlock): Log {
264
231
  const event = "RequestedV3SlowFill";
265
232
 
266
233
  const { originChainId, depositId } = request;
@@ -279,7 +246,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
279
246
 
280
247
  // This is a simple wrapper around fillV3Relay().
281
248
  // rootBundleId and proof are discarded here - we have no interest in verifying that.
282
- executeV3SlowRelayLeaf(leaf: SlowFillLeaf): Event {
249
+ executeV3SlowRelayLeaf(leaf: SlowFillLeaf): Log {
283
250
  const fill: Fill = {
284
251
  ...leaf.relayData,
285
252
  destinationChainId: this.chainId,
@@ -296,7 +263,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
296
263
  return this.fillV3Relay(fill as FillWithBlock);
297
264
  }
298
265
 
299
- executeRelayerRefundLeaf(refund: RelayerRefundExecutionWithBlock): Event {
266
+ executeRelayerRefundLeaf(refund: RelayerRefundExecutionWithBlock): Log {
300
267
  const event = "ExecutedRelayerRefundRoot";
301
268
 
302
269
  const chainId = refund.chainId ?? this.chainId;
@@ -328,7 +295,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
328
295
  destinationChainId: number,
329
296
  enabled: boolean,
330
297
  overrides: EventOverrides = {}
331
- ): Event {
298
+ ): Log {
332
299
  const event = "EnabledDepositRoute";
333
300
 
334
301
  const topics = [originToken, destinationChainId];
@@ -1,5 +1,6 @@
1
1
  import assert from "assert";
2
- import { Event } from "ethers";
2
+ // eslint-disable-next-line no-restricted-imports
3
+ import { Event } from "@ethersproject/contracts";
3
4
  import { BigNumber, BigNumberish, isDefined } from "../utils";
4
5
 
5
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { providers } from "ethers";
2
2
  import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
3
- import { bnZero, isDefined, parseUnits } from "../../utils";
3
+ import { BigNumber, bnZero, isDefined, parseUnits } from "../../utils";
4
4
  import { CHAIN_IDs } from "../../constants";
5
5
  import { GasPriceEstimate } from "../types";
6
6
  import { gasPriceError } from "../util";
@@ -27,8 +27,6 @@ type GasStationArgs = BaseHTTPAdapterArgs & {
27
27
 
28
28
  const { POLYGON } = CHAIN_IDs;
29
29
 
30
- // @dev toBNWei() is not imported from ../utils because of a circular dependency loop.
31
- // The fix is probably to relocate the function estimateTotalGasRequiredByUnsignedTransaction().
32
30
  class PolygonGasStation extends BaseHTTPAdapter {
33
31
  readonly chainId: number;
34
32
 
@@ -42,7 +40,7 @@ class PolygonGasStation extends BaseHTTPAdapter {
42
40
  async getFeeData(strategy: "safeLow" | "standard" | "fast" = "fast"): Promise<GasPriceEstimate> {
43
41
  const gas = await this.query("v2", {});
44
42
 
45
- const gasPrice: Polygon1559GasPrice = (gas as GasStationV2Response)?.[strategy];
43
+ const gasPrice = (gas as GasStationV2Response)?.[strategy];
46
44
  if (!this.isPolygon1559GasPrice(gasPrice)) {
47
45
  // @todo: generalise gasPriceError() to accept a reason/cause?
48
46
  gasPriceError("getFeeData()", this.chainId, bnZero);
@@ -69,12 +67,25 @@ class PolygonGasStation extends BaseHTTPAdapter {
69
67
  }
70
68
  }
71
69
 
72
- export function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
73
- const gasStation = new PolygonGasStation({ chainId: chainId });
70
+ export async function gasStation(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
71
+ const gasStation = new PolygonGasStation({ chainId: chainId, timeout: 2000, retries: 0 });
72
+ let maxPriorityFeePerGas: BigNumber;
73
+ let maxFeePerGas: BigNumber;
74
74
  try {
75
- return gasStation.getFeeData();
75
+ ({ maxPriorityFeePerGas, maxFeePerGas } = await gasStation.getFeeData());
76
76
  } catch (err) {
77
77
  // Fall back to the RPC provider. May be less accurate.
78
- return eip1559(provider, chainId);
78
+ ({ maxPriorityFeePerGas, maxFeePerGas } = await eip1559(provider, chainId));
79
+
80
+ // Per the GasStation docs, the minimum priority fee on Polygon is 30 Gwei.
81
+ // https://docs.polygon.technology/tools/gas/polygon-gas-station/#interpretation
82
+ const minPriorityFee = parseUnits("30", 9);
83
+ if (maxPriorityFeePerGas.lt(minPriorityFee)) {
84
+ const priorityDelta = minPriorityFee.sub(maxPriorityFeePerGas);
85
+ maxPriorityFeePerGas = minPriorityFee;
86
+ maxFeePerGas = maxFeePerGas.add(priorityDelta);
87
+ }
79
88
  }
89
+
90
+ return { maxPriorityFeePerGas, maxFeePerGas };
80
91
  }
@@ -1,5 +1,12 @@
1
+ import { Log as _Log } from "@ethersproject/abstract-provider";
1
2
  import { BigNumber } from "../utils";
2
3
 
4
+ export type Log = _Log & {
5
+ event: string;
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ args: { [key: string]: any };
8
+ };
9
+
3
10
  export interface SortableEvent {
4
11
  blockNumber: number;
5
12
  transactionIndex: number;
@@ -40,6 +40,7 @@ export class BaseHTTPAdapter {
40
40
  protected async query(path: string, urlArgs?: object): Promise<unknown> {
41
41
  const url = `https://${this.host}/${path ?? ""}`;
42
42
  const args = {
43
+ headers: { "User-Agent": process.env.ACROSS_USER_AGENT ?? "across-protocol" },
43
44
  timeout: this.timeout,
44
45
  params: urlArgs ?? {},
45
46
  };
@@ -1,17 +1,18 @@
1
1
  import { Result } from "@ethersproject/abi";
2
- import { delay } from "./common";
3
- import { SortableEvent } from "../interfaces";
2
+ // eslint-disable-next-line no-restricted-imports
4
3
  import { Contract, Event, EventFilter } from "ethers";
4
+ import { Log, SortableEvent } from "../interfaces";
5
+ import { delay } from "./common";
5
6
 
6
7
  const maxRetries = 3;
7
8
  const retrySleepTime = 10;
8
9
 
9
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- export function spreadEvent(args: Result = {} as Result): any {
11
+ export function spreadEvent(args: Result | Record<string, unknown>): { [key: string]: any } {
11
12
  const keys = Object.keys(args).filter((key: string) => isNaN(+key)); // Extract non-numeric keys.
12
13
 
13
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const returnedObject: any = {};
15
+ const returnedObject: { [key: string]: unknown } = {};
15
16
  keys.forEach((key: string) => {
16
17
  switch (typeof args[key]) {
17
18
  case "boolean": // fallthrough
@@ -67,15 +68,18 @@ export interface EventSearchConfig {
67
68
  maxBlockLookBack?: number;
68
69
  }
69
70
 
71
+ export const eventToLog = (event: Event): Log => ({ ...event, event: event.event!, args: spreadEvent(event.args!) });
72
+
70
73
  export async function paginatedEventQuery(
71
74
  contract: Contract,
72
75
  filter: EventFilter,
73
76
  searchConfig: EventSearchConfig,
74
77
  retryCount = 0
75
- ): Promise<Event[]> {
78
+ ): Promise<Log[]> {
76
79
  // If the max block look back is set to 0 then we dont need to do any pagination and can query over the whole range.
77
80
  if (searchConfig.maxBlockLookBack === 0) {
78
- return await contract.queryFilter(filter, searchConfig.fromBlock, searchConfig.toBlock);
81
+ const events = await contract.queryFilter(filter, searchConfig.fromBlock, searchConfig.toBlock);
82
+ return events.map(eventToLog);
79
83
  }
80
84
 
81
85
  // Compute the number of queries needed. If there is no maxBlockLookBack set then we can execute the whole query in
@@ -93,6 +97,7 @@ export async function paginatedEventQuery(
93
97
  .flat()
94
98
  // Filter events by block number because ranges can include blocks that are outside the range specified for caching reasons.
95
99
  .filter((event) => event.blockNumber >= searchConfig.fromBlock && event.blockNumber <= searchConfig.toBlock)
100
+ .map(eventToLog)
96
101
  );
97
102
  } catch (error) {
98
103
  if (retryCount < maxRetries) {
@@ -163,7 +168,7 @@ export function getPaginatedBlockRanges({
163
168
  return ranges;
164
169
  }
165
170
 
166
- export function spreadEventWithBlockNumber(event: Event): SortableEvent {
171
+ export function spreadEventWithBlockNumber(event: Log): SortableEvent {
167
172
  return {
168
173
  ...spreadEvent(event.args),
169
174
  blockNumber: event.blockNumber,
@@ -53,7 +53,7 @@ export function jsonReplacerWithBigNumbers(_key: string, value: unknown): unknow
53
53
  // We need to check if this is a big number, because the JSON parser
54
54
  // is not aware of BigNumbers and will convert them to the string representation
55
55
  // of the object itself which is not what we want.
56
- if (BigNumber.isBigNumber(value)) {
56
+ if (BigNumber.isBigNumber(value) || typeof value === "bigint") {
57
57
  return value.toString();
58
58
  }
59
59
  // There's a legacy issues that returns BigNumbers as { type: "BigNumber", hex: "0x..." }