@sentio/sdk 2.40.0-rc.3 → 2.40.0-rc.30

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 (147) hide show
  1. package/lib/aptos/aptos-processor.d.ts +1 -1
  2. package/lib/aptos/aptos-processor.d.ts.map +1 -1
  3. package/lib/aptos/aptos-processor.js +1 -1
  4. package/lib/aptos/aptos-processor.js.map +1 -1
  5. package/lib/aptos/context.d.ts +2 -2
  6. package/lib/aptos/context.d.ts.map +1 -1
  7. package/lib/aptos/context.js +1 -1
  8. package/lib/aptos/ext/aptos-dex.d.ts +1 -1
  9. package/lib/aptos/ext/aptos-dex.d.ts.map +1 -1
  10. package/lib/aptos/ext/aptos-dex.js +1 -1
  11. package/lib/aptos/ext/aptos-dex.js.map +1 -1
  12. package/lib/aptos/ext/coin-event.d.ts +1 -1
  13. package/lib/aptos/ext/coin-event.d.ts.map +1 -1
  14. package/lib/aptos/ext/coin.js +2 -2
  15. package/lib/aptos/ext/coin.js.map +1 -1
  16. package/lib/eth/account-processor.d.ts +21 -7
  17. package/lib/eth/account-processor.d.ts.map +1 -1
  18. package/lib/eth/account-processor.js +2 -2
  19. package/lib/eth/account-processor.js.map +1 -1
  20. package/lib/eth/base-processor-template.d.ts +24 -8
  21. package/lib/eth/base-processor-template.d.ts.map +1 -1
  22. package/lib/eth/base-processor-template.js.map +1 -1
  23. package/lib/eth/base-processor.d.ts +30 -10
  24. package/lib/eth/base-processor.d.ts.map +1 -1
  25. package/lib/eth/base-processor.js +6 -6
  26. package/lib/eth/base-processor.js.map +1 -1
  27. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +100 -31
  28. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  29. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +1295 -46
  30. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  31. package/lib/eth/builtin/internal/erc1155-processor.d.ts +55 -16
  32. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  33. package/lib/eth/builtin/internal/erc1155-processor.js +510 -16
  34. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  35. package/lib/eth/builtin/internal/erc20-processor.d.ts +79 -24
  36. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  37. package/lib/eth/builtin/internal/erc20-processor.js +1039 -36
  38. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  39. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +46 -13
  40. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  41. package/lib/eth/builtin/internal/erc20bytes-processor.js +512 -18
  42. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  43. package/lib/eth/builtin/internal/erc721-processor.d.ts +67 -20
  44. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  45. package/lib/eth/builtin/internal/erc721-processor.js +826 -28
  46. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  47. package/lib/eth/builtin/internal/weth9-processor.d.ts +64 -19
  48. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  49. package/lib/eth/builtin/internal/weth9-processor.js +607 -22
  50. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  51. package/lib/eth/codegen/event-handler.js +1 -1
  52. package/lib/eth/codegen/file.d.ts.map +1 -1
  53. package/lib/eth/codegen/file.js +21 -3
  54. package/lib/eth/codegen/file.js.map +1 -1
  55. package/lib/eth/codegen/function-calls.d.ts +4 -0
  56. package/lib/eth/codegen/function-calls.d.ts.map +1 -1
  57. package/lib/eth/codegen/function-calls.js +83 -5
  58. package/lib/eth/codegen/function-calls.js.map +1 -1
  59. package/lib/eth/codegen/types.d.ts +1 -0
  60. package/lib/eth/codegen/types.d.ts.map +1 -1
  61. package/lib/eth/codegen/types.js +13 -0
  62. package/lib/eth/codegen/types.js.map +1 -1
  63. package/lib/eth/context.d.ts +4 -0
  64. package/lib/eth/context.d.ts.map +1 -1
  65. package/lib/eth/context.js +4 -0
  66. package/lib/eth/context.js.map +1 -1
  67. package/lib/eth/eth-plugin.d.ts +27 -9
  68. package/lib/eth/eth-plugin.d.ts.map +1 -1
  69. package/lib/eth/eth-plugin.js +20 -17
  70. package/lib/eth/eth-plugin.js.map +1 -1
  71. package/lib/eth/eth.d.ts.map +1 -1
  72. package/lib/eth/eth.js +1 -1
  73. package/lib/eth/eth.js.map +1 -1
  74. package/lib/eth/generic-processor.js +1 -1
  75. package/lib/eth/generic-processor.js.map +1 -1
  76. package/lib/eth/generic-processor.test.js.map +1 -1
  77. package/lib/eth/index.d.ts +2 -1
  78. package/lib/eth/index.d.ts.map +1 -1
  79. package/lib/eth/index.js +2 -1
  80. package/lib/eth/index.js.map +1 -1
  81. package/lib/solana/builtin/spl-token-processor.d.ts +1 -1
  82. package/lib/solana/builtin/spl-token-processor.d.ts.map +1 -1
  83. package/lib/solana/builtin/spl-token-processor.js +1 -1
  84. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  85. package/lib/solana/solana-context.d.ts +1 -1
  86. package/lib/solana/solana-context.js +2 -2
  87. package/lib/store/cache.d.ts +14 -0
  88. package/lib/store/cache.d.ts.map +1 -0
  89. package/lib/store/cache.js +35 -0
  90. package/lib/store/cache.js.map +1 -0
  91. package/lib/store/store.d.ts +2 -3
  92. package/lib/store/store.d.ts.map +1 -1
  93. package/lib/store/store.js +34 -9
  94. package/lib/store/store.js.map +1 -1
  95. package/lib/sui/context.d.ts +1 -1
  96. package/lib/sui/context.d.ts.map +1 -1
  97. package/lib/sui/sui-processor.d.ts +1 -1
  98. package/lib/sui/sui-processor.d.ts.map +1 -1
  99. package/lib/sui/sui-processor.js +1 -1
  100. package/lib/sui/sui-processor.js.map +1 -1
  101. package/lib/testing/aptos-facet.d.ts +1 -1
  102. package/lib/testing/aptos-facet.js +2 -2
  103. package/lib/testing/sui-facet.js +1 -1
  104. package/lib/utils/dex-price.d.ts +1 -0
  105. package/lib/utils/dex-price.d.ts.map +1 -1
  106. package/lib/utils/dex-price.js +13 -2
  107. package/lib/utils/dex-price.js.map +1 -1
  108. package/package.json +8 -7
  109. package/src/aptos/aptos-processor.ts +1 -1
  110. package/src/aptos/context.ts +2 -2
  111. package/src/aptos/ext/aptos-dex.ts +1 -1
  112. package/src/aptos/ext/coin-event.ts +1 -1
  113. package/src/aptos/ext/coin.ts +2 -2
  114. package/src/eth/account-processor.ts +28 -12
  115. package/src/eth/base-processor-template.ts +16 -8
  116. package/src/eth/base-processor.ts +25 -16
  117. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +1643 -123
  118. package/src/eth/builtin/internal/erc1155-processor.ts +724 -42
  119. package/src/eth/builtin/internal/erc20-processor.ts +1368 -90
  120. package/src/eth/builtin/internal/erc20bytes-processor.ts +685 -49
  121. package/src/eth/builtin/internal/erc721-processor.ts +1116 -70
  122. package/src/eth/builtin/internal/weth9-processor.ts +798 -63
  123. package/src/eth/codegen/event-handler.ts +1 -1
  124. package/src/eth/codegen/file.ts +26 -3
  125. package/src/eth/codegen/function-calls.ts +101 -8
  126. package/src/eth/codegen/types.ts +22 -1
  127. package/src/eth/context.ts +7 -0
  128. package/src/eth/eth-plugin.ts +34 -26
  129. package/src/eth/eth.ts +1 -2
  130. package/src/eth/generic-processor.ts +1 -1
  131. package/src/eth/index.ts +5 -1
  132. package/src/solana/builtin/spl-token-processor.ts +1 -1
  133. package/src/solana/solana-context.ts +2 -2
  134. package/src/store/cache.ts +46 -0
  135. package/src/store/store.ts +40 -22
  136. package/src/sui/context.ts +1 -1
  137. package/src/sui/sui-processor.ts +1 -1
  138. package/src/testing/aptos-facet.ts +2 -2
  139. package/src/testing/sui-facet.ts +1 -1
  140. package/src/utils/dex-price.ts +15 -2
  141. package/lib/eth/provider.d.ts +0 -5
  142. package/lib/eth/provider.d.ts.map +0 -1
  143. package/lib/eth/provider.js +0 -134
  144. package/lib/eth/provider.js.map +0 -1
  145. package/lib/utils/chainlink-oracles-sepolia.csv +0 -19
  146. package/lib/utils/chainlink-oracles.csv +0 -217
  147. package/src/eth/provider.ts +0 -163
@@ -1,7 +1,7 @@
1
1
  /* Autogenerated file. Do not edit manually. */
2
2
  /* tslint:disable */
3
3
  /* eslint-disable */
4
- import { BigNumberish, Overrides } from "ethers";
4
+ import { BigNumberish, Overrides, Interface } from "ethers";
5
5
  import {
6
6
  addContractByABI,
7
7
  getContractByABI,
@@ -21,7 +21,9 @@ import {
21
21
  EthContext,
22
22
  EthFetchConfig,
23
23
  PreprocessResult,
24
+ makeEthCallKey,
24
25
  } from "@sentio/sdk/eth";
26
+ import { EthCallParam, EthCallContext, PreparedData } from "@sentio/protos";
25
27
 
26
28
  import { ERC20Bytes__factory } from "./index.js";
27
29
  import {
@@ -103,8 +105,28 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
103
105
  this.callStatic.contract = contract;
104
106
  }
105
107
 
106
- async name(overrides?: Overrides): Promise<string> {
108
+ async name(
109
+ overrides?: Overrides,
110
+ preparedData?: PreparedData,
111
+ ethCallContext?: EthCallContext
112
+ ): Promise<string> {
107
113
  try {
114
+ if (preparedData?.ethCallResults && ethCallContext) {
115
+ const iface = new Interface(["function name() view returns (bytes32)"]);
116
+ const calldata = iface.encodeFunctionData("name", []);
117
+ const key = makeEthCallKey({
118
+ context: ethCallContext,
119
+ calldata,
120
+ });
121
+ console.debug("looking up eth call key:", key);
122
+ const ret = preparedData.ethCallResults[key];
123
+ if (ret) {
124
+ console.debug("prepared eth call found:", key);
125
+ const result = iface.decodeFunctionResult("name", ret).toArray();
126
+ return result.length == 1 ? result[0] : result;
127
+ }
128
+ console.debug("missing eth call key:", "name", key);
129
+ }
108
130
  return await this.contract.getFunction("name()")(overrides || {});
109
131
  } catch (e) {
110
132
  const stack = new Error().stack;
@@ -112,8 +134,32 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
112
134
  }
113
135
  }
114
136
 
115
- async totalSupply(overrides?: Overrides): Promise<bigint> {
137
+ async totalSupply(
138
+ overrides?: Overrides,
139
+ preparedData?: PreparedData,
140
+ ethCallContext?: EthCallContext
141
+ ): Promise<bigint> {
116
142
  try {
143
+ if (preparedData?.ethCallResults && ethCallContext) {
144
+ const iface = new Interface([
145
+ "function totalSupply() view returns (uint256)",
146
+ ]);
147
+ const calldata = iface.encodeFunctionData("totalSupply", []);
148
+ const key = makeEthCallKey({
149
+ context: ethCallContext,
150
+ calldata,
151
+ });
152
+ console.debug("looking up eth call key:", key);
153
+ const ret = preparedData.ethCallResults[key];
154
+ if (ret) {
155
+ console.debug("prepared eth call found:", key);
156
+ const result = iface
157
+ .decodeFunctionResult("totalSupply", ret)
158
+ .toArray();
159
+ return result.length == 1 ? result[0] : result;
160
+ }
161
+ console.debug("missing eth call key:", "totalSupply", key);
162
+ }
117
163
  return await this.contract.getFunction("totalSupply()")(overrides || {});
118
164
  } catch (e) {
119
165
  const stack = new Error().stack;
@@ -121,8 +167,30 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
121
167
  }
122
168
  }
123
169
 
124
- async decimals(overrides?: Overrides): Promise<bigint> {
170
+ async decimals(
171
+ overrides?: Overrides,
172
+ preparedData?: PreparedData,
173
+ ethCallContext?: EthCallContext
174
+ ): Promise<bigint> {
125
175
  try {
176
+ if (preparedData?.ethCallResults && ethCallContext) {
177
+ const iface = new Interface([
178
+ "function decimals() view returns (uint8)",
179
+ ]);
180
+ const calldata = iface.encodeFunctionData("decimals", []);
181
+ const key = makeEthCallKey({
182
+ context: ethCallContext,
183
+ calldata,
184
+ });
185
+ console.debug("looking up eth call key:", key);
186
+ const ret = preparedData.ethCallResults[key];
187
+ if (ret) {
188
+ console.debug("prepared eth call found:", key);
189
+ const result = iface.decodeFunctionResult("decimals", ret).toArray();
190
+ return result.length == 1 ? result[0] : result;
191
+ }
192
+ console.debug("missing eth call key:", "decimals", key);
193
+ }
126
194
  return await this.contract.getFunction("decimals()")(overrides || {});
127
195
  } catch (e) {
128
196
  const stack = new Error().stack;
@@ -130,8 +198,31 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
130
198
  }
131
199
  }
132
200
 
133
- async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
201
+ async balanceOf(
202
+ who: string,
203
+ overrides?: Overrides,
204
+ preparedData?: PreparedData,
205
+ ethCallContext?: EthCallContext
206
+ ): Promise<bigint> {
134
207
  try {
208
+ if (preparedData?.ethCallResults && ethCallContext) {
209
+ const iface = new Interface([
210
+ "function balanceOf(address) view returns (uint256)",
211
+ ]);
212
+ const calldata = iface.encodeFunctionData("balanceOf", [who]);
213
+ const key = makeEthCallKey({
214
+ context: ethCallContext,
215
+ calldata,
216
+ });
217
+ console.debug("looking up eth call key:", key);
218
+ const ret = preparedData.ethCallResults[key];
219
+ if (ret) {
220
+ console.debug("prepared eth call found:", key);
221
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
222
+ return result.length == 1 ? result[0] : result;
223
+ }
224
+ console.debug("missing eth call key:", "balanceOf", who, key);
225
+ }
135
226
  return await this.contract.getFunction("balanceOf(address)")(
136
227
  who,
137
228
  overrides || {}
@@ -142,8 +233,30 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
142
233
  }
143
234
  }
144
235
 
145
- async symbol(overrides?: Overrides): Promise<string> {
236
+ async symbol(
237
+ overrides?: Overrides,
238
+ preparedData?: PreparedData,
239
+ ethCallContext?: EthCallContext
240
+ ): Promise<string> {
146
241
  try {
242
+ if (preparedData?.ethCallResults && ethCallContext) {
243
+ const iface = new Interface([
244
+ "function symbol() view returns (bytes32)",
245
+ ]);
246
+ const calldata = iface.encodeFunctionData("symbol", []);
247
+ const key = makeEthCallKey({
248
+ context: ethCallContext,
249
+ calldata,
250
+ });
251
+ console.debug("looking up eth call key:", key);
252
+ const ret = preparedData.ethCallResults[key];
253
+ if (ret) {
254
+ console.debug("prepared eth call found:", key);
255
+ const result = iface.decodeFunctionResult("symbol", ret).toArray();
256
+ return result.length == 1 ? result[0] : result;
257
+ }
258
+ console.debug("missing eth call key:", "symbol", key);
259
+ }
147
260
  return await this.contract.getFunction("symbol()")(overrides || {});
148
261
  } catch (e) {
149
262
  const stack = new Error().stack;
@@ -154,9 +267,38 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
154
267
  async allowance(
155
268
  owner: string,
156
269
  spender: string,
157
- overrides?: Overrides
270
+ overrides?: Overrides,
271
+ preparedData?: PreparedData,
272
+ ethCallContext?: EthCallContext
158
273
  ): Promise<bigint> {
159
274
  try {
275
+ if (preparedData?.ethCallResults && ethCallContext) {
276
+ const iface = new Interface([
277
+ "function allowance(address,address) view returns (uint256)",
278
+ ]);
279
+ const calldata = iface.encodeFunctionData("allowance", [
280
+ owner,
281
+ spender,
282
+ ]);
283
+ const key = makeEthCallKey({
284
+ context: ethCallContext,
285
+ calldata,
286
+ });
287
+ console.debug("looking up eth call key:", key);
288
+ const ret = preparedData.ethCallResults[key];
289
+ if (ret) {
290
+ console.debug("prepared eth call found:", key);
291
+ const result = iface.decodeFunctionResult("allowance", ret).toArray();
292
+ return result.length == 1 ? result[0] : result;
293
+ }
294
+ console.debug(
295
+ "missing eth call key:",
296
+ "allowance",
297
+ owner,
298
+ spender,
299
+ key
300
+ );
301
+ }
160
302
  return await this.contract.getFunction("allowance(address,address)")(
161
303
  owner,
162
304
  spender,
@@ -174,9 +316,38 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
174
316
  async approve(
175
317
  spender: string,
176
318
  value: BigNumberish,
177
- overrides?: Overrides
319
+ overrides?: Overrides,
320
+ preparedData?: PreparedData,
321
+ ethCallContext?: EthCallContext
178
322
  ): Promise<boolean> {
179
323
  try {
324
+ if (preparedData?.ethCallResults && ethCallContext) {
325
+ const iface = new Interface([
326
+ "function approve(address,uint256) nonpayable returns (bool)",
327
+ ]);
328
+ const calldata = iface.encodeFunctionData("approve", [
329
+ spender,
330
+ value,
331
+ ]);
332
+ const key = makeEthCallKey({
333
+ context: ethCallContext,
334
+ calldata,
335
+ });
336
+ console.debug("looking up eth call key:", key);
337
+ const ret = preparedData.ethCallResults[key];
338
+ if (ret) {
339
+ console.debug("prepared eth call found:", key);
340
+ const result = iface.decodeFunctionResult("approve", ret).toArray();
341
+ return result.length == 1 ? result[0] : result;
342
+ }
343
+ console.debug(
344
+ "missing eth call key:",
345
+ "approve",
346
+ spender,
347
+ value,
348
+ key
349
+ );
350
+ }
180
351
  return await this.contract
181
352
  .getFunction("approve(address,uint256)")
182
353
  .staticCall(spender, value, overrides || {});
@@ -189,9 +360,42 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
189
360
  from: string,
190
361
  to: string,
191
362
  value: BigNumberish,
192
- overrides?: Overrides
363
+ overrides?: Overrides,
364
+ preparedData?: PreparedData,
365
+ ethCallContext?: EthCallContext
193
366
  ): Promise<boolean> {
194
367
  try {
368
+ if (preparedData?.ethCallResults && ethCallContext) {
369
+ const iface = new Interface([
370
+ "function transferFrom(address,address,uint256) nonpayable returns (bool)",
371
+ ]);
372
+ const calldata = iface.encodeFunctionData("transferFrom", [
373
+ from,
374
+ to,
375
+ value,
376
+ ]);
377
+ const key = makeEthCallKey({
378
+ context: ethCallContext,
379
+ calldata,
380
+ });
381
+ console.debug("looking up eth call key:", key);
382
+ const ret = preparedData.ethCallResults[key];
383
+ if (ret) {
384
+ console.debug("prepared eth call found:", key);
385
+ const result = iface
386
+ .decodeFunctionResult("transferFrom", ret)
387
+ .toArray();
388
+ return result.length == 1 ? result[0] : result;
389
+ }
390
+ console.debug(
391
+ "missing eth call key:",
392
+ "transferFrom",
393
+ from,
394
+ to,
395
+ value,
396
+ key
397
+ );
398
+ }
195
399
  return await this.contract
196
400
  .getFunction("transferFrom(address,address,uint256)")
197
401
  .staticCall(from, to, value, overrides || {});
@@ -203,9 +407,31 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
203
407
  async transfer(
204
408
  to: string,
205
409
  value: BigNumberish,
206
- overrides?: Overrides
410
+ overrides?: Overrides,
411
+ preparedData?: PreparedData,
412
+ ethCallContext?: EthCallContext
207
413
  ): Promise<boolean> {
208
414
  try {
415
+ if (preparedData?.ethCallResults && ethCallContext) {
416
+ const iface = new Interface([
417
+ "function transfer(address,uint256) nonpayable returns (bool)",
418
+ ]);
419
+ const calldata = iface.encodeFunctionData("transfer", [to, value]);
420
+ const key = makeEthCallKey({
421
+ context: ethCallContext,
422
+ calldata,
423
+ });
424
+ console.debug("looking up eth call key:", key);
425
+ const ret = preparedData.ethCallResults[key];
426
+ if (ret) {
427
+ console.debug("prepared eth call found:", key);
428
+ const result = iface
429
+ .decodeFunctionResult("transfer", ret)
430
+ .toArray();
431
+ return result.length == 1 ? result[0] : result;
432
+ }
433
+ console.debug("missing eth call key:", "transfer", to, value, key);
434
+ }
209
435
  return await this.contract
210
436
  .getFunction("transfer(address,uint256)")
211
437
  .staticCall(to, value, overrides || {});
@@ -215,6 +441,152 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
215
441
  }
216
442
  },
217
443
  };
444
+
445
+ encodeCall = {
446
+ name(ethCallContext: EthCallContext): EthCallParam {
447
+ try {
448
+ const iface = new Interface(["function name()"]);
449
+ const calldata = iface.encodeFunctionData("name", []);
450
+ return {
451
+ context: ethCallContext,
452
+ calldata,
453
+ };
454
+ } catch (e) {
455
+ const stack = new Error().stack;
456
+ throw transformEtherError(e, undefined, stack);
457
+ }
458
+ },
459
+ approve(
460
+ spender: string,
461
+ value: BigNumberish,
462
+ ethCallContext: EthCallContext
463
+ ): EthCallParam {
464
+ try {
465
+ const iface = new Interface(["function approve(address,uint256)"]);
466
+ const calldata = iface.encodeFunctionData("approve", [spender, value]);
467
+ return {
468
+ context: ethCallContext,
469
+ calldata,
470
+ };
471
+ } catch (e) {
472
+ const stack = new Error().stack;
473
+ throw transformEtherError(e, undefined, stack);
474
+ }
475
+ },
476
+ totalSupply(ethCallContext: EthCallContext): EthCallParam {
477
+ try {
478
+ const iface = new Interface(["function totalSupply()"]);
479
+ const calldata = iface.encodeFunctionData("totalSupply", []);
480
+ return {
481
+ context: ethCallContext,
482
+ calldata,
483
+ };
484
+ } catch (e) {
485
+ const stack = new Error().stack;
486
+ throw transformEtherError(e, undefined, stack);
487
+ }
488
+ },
489
+ transferFrom(
490
+ from: string,
491
+ to: string,
492
+ value: BigNumberish,
493
+ ethCallContext: EthCallContext
494
+ ): EthCallParam {
495
+ try {
496
+ const iface = new Interface([
497
+ "function transferFrom(address,address,uint256)",
498
+ ]);
499
+ const calldata = iface.encodeFunctionData("transferFrom", [
500
+ from,
501
+ to,
502
+ value,
503
+ ]);
504
+ return {
505
+ context: ethCallContext,
506
+ calldata,
507
+ };
508
+ } catch (e) {
509
+ const stack = new Error().stack;
510
+ throw transformEtherError(e, undefined, stack);
511
+ }
512
+ },
513
+ decimals(ethCallContext: EthCallContext): EthCallParam {
514
+ try {
515
+ const iface = new Interface(["function decimals()"]);
516
+ const calldata = iface.encodeFunctionData("decimals", []);
517
+ return {
518
+ context: ethCallContext,
519
+ calldata,
520
+ };
521
+ } catch (e) {
522
+ const stack = new Error().stack;
523
+ throw transformEtherError(e, undefined, stack);
524
+ }
525
+ },
526
+ balanceOf(who: string, ethCallContext: EthCallContext): EthCallParam {
527
+ try {
528
+ const iface = new Interface(["function balanceOf(address)"]);
529
+ const calldata = iface.encodeFunctionData("balanceOf", [who]);
530
+ return {
531
+ context: ethCallContext,
532
+ calldata,
533
+ };
534
+ } catch (e) {
535
+ const stack = new Error().stack;
536
+ throw transformEtherError(e, undefined, stack);
537
+ }
538
+ },
539
+ symbol(ethCallContext: EthCallContext): EthCallParam {
540
+ try {
541
+ const iface = new Interface(["function symbol()"]);
542
+ const calldata = iface.encodeFunctionData("symbol", []);
543
+ return {
544
+ context: ethCallContext,
545
+ calldata,
546
+ };
547
+ } catch (e) {
548
+ const stack = new Error().stack;
549
+ throw transformEtherError(e, undefined, stack);
550
+ }
551
+ },
552
+ transfer(
553
+ to: string,
554
+ value: BigNumberish,
555
+ ethCallContext: EthCallContext
556
+ ): EthCallParam {
557
+ try {
558
+ const iface = new Interface(["function transfer(address,uint256)"]);
559
+ const calldata = iface.encodeFunctionData("transfer", [to, value]);
560
+ return {
561
+ context: ethCallContext,
562
+ calldata,
563
+ };
564
+ } catch (e) {
565
+ const stack = new Error().stack;
566
+ throw transformEtherError(e, undefined, stack);
567
+ }
568
+ },
569
+ allowance(
570
+ owner: string,
571
+ spender: string,
572
+ ethCallContext: EthCallContext
573
+ ): EthCallParam {
574
+ try {
575
+ const iface = new Interface(["function allowance(address,address)"]);
576
+ const calldata = iface.encodeFunctionData("allowance", [
577
+ owner,
578
+ spender,
579
+ ]);
580
+ return {
581
+ context: ethCallContext,
582
+ calldata,
583
+ };
584
+ } catch (e) {
585
+ const stack = new Error().stack;
586
+ throw transformEtherError(e, undefined, stack);
587
+ }
588
+ },
589
+ };
218
590
  }
219
591
 
220
592
  export class ERC20BytesBoundContractView extends BoundContractView<
@@ -222,38 +594,84 @@ export class ERC20BytesBoundContractView extends BoundContractView<
222
594
  ERC20BytesContractView
223
595
  > {
224
596
  async name(overrides?: Overrides): Promise<string> {
225
- return await this.view.name({
226
- blockTag: this.context.blockNumber,
227
- ...overrides,
228
- });
597
+ const ethCallContext = {
598
+ chainId: this.context.chainId,
599
+ blockTag: "0x" + this.context.blockNumber.toString(16),
600
+ address: this.context.address,
601
+ };
602
+ return await this.view.name(
603
+ {
604
+ blockTag: this.context.blockNumber,
605
+ ...overrides,
606
+ },
607
+ this.context.preparedData,
608
+ ethCallContext
609
+ );
229
610
  }
230
611
 
231
612
  async totalSupply(overrides?: Overrides): Promise<bigint> {
232
- return await this.view.totalSupply({
233
- blockTag: this.context.blockNumber,
234
- ...overrides,
235
- });
613
+ const ethCallContext = {
614
+ chainId: this.context.chainId,
615
+ blockTag: "0x" + this.context.blockNumber.toString(16),
616
+ address: this.context.address,
617
+ };
618
+ return await this.view.totalSupply(
619
+ {
620
+ blockTag: this.context.blockNumber,
621
+ ...overrides,
622
+ },
623
+ this.context.preparedData,
624
+ ethCallContext
625
+ );
236
626
  }
237
627
 
238
628
  async decimals(overrides?: Overrides): Promise<bigint> {
239
- return await this.view.decimals({
240
- blockTag: this.context.blockNumber,
241
- ...overrides,
242
- });
629
+ const ethCallContext = {
630
+ chainId: this.context.chainId,
631
+ blockTag: "0x" + this.context.blockNumber.toString(16),
632
+ address: this.context.address,
633
+ };
634
+ return await this.view.decimals(
635
+ {
636
+ blockTag: this.context.blockNumber,
637
+ ...overrides,
638
+ },
639
+ this.context.preparedData,
640
+ ethCallContext
641
+ );
243
642
  }
244
643
 
245
644
  async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
246
- return await this.view.balanceOf(who, {
247
- blockTag: this.context.blockNumber,
248
- ...overrides,
249
- });
645
+ const ethCallContext = {
646
+ chainId: this.context.chainId,
647
+ blockTag: "0x" + this.context.blockNumber.toString(16),
648
+ address: this.context.address,
649
+ };
650
+ return await this.view.balanceOf(
651
+ who,
652
+ {
653
+ blockTag: this.context.blockNumber,
654
+ ...overrides,
655
+ },
656
+ this.context.preparedData,
657
+ ethCallContext
658
+ );
250
659
  }
251
660
 
252
661
  async symbol(overrides?: Overrides): Promise<string> {
253
- return await this.view.symbol({
254
- blockTag: this.context.blockNumber,
255
- ...overrides,
256
- });
662
+ const ethCallContext = {
663
+ chainId: this.context.chainId,
664
+ blockTag: "0x" + this.context.blockNumber.toString(16),
665
+ address: this.context.address,
666
+ };
667
+ return await this.view.symbol(
668
+ {
669
+ blockTag: this.context.blockNumber,
670
+ ...overrides,
671
+ },
672
+ this.context.preparedData,
673
+ ethCallContext
674
+ );
257
675
  }
258
676
 
259
677
  async allowance(
@@ -261,10 +679,21 @@ export class ERC20BytesBoundContractView extends BoundContractView<
261
679
  spender: string,
262
680
  overrides?: Overrides
263
681
  ): Promise<bigint> {
264
- return await this.view.allowance(owner, spender, {
265
- blockTag: this.context.blockNumber,
266
- ...overrides,
267
- });
682
+ const ethCallContext = {
683
+ chainId: this.context.chainId,
684
+ blockTag: "0x" + this.context.blockNumber.toString(16),
685
+ address: this.context.address,
686
+ };
687
+ return await this.view.allowance(
688
+ owner,
689
+ spender,
690
+ {
691
+ blockTag: this.context.blockNumber,
692
+ ...overrides,
693
+ },
694
+ this.context.preparedData,
695
+ ethCallContext
696
+ );
268
697
  }
269
698
 
270
699
  callStatic = {
@@ -276,10 +705,21 @@ export class ERC20BytesBoundContractView extends BoundContractView<
276
705
  value: BigNumberish,
277
706
  overrides?: Overrides
278
707
  ): Promise<boolean> {
279
- return await this.view.callStatic.approve(spender, value, {
280
- blockTag: this.context.blockNumber,
281
- ...overrides,
282
- });
708
+ const ethCallContext = {
709
+ chainId: this.context.chainId,
710
+ blockTag: "0x" + this.context.blockNumber.toString(16),
711
+ address: this.context.address,
712
+ };
713
+ return await this.view.callStatic.approve(
714
+ spender,
715
+ value,
716
+ {
717
+ blockTag: this.context.blockNumber,
718
+ ...overrides,
719
+ },
720
+ this.context.preparedData,
721
+ ethCallContext
722
+ );
283
723
  },
284
724
  async transferFrom(
285
725
  from: string,
@@ -287,19 +727,211 @@ export class ERC20BytesBoundContractView extends BoundContractView<
287
727
  value: BigNumberish,
288
728
  overrides?: Overrides
289
729
  ): Promise<boolean> {
290
- return await this.view.callStatic.transferFrom(from, to, value, {
291
- blockTag: this.context.blockNumber,
292
- ...overrides,
293
- });
730
+ const ethCallContext = {
731
+ chainId: this.context.chainId,
732
+ blockTag: "0x" + this.context.blockNumber.toString(16),
733
+ address: this.context.address,
734
+ };
735
+ return await this.view.callStatic.transferFrom(
736
+ from,
737
+ to,
738
+ value,
739
+ {
740
+ blockTag: this.context.blockNumber,
741
+ ...overrides,
742
+ },
743
+ this.context.preparedData,
744
+ ethCallContext
745
+ );
294
746
  },
295
747
  async transfer(
296
748
  to: string,
297
749
  value: BigNumberish,
298
750
  overrides?: Overrides
299
751
  ): Promise<boolean> {
300
- return await this.view.callStatic.transfer(to, value, {
301
- blockTag: this.context.blockNumber,
302
- ...overrides,
752
+ const ethCallContext = {
753
+ chainId: this.context.chainId,
754
+ blockTag: "0x" + this.context.blockNumber.toString(16),
755
+ address: this.context.address,
756
+ };
757
+ return await this.view.callStatic.transfer(
758
+ to,
759
+ value,
760
+ {
761
+ blockTag: this.context.blockNumber,
762
+ ...overrides,
763
+ },
764
+ this.context.preparedData,
765
+ ethCallContext
766
+ );
767
+ },
768
+ };
769
+
770
+ encodeCall = {
771
+ view: this.view,
772
+ context: this.context,
773
+
774
+ name(overrides?: Overrides): EthCallParam {
775
+ const chainId =
776
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
777
+ const address = this.context.address;
778
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
779
+ if (overrides?.blockTag) {
780
+ blockTag =
781
+ typeof overrides.blockTag == "string"
782
+ ? overrides.blockTag
783
+ : "0x" + overrides.blockTag.toString(16);
784
+ }
785
+
786
+ return this.view.encodeCall.name({ chainId, address, blockTag });
787
+ },
788
+ approve(
789
+ spender: string,
790
+ value: BigNumberish,
791
+ overrides?: Overrides
792
+ ): EthCallParam {
793
+ const chainId =
794
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
795
+ const address = this.context.address;
796
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
797
+ if (overrides?.blockTag) {
798
+ blockTag =
799
+ typeof overrides.blockTag == "string"
800
+ ? overrides.blockTag
801
+ : "0x" + overrides.blockTag.toString(16);
802
+ }
803
+
804
+ return this.view.encodeCall.approve(spender, value, {
805
+ chainId,
806
+ address,
807
+ blockTag,
808
+ });
809
+ },
810
+ totalSupply(overrides?: Overrides): EthCallParam {
811
+ const chainId =
812
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
813
+ const address = this.context.address;
814
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
815
+ if (overrides?.blockTag) {
816
+ blockTag =
817
+ typeof overrides.blockTag == "string"
818
+ ? overrides.blockTag
819
+ : "0x" + overrides.blockTag.toString(16);
820
+ }
821
+
822
+ return this.view.encodeCall.totalSupply({ chainId, address, blockTag });
823
+ },
824
+ transferFrom(
825
+ from: string,
826
+ to: string,
827
+ value: BigNumberish,
828
+ overrides?: Overrides
829
+ ): EthCallParam {
830
+ const chainId =
831
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
832
+ const address = this.context.address;
833
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
834
+ if (overrides?.blockTag) {
835
+ blockTag =
836
+ typeof overrides.blockTag == "string"
837
+ ? overrides.blockTag
838
+ : "0x" + overrides.blockTag.toString(16);
839
+ }
840
+
841
+ return this.view.encodeCall.transferFrom(from, to, value, {
842
+ chainId,
843
+ address,
844
+ blockTag,
845
+ });
846
+ },
847
+ decimals(overrides?: Overrides): EthCallParam {
848
+ const chainId =
849
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
850
+ const address = this.context.address;
851
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
852
+ if (overrides?.blockTag) {
853
+ blockTag =
854
+ typeof overrides.blockTag == "string"
855
+ ? overrides.blockTag
856
+ : "0x" + overrides.blockTag.toString(16);
857
+ }
858
+
859
+ return this.view.encodeCall.decimals({ chainId, address, blockTag });
860
+ },
861
+ balanceOf(who: string, overrides?: Overrides): EthCallParam {
862
+ const chainId =
863
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
864
+ const address = this.context.address;
865
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
866
+ if (overrides?.blockTag) {
867
+ blockTag =
868
+ typeof overrides.blockTag == "string"
869
+ ? overrides.blockTag
870
+ : "0x" + overrides.blockTag.toString(16);
871
+ }
872
+
873
+ return this.view.encodeCall.balanceOf(who, {
874
+ chainId,
875
+ address,
876
+ blockTag,
877
+ });
878
+ },
879
+ symbol(overrides?: Overrides): EthCallParam {
880
+ const chainId =
881
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
882
+ const address = this.context.address;
883
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
884
+ if (overrides?.blockTag) {
885
+ blockTag =
886
+ typeof overrides.blockTag == "string"
887
+ ? overrides.blockTag
888
+ : "0x" + overrides.blockTag.toString(16);
889
+ }
890
+
891
+ return this.view.encodeCall.symbol({ chainId, address, blockTag });
892
+ },
893
+ transfer(
894
+ to: string,
895
+ value: BigNumberish,
896
+ overrides?: Overrides
897
+ ): EthCallParam {
898
+ const chainId =
899
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
900
+ const address = this.context.address;
901
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
902
+ if (overrides?.blockTag) {
903
+ blockTag =
904
+ typeof overrides.blockTag == "string"
905
+ ? overrides.blockTag
906
+ : "0x" + overrides.blockTag.toString(16);
907
+ }
908
+
909
+ return this.view.encodeCall.transfer(to, value, {
910
+ chainId,
911
+ address,
912
+ blockTag,
913
+ });
914
+ },
915
+ allowance(
916
+ owner: string,
917
+ spender: string,
918
+ overrides?: Overrides
919
+ ): EthCallParam {
920
+ const chainId =
921
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
922
+ const address = this.context.address;
923
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
924
+ if (overrides?.blockTag) {
925
+ blockTag =
926
+ typeof overrides.blockTag == "string"
927
+ ? overrides.blockTag
928
+ : "0x" + overrides.blockTag.toString(16);
929
+ }
930
+
931
+ return this.view.encodeCall.allowance(owner, spender, {
932
+ chainId,
933
+ address,
934
+ blockTag,
303
935
  });
304
936
  },
305
937
  };
@@ -320,7 +952,8 @@ export class ERC20BytesProcessor extends BaseProcessor<
320
952
  fetchConfig?: Partial<EthFetchConfig>,
321
953
  preprocessHandler?: (
322
954
  event: ApprovalEvent,
323
- ctx: ERC20BytesContext
955
+ ctx: ERC20BytesContext,
956
+ preprocessStore: { [k: string]: any }
324
957
  ) => Promise<PreprocessResult>
325
958
  ): this {
326
959
  if (!filter) {
@@ -339,7 +972,8 @@ export class ERC20BytesProcessor extends BaseProcessor<
339
972
  fetchConfig?: Partial<EthFetchConfig>,
340
973
  preprocessHandler?: (
341
974
  event: TransferEvent,
342
- ctx: ERC20BytesContext
975
+ ctx: ERC20BytesContext,
976
+ preprocessStore: { [k: string]: any }
343
977
  ) => Promise<PreprocessResult>
344
978
  ): this {
345
979
  if (!filter) {
@@ -564,7 +1198,8 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
564
1198
  fetchConfig?: Partial<EthFetchConfig>,
565
1199
  preprocessHandler?: (
566
1200
  event: ApprovalEvent,
567
- ctx: ERC20BytesContext
1201
+ ctx: ERC20BytesContext,
1202
+ preprocessStore: { [k: string]: any }
568
1203
  ) => Promise<PreprocessResult>
569
1204
  ): this {
570
1205
  if (!filter) {
@@ -583,7 +1218,8 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
583
1218
  fetchConfig?: Partial<EthFetchConfig>,
584
1219
  preprocessHandler?: (
585
1220
  event: TransferEvent,
586
- ctx: ERC20BytesContext
1221
+ ctx: ERC20BytesContext,
1222
+ preprocessStore: { [k: string]: any }
587
1223
  ) => Promise<PreprocessResult>
588
1224
  ): this {
589
1225
  if (!filter) {