@across-protocol/sdk 4.1.31 → 4.1.33

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 (105) hide show
  1. package/dist/cjs/arch/evm/index.d.ts +1 -0
  2. package/dist/cjs/arch/evm/index.js +5 -0
  3. package/dist/cjs/arch/evm/index.js.map +1 -0
  4. package/dist/cjs/arch/index.d.ts +2 -0
  5. package/dist/cjs/arch/index.js +7 -0
  6. package/dist/cjs/arch/index.js.map +1 -0
  7. package/dist/cjs/arch/svm/index.d.ts +1 -0
  8. package/dist/cjs/arch/svm/index.js +5 -0
  9. package/dist/cjs/arch/svm/index.js.map +1 -0
  10. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +26 -5
  11. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  12. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +2 -2
  13. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +19 -0
  14. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +170 -0
  15. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -0
  16. package/dist/cjs/clients/{SpokePoolClient.d.ts → SpokePoolClient/SpokePoolClient.d.ts} +17 -21
  17. package/dist/cjs/clients/{SpokePoolClient.js → SpokePoolClient/SpokePoolClient.js} +24 -171
  18. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -0
  19. package/dist/cjs/clients/SpokePoolClient/index.d.ts +5 -0
  20. package/dist/cjs/clients/SpokePoolClient/index.js +13 -0
  21. package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -0
  22. package/dist/cjs/clients/index.d.ts +1 -1
  23. package/dist/cjs/clients/index.js +2 -1
  24. package/dist/cjs/clients/index.js.map +1 -1
  25. package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +2 -2
  26. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +1 -1
  27. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  28. package/dist/cjs/utils/BundleUtils.js +7 -7
  29. package/dist/cjs/utils/BundleUtils.js.map +1 -1
  30. package/dist/cjs/utils/SpokeUtils.d.ts +2 -1
  31. package/dist/cjs/utils/SpokeUtils.js +18 -3
  32. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  33. package/dist/esm/arch/evm/index.d.ts +1 -0
  34. package/dist/esm/arch/evm/index.js +2 -0
  35. package/dist/esm/arch/evm/index.js.map +1 -0
  36. package/dist/esm/arch/index.d.ts +2 -0
  37. package/dist/esm/arch/index.js +5 -0
  38. package/dist/esm/arch/index.js.map +1 -0
  39. package/dist/esm/arch/svm/index.d.ts +1 -0
  40. package/dist/esm/arch/svm/index.js +2 -0
  41. package/dist/esm/arch/svm/index.js.map +1 -0
  42. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +32 -5
  43. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  44. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +2 -2
  45. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +22 -0
  46. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +174 -0
  47. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -0
  48. package/dist/{types/clients → esm/clients/SpokePoolClient}/SpokePoolClient.d.ts +58 -56
  49. package/dist/esm/clients/{SpokePoolClient.js → SpokePoolClient/SpokePoolClient.js} +22 -209
  50. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -0
  51. package/dist/esm/clients/SpokePoolClient/index.d.ts +10 -0
  52. package/dist/esm/clients/SpokePoolClient/index.js +12 -0
  53. package/dist/esm/clients/SpokePoolClient/index.js.map +1 -0
  54. package/dist/esm/clients/index.d.ts +1 -1
  55. package/dist/esm/clients/index.js +1 -1
  56. package/dist/esm/clients/index.js.map +1 -1
  57. package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +2 -2
  58. package/dist/esm/clients/mocks/MockSpokePoolClient.js +2 -2
  59. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  60. package/dist/esm/utils/BundleUtils.js +7 -7
  61. package/dist/esm/utils/BundleUtils.js.map +1 -1
  62. package/dist/esm/utils/SpokeUtils.d.ts +8 -2
  63. package/dist/esm/utils/SpokeUtils.js +22 -3
  64. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  65. package/dist/esm/utils/abi/typechain/Multicall3.d.ts +1 -4
  66. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
  67. package/dist/types/arch/evm/index.d.ts +2 -0
  68. package/dist/types/arch/evm/index.d.ts.map +1 -0
  69. package/dist/types/arch/index.d.ts +3 -0
  70. package/dist/types/arch/index.d.ts.map +1 -0
  71. package/dist/types/arch/svm/index.d.ts +2 -0
  72. package/dist/types/arch/svm/index.d.ts.map +1 -0
  73. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  74. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +2 -2
  75. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +23 -0
  76. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -0
  77. package/dist/{esm/clients → types/clients/SpokePoolClient}/SpokePoolClient.d.ts +59 -55
  78. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -0
  79. package/dist/types/clients/SpokePoolClient/index.d.ts +11 -0
  80. package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -0
  81. package/dist/types/clients/index.d.ts +1 -1
  82. package/dist/types/clients/index.d.ts.map +1 -1
  83. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +2 -2
  84. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  85. package/dist/types/utils/SpokeUtils.d.ts +8 -2
  86. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  87. package/dist/types/utils/abi/typechain/Multicall3.d.ts +1 -4
  88. package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -1
  89. package/dist/types/utils/abi/typechain/common.d.ts.map +1 -1
  90. package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -1
  91. package/package.json +4 -3
  92. package/src/arch/evm/index.ts +1 -0
  93. package/src/arch/index.ts +2 -0
  94. package/src/arch/svm/index.ts +1 -0
  95. package/src/clients/BundleDataClient/BundleDataClient.ts +31 -3
  96. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +206 -0
  97. package/src/clients/{SpokePoolClient.ts → SpokePoolClient/SpokePoolClient.ts} +88 -233
  98. package/src/clients/SpokePoolClient/index.ts +14 -0
  99. package/src/clients/index.ts +1 -1
  100. package/src/clients/mocks/MockSpokePoolClient.ts +2 -2
  101. package/src/utils/BundleUtils.ts +6 -6
  102. package/src/utils/SpokeUtils.ts +14 -3
  103. package/dist/cjs/clients/SpokePoolClient.js.map +0 -1
  104. package/dist/esm/clients/SpokePoolClient.js.map +0 -1
  105. package/dist/types/clients/SpokePoolClient.d.ts.map +0 -1
@@ -0,0 +1,174 @@
1
+ import { __assign, __awaiter, __extends, __generator, __spreadArray } from "tslib";
2
+ import { BigNumber, getNetworkName, InvalidFill, toBN } from "../../utils";
3
+ import { paginatedEventQuery, sortEventsAscendingInPlace, spreadEventWithBlockNumber, } from "../../utils/EventUtils";
4
+ import { isUpdateFailureReason } from "../BaseAbstractClient";
5
+ import { knownEventNames, SpokePoolClient } from "./SpokePoolClient";
6
+ import { findDepositBlock, getMaxFillDeadlineInRange as getMaxFillDeadline, getTimeAt as _getTimeAt, relayFillStatus, isZeroAddress, getTimestampForBlock as _getTimestampForBlock, } from "../../utils/SpokeUtils";
7
+ /**
8
+ * An EVM-specific SpokePoolClient.
9
+ */
10
+ var EVMSpokePoolClient = /** @class */ (function (_super) {
11
+ __extends(EVMSpokePoolClient, _super);
12
+ function EVMSpokePoolClient(logger, spokePool, hubPoolClient, chainId, deploymentBlock, eventSearchConfig) {
13
+ if (eventSearchConfig === void 0) { eventSearchConfig = { fromBlock: 0, maxBlockLookBack: 0 }; }
14
+ var _this = _super.call(this, logger, hubPoolClient, chainId, deploymentBlock, eventSearchConfig) || this;
15
+ _this.spokePool = spokePool;
16
+ return _this;
17
+ }
18
+ EVMSpokePoolClient.prototype.relayFillStatus = function (relayData, blockTag, destinationChainId) {
19
+ return relayFillStatus(this.spokePool, relayData, blockTag, destinationChainId);
20
+ };
21
+ EVMSpokePoolClient.prototype.getMaxFillDeadlineInRange = function (startBlock, endBlock) {
22
+ return getMaxFillDeadline(this.spokePool, startBlock, endBlock);
23
+ };
24
+ EVMSpokePoolClient.prototype._availableEventsOnSpoke = function (eventNames) {
25
+ var _this = this;
26
+ if (eventNames === void 0) { eventNames = knownEventNames; }
27
+ return Object.fromEntries(this.spokePool.interface.fragments
28
+ .filter(function (_a) {
29
+ var name = _a.name, type = _a.type;
30
+ return type === "event" && eventNames.includes(name);
31
+ })
32
+ .map(function (_a) {
33
+ var name = _a.name;
34
+ return [name, _this.spokePool.filters[name]()];
35
+ }));
36
+ };
37
+ EVMSpokePoolClient.prototype._queryableEventNames = function () {
38
+ return Object.keys(this._availableEventsOnSpoke(knownEventNames));
39
+ };
40
+ EVMSpokePoolClient.prototype._update = function (eventsToQuery) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var searchConfig, reason, eventSearchConfigs, spokePool, timerStart, multicallFunctions, _a, multicallOutput, events, currentTime, errMsg;
43
+ var _this = this;
44
+ return __generator(this, function (_b) {
45
+ switch (_b.label) {
46
+ case 0: return [4 /*yield*/, this.updateSearchConfig(this.spokePool.provider)];
47
+ case 1:
48
+ searchConfig = _b.sent();
49
+ if (isUpdateFailureReason(searchConfig)) {
50
+ reason = searchConfig;
51
+ return [2 /*return*/, { success: false, reason: reason }];
52
+ }
53
+ eventSearchConfigs = eventsToQuery.map(function (eventName) {
54
+ if (!_this._queryableEventNames().includes(eventName)) {
55
+ throw new Error("SpokePoolClient: Cannot query unrecognised SpokePool event name: ".concat(eventName));
56
+ }
57
+ var _searchConfig = __assign({}, searchConfig); // shallow copy
58
+ // By default, an event's query range is controlled by the `eventSearchConfig` passed in during instantiation.
59
+ // However, certain events have special overriding requirements to their search ranges:
60
+ // - EnabledDepositRoute: The full history is always required, so override the requested fromBlock.
61
+ if (eventName === "EnabledDepositRoute" && !_this.isUpdated) {
62
+ _searchConfig.fromBlock = _this.deploymentBlock;
63
+ }
64
+ return {
65
+ filter: _this._availableEventsOnSpoke()[eventName],
66
+ searchConfig: _searchConfig,
67
+ };
68
+ });
69
+ spokePool = this.spokePool;
70
+ this.log("debug", "Updating SpokePool client for chain ".concat(this.chainId), {
71
+ eventsToQuery: eventsToQuery,
72
+ searchConfig: searchConfig,
73
+ spokePool: spokePool.address,
74
+ });
75
+ timerStart = Date.now();
76
+ multicallFunctions = ["getCurrentTime"];
77
+ return [4 /*yield*/, Promise.all(__spreadArray([
78
+ spokePool.callStatic.multicall(multicallFunctions.map(function (f) { return spokePool.interface.encodeFunctionData(f); }), { blockTag: searchConfig.toBlock })
79
+ ], eventSearchConfigs.map(function (config) { return paginatedEventQuery(_this.spokePool, config.filter, config.searchConfig); }), true))];
80
+ case 2:
81
+ _a = _b.sent(), multicallOutput = _a[0], events = _a.slice(1);
82
+ this.log("debug", "Time to query new events from RPC for ".concat(this.chainId, ": ").concat(Date.now() - timerStart, " ms"));
83
+ currentTime = multicallFunctions.map(function (fn, idx) { return spokePool.interface.decodeFunctionResult(fn, multicallOutput[idx])[0]; })[0];
84
+ if (!BigNumber.isBigNumber(currentTime) || currentTime.lt(this.currentTime)) {
85
+ errMsg = BigNumber.isBigNumber(currentTime)
86
+ ? "currentTime: ".concat(currentTime, " < ").concat(toBN(this.currentTime))
87
+ : "currentTime is not a BigNumber: ".concat(JSON.stringify(currentTime));
88
+ throw new Error("SpokePoolClient::update: ".concat(errMsg));
89
+ }
90
+ // Sort all events to ensure they are stored in a consistent order.
91
+ events.forEach(function (events) { return sortEventsAscendingInPlace(events); });
92
+ return [2 /*return*/, {
93
+ success: true,
94
+ currentTime: currentTime.toNumber(),
95
+ searchEndBlock: searchConfig.toBlock,
96
+ events: events,
97
+ }];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ EVMSpokePoolClient.prototype.getTimeAt = function (blockNumber) {
103
+ return _getTimeAt(this.spokePool, blockNumber);
104
+ };
105
+ EVMSpokePoolClient.prototype.findDeposit = function (depositId) {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var deposit, upperBound, fromBlock, chain, reason, toBlock, tStart, maxBlockLookBack, query, tStop, event, _a;
108
+ var _b;
109
+ return __generator(this, function (_c) {
110
+ switch (_c.label) {
111
+ case 0:
112
+ deposit = this.getDeposit(depositId);
113
+ if (deposit) {
114
+ return [2 /*return*/, { found: true, deposit: deposit }];
115
+ }
116
+ upperBound = this.latestBlockSearched || undefined;
117
+ return [4 /*yield*/, findDepositBlock(this.spokePool, depositId, this.deploymentBlock, upperBound)];
118
+ case 1:
119
+ fromBlock = _c.sent();
120
+ chain = getNetworkName(this.chainId);
121
+ if (!fromBlock) {
122
+ reason = "Unable to find ".concat(chain, " depositId ").concat(depositId) +
123
+ " within blocks [".concat(this.deploymentBlock, ", ").concat(upperBound !== null && upperBound !== void 0 ? upperBound : "latest", "].");
124
+ return [2 /*return*/, { found: false, code: InvalidFill.DepositIdNotFound, reason: reason }];
125
+ }
126
+ toBlock = fromBlock;
127
+ tStart = Date.now();
128
+ maxBlockLookBack = this.eventSearchConfig.maxBlockLookBack;
129
+ return [4 /*yield*/, Promise.all([
130
+ paginatedEventQuery(this.spokePool, this.spokePool.filters.V3FundsDeposited(null, null, null, null, null, depositId), { fromBlock: fromBlock, toBlock: toBlock, maxBlockLookBack: maxBlockLookBack }),
131
+ paginatedEventQuery(this.spokePool, this.spokePool.filters.FundsDeposited(null, null, null, null, null, depositId), { fromBlock: fromBlock, toBlock: toBlock, maxBlockLookBack: maxBlockLookBack }),
132
+ ])];
133
+ case 2:
134
+ query = (_c.sent()).flat();
135
+ tStop = Date.now();
136
+ event = query.find(function (_a) {
137
+ var args = _a.args;
138
+ return args["depositId"].eq(depositId);
139
+ });
140
+ if (event === undefined) {
141
+ return [2 /*return*/, {
142
+ found: false,
143
+ code: InvalidFill.DepositIdNotFound,
144
+ reason: "".concat(chain, " depositId ").concat(depositId, " not found at block ").concat(fromBlock, "."),
145
+ }];
146
+ }
147
+ _a = [__assign({}, spreadEventWithBlockNumber(event))];
148
+ _b = { originChainId: this.chainId };
149
+ return [4 /*yield*/, this.getBlockNumber(Number(event.args["quoteTimestamp"]))];
150
+ case 3:
151
+ deposit = __assign.apply(void 0, _a.concat([(_b.quoteBlockNumber = _c.sent(), _b.fromLiteChain = true, _b.toLiteChain = true, _b)]));
152
+ if (isZeroAddress(deposit.outputToken)) {
153
+ deposit.outputToken = this.getDestinationTokenForDeposit(deposit);
154
+ }
155
+ deposit.fromLiteChain = this.isOriginLiteChain(deposit);
156
+ deposit.toLiteChain = this.isDestinationLiteChain(deposit);
157
+ this.logger.debug({
158
+ at: "SpokePoolClient#findDeposit",
159
+ message: "Located V3 deposit outside of SpokePoolClient's search range",
160
+ deposit: deposit,
161
+ elapsedMs: tStop - tStart,
162
+ });
163
+ return [2 /*return*/, { found: true, deposit: deposit }];
164
+ }
165
+ });
166
+ });
167
+ };
168
+ EVMSpokePoolClient.prototype.getTimestampForBlock = function (blockNumber) {
169
+ return _getTimestampForBlock(this.spokePool.provider, blockNumber);
170
+ };
171
+ return EVMSpokePoolClient;
172
+ }(SpokePoolClient));
173
+ export { EVMSpokePoolClient };
174
+ //# sourceMappingURL=EVMSpokePoolClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EVMSpokePoolClient.js","sourceRoot":"","sources":["../../../../src/clients/SpokePoolClient/EVMSpokePoolClient.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAuB,cAAc,EAAE,WAAW,EAAgB,IAAI,EAAE,M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CAAwC,eAAe,GAoLtD"}
@@ -1,28 +1,27 @@
1
- import { Contract, EventFilter } from "ethers";
2
1
  import winston from "winston";
3
- import { AnyObject, BigNumber, DefaultLogLevels, DepositSearchResult, EventSearchConfig, MakeOptional } from "../utils";
4
- import { Deposit, DepositWithBlock, Fill, FillStatus, FillWithBlock, Log, RelayData, RelayerRefundExecutionWithBlock, RootBundleRelayWithBlock, SlowFillRequestWithBlock, SpeedUpWithBlock, TokensBridged } from "../interfaces";
5
- import { BaseAbstractClient, UpdateFailureReason } from "./BaseAbstractClient";
6
- import { HubPoolClient } from "./HubPoolClient";
7
- import { AcrossConfigStoreClient } from "./AcrossConfigStoreClient";
8
- type SpokePoolUpdateSuccess = {
2
+ import { AnyObject, BigNumber, DefaultLogLevels, DepositSearchResult, EventSearchConfig, MakeOptional } from "../../utils";
3
+ import { Deposit, DepositWithBlock, Fill, FillStatus, FillWithBlock, Log, RelayData, RelayerRefundExecutionWithBlock, RootBundleRelayWithBlock, SlowFillRequestWithBlock, SpeedUpWithBlock, TokensBridged } from "../../interfaces";
4
+ import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
5
+ import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
6
+ import { HubPoolClient } from "../HubPoolClient";
7
+ export type SpokePoolUpdateSuccess = {
9
8
  success: true;
10
9
  currentTime: number;
11
10
  events: Log[][];
12
11
  searchEndBlock: number;
13
12
  };
14
- type SpokePoolUpdateFailure = {
13
+ export type SpokePoolUpdateFailure = {
15
14
  success: false;
16
15
  reason: UpdateFailureReason;
17
16
  };
18
17
  export type SpokePoolUpdate = SpokePoolUpdateSuccess | SpokePoolUpdateFailure;
18
+ export declare const knownEventNames: string[];
19
19
  /**
20
20
  * SpokePoolClient is a client for the SpokePool contract. It is responsible for querying the SpokePool contract
21
21
  * for events and storing them in memory. It also provides some convenience methods for querying the stored events.
22
22
  */
23
- export declare class SpokePoolClient extends BaseAbstractClient {
23
+ export declare abstract class SpokePoolClient extends BaseAbstractClient {
24
24
  readonly logger: winston.Logger;
25
- readonly spokePool: Contract;
26
25
  readonly hubPoolClient: HubPoolClient | null;
27
26
  readonly chainId: number;
28
27
  deploymentBlock: number;
@@ -52,7 +51,6 @@ export declare class SpokePoolClient extends BaseAbstractClient {
52
51
  protected tokensBridged: TokensBridged[];
53
52
  protected rootBundleRelays: RootBundleRelayWithBlock[];
54
53
  protected relayerRefundExecutions: RelayerRefundExecutionWithBlock[];
55
- protected queryableEventNames: string[];
56
54
  protected configStoreClient: AcrossConfigStoreClient | undefined;
57
55
  protected invalidFills: Set<string>;
58
56
  fills: {
@@ -61,16 +59,12 @@ export declare class SpokePoolClient extends BaseAbstractClient {
61
59
  /**
62
60
  * Creates a new SpokePoolClient.
63
61
  * @param logger A logger instance.
64
- * @param spokePool The SpokePool contract instance that this client will query.
65
62
  * @param hubPoolClient An optional HubPoolClient instance. This is used to fetch spoke data that is not stored on the SpokePool contract but is stored on the HubPool contract.
66
63
  * @param chainId The chain ID of the chain that this client is querying.
67
64
  * @param deploymentBlock The block number that the SpokePool contract was deployed at.
68
65
  * @param eventSearchConfig An optional EventSearchConfig object that controls how far back in history the client will search for events. If not provided, the client will only search for events from the deployment block.
69
66
  */
70
- constructor(logger: winston.Logger, spokePool: Contract, hubPoolClient: HubPoolClient | null, chainId: number, deploymentBlock: number, eventSearchConfig?: MakeOptional<EventSearchConfig, "toBlock">);
71
- _queryableEventNames(): {
72
- [eventName: string]: EventFilter;
73
- };
67
+ protected constructor(logger: winston.Logger, hubPoolClient: HubPoolClient | null, chainId: number, deploymentBlock: number, eventSearchConfig?: MakeOptional<EventSearchConfig, "toBlock">);
74
68
  /**
75
69
  * Retrieves a list of unique deposits from the SpokePool contract destined for the given destination chain ID.
76
70
  * @param destinationChainId The destination chain ID.
@@ -224,27 +218,6 @@ export declare class SpokePoolClient extends BaseAbstractClient {
224
218
  depositId: BigNumber;
225
219
  originChainId: number;
226
220
  }): string;
227
- /**
228
- * @notice Return maximum of fill deadline buffer at start and end of block range. This is a contract
229
- * immutable state variable so we can't query other events to find its updates.
230
- * @dev V3 deposits have a fill deadline which can be set to a maximum of fillDeadlineBuffer + deposit.block.timestamp.
231
- * Therefore, we cannot evaluate a block range for expired deposits if the spoke pool client doesn't return us
232
- * deposits whose block.timestamp is within fillDeadlineBuffer of the end block time. As a conservative check,
233
- * we verify that the time between the end block timestamp and the first timestamp queried by the
234
- * spoke pool client is greater than the maximum of the fill deadline buffers at the start and end of the block
235
- * range. We assume the fill deadline buffer wasn't changed more than once within a bundle.
236
- * @param startBlock start block
237
- * @param endBlock end block
238
- * @returns maximum of fill deadline buffer at start and end block
239
- */
240
- getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number>;
241
- /**
242
- * Performs an update to refresh the state of this client. This will query the SpokePool contract for new events
243
- * and store them in memory. This method is the primary method for updating the state of this client.
244
- * @param eventsToQuery An optional list of events to query. If not provided, all events will be queried.
245
- * @returns A Promise that resolves to a SpokePoolUpdate object.
246
- */
247
- protected _update(eventsToQuery: string[]): Promise<SpokePoolUpdate>;
248
221
  /**
249
222
  * A wrapper over the `_update` method that handles errors and logs. This method additionally calls into the
250
223
  * HubPoolClient to update the state of this client with data from the HubPool contract.
@@ -286,18 +259,6 @@ export declare class SpokePoolClient extends BaseAbstractClient {
286
259
  * @returns The current time, which will be 0 if there has been no update() yet.
287
260
  */
288
261
  getCurrentTime(): number;
289
- /**
290
- * Retrieves the SpokePool chain time at a particular block.
291
- * @returns The time at the specified block tag.
292
- */
293
- getTimeAt(blockNumber: number): Promise<number>;
294
- /**
295
- * For a given origin chain depositId, resolve the corresponding Deposit.
296
- * Note: This method can only be used for depositIds within the non-deterministic range (0 < depositId < 2^32 - 1).
297
- * @param depositId Deposit ID of the deposit to resolve.
298
- * @returns A DepositSearchResult instance.
299
- */
300
- findDeposit(depositId: BigNumber): Promise<DepositSearchResult>;
301
262
  /**
302
263
  * Determines whether a deposit originates from a lite chain.
303
264
  * @param deposit The deposit to evaluate.
@@ -313,12 +274,53 @@ export declare class SpokePoolClient extends BaseAbstractClient {
313
274
  */
314
275
  protected isDestinationLiteChain(deposit: DepositWithBlock): boolean;
315
276
  /**
316
- * Find the amount filled for a deposit at a particular block.
317
- * @param relayData Deposit information that is used to complete a fill.
318
- * @param blockTag Block tag (numeric or "latest") to query at.
319
- * @returns The amount filled for the specified deposit at the requested block (or latest).
277
+ * Returns a list of event names that are queryable for the SpokePoolClient.
278
+ * @returns A list of event names that are queryable for the SpokePoolClient.
279
+ */
280
+ abstract _queryableEventNames(): string[];
281
+ /**
282
+ * Performs an update to refresh the state of this client. This will query the SpokePool contract for new events
283
+ * and store them in memory. This method is the primary method for updating the state of this client.
284
+ * @param eventsToQuery An optional list of events to query. If not provided, all events will be queried.
285
+ * @returns A Promise that resolves to a SpokePoolUpdate object.
286
+ */
287
+ protected abstract _update(eventsToQuery: string[]): Promise<SpokePoolUpdate>;
288
+ /**
289
+ * @notice Return maximum of fill deadline buffer at start and end of block range. This is a contract
290
+ * immutable state variable so we can't query other events to find its updates.
291
+ * @dev V3 deposits have a fill deadline which can be set to a maximum of fillDeadlineBuffer + deposit.block.timestamp.
292
+ * Therefore, we cannot evaluate a block range for expired deposits if the spoke pool client doesn't return us
293
+ * deposits whose block.timestamp is within fillDeadlineBuffer of the end block time. As a conservative check,
294
+ * we verify that the time between the end block timestamp and the first timestamp queried by the
295
+ * spoke pool client is greater than the maximum of the fill deadline buffers at the start and end of the block
296
+ * range. We assume the fill deadline buffer wasn't changed more than once within a bundle.
297
+ * @param startBlock start block
298
+ * @param endBlock end block
299
+ * @returns maximum of fill deadline buffer at start and end block
300
+ */
301
+ abstract getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number>;
302
+ /**
303
+ * Retrieves the timestamp for a given block number.
304
+ * @param blockTag The block number to retrieve the timestamp for.
305
+ * @returns The timestamp for the given block number.
306
+ */
307
+ abstract getTimestampForBlock(blockTag: number): Promise<number>;
308
+ /**
309
+ * Retrieves the time from the SpokePool contract at a particular block.
310
+ * @returns The time at the specified block tag.
311
+ */
312
+ abstract getTimeAt(blockNumber: number): Promise<number>;
313
+ /**
314
+ * For a given origin chain depositId, resolve the corresponding Deposit.
315
+ * Note: This method can only be used for depositIds within the non-deterministic range (0 < depositId < 2^32 - 1).
316
+ * @param depositId Deposit ID of the deposit to resolve.
317
+ * @returns A DepositSearchResult instance.
318
+ */
319
+ abstract findDeposit(depositId: BigNumber): Promise<DepositSearchResult>;
320
+ /**
321
+ * Retrieves the fill status for a given relay data.
322
+ * @param relayData The relay data to retrieve the fill status for.
323
+ * @returns The fill status for the given relay data.
320
324
  */
321
- relayFillStatus(relayData: RelayData, blockTag?: number | "latest", destinationChainId?: number): Promise<FillStatus>;
325
+ abstract relayFillStatus(relayData: RelayData, blockTag?: number | "latest", destinationChainId?: number): Promise<FillStatus>;
322
326
  }
323
- export {};
324
- //# sourceMappingURL=SpokePoolClient.d.ts.map