@sentio/sdk 2.40.0-rc.2 → 2.40.0-rc.20

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 (135) 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 +17 -17
  70. package/lib/eth/eth-plugin.js.map +1 -1
  71. package/lib/eth/generic-processor.test.js.map +1 -1
  72. package/lib/eth/index.d.ts +1 -0
  73. package/lib/eth/index.d.ts.map +1 -1
  74. package/lib/eth/index.js +1 -0
  75. package/lib/eth/index.js.map +1 -1
  76. package/lib/solana/builtin/spl-token-processor.d.ts +1 -1
  77. package/lib/solana/builtin/spl-token-processor.d.ts.map +1 -1
  78. package/lib/solana/builtin/spl-token-processor.js +1 -1
  79. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  80. package/lib/solana/solana-context.d.ts +1 -1
  81. package/lib/solana/solana-context.js +2 -2
  82. package/lib/store/cache.d.ts +14 -0
  83. package/lib/store/cache.d.ts.map +1 -0
  84. package/lib/store/cache.js +35 -0
  85. package/lib/store/cache.js.map +1 -0
  86. package/lib/store/store.d.ts +2 -3
  87. package/lib/store/store.d.ts.map +1 -1
  88. package/lib/store/store.js +34 -8
  89. package/lib/store/store.js.map +1 -1
  90. package/lib/sui/context.d.ts +1 -1
  91. package/lib/sui/context.d.ts.map +1 -1
  92. package/lib/sui/sui-processor.d.ts +1 -1
  93. package/lib/sui/sui-processor.d.ts.map +1 -1
  94. package/lib/sui/sui-processor.js +1 -1
  95. package/lib/sui/sui-processor.js.map +1 -1
  96. package/lib/testing/aptos-facet.d.ts +1 -1
  97. package/lib/testing/aptos-facet.js +2 -2
  98. package/lib/testing/sui-facet.js +1 -1
  99. package/lib/utils/dex-price.d.ts +1 -0
  100. package/lib/utils/dex-price.d.ts.map +1 -1
  101. package/lib/utils/dex-price.js +13 -2
  102. package/lib/utils/dex-price.js.map +1 -1
  103. package/package.json +8 -7
  104. package/src/aptos/aptos-processor.ts +1 -1
  105. package/src/aptos/context.ts +2 -2
  106. package/src/aptos/ext/aptos-dex.ts +1 -1
  107. package/src/aptos/ext/coin-event.ts +1 -1
  108. package/src/aptos/ext/coin.ts +2 -2
  109. package/src/eth/account-processor.ts +28 -12
  110. package/src/eth/base-processor-template.ts +16 -8
  111. package/src/eth/base-processor.ts +25 -16
  112. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +1643 -123
  113. package/src/eth/builtin/internal/erc1155-processor.ts +724 -42
  114. package/src/eth/builtin/internal/erc20-processor.ts +1368 -90
  115. package/src/eth/builtin/internal/erc20bytes-processor.ts +685 -49
  116. package/src/eth/builtin/internal/erc721-processor.ts +1116 -70
  117. package/src/eth/builtin/internal/weth9-processor.ts +798 -63
  118. package/src/eth/codegen/event-handler.ts +1 -1
  119. package/src/eth/codegen/file.ts +26 -3
  120. package/src/eth/codegen/function-calls.ts +101 -8
  121. package/src/eth/codegen/types.ts +22 -1
  122. package/src/eth/context.ts +7 -0
  123. package/src/eth/eth-plugin.ts +31 -26
  124. package/src/eth/index.ts +2 -0
  125. package/src/solana/builtin/spl-token-processor.ts +1 -1
  126. package/src/solana/solana-context.ts +2 -2
  127. package/src/store/cache.ts +46 -0
  128. package/src/store/store.ts +62 -34
  129. package/src/sui/context.ts +1 -1
  130. package/src/sui/sui-processor.ts +1 -1
  131. package/src/testing/aptos-facet.ts +2 -2
  132. package/src/testing/sui-facet.ts +1 -1
  133. package/src/utils/dex-price.ts +15 -2
  134. package/lib/utils/chainlink-oracles-sepolia.csv +0 -19
  135. package/lib/utils/chainlink-oracles.csv +0 -217
@@ -1,7 +1,7 @@
1
1
  /* Autogenerated file. Do not edit manually. */
2
2
  /* tslint:disable */
3
3
  /* eslint-disable */
4
- import { BigNumberish, Overrides, BytesLike } from "ethers";
4
+ import { BigNumberish, Overrides, BytesLike, 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 { ERC1155__factory } from "./index.js";
27
29
  import {
@@ -128,9 +130,29 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
128
130
  async balanceOf(
129
131
  account: string,
130
132
  id: BigNumberish,
131
- overrides?: Overrides
133
+ overrides?: Overrides,
134
+ preparedData?: PreparedData,
135
+ ethCallContext?: EthCallContext
132
136
  ): Promise<bigint> {
133
137
  try {
138
+ if (preparedData?.ethCallResults && ethCallContext) {
139
+ const iface = new Interface([
140
+ "function balanceOf(address,uint256) view returns (uint256)",
141
+ ]);
142
+ const calldata = iface.encodeFunctionData("balanceOf", [account, id]);
143
+ const key = makeEthCallKey({
144
+ context: ethCallContext,
145
+ calldata,
146
+ });
147
+ console.debug("looking up eth call key:", key);
148
+ const ret = preparedData.ethCallResults[key];
149
+ if (ret) {
150
+ console.debug("prepared eth call found:", key);
151
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
152
+ return result.length == 1 ? result[0] : result;
153
+ }
154
+ console.debug("missing eth call key:", "balanceOf", account, id, key);
155
+ }
134
156
  return await this.contract.getFunction("balanceOf(address,uint256)")(
135
157
  account,
136
158
  id,
@@ -145,9 +167,40 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
145
167
  async balanceOfBatch(
146
168
  accounts: string[],
147
169
  ids: BigNumberish[],
148
- overrides?: Overrides
170
+ overrides?: Overrides,
171
+ preparedData?: PreparedData,
172
+ ethCallContext?: EthCallContext
149
173
  ): Promise<bigint[]> {
150
174
  try {
175
+ if (preparedData?.ethCallResults && ethCallContext) {
176
+ const iface = new Interface([
177
+ "function balanceOfBatch(address[],uint256[]) view returns (uint256[])",
178
+ ]);
179
+ const calldata = iface.encodeFunctionData("balanceOfBatch", [
180
+ accounts,
181
+ ids,
182
+ ]);
183
+ const key = makeEthCallKey({
184
+ context: ethCallContext,
185
+ calldata,
186
+ });
187
+ console.debug("looking up eth call key:", key);
188
+ const ret = preparedData.ethCallResults[key];
189
+ if (ret) {
190
+ console.debug("prepared eth call found:", key);
191
+ const result = iface
192
+ .decodeFunctionResult("balanceOfBatch", ret)
193
+ .toArray();
194
+ return result.length == 1 ? result[0] : result;
195
+ }
196
+ console.debug(
197
+ "missing eth call key:",
198
+ "balanceOfBatch",
199
+ accounts,
200
+ ids,
201
+ key
202
+ );
203
+ }
151
204
  return await this.contract.getFunction(
152
205
  "balanceOfBatch(address[],uint256[])"
153
206
  )(accounts, ids, overrides || {});
@@ -160,9 +213,40 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
160
213
  async isApprovedForAll(
161
214
  account: string,
162
215
  operator: string,
163
- overrides?: Overrides
216
+ overrides?: Overrides,
217
+ preparedData?: PreparedData,
218
+ ethCallContext?: EthCallContext
164
219
  ): Promise<boolean> {
165
220
  try {
221
+ if (preparedData?.ethCallResults && ethCallContext) {
222
+ const iface = new Interface([
223
+ "function isApprovedForAll(address,address) view returns (bool)",
224
+ ]);
225
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
226
+ account,
227
+ operator,
228
+ ]);
229
+ const key = makeEthCallKey({
230
+ context: ethCallContext,
231
+ calldata,
232
+ });
233
+ console.debug("looking up eth call key:", key);
234
+ const ret = preparedData.ethCallResults[key];
235
+ if (ret) {
236
+ console.debug("prepared eth call found:", key);
237
+ const result = iface
238
+ .decodeFunctionResult("isApprovedForAll", ret)
239
+ .toArray();
240
+ return result.length == 1 ? result[0] : result;
241
+ }
242
+ console.debug(
243
+ "missing eth call key:",
244
+ "isApprovedForAll",
245
+ account,
246
+ operator,
247
+ key
248
+ );
249
+ }
166
250
  return await this.contract.getFunction(
167
251
  "isApprovedForAll(address,address)"
168
252
  )(account, operator, overrides || {});
@@ -174,9 +258,38 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
174
258
 
175
259
  async supportsInterface(
176
260
  interfaceId: BytesLike,
177
- overrides?: Overrides
261
+ overrides?: Overrides,
262
+ preparedData?: PreparedData,
263
+ ethCallContext?: EthCallContext
178
264
  ): Promise<boolean> {
179
265
  try {
266
+ if (preparedData?.ethCallResults && ethCallContext) {
267
+ const iface = new Interface([
268
+ "function supportsInterface(bytes4) view returns (bool)",
269
+ ]);
270
+ const calldata = iface.encodeFunctionData("supportsInterface", [
271
+ interfaceId,
272
+ ]);
273
+ const key = makeEthCallKey({
274
+ context: ethCallContext,
275
+ calldata,
276
+ });
277
+ console.debug("looking up eth call key:", key);
278
+ const ret = preparedData.ethCallResults[key];
279
+ if (ret) {
280
+ console.debug("prepared eth call found:", key);
281
+ const result = iface
282
+ .decodeFunctionResult("supportsInterface", ret)
283
+ .toArray();
284
+ return result.length == 1 ? result[0] : result;
285
+ }
286
+ console.debug(
287
+ "missing eth call key:",
288
+ "supportsInterface",
289
+ interfaceId,
290
+ key
291
+ );
292
+ }
180
293
  return await this.contract.getFunction("supportsInterface(bytes4)")(
181
294
  interfaceId,
182
295
  overrides || {}
@@ -187,8 +300,31 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
187
300
  }
188
301
  }
189
302
 
190
- async uri(id: BigNumberish, overrides?: Overrides): Promise<string> {
303
+ async uri(
304
+ id: BigNumberish,
305
+ overrides?: Overrides,
306
+ preparedData?: PreparedData,
307
+ ethCallContext?: EthCallContext
308
+ ): Promise<string> {
191
309
  try {
310
+ if (preparedData?.ethCallResults && ethCallContext) {
311
+ const iface = new Interface([
312
+ "function uri(uint256) view returns (string)",
313
+ ]);
314
+ const calldata = iface.encodeFunctionData("uri", [id]);
315
+ const key = makeEthCallKey({
316
+ context: ethCallContext,
317
+ calldata,
318
+ });
319
+ console.debug("looking up eth call key:", key);
320
+ const ret = preparedData.ethCallResults[key];
321
+ if (ret) {
322
+ console.debug("prepared eth call found:", key);
323
+ const result = iface.decodeFunctionResult("uri", ret).toArray();
324
+ return result.length == 1 ? result[0] : result;
325
+ }
326
+ console.debug("missing eth call key:", "uri", id, key);
327
+ }
192
328
  return await this.contract.getFunction("uri(uint256)")(
193
329
  id,
194
330
  overrides || {}
@@ -208,9 +344,46 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
208
344
  ids: BigNumberish[],
209
345
  amounts: BigNumberish[],
210
346
  data: BytesLike,
211
- overrides?: Overrides
347
+ overrides?: Overrides,
348
+ preparedData?: PreparedData,
349
+ ethCallContext?: EthCallContext
212
350
  ): Promise<void> {
213
351
  try {
352
+ if (preparedData?.ethCallResults && ethCallContext) {
353
+ const iface = new Interface([
354
+ "function safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) nonpayable returns ()",
355
+ ]);
356
+ const calldata = iface.encodeFunctionData("safeBatchTransferFrom", [
357
+ from,
358
+ to,
359
+ ids,
360
+ amounts,
361
+ data,
362
+ ]);
363
+ const key = makeEthCallKey({
364
+ context: ethCallContext,
365
+ calldata,
366
+ });
367
+ console.debug("looking up eth call key:", key);
368
+ const ret = preparedData.ethCallResults[key];
369
+ if (ret) {
370
+ console.debug("prepared eth call found:", key);
371
+ const result = iface
372
+ .decodeFunctionResult("safeBatchTransferFrom", ret)
373
+ .toArray();
374
+ return result.length == 1 ? result[0] : result;
375
+ }
376
+ console.debug(
377
+ "missing eth call key:",
378
+ "safeBatchTransferFrom",
379
+ from,
380
+ to,
381
+ ids,
382
+ amounts,
383
+ data,
384
+ key
385
+ );
386
+ }
214
387
  return await this.contract
215
388
  .getFunction(
216
389
  "safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)"
@@ -227,9 +400,46 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
227
400
  id: BigNumberish,
228
401
  amount: BigNumberish,
229
402
  data: BytesLike,
230
- overrides?: Overrides
403
+ overrides?: Overrides,
404
+ preparedData?: PreparedData,
405
+ ethCallContext?: EthCallContext
231
406
  ): Promise<void> {
232
407
  try {
408
+ if (preparedData?.ethCallResults && ethCallContext) {
409
+ const iface = new Interface([
410
+ "function safeTransferFrom(address,address,uint256,uint256,bytes) nonpayable returns ()",
411
+ ]);
412
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
413
+ from,
414
+ to,
415
+ id,
416
+ amount,
417
+ data,
418
+ ]);
419
+ const key = makeEthCallKey({
420
+ context: ethCallContext,
421
+ calldata,
422
+ });
423
+ console.debug("looking up eth call key:", key);
424
+ const ret = preparedData.ethCallResults[key];
425
+ if (ret) {
426
+ console.debug("prepared eth call found:", key);
427
+ const result = iface
428
+ .decodeFunctionResult("safeTransferFrom", ret)
429
+ .toArray();
430
+ return result.length == 1 ? result[0] : result;
431
+ }
432
+ console.debug(
433
+ "missing eth call key:",
434
+ "safeTransferFrom",
435
+ from,
436
+ to,
437
+ id,
438
+ amount,
439
+ data,
440
+ key
441
+ );
442
+ }
233
443
  return await this.contract
234
444
  .getFunction(
235
445
  "safeTransferFrom(address,address,uint256,uint256,bytes)"
@@ -243,9 +453,40 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
243
453
  async setApprovalForAll(
244
454
  operator: string,
245
455
  approved: boolean,
246
- overrides?: Overrides
456
+ overrides?: Overrides,
457
+ preparedData?: PreparedData,
458
+ ethCallContext?: EthCallContext
247
459
  ): Promise<void> {
248
460
  try {
461
+ if (preparedData?.ethCallResults && ethCallContext) {
462
+ const iface = new Interface([
463
+ "function setApprovalForAll(address,bool) nonpayable returns ()",
464
+ ]);
465
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
466
+ operator,
467
+ approved,
468
+ ]);
469
+ const key = makeEthCallKey({
470
+ context: ethCallContext,
471
+ calldata,
472
+ });
473
+ console.debug("looking up eth call key:", key);
474
+ const ret = preparedData.ethCallResults[key];
475
+ if (ret) {
476
+ console.debug("prepared eth call found:", key);
477
+ const result = iface
478
+ .decodeFunctionResult("setApprovalForAll", ret)
479
+ .toArray();
480
+ return result.length == 1 ? result[0] : result;
481
+ }
482
+ console.debug(
483
+ "missing eth call key:",
484
+ "setApprovalForAll",
485
+ operator,
486
+ approved,
487
+ key
488
+ );
489
+ }
249
490
  return await this.contract
250
491
  .getFunction("setApprovalForAll(address,bool)")
251
492
  .staticCall(operator, approved, overrides || {});
@@ -255,6 +496,179 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
255
496
  }
256
497
  },
257
498
  };
499
+
500
+ encodeCall = {
501
+ balanceOf(
502
+ account: string,
503
+ id: BigNumberish,
504
+ ethCallContext: EthCallContext
505
+ ): EthCallParam {
506
+ try {
507
+ const iface = new Interface(["function balanceOf(address,uint256)"]);
508
+ const calldata = iface.encodeFunctionData("balanceOf", [account, id]);
509
+ return {
510
+ context: ethCallContext,
511
+ calldata,
512
+ };
513
+ } catch (e) {
514
+ const stack = new Error().stack;
515
+ throw transformEtherError(e, undefined, stack);
516
+ }
517
+ },
518
+ balanceOfBatch(
519
+ accounts: string[],
520
+ ids: BigNumberish[],
521
+ ethCallContext: EthCallContext
522
+ ): EthCallParam {
523
+ try {
524
+ const iface = new Interface([
525
+ "function balanceOfBatch(address[],uint256[])",
526
+ ]);
527
+ const calldata = iface.encodeFunctionData("balanceOfBatch", [
528
+ accounts,
529
+ ids,
530
+ ]);
531
+ return {
532
+ context: ethCallContext,
533
+ calldata,
534
+ };
535
+ } catch (e) {
536
+ const stack = new Error().stack;
537
+ throw transformEtherError(e, undefined, stack);
538
+ }
539
+ },
540
+ isApprovedForAll(
541
+ account: string,
542
+ operator: string,
543
+ ethCallContext: EthCallContext
544
+ ): EthCallParam {
545
+ try {
546
+ const iface = new Interface([
547
+ "function isApprovedForAll(address,address)",
548
+ ]);
549
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
550
+ account,
551
+ operator,
552
+ ]);
553
+ return {
554
+ context: ethCallContext,
555
+ calldata,
556
+ };
557
+ } catch (e) {
558
+ const stack = new Error().stack;
559
+ throw transformEtherError(e, undefined, stack);
560
+ }
561
+ },
562
+ safeBatchTransferFrom(
563
+ from: string,
564
+ to: string,
565
+ ids: BigNumberish[],
566
+ amounts: BigNumberish[],
567
+ data: BytesLike,
568
+ ethCallContext: EthCallContext
569
+ ): EthCallParam {
570
+ try {
571
+ const iface = new Interface([
572
+ "function safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)",
573
+ ]);
574
+ const calldata = iface.encodeFunctionData("safeBatchTransferFrom", [
575
+ from,
576
+ to,
577
+ ids,
578
+ amounts,
579
+ data,
580
+ ]);
581
+ return {
582
+ context: ethCallContext,
583
+ calldata,
584
+ };
585
+ } catch (e) {
586
+ const stack = new Error().stack;
587
+ throw transformEtherError(e, undefined, stack);
588
+ }
589
+ },
590
+ safeTransferFrom(
591
+ from: string,
592
+ to: string,
593
+ id: BigNumberish,
594
+ amount: BigNumberish,
595
+ data: BytesLike,
596
+ ethCallContext: EthCallContext
597
+ ): EthCallParam {
598
+ try {
599
+ const iface = new Interface([
600
+ "function safeTransferFrom(address,address,uint256,uint256,bytes)",
601
+ ]);
602
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
603
+ from,
604
+ to,
605
+ id,
606
+ amount,
607
+ data,
608
+ ]);
609
+ return {
610
+ context: ethCallContext,
611
+ calldata,
612
+ };
613
+ } catch (e) {
614
+ const stack = new Error().stack;
615
+ throw transformEtherError(e, undefined, stack);
616
+ }
617
+ },
618
+ setApprovalForAll(
619
+ operator: string,
620
+ approved: boolean,
621
+ ethCallContext: EthCallContext
622
+ ): EthCallParam {
623
+ try {
624
+ const iface = new Interface([
625
+ "function setApprovalForAll(address,bool)",
626
+ ]);
627
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
628
+ operator,
629
+ approved,
630
+ ]);
631
+ return {
632
+ context: ethCallContext,
633
+ calldata,
634
+ };
635
+ } catch (e) {
636
+ const stack = new Error().stack;
637
+ throw transformEtherError(e, undefined, stack);
638
+ }
639
+ },
640
+ supportsInterface(
641
+ interfaceId: BytesLike,
642
+ ethCallContext: EthCallContext
643
+ ): EthCallParam {
644
+ try {
645
+ const iface = new Interface(["function supportsInterface(bytes4)"]);
646
+ const calldata = iface.encodeFunctionData("supportsInterface", [
647
+ interfaceId,
648
+ ]);
649
+ return {
650
+ context: ethCallContext,
651
+ calldata,
652
+ };
653
+ } catch (e) {
654
+ const stack = new Error().stack;
655
+ throw transformEtherError(e, undefined, stack);
656
+ }
657
+ },
658
+ uri(id: BigNumberish, ethCallContext: EthCallContext): EthCallParam {
659
+ try {
660
+ const iface = new Interface(["function uri(uint256)"]);
661
+ const calldata = iface.encodeFunctionData("uri", [id]);
662
+ return {
663
+ context: ethCallContext,
664
+ calldata,
665
+ };
666
+ } catch (e) {
667
+ const stack = new Error().stack;
668
+ throw transformEtherError(e, undefined, stack);
669
+ }
670
+ },
671
+ };
258
672
  }
259
673
 
260
674
  export class ERC1155BoundContractView extends BoundContractView<
@@ -266,10 +680,21 @@ export class ERC1155BoundContractView extends BoundContractView<
266
680
  id: BigNumberish,
267
681
  overrides?: Overrides
268
682
  ): Promise<bigint> {
269
- return await this.view.balanceOf(account, id, {
270
- blockTag: this.context.blockNumber,
271
- ...overrides,
272
- });
683
+ const ethCallContext = {
684
+ chainId: this.context.chainId,
685
+ blockTag: "0x" + this.context.blockNumber.toString(16),
686
+ address: this.context.address,
687
+ };
688
+ return await this.view.balanceOf(
689
+ account,
690
+ id,
691
+ {
692
+ blockTag: this.context.blockNumber,
693
+ ...overrides,
694
+ },
695
+ this.context.preparedData,
696
+ ethCallContext
697
+ );
273
698
  }
274
699
 
275
700
  async balanceOfBatch(
@@ -277,10 +702,21 @@ export class ERC1155BoundContractView extends BoundContractView<
277
702
  ids: BigNumberish[],
278
703
  overrides?: Overrides
279
704
  ): Promise<bigint[]> {
280
- return await this.view.balanceOfBatch(accounts, ids, {
281
- blockTag: this.context.blockNumber,
282
- ...overrides,
283
- });
705
+ const ethCallContext = {
706
+ chainId: this.context.chainId,
707
+ blockTag: "0x" + this.context.blockNumber.toString(16),
708
+ address: this.context.address,
709
+ };
710
+ return await this.view.balanceOfBatch(
711
+ accounts,
712
+ ids,
713
+ {
714
+ blockTag: this.context.blockNumber,
715
+ ...overrides,
716
+ },
717
+ this.context.preparedData,
718
+ ethCallContext
719
+ );
284
720
  }
285
721
 
286
722
  async isApprovedForAll(
@@ -288,27 +724,58 @@ export class ERC1155BoundContractView extends BoundContractView<
288
724
  operator: string,
289
725
  overrides?: Overrides
290
726
  ): Promise<boolean> {
291
- return await this.view.isApprovedForAll(account, operator, {
292
- blockTag: this.context.blockNumber,
293
- ...overrides,
294
- });
727
+ const ethCallContext = {
728
+ chainId: this.context.chainId,
729
+ blockTag: "0x" + this.context.blockNumber.toString(16),
730
+ address: this.context.address,
731
+ };
732
+ return await this.view.isApprovedForAll(
733
+ account,
734
+ operator,
735
+ {
736
+ blockTag: this.context.blockNumber,
737
+ ...overrides,
738
+ },
739
+ this.context.preparedData,
740
+ ethCallContext
741
+ );
295
742
  }
296
743
 
297
744
  async supportsInterface(
298
745
  interfaceId: BytesLike,
299
746
  overrides?: Overrides
300
747
  ): Promise<boolean> {
301
- return await this.view.supportsInterface(interfaceId, {
302
- blockTag: this.context.blockNumber,
303
- ...overrides,
304
- });
748
+ const ethCallContext = {
749
+ chainId: this.context.chainId,
750
+ blockTag: "0x" + this.context.blockNumber.toString(16),
751
+ address: this.context.address,
752
+ };
753
+ return await this.view.supportsInterface(
754
+ interfaceId,
755
+ {
756
+ blockTag: this.context.blockNumber,
757
+ ...overrides,
758
+ },
759
+ this.context.preparedData,
760
+ ethCallContext
761
+ );
305
762
  }
306
763
 
307
764
  async uri(id: BigNumberish, overrides?: Overrides): Promise<string> {
308
- return await this.view.uri(id, {
309
- blockTag: this.context.blockNumber,
310
- ...overrides,
311
- });
765
+ const ethCallContext = {
766
+ chainId: this.context.chainId,
767
+ blockTag: "0x" + this.context.blockNumber.toString(16),
768
+ address: this.context.address,
769
+ };
770
+ return await this.view.uri(
771
+ id,
772
+ {
773
+ blockTag: this.context.blockNumber,
774
+ ...overrides,
775
+ },
776
+ this.context.preparedData,
777
+ ethCallContext
778
+ );
312
779
  }
313
780
 
314
781
  callStatic = {
@@ -323,6 +790,11 @@ export class ERC1155BoundContractView extends BoundContractView<
323
790
  data: BytesLike,
324
791
  overrides?: Overrides
325
792
  ): Promise<void> {
793
+ const ethCallContext = {
794
+ chainId: this.context.chainId,
795
+ blockTag: "0x" + this.context.blockNumber.toString(16),
796
+ address: this.context.address,
797
+ };
326
798
  return await this.view.callStatic.safeBatchTransferFrom(
327
799
  from,
328
800
  to,
@@ -332,7 +804,9 @@ export class ERC1155BoundContractView extends BoundContractView<
332
804
  {
333
805
  blockTag: this.context.blockNumber,
334
806
  ...overrides,
335
- }
807
+ },
808
+ this.context.preparedData,
809
+ ethCallContext
336
810
  );
337
811
  },
338
812
  async safeTransferFrom(
@@ -343,6 +817,11 @@ export class ERC1155BoundContractView extends BoundContractView<
343
817
  data: BytesLike,
344
818
  overrides?: Overrides
345
819
  ): Promise<void> {
820
+ const ethCallContext = {
821
+ chainId: this.context.chainId,
822
+ blockTag: "0x" + this.context.blockNumber.toString(16),
823
+ address: this.context.address,
824
+ };
346
825
  return await this.view.callStatic.safeTransferFrom(
347
826
  from,
348
827
  to,
@@ -352,7 +831,9 @@ export class ERC1155BoundContractView extends BoundContractView<
352
831
  {
353
832
  blockTag: this.context.blockNumber,
354
833
  ...overrides,
355
- }
834
+ },
835
+ this.context.preparedData,
836
+ ethCallContext
356
837
  );
357
838
  },
358
839
  async setApprovalForAll(
@@ -360,11 +841,204 @@ export class ERC1155BoundContractView extends BoundContractView<
360
841
  approved: boolean,
361
842
  overrides?: Overrides
362
843
  ): Promise<void> {
363
- return await this.view.callStatic.setApprovalForAll(operator, approved, {
364
- blockTag: this.context.blockNumber,
365
- ...overrides,
844
+ const ethCallContext = {
845
+ chainId: this.context.chainId,
846
+ blockTag: "0x" + this.context.blockNumber.toString(16),
847
+ address: this.context.address,
848
+ };
849
+ return await this.view.callStatic.setApprovalForAll(
850
+ operator,
851
+ approved,
852
+ {
853
+ blockTag: this.context.blockNumber,
854
+ ...overrides,
855
+ },
856
+ this.context.preparedData,
857
+ ethCallContext
858
+ );
859
+ },
860
+ };
861
+
862
+ encodeCall = {
863
+ view: this.view,
864
+ context: this.context,
865
+
866
+ balanceOf(
867
+ account: string,
868
+ id: BigNumberish,
869
+ overrides?: Overrides
870
+ ): EthCallParam {
871
+ const chainId =
872
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
873
+ const address = this.context.address;
874
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
875
+ if (overrides?.blockTag) {
876
+ blockTag =
877
+ typeof overrides.blockTag == "string"
878
+ ? overrides.blockTag
879
+ : "0x" + overrides.blockTag.toString(16);
880
+ }
881
+
882
+ return this.view.encodeCall.balanceOf(account, id, {
883
+ chainId,
884
+ address,
885
+ blockTag,
886
+ });
887
+ },
888
+ balanceOfBatch(
889
+ accounts: string[],
890
+ ids: BigNumberish[],
891
+ overrides?: Overrides
892
+ ): EthCallParam {
893
+ const chainId =
894
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
895
+ const address = this.context.address;
896
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
897
+ if (overrides?.blockTag) {
898
+ blockTag =
899
+ typeof overrides.blockTag == "string"
900
+ ? overrides.blockTag
901
+ : "0x" + overrides.blockTag.toString(16);
902
+ }
903
+
904
+ return this.view.encodeCall.balanceOfBatch(accounts, ids, {
905
+ chainId,
906
+ address,
907
+ blockTag,
908
+ });
909
+ },
910
+ isApprovedForAll(
911
+ account: string,
912
+ operator: string,
913
+ overrides?: Overrides
914
+ ): EthCallParam {
915
+ const chainId =
916
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
917
+ const address = this.context.address;
918
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
919
+ if (overrides?.blockTag) {
920
+ blockTag =
921
+ typeof overrides.blockTag == "string"
922
+ ? overrides.blockTag
923
+ : "0x" + overrides.blockTag.toString(16);
924
+ }
925
+
926
+ return this.view.encodeCall.isApprovedForAll(account, operator, {
927
+ chainId,
928
+ address,
929
+ blockTag,
930
+ });
931
+ },
932
+ safeBatchTransferFrom(
933
+ from: string,
934
+ to: string,
935
+ ids: BigNumberish[],
936
+ amounts: BigNumberish[],
937
+ data: BytesLike,
938
+ overrides?: Overrides
939
+ ): EthCallParam {
940
+ const chainId =
941
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
942
+ const address = this.context.address;
943
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
944
+ if (overrides?.blockTag) {
945
+ blockTag =
946
+ typeof overrides.blockTag == "string"
947
+ ? overrides.blockTag
948
+ : "0x" + overrides.blockTag.toString(16);
949
+ }
950
+
951
+ return this.view.encodeCall.safeBatchTransferFrom(
952
+ from,
953
+ to,
954
+ ids,
955
+ amounts,
956
+ data,
957
+ { chainId, address, blockTag }
958
+ );
959
+ },
960
+ safeTransferFrom(
961
+ from: string,
962
+ to: string,
963
+ id: BigNumberish,
964
+ amount: BigNumberish,
965
+ data: BytesLike,
966
+ overrides?: Overrides
967
+ ): EthCallParam {
968
+ const chainId =
969
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
970
+ const address = this.context.address;
971
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
972
+ if (overrides?.blockTag) {
973
+ blockTag =
974
+ typeof overrides.blockTag == "string"
975
+ ? overrides.blockTag
976
+ : "0x" + overrides.blockTag.toString(16);
977
+ }
978
+
979
+ return this.view.encodeCall.safeTransferFrom(from, to, id, amount, data, {
980
+ chainId,
981
+ address,
982
+ blockTag,
366
983
  });
367
984
  },
985
+ setApprovalForAll(
986
+ operator: string,
987
+ approved: boolean,
988
+ overrides?: Overrides
989
+ ): EthCallParam {
990
+ const chainId =
991
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
992
+ const address = this.context.address;
993
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
994
+ if (overrides?.blockTag) {
995
+ blockTag =
996
+ typeof overrides.blockTag == "string"
997
+ ? overrides.blockTag
998
+ : "0x" + overrides.blockTag.toString(16);
999
+ }
1000
+
1001
+ return this.view.encodeCall.setApprovalForAll(operator, approved, {
1002
+ chainId,
1003
+ address,
1004
+ blockTag,
1005
+ });
1006
+ },
1007
+ supportsInterface(
1008
+ interfaceId: BytesLike,
1009
+ overrides?: Overrides
1010
+ ): EthCallParam {
1011
+ const chainId =
1012
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1013
+ const address = this.context.address;
1014
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1015
+ if (overrides?.blockTag) {
1016
+ blockTag =
1017
+ typeof overrides.blockTag == "string"
1018
+ ? overrides.blockTag
1019
+ : "0x" + overrides.blockTag.toString(16);
1020
+ }
1021
+
1022
+ return this.view.encodeCall.supportsInterface(interfaceId, {
1023
+ chainId,
1024
+ address,
1025
+ blockTag,
1026
+ });
1027
+ },
1028
+ uri(id: BigNumberish, overrides?: Overrides): EthCallParam {
1029
+ const chainId =
1030
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1031
+ const address = this.context.address;
1032
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1033
+ if (overrides?.blockTag) {
1034
+ blockTag =
1035
+ typeof overrides.blockTag == "string"
1036
+ ? overrides.blockTag
1037
+ : "0x" + overrides.blockTag.toString(16);
1038
+ }
1039
+
1040
+ return this.view.encodeCall.uri(id, { chainId, address, blockTag });
1041
+ },
368
1042
  };
369
1043
  }
370
1044
 
@@ -380,7 +1054,8 @@ export class ERC1155Processor extends BaseProcessor<
380
1054
  fetchConfig?: Partial<EthFetchConfig>,
381
1055
  preprocessHandler?: (
382
1056
  event: ApprovalForAllEvent,
383
- ctx: ERC1155Context
1057
+ ctx: ERC1155Context,
1058
+ preprocessStore: { [k: string]: any }
384
1059
  ) => Promise<PreprocessResult>
385
1060
  ): this {
386
1061
  if (!filter) {
@@ -399,7 +1074,8 @@ export class ERC1155Processor extends BaseProcessor<
399
1074
  fetchConfig?: Partial<EthFetchConfig>,
400
1075
  preprocessHandler?: (
401
1076
  event: TransferBatchEvent,
402
- ctx: ERC1155Context
1077
+ ctx: ERC1155Context,
1078
+ preprocessStore: { [k: string]: any }
403
1079
  ) => Promise<PreprocessResult>
404
1080
  ): this {
405
1081
  if (!filter) {
@@ -416,7 +1092,8 @@ export class ERC1155Processor extends BaseProcessor<
416
1092
  fetchConfig?: Partial<EthFetchConfig>,
417
1093
  preprocessHandler?: (
418
1094
  event: TransferSingleEvent,
419
- ctx: ERC1155Context
1095
+ ctx: ERC1155Context,
1096
+ preprocessStore: { [k: string]: any }
420
1097
  ) => Promise<PreprocessResult>
421
1098
  ): this {
422
1099
  if (!filter) {
@@ -433,7 +1110,8 @@ export class ERC1155Processor extends BaseProcessor<
433
1110
  fetchConfig?: Partial<EthFetchConfig>,
434
1111
  preprocessHandler?: (
435
1112
  event: URIEvent,
436
- ctx: ERC1155Context
1113
+ ctx: ERC1155Context,
1114
+ preprocessStore: { [k: string]: any }
437
1115
  ) => Promise<PreprocessResult>
438
1116
  ): this {
439
1117
  if (!filter) {
@@ -652,7 +1330,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
652
1330
  fetchConfig?: Partial<EthFetchConfig>,
653
1331
  preprocessHandler?: (
654
1332
  event: ApprovalForAllEvent,
655
- ctx: ERC1155Context
1333
+ ctx: ERC1155Context,
1334
+ preprocessStore: { [k: string]: any }
656
1335
  ) => Promise<PreprocessResult>
657
1336
  ): this {
658
1337
  if (!filter) {
@@ -671,7 +1350,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
671
1350
  fetchConfig?: Partial<EthFetchConfig>,
672
1351
  preprocessHandler?: (
673
1352
  event: TransferBatchEvent,
674
- ctx: ERC1155Context
1353
+ ctx: ERC1155Context,
1354
+ preprocessStore: { [k: string]: any }
675
1355
  ) => Promise<PreprocessResult>
676
1356
  ): this {
677
1357
  if (!filter) {
@@ -688,7 +1368,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
688
1368
  fetchConfig?: Partial<EthFetchConfig>,
689
1369
  preprocessHandler?: (
690
1370
  event: TransferSingleEvent,
691
- ctx: ERC1155Context
1371
+ ctx: ERC1155Context,
1372
+ preprocessStore: { [k: string]: any }
692
1373
  ) => Promise<PreprocessResult>
693
1374
  ): this {
694
1375
  if (!filter) {
@@ -705,7 +1386,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
705
1386
  fetchConfig?: Partial<EthFetchConfig>,
706
1387
  preprocessHandler?: (
707
1388
  event: URIEvent,
708
- ctx: ERC1155Context
1389
+ ctx: ERC1155Context,
1390
+ preprocessStore: { [k: string]: any }
709
1391
  ) => Promise<PreprocessResult>
710
1392
  ): this {
711
1393
  if (!filter) {