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

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 +33 -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 +39 -21
  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 { ERC721__factory } from "./index.js";
27
29
  import {
@@ -155,8 +157,32 @@ export class ERC721ContractView extends ContractView<ERC721> {
155
157
  this.callStatic.contract = contract;
156
158
  }
157
159
 
158
- async totalSupply(overrides?: Overrides): Promise<bigint> {
160
+ async totalSupply(
161
+ overrides?: Overrides,
162
+ preparedData?: PreparedData,
163
+ ethCallContext?: EthCallContext
164
+ ): Promise<bigint> {
159
165
  try {
166
+ if (preparedData?.ethCallResults && ethCallContext) {
167
+ const iface = new Interface([
168
+ "function totalSupply() view returns (uint256)",
169
+ ]);
170
+ const calldata = iface.encodeFunctionData("totalSupply", []);
171
+ const key = makeEthCallKey({
172
+ context: ethCallContext,
173
+ calldata,
174
+ });
175
+ console.debug("looking up eth call key:", key);
176
+ const ret = preparedData.ethCallResults[key];
177
+ if (ret) {
178
+ console.debug("prepared eth call found:", key);
179
+ const result = iface
180
+ .decodeFunctionResult("totalSupply", ret)
181
+ .toArray();
182
+ return result.length == 1 ? result[0] : result;
183
+ }
184
+ console.debug("missing eth call key:", "totalSupply", key);
185
+ }
160
186
  return await this.contract.getFunction("totalSupply()")(overrides || {});
161
187
  } catch (e) {
162
188
  const stack = new Error().stack;
@@ -164,8 +190,31 @@ export class ERC721ContractView extends ContractView<ERC721> {
164
190
  }
165
191
  }
166
192
 
167
- async balanceOf(owner: string, overrides?: Overrides): Promise<bigint> {
193
+ async balanceOf(
194
+ owner: string,
195
+ overrides?: Overrides,
196
+ preparedData?: PreparedData,
197
+ ethCallContext?: EthCallContext
198
+ ): Promise<bigint> {
168
199
  try {
200
+ if (preparedData?.ethCallResults && ethCallContext) {
201
+ const iface = new Interface([
202
+ "function balanceOf(address) view returns (uint256)",
203
+ ]);
204
+ const calldata = iface.encodeFunctionData("balanceOf", [owner]);
205
+ const key = makeEthCallKey({
206
+ context: ethCallContext,
207
+ calldata,
208
+ });
209
+ console.debug("looking up eth call key:", key);
210
+ const ret = preparedData.ethCallResults[key];
211
+ if (ret) {
212
+ console.debug("prepared eth call found:", key);
213
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
214
+ return result.length == 1 ? result[0] : result;
215
+ }
216
+ console.debug("missing eth call key:", "balanceOf", owner, key);
217
+ }
169
218
  return await this.contract.getFunction("balanceOf(address)")(
170
219
  owner,
171
220
  overrides || {}
@@ -178,9 +227,31 @@ export class ERC721ContractView extends ContractView<ERC721> {
178
227
 
179
228
  async getApproved(
180
229
  tokenId: BigNumberish,
181
- overrides?: Overrides
230
+ overrides?: Overrides,
231
+ preparedData?: PreparedData,
232
+ ethCallContext?: EthCallContext
182
233
  ): Promise<string> {
183
234
  try {
235
+ if (preparedData?.ethCallResults && ethCallContext) {
236
+ const iface = new Interface([
237
+ "function getApproved(uint256) view returns (address)",
238
+ ]);
239
+ const calldata = iface.encodeFunctionData("getApproved", [tokenId]);
240
+ const key = makeEthCallKey({
241
+ context: ethCallContext,
242
+ calldata,
243
+ });
244
+ console.debug("looking up eth call key:", key);
245
+ const ret = preparedData.ethCallResults[key];
246
+ if (ret) {
247
+ console.debug("prepared eth call found:", key);
248
+ const result = iface
249
+ .decodeFunctionResult("getApproved", ret)
250
+ .toArray();
251
+ return result.length == 1 ? result[0] : result;
252
+ }
253
+ console.debug("missing eth call key:", "getApproved", tokenId, key);
254
+ }
184
255
  return await this.contract.getFunction("getApproved(uint256)")(
185
256
  tokenId,
186
257
  overrides || {}
@@ -194,9 +265,40 @@ export class ERC721ContractView extends ContractView<ERC721> {
194
265
  async isApprovedForAll(
195
266
  owner: string,
196
267
  operator: string,
197
- overrides?: Overrides
268
+ overrides?: Overrides,
269
+ preparedData?: PreparedData,
270
+ ethCallContext?: EthCallContext
198
271
  ): Promise<boolean> {
199
272
  try {
273
+ if (preparedData?.ethCallResults && ethCallContext) {
274
+ const iface = new Interface([
275
+ "function isApprovedForAll(address,address) view returns (bool)",
276
+ ]);
277
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
278
+ owner,
279
+ operator,
280
+ ]);
281
+ const key = makeEthCallKey({
282
+ context: ethCallContext,
283
+ calldata,
284
+ });
285
+ console.debug("looking up eth call key:", key);
286
+ const ret = preparedData.ethCallResults[key];
287
+ if (ret) {
288
+ console.debug("prepared eth call found:", key);
289
+ const result = iface
290
+ .decodeFunctionResult("isApprovedForAll", ret)
291
+ .toArray();
292
+ return result.length == 1 ? result[0] : result;
293
+ }
294
+ console.debug(
295
+ "missing eth call key:",
296
+ "isApprovedForAll",
297
+ owner,
298
+ operator,
299
+ key
300
+ );
301
+ }
200
302
  return await this.contract.getFunction(
201
303
  "isApprovedForAll(address,address)"
202
304
  )(owner, operator, overrides || {});
@@ -206,8 +308,28 @@ export class ERC721ContractView extends ContractView<ERC721> {
206
308
  }
207
309
  }
208
310
 
209
- async name(overrides?: Overrides): Promise<string> {
311
+ async name(
312
+ overrides?: Overrides,
313
+ preparedData?: PreparedData,
314
+ ethCallContext?: EthCallContext
315
+ ): Promise<string> {
210
316
  try {
317
+ if (preparedData?.ethCallResults && ethCallContext) {
318
+ const iface = new Interface(["function name() view returns (string)"]);
319
+ const calldata = iface.encodeFunctionData("name", []);
320
+ const key = makeEthCallKey({
321
+ context: ethCallContext,
322
+ calldata,
323
+ });
324
+ console.debug("looking up eth call key:", key);
325
+ const ret = preparedData.ethCallResults[key];
326
+ if (ret) {
327
+ console.debug("prepared eth call found:", key);
328
+ const result = iface.decodeFunctionResult("name", ret).toArray();
329
+ return result.length == 1 ? result[0] : result;
330
+ }
331
+ console.debug("missing eth call key:", "name", key);
332
+ }
211
333
  return await this.contract.getFunction("name()")(overrides || {});
212
334
  } catch (e) {
213
335
  const stack = new Error().stack;
@@ -215,8 +337,31 @@ export class ERC721ContractView extends ContractView<ERC721> {
215
337
  }
216
338
  }
217
339
 
218
- async ownerOf(tokenId: BigNumberish, overrides?: Overrides): Promise<string> {
340
+ async ownerOf(
341
+ tokenId: BigNumberish,
342
+ overrides?: Overrides,
343
+ preparedData?: PreparedData,
344
+ ethCallContext?: EthCallContext
345
+ ): Promise<string> {
219
346
  try {
347
+ if (preparedData?.ethCallResults && ethCallContext) {
348
+ const iface = new Interface([
349
+ "function ownerOf(uint256) view returns (address)",
350
+ ]);
351
+ const calldata = iface.encodeFunctionData("ownerOf", [tokenId]);
352
+ const key = makeEthCallKey({
353
+ context: ethCallContext,
354
+ calldata,
355
+ });
356
+ console.debug("looking up eth call key:", key);
357
+ const ret = preparedData.ethCallResults[key];
358
+ if (ret) {
359
+ console.debug("prepared eth call found:", key);
360
+ const result = iface.decodeFunctionResult("ownerOf", ret).toArray();
361
+ return result.length == 1 ? result[0] : result;
362
+ }
363
+ console.debug("missing eth call key:", "ownerOf", tokenId, key);
364
+ }
220
365
  return await this.contract.getFunction("ownerOf(uint256)")(
221
366
  tokenId,
222
367
  overrides || {}
@@ -229,9 +374,38 @@ export class ERC721ContractView extends ContractView<ERC721> {
229
374
 
230
375
  async supportsInterface(
231
376
  interfaceId: BytesLike,
232
- overrides?: Overrides
377
+ overrides?: Overrides,
378
+ preparedData?: PreparedData,
379
+ ethCallContext?: EthCallContext
233
380
  ): Promise<boolean> {
234
381
  try {
382
+ if (preparedData?.ethCallResults && ethCallContext) {
383
+ const iface = new Interface([
384
+ "function supportsInterface(bytes4) view returns (bool)",
385
+ ]);
386
+ const calldata = iface.encodeFunctionData("supportsInterface", [
387
+ interfaceId,
388
+ ]);
389
+ const key = makeEthCallKey({
390
+ context: ethCallContext,
391
+ calldata,
392
+ });
393
+ console.debug("looking up eth call key:", key);
394
+ const ret = preparedData.ethCallResults[key];
395
+ if (ret) {
396
+ console.debug("prepared eth call found:", key);
397
+ const result = iface
398
+ .decodeFunctionResult("supportsInterface", ret)
399
+ .toArray();
400
+ return result.length == 1 ? result[0] : result;
401
+ }
402
+ console.debug(
403
+ "missing eth call key:",
404
+ "supportsInterface",
405
+ interfaceId,
406
+ key
407
+ );
408
+ }
235
409
  return await this.contract.getFunction("supportsInterface(bytes4)")(
236
410
  interfaceId,
237
411
  overrides || {}
@@ -242,8 +416,30 @@ export class ERC721ContractView extends ContractView<ERC721> {
242
416
  }
243
417
  }
244
418
 
245
- async symbol(overrides?: Overrides): Promise<string> {
419
+ async symbol(
420
+ overrides?: Overrides,
421
+ preparedData?: PreparedData,
422
+ ethCallContext?: EthCallContext
423
+ ): Promise<string> {
246
424
  try {
425
+ if (preparedData?.ethCallResults && ethCallContext) {
426
+ const iface = new Interface([
427
+ "function symbol() view returns (string)",
428
+ ]);
429
+ const calldata = iface.encodeFunctionData("symbol", []);
430
+ const key = makeEthCallKey({
431
+ context: ethCallContext,
432
+ calldata,
433
+ });
434
+ console.debug("looking up eth call key:", key);
435
+ const ret = preparedData.ethCallResults[key];
436
+ if (ret) {
437
+ console.debug("prepared eth call found:", key);
438
+ const result = iface.decodeFunctionResult("symbol", ret).toArray();
439
+ return result.length == 1 ? result[0] : result;
440
+ }
441
+ console.debug("missing eth call key:", "symbol", key);
442
+ }
247
443
  return await this.contract.getFunction("symbol()")(overrides || {});
248
444
  } catch (e) {
249
445
  const stack = new Error().stack;
@@ -253,9 +449,29 @@ export class ERC721ContractView extends ContractView<ERC721> {
253
449
 
254
450
  async tokenURI(
255
451
  tokenId: BigNumberish,
256
- overrides?: Overrides
452
+ overrides?: Overrides,
453
+ preparedData?: PreparedData,
454
+ ethCallContext?: EthCallContext
257
455
  ): Promise<string> {
258
456
  try {
457
+ if (preparedData?.ethCallResults && ethCallContext) {
458
+ const iface = new Interface([
459
+ "function tokenURI(uint256) view returns (string)",
460
+ ]);
461
+ const calldata = iface.encodeFunctionData("tokenURI", [tokenId]);
462
+ const key = makeEthCallKey({
463
+ context: ethCallContext,
464
+ calldata,
465
+ });
466
+ console.debug("looking up eth call key:", key);
467
+ const ret = preparedData.ethCallResults[key];
468
+ if (ret) {
469
+ console.debug("prepared eth call found:", key);
470
+ const result = iface.decodeFunctionResult("tokenURI", ret).toArray();
471
+ return result.length == 1 ? result[0] : result;
472
+ }
473
+ console.debug("missing eth call key:", "tokenURI", tokenId, key);
474
+ }
259
475
  return await this.contract.getFunction("tokenURI(uint256)")(
260
476
  tokenId,
261
477
  overrides || {}
@@ -272,9 +488,29 @@ export class ERC721ContractView extends ContractView<ERC721> {
272
488
  async approve(
273
489
  to: string,
274
490
  tokenId: BigNumberish,
275
- overrides?: Overrides
491
+ overrides?: Overrides,
492
+ preparedData?: PreparedData,
493
+ ethCallContext?: EthCallContext
276
494
  ): Promise<void> {
277
495
  try {
496
+ if (preparedData?.ethCallResults && ethCallContext) {
497
+ const iface = new Interface([
498
+ "function approve(address,uint256) nonpayable returns ()",
499
+ ]);
500
+ const calldata = iface.encodeFunctionData("approve", [to, tokenId]);
501
+ const key = makeEthCallKey({
502
+ context: ethCallContext,
503
+ calldata,
504
+ });
505
+ console.debug("looking up eth call key:", key);
506
+ const ret = preparedData.ethCallResults[key];
507
+ if (ret) {
508
+ console.debug("prepared eth call found:", key);
509
+ const result = iface.decodeFunctionResult("approve", ret).toArray();
510
+ return result.length == 1 ? result[0] : result;
511
+ }
512
+ console.debug("missing eth call key:", "approve", to, tokenId, key);
513
+ }
278
514
  return await this.contract
279
515
  .getFunction("approve(address,uint256)")
280
516
  .staticCall(to, tokenId, overrides || {});
@@ -287,9 +523,42 @@ export class ERC721ContractView extends ContractView<ERC721> {
287
523
  from: string,
288
524
  to: string,
289
525
  tokenId: BigNumberish,
290
- overrides?: Overrides
526
+ overrides?: Overrides,
527
+ preparedData?: PreparedData,
528
+ ethCallContext?: EthCallContext
291
529
  ): Promise<void> {
292
530
  try {
531
+ if (preparedData?.ethCallResults && ethCallContext) {
532
+ const iface = new Interface([
533
+ "function safeTransferFrom(address,address,uint256) nonpayable returns ()",
534
+ ]);
535
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
536
+ from,
537
+ to,
538
+ tokenId,
539
+ ]);
540
+ const key = makeEthCallKey({
541
+ context: ethCallContext,
542
+ calldata,
543
+ });
544
+ console.debug("looking up eth call key:", key);
545
+ const ret = preparedData.ethCallResults[key];
546
+ if (ret) {
547
+ console.debug("prepared eth call found:", key);
548
+ const result = iface
549
+ .decodeFunctionResult("safeTransferFrom", ret)
550
+ .toArray();
551
+ return result.length == 1 ? result[0] : result;
552
+ }
553
+ console.debug(
554
+ "missing eth call key:",
555
+ "safeTransferFrom",
556
+ from,
557
+ to,
558
+ tokenId,
559
+ key
560
+ );
561
+ }
293
562
  return await this.contract
294
563
  .getFunction("safeTransferFrom(address,address,uint256)")
295
564
  .staticCall(from, to, tokenId, overrides || {});
@@ -303,9 +572,44 @@ export class ERC721ContractView extends ContractView<ERC721> {
303
572
  to: string,
304
573
  tokenId: BigNumberish,
305
574
  data: BytesLike,
306
- overrides?: Overrides
575
+ overrides?: Overrides,
576
+ preparedData?: PreparedData,
577
+ ethCallContext?: EthCallContext
307
578
  ): Promise<void> {
308
579
  try {
580
+ if (preparedData?.ethCallResults && ethCallContext) {
581
+ const iface = new Interface([
582
+ "function safeTransferFrom(address,address,uint256,bytes) nonpayable returns ()",
583
+ ]);
584
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
585
+ from,
586
+ to,
587
+ tokenId,
588
+ data,
589
+ ]);
590
+ const key = makeEthCallKey({
591
+ context: ethCallContext,
592
+ calldata,
593
+ });
594
+ console.debug("looking up eth call key:", key);
595
+ const ret = preparedData.ethCallResults[key];
596
+ if (ret) {
597
+ console.debug("prepared eth call found:", key);
598
+ const result = iface
599
+ .decodeFunctionResult("safeTransferFrom", ret)
600
+ .toArray();
601
+ return result.length == 1 ? result[0] : result;
602
+ }
603
+ console.debug(
604
+ "missing eth call key:",
605
+ "safeTransferFrom",
606
+ from,
607
+ to,
608
+ tokenId,
609
+ data,
610
+ key
611
+ );
612
+ }
309
613
  return await this.contract
310
614
  .getFunction("safeTransferFrom(address,address,uint256,bytes)")
311
615
  .staticCall(from, to, tokenId, data, overrides || {});
@@ -317,9 +621,40 @@ export class ERC721ContractView extends ContractView<ERC721> {
317
621
  async setApprovalForAll(
318
622
  operator: string,
319
623
  _approved: boolean,
320
- overrides?: Overrides
624
+ overrides?: Overrides,
625
+ preparedData?: PreparedData,
626
+ ethCallContext?: EthCallContext
321
627
  ): Promise<void> {
322
628
  try {
629
+ if (preparedData?.ethCallResults && ethCallContext) {
630
+ const iface = new Interface([
631
+ "function setApprovalForAll(address,bool) nonpayable returns ()",
632
+ ]);
633
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
634
+ operator,
635
+ _approved,
636
+ ]);
637
+ const key = makeEthCallKey({
638
+ context: ethCallContext,
639
+ calldata,
640
+ });
641
+ console.debug("looking up eth call key:", key);
642
+ const ret = preparedData.ethCallResults[key];
643
+ if (ret) {
644
+ console.debug("prepared eth call found:", key);
645
+ const result = iface
646
+ .decodeFunctionResult("setApprovalForAll", ret)
647
+ .toArray();
648
+ return result.length == 1 ? result[0] : result;
649
+ }
650
+ console.debug(
651
+ "missing eth call key:",
652
+ "setApprovalForAll",
653
+ operator,
654
+ _approved,
655
+ key
656
+ );
657
+ }
323
658
  return await this.contract
324
659
  .getFunction("setApprovalForAll(address,bool)")
325
660
  .staticCall(operator, _approved, overrides || {});
@@ -332,9 +667,42 @@ export class ERC721ContractView extends ContractView<ERC721> {
332
667
  from: string,
333
668
  to: string,
334
669
  tokenId: BigNumberish,
335
- overrides?: Overrides
670
+ overrides?: Overrides,
671
+ preparedData?: PreparedData,
672
+ ethCallContext?: EthCallContext
336
673
  ): Promise<void> {
337
674
  try {
675
+ if (preparedData?.ethCallResults && ethCallContext) {
676
+ const iface = new Interface([
677
+ "function transferFrom(address,address,uint256) nonpayable returns ()",
678
+ ]);
679
+ const calldata = iface.encodeFunctionData("transferFrom", [
680
+ from,
681
+ to,
682
+ tokenId,
683
+ ]);
684
+ const key = makeEthCallKey({
685
+ context: ethCallContext,
686
+ calldata,
687
+ });
688
+ console.debug("looking up eth call key:", key);
689
+ const ret = preparedData.ethCallResults[key];
690
+ if (ret) {
691
+ console.debug("prepared eth call found:", key);
692
+ const result = iface
693
+ .decodeFunctionResult("transferFrom", ret)
694
+ .toArray();
695
+ return result.length == 1 ? result[0] : result;
696
+ }
697
+ console.debug(
698
+ "missing eth call key:",
699
+ "transferFrom",
700
+ from,
701
+ to,
702
+ tokenId,
703
+ key
704
+ );
705
+ }
338
706
  return await this.contract
339
707
  .getFunction("transferFrom(address,address,uint256)")
340
708
  .staticCall(from, to, tokenId, overrides || {});
@@ -344,6 +712,262 @@ export class ERC721ContractView extends ContractView<ERC721> {
344
712
  }
345
713
  },
346
714
  };
715
+
716
+ encodeCall = {
717
+ approve(
718
+ to: string,
719
+ tokenId: BigNumberish,
720
+ ethCallContext: EthCallContext
721
+ ): EthCallParam {
722
+ try {
723
+ const iface = new Interface(["function approve(address,uint256)"]);
724
+ const calldata = iface.encodeFunctionData("approve", [to, tokenId]);
725
+ return {
726
+ context: ethCallContext,
727
+ calldata,
728
+ };
729
+ } catch (e) {
730
+ const stack = new Error().stack;
731
+ throw transformEtherError(e, undefined, stack);
732
+ }
733
+ },
734
+ totalSupply(ethCallContext: EthCallContext): EthCallParam {
735
+ try {
736
+ const iface = new Interface(["function totalSupply()"]);
737
+ const calldata = iface.encodeFunctionData("totalSupply", []);
738
+ return {
739
+ context: ethCallContext,
740
+ calldata,
741
+ };
742
+ } catch (e) {
743
+ const stack = new Error().stack;
744
+ throw transformEtherError(e, undefined, stack);
745
+ }
746
+ },
747
+ balanceOf(owner: string, ethCallContext: EthCallContext): EthCallParam {
748
+ try {
749
+ const iface = new Interface(["function balanceOf(address)"]);
750
+ const calldata = iface.encodeFunctionData("balanceOf", [owner]);
751
+ return {
752
+ context: ethCallContext,
753
+ calldata,
754
+ };
755
+ } catch (e) {
756
+ const stack = new Error().stack;
757
+ throw transformEtherError(e, undefined, stack);
758
+ }
759
+ },
760
+ getApproved(
761
+ tokenId: BigNumberish,
762
+ ethCallContext: EthCallContext
763
+ ): EthCallParam {
764
+ try {
765
+ const iface = new Interface(["function getApproved(uint256)"]);
766
+ const calldata = iface.encodeFunctionData("getApproved", [tokenId]);
767
+ return {
768
+ context: ethCallContext,
769
+ calldata,
770
+ };
771
+ } catch (e) {
772
+ const stack = new Error().stack;
773
+ throw transformEtherError(e, undefined, stack);
774
+ }
775
+ },
776
+ isApprovedForAll(
777
+ owner: string,
778
+ operator: string,
779
+ ethCallContext: EthCallContext
780
+ ): EthCallParam {
781
+ try {
782
+ const iface = new Interface([
783
+ "function isApprovedForAll(address,address)",
784
+ ]);
785
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
786
+ owner,
787
+ operator,
788
+ ]);
789
+ return {
790
+ context: ethCallContext,
791
+ calldata,
792
+ };
793
+ } catch (e) {
794
+ const stack = new Error().stack;
795
+ throw transformEtherError(e, undefined, stack);
796
+ }
797
+ },
798
+ name(ethCallContext: EthCallContext): EthCallParam {
799
+ try {
800
+ const iface = new Interface(["function name()"]);
801
+ const calldata = iface.encodeFunctionData("name", []);
802
+ return {
803
+ context: ethCallContext,
804
+ calldata,
805
+ };
806
+ } catch (e) {
807
+ const stack = new Error().stack;
808
+ throw transformEtherError(e, undefined, stack);
809
+ }
810
+ },
811
+ ownerOf(
812
+ tokenId: BigNumberish,
813
+ ethCallContext: EthCallContext
814
+ ): EthCallParam {
815
+ try {
816
+ const iface = new Interface(["function ownerOf(uint256)"]);
817
+ const calldata = iface.encodeFunctionData("ownerOf", [tokenId]);
818
+ return {
819
+ context: ethCallContext,
820
+ calldata,
821
+ };
822
+ } catch (e) {
823
+ const stack = new Error().stack;
824
+ throw transformEtherError(e, undefined, stack);
825
+ }
826
+ },
827
+ safeTransferFrom_address_address_uint256(
828
+ from: string,
829
+ to: string,
830
+ tokenId: BigNumberish,
831
+ ethCallContext: EthCallContext
832
+ ): EthCallParam {
833
+ try {
834
+ const iface = new Interface([
835
+ "function safeTransferFrom(address,address,uint256)",
836
+ ]);
837
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
838
+ from,
839
+ to,
840
+ tokenId,
841
+ ]);
842
+ return {
843
+ context: ethCallContext,
844
+ calldata,
845
+ };
846
+ } catch (e) {
847
+ const stack = new Error().stack;
848
+ throw transformEtherError(e, undefined, stack);
849
+ }
850
+ },
851
+ safeTransferFrom_address_address_uint256_bytes(
852
+ from: string,
853
+ to: string,
854
+ tokenId: BigNumberish,
855
+ data: BytesLike,
856
+ ethCallContext: EthCallContext
857
+ ): EthCallParam {
858
+ try {
859
+ const iface = new Interface([
860
+ "function safeTransferFrom(address,address,uint256,bytes)",
861
+ ]);
862
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
863
+ from,
864
+ to,
865
+ tokenId,
866
+ data,
867
+ ]);
868
+ return {
869
+ context: ethCallContext,
870
+ calldata,
871
+ };
872
+ } catch (e) {
873
+ const stack = new Error().stack;
874
+ throw transformEtherError(e, undefined, stack);
875
+ }
876
+ },
877
+ setApprovalForAll(
878
+ operator: string,
879
+ _approved: boolean,
880
+ ethCallContext: EthCallContext
881
+ ): EthCallParam {
882
+ try {
883
+ const iface = new Interface([
884
+ "function setApprovalForAll(address,bool)",
885
+ ]);
886
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
887
+ operator,
888
+ _approved,
889
+ ]);
890
+ return {
891
+ context: ethCallContext,
892
+ calldata,
893
+ };
894
+ } catch (e) {
895
+ const stack = new Error().stack;
896
+ throw transformEtherError(e, undefined, stack);
897
+ }
898
+ },
899
+ supportsInterface(
900
+ interfaceId: BytesLike,
901
+ ethCallContext: EthCallContext
902
+ ): EthCallParam {
903
+ try {
904
+ const iface = new Interface(["function supportsInterface(bytes4)"]);
905
+ const calldata = iface.encodeFunctionData("supportsInterface", [
906
+ interfaceId,
907
+ ]);
908
+ return {
909
+ context: ethCallContext,
910
+ calldata,
911
+ };
912
+ } catch (e) {
913
+ const stack = new Error().stack;
914
+ throw transformEtherError(e, undefined, stack);
915
+ }
916
+ },
917
+ symbol(ethCallContext: EthCallContext): EthCallParam {
918
+ try {
919
+ const iface = new Interface(["function symbol()"]);
920
+ const calldata = iface.encodeFunctionData("symbol", []);
921
+ return {
922
+ context: ethCallContext,
923
+ calldata,
924
+ };
925
+ } catch (e) {
926
+ const stack = new Error().stack;
927
+ throw transformEtherError(e, undefined, stack);
928
+ }
929
+ },
930
+ tokenURI(
931
+ tokenId: BigNumberish,
932
+ ethCallContext: EthCallContext
933
+ ): EthCallParam {
934
+ try {
935
+ const iface = new Interface(["function tokenURI(uint256)"]);
936
+ const calldata = iface.encodeFunctionData("tokenURI", [tokenId]);
937
+ return {
938
+ context: ethCallContext,
939
+ calldata,
940
+ };
941
+ } catch (e) {
942
+ const stack = new Error().stack;
943
+ throw transformEtherError(e, undefined, stack);
944
+ }
945
+ },
946
+ transferFrom(
947
+ from: string,
948
+ to: string,
949
+ tokenId: BigNumberish,
950
+ ethCallContext: EthCallContext
951
+ ): EthCallParam {
952
+ try {
953
+ const iface = new Interface([
954
+ "function transferFrom(address,address,uint256)",
955
+ ]);
956
+ const calldata = iface.encodeFunctionData("transferFrom", [
957
+ from,
958
+ to,
959
+ tokenId,
960
+ ]);
961
+ return {
962
+ context: ethCallContext,
963
+ calldata,
964
+ };
965
+ } catch (e) {
966
+ const stack = new Error().stack;
967
+ throw transformEtherError(e, undefined, stack);
968
+ }
969
+ },
970
+ };
347
971
  }
348
972
 
349
973
  export class ERC721BoundContractView extends BoundContractView<
@@ -351,27 +975,56 @@ export class ERC721BoundContractView extends BoundContractView<
351
975
  ERC721ContractView
352
976
  > {
353
977
  async totalSupply(overrides?: Overrides): Promise<bigint> {
354
- return await this.view.totalSupply({
355
- blockTag: this.context.blockNumber,
356
- ...overrides,
357
- });
978
+ const ethCallContext = {
979
+ chainId: this.context.chainId,
980
+ blockTag: "0x" + this.context.blockNumber.toString(16),
981
+ address: this.context.address,
982
+ };
983
+ return await this.view.totalSupply(
984
+ {
985
+ blockTag: this.context.blockNumber,
986
+ ...overrides,
987
+ },
988
+ this.context.preparedData,
989
+ ethCallContext
990
+ );
358
991
  }
359
992
 
360
993
  async balanceOf(owner: string, overrides?: Overrides): Promise<bigint> {
361
- return await this.view.balanceOf(owner, {
362
- blockTag: this.context.blockNumber,
363
- ...overrides,
364
- });
994
+ const ethCallContext = {
995
+ chainId: this.context.chainId,
996
+ blockTag: "0x" + this.context.blockNumber.toString(16),
997
+ address: this.context.address,
998
+ };
999
+ return await this.view.balanceOf(
1000
+ owner,
1001
+ {
1002
+ blockTag: this.context.blockNumber,
1003
+ ...overrides,
1004
+ },
1005
+ this.context.preparedData,
1006
+ ethCallContext
1007
+ );
365
1008
  }
366
1009
 
367
1010
  async getApproved(
368
1011
  tokenId: BigNumberish,
369
1012
  overrides?: Overrides
370
1013
  ): Promise<string> {
371
- return await this.view.getApproved(tokenId, {
372
- blockTag: this.context.blockNumber,
373
- ...overrides,
374
- });
1014
+ const ethCallContext = {
1015
+ chainId: this.context.chainId,
1016
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1017
+ address: this.context.address,
1018
+ };
1019
+ return await this.view.getApproved(
1020
+ tokenId,
1021
+ {
1022
+ blockTag: this.context.blockNumber,
1023
+ ...overrides,
1024
+ },
1025
+ this.context.preparedData,
1026
+ ethCallContext
1027
+ );
375
1028
  }
376
1029
 
377
1030
  async isApprovedForAll(
@@ -379,51 +1032,110 @@ export class ERC721BoundContractView extends BoundContractView<
379
1032
  operator: string,
380
1033
  overrides?: Overrides
381
1034
  ): Promise<boolean> {
382
- return await this.view.isApprovedForAll(owner, operator, {
383
- blockTag: this.context.blockNumber,
384
- ...overrides,
385
- });
1035
+ const ethCallContext = {
1036
+ chainId: this.context.chainId,
1037
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1038
+ address: this.context.address,
1039
+ };
1040
+ return await this.view.isApprovedForAll(
1041
+ owner,
1042
+ operator,
1043
+ {
1044
+ blockTag: this.context.blockNumber,
1045
+ ...overrides,
1046
+ },
1047
+ this.context.preparedData,
1048
+ ethCallContext
1049
+ );
386
1050
  }
387
1051
 
388
1052
  async name(overrides?: Overrides): Promise<string> {
389
- return await this.view.name({
390
- blockTag: this.context.blockNumber,
391
- ...overrides,
392
- });
1053
+ const ethCallContext = {
1054
+ chainId: this.context.chainId,
1055
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1056
+ address: this.context.address,
1057
+ };
1058
+ return await this.view.name(
1059
+ {
1060
+ blockTag: this.context.blockNumber,
1061
+ ...overrides,
1062
+ },
1063
+ this.context.preparedData,
1064
+ ethCallContext
1065
+ );
393
1066
  }
394
1067
 
395
1068
  async ownerOf(tokenId: BigNumberish, overrides?: Overrides): Promise<string> {
396
- return await this.view.ownerOf(tokenId, {
397
- blockTag: this.context.blockNumber,
398
- ...overrides,
399
- });
1069
+ const ethCallContext = {
1070
+ chainId: this.context.chainId,
1071
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1072
+ address: this.context.address,
1073
+ };
1074
+ return await this.view.ownerOf(
1075
+ tokenId,
1076
+ {
1077
+ blockTag: this.context.blockNumber,
1078
+ ...overrides,
1079
+ },
1080
+ this.context.preparedData,
1081
+ ethCallContext
1082
+ );
400
1083
  }
401
1084
 
402
1085
  async supportsInterface(
403
1086
  interfaceId: BytesLike,
404
1087
  overrides?: Overrides
405
1088
  ): Promise<boolean> {
406
- return await this.view.supportsInterface(interfaceId, {
407
- blockTag: this.context.blockNumber,
408
- ...overrides,
409
- });
1089
+ const ethCallContext = {
1090
+ chainId: this.context.chainId,
1091
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1092
+ address: this.context.address,
1093
+ };
1094
+ return await this.view.supportsInterface(
1095
+ interfaceId,
1096
+ {
1097
+ blockTag: this.context.blockNumber,
1098
+ ...overrides,
1099
+ },
1100
+ this.context.preparedData,
1101
+ ethCallContext
1102
+ );
410
1103
  }
411
1104
 
412
1105
  async symbol(overrides?: Overrides): Promise<string> {
413
- return await this.view.symbol({
414
- blockTag: this.context.blockNumber,
415
- ...overrides,
416
- });
1106
+ const ethCallContext = {
1107
+ chainId: this.context.chainId,
1108
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1109
+ address: this.context.address,
1110
+ };
1111
+ return await this.view.symbol(
1112
+ {
1113
+ blockTag: this.context.blockNumber,
1114
+ ...overrides,
1115
+ },
1116
+ this.context.preparedData,
1117
+ ethCallContext
1118
+ );
417
1119
  }
418
1120
 
419
1121
  async tokenURI(
420
1122
  tokenId: BigNumberish,
421
1123
  overrides?: Overrides
422
1124
  ): Promise<string> {
423
- return await this.view.tokenURI(tokenId, {
424
- blockTag: this.context.blockNumber,
425
- ...overrides,
426
- });
1125
+ const ethCallContext = {
1126
+ chainId: this.context.chainId,
1127
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1128
+ address: this.context.address,
1129
+ };
1130
+ return await this.view.tokenURI(
1131
+ tokenId,
1132
+ {
1133
+ blockTag: this.context.blockNumber,
1134
+ ...overrides,
1135
+ },
1136
+ this.context.preparedData,
1137
+ ethCallContext
1138
+ );
427
1139
  }
428
1140
 
429
1141
  callStatic = {
@@ -435,10 +1147,21 @@ export class ERC721BoundContractView extends BoundContractView<
435
1147
  tokenId: BigNumberish,
436
1148
  overrides?: Overrides
437
1149
  ): Promise<void> {
438
- return await this.view.callStatic.approve(to, tokenId, {
439
- blockTag: this.context.blockNumber,
440
- ...overrides,
441
- });
1150
+ const ethCallContext = {
1151
+ chainId: this.context.chainId,
1152
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1153
+ address: this.context.address,
1154
+ };
1155
+ return await this.view.callStatic.approve(
1156
+ to,
1157
+ tokenId,
1158
+ {
1159
+ blockTag: this.context.blockNumber,
1160
+ ...overrides,
1161
+ },
1162
+ this.context.preparedData,
1163
+ ethCallContext
1164
+ );
442
1165
  },
443
1166
  async safeTransferFrom_address_address_uint256(
444
1167
  from: string,
@@ -446,6 +1169,11 @@ export class ERC721BoundContractView extends BoundContractView<
446
1169
  tokenId: BigNumberish,
447
1170
  overrides?: Overrides
448
1171
  ): Promise<void> {
1172
+ const ethCallContext = {
1173
+ chainId: this.context.chainId,
1174
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1175
+ address: this.context.address,
1176
+ };
449
1177
  return await this.view.callStatic.safeTransferFrom_address_address_uint256(
450
1178
  from,
451
1179
  to,
@@ -453,7 +1181,9 @@ export class ERC721BoundContractView extends BoundContractView<
453
1181
  {
454
1182
  blockTag: this.context.blockNumber,
455
1183
  ...overrides,
456
- }
1184
+ },
1185
+ this.context.preparedData,
1186
+ ethCallContext
457
1187
  );
458
1188
  },
459
1189
  async safeTransferFrom_address_address_uint256_bytes(
@@ -463,6 +1193,11 @@ export class ERC721BoundContractView extends BoundContractView<
463
1193
  data: BytesLike,
464
1194
  overrides?: Overrides
465
1195
  ): Promise<void> {
1196
+ const ethCallContext = {
1197
+ chainId: this.context.chainId,
1198
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1199
+ address: this.context.address,
1200
+ };
466
1201
  return await this.view.callStatic.safeTransferFrom_address_address_uint256_bytes(
467
1202
  from,
468
1203
  to,
@@ -471,7 +1206,9 @@ export class ERC721BoundContractView extends BoundContractView<
471
1206
  {
472
1207
  blockTag: this.context.blockNumber,
473
1208
  ...overrides,
474
- }
1209
+ },
1210
+ this.context.preparedData,
1211
+ ethCallContext
475
1212
  );
476
1213
  },
477
1214
  async setApprovalForAll(
@@ -479,10 +1216,21 @@ export class ERC721BoundContractView extends BoundContractView<
479
1216
  _approved: boolean,
480
1217
  overrides?: Overrides
481
1218
  ): Promise<void> {
482
- return await this.view.callStatic.setApprovalForAll(operator, _approved, {
483
- blockTag: this.context.blockNumber,
484
- ...overrides,
485
- });
1219
+ const ethCallContext = {
1220
+ chainId: this.context.chainId,
1221
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1222
+ address: this.context.address,
1223
+ };
1224
+ return await this.view.callStatic.setApprovalForAll(
1225
+ operator,
1226
+ _approved,
1227
+ {
1228
+ blockTag: this.context.blockNumber,
1229
+ ...overrides,
1230
+ },
1231
+ this.context.preparedData,
1232
+ ethCallContext
1233
+ );
486
1234
  },
487
1235
  async transferFrom(
488
1236
  from: string,
@@ -490,9 +1238,301 @@ export class ERC721BoundContractView extends BoundContractView<
490
1238
  tokenId: BigNumberish,
491
1239
  overrides?: Overrides
492
1240
  ): Promise<void> {
493
- return await this.view.callStatic.transferFrom(from, to, tokenId, {
494
- blockTag: this.context.blockNumber,
495
- ...overrides,
1241
+ const ethCallContext = {
1242
+ chainId: this.context.chainId,
1243
+ blockTag: "0x" + this.context.blockNumber.toString(16),
1244
+ address: this.context.address,
1245
+ };
1246
+ return await this.view.callStatic.transferFrom(
1247
+ from,
1248
+ to,
1249
+ tokenId,
1250
+ {
1251
+ blockTag: this.context.blockNumber,
1252
+ ...overrides,
1253
+ },
1254
+ this.context.preparedData,
1255
+ ethCallContext
1256
+ );
1257
+ },
1258
+ };
1259
+
1260
+ encodeCall = {
1261
+ view: this.view,
1262
+ context: this.context,
1263
+
1264
+ approve(
1265
+ to: string,
1266
+ tokenId: BigNumberish,
1267
+ overrides?: Overrides
1268
+ ): EthCallParam {
1269
+ const chainId =
1270
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1271
+ const address = this.context.address;
1272
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1273
+ if (overrides?.blockTag) {
1274
+ blockTag =
1275
+ typeof overrides.blockTag == "string"
1276
+ ? overrides.blockTag
1277
+ : "0x" + overrides.blockTag.toString(16);
1278
+ }
1279
+
1280
+ return this.view.encodeCall.approve(to, tokenId, {
1281
+ chainId,
1282
+ address,
1283
+ blockTag,
1284
+ });
1285
+ },
1286
+ totalSupply(overrides?: Overrides): EthCallParam {
1287
+ const chainId =
1288
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1289
+ const address = this.context.address;
1290
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1291
+ if (overrides?.blockTag) {
1292
+ blockTag =
1293
+ typeof overrides.blockTag == "string"
1294
+ ? overrides.blockTag
1295
+ : "0x" + overrides.blockTag.toString(16);
1296
+ }
1297
+
1298
+ return this.view.encodeCall.totalSupply({ chainId, address, blockTag });
1299
+ },
1300
+ balanceOf(owner: string, overrides?: Overrides): EthCallParam {
1301
+ const chainId =
1302
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1303
+ const address = this.context.address;
1304
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1305
+ if (overrides?.blockTag) {
1306
+ blockTag =
1307
+ typeof overrides.blockTag == "string"
1308
+ ? overrides.blockTag
1309
+ : "0x" + overrides.blockTag.toString(16);
1310
+ }
1311
+
1312
+ return this.view.encodeCall.balanceOf(owner, {
1313
+ chainId,
1314
+ address,
1315
+ blockTag,
1316
+ });
1317
+ },
1318
+ getApproved(tokenId: BigNumberish, overrides?: Overrides): EthCallParam {
1319
+ const chainId =
1320
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1321
+ const address = this.context.address;
1322
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1323
+ if (overrides?.blockTag) {
1324
+ blockTag =
1325
+ typeof overrides.blockTag == "string"
1326
+ ? overrides.blockTag
1327
+ : "0x" + overrides.blockTag.toString(16);
1328
+ }
1329
+
1330
+ return this.view.encodeCall.getApproved(tokenId, {
1331
+ chainId,
1332
+ address,
1333
+ blockTag,
1334
+ });
1335
+ },
1336
+ isApprovedForAll(
1337
+ owner: string,
1338
+ operator: string,
1339
+ overrides?: Overrides
1340
+ ): EthCallParam {
1341
+ const chainId =
1342
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1343
+ const address = this.context.address;
1344
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1345
+ if (overrides?.blockTag) {
1346
+ blockTag =
1347
+ typeof overrides.blockTag == "string"
1348
+ ? overrides.blockTag
1349
+ : "0x" + overrides.blockTag.toString(16);
1350
+ }
1351
+
1352
+ return this.view.encodeCall.isApprovedForAll(owner, operator, {
1353
+ chainId,
1354
+ address,
1355
+ blockTag,
1356
+ });
1357
+ },
1358
+ name(overrides?: Overrides): EthCallParam {
1359
+ const chainId =
1360
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1361
+ const address = this.context.address;
1362
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1363
+ if (overrides?.blockTag) {
1364
+ blockTag =
1365
+ typeof overrides.blockTag == "string"
1366
+ ? overrides.blockTag
1367
+ : "0x" + overrides.blockTag.toString(16);
1368
+ }
1369
+
1370
+ return this.view.encodeCall.name({ chainId, address, blockTag });
1371
+ },
1372
+ ownerOf(tokenId: BigNumberish, overrides?: Overrides): EthCallParam {
1373
+ const chainId =
1374
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1375
+ const address = this.context.address;
1376
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1377
+ if (overrides?.blockTag) {
1378
+ blockTag =
1379
+ typeof overrides.blockTag == "string"
1380
+ ? overrides.blockTag
1381
+ : "0x" + overrides.blockTag.toString(16);
1382
+ }
1383
+
1384
+ return this.view.encodeCall.ownerOf(tokenId, {
1385
+ chainId,
1386
+ address,
1387
+ blockTag,
1388
+ });
1389
+ },
1390
+ safeTransferFrom_address_address_uint256(
1391
+ from: string,
1392
+ to: string,
1393
+ tokenId: BigNumberish,
1394
+ overrides?: Overrides
1395
+ ): EthCallParam {
1396
+ const chainId =
1397
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1398
+ const address = this.context.address;
1399
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1400
+ if (overrides?.blockTag) {
1401
+ blockTag =
1402
+ typeof overrides.blockTag == "string"
1403
+ ? overrides.blockTag
1404
+ : "0x" + overrides.blockTag.toString(16);
1405
+ }
1406
+
1407
+ return this.view.encodeCall.safeTransferFrom_address_address_uint256(
1408
+ from,
1409
+ to,
1410
+ tokenId,
1411
+ { chainId, address, blockTag }
1412
+ );
1413
+ },
1414
+ safeTransferFrom_address_address_uint256_bytes(
1415
+ from: string,
1416
+ to: string,
1417
+ tokenId: BigNumberish,
1418
+ data: BytesLike,
1419
+ overrides?: Overrides
1420
+ ): EthCallParam {
1421
+ const chainId =
1422
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1423
+ const address = this.context.address;
1424
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1425
+ if (overrides?.blockTag) {
1426
+ blockTag =
1427
+ typeof overrides.blockTag == "string"
1428
+ ? overrides.blockTag
1429
+ : "0x" + overrides.blockTag.toString(16);
1430
+ }
1431
+
1432
+ return this.view.encodeCall.safeTransferFrom_address_address_uint256_bytes(
1433
+ from,
1434
+ to,
1435
+ tokenId,
1436
+ data,
1437
+ { chainId, address, blockTag }
1438
+ );
1439
+ },
1440
+ setApprovalForAll(
1441
+ operator: string,
1442
+ _approved: boolean,
1443
+ overrides?: Overrides
1444
+ ): EthCallParam {
1445
+ const chainId =
1446
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1447
+ const address = this.context.address;
1448
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1449
+ if (overrides?.blockTag) {
1450
+ blockTag =
1451
+ typeof overrides.blockTag == "string"
1452
+ ? overrides.blockTag
1453
+ : "0x" + overrides.blockTag.toString(16);
1454
+ }
1455
+
1456
+ return this.view.encodeCall.setApprovalForAll(operator, _approved, {
1457
+ chainId,
1458
+ address,
1459
+ blockTag,
1460
+ });
1461
+ },
1462
+ supportsInterface(
1463
+ interfaceId: BytesLike,
1464
+ overrides?: Overrides
1465
+ ): EthCallParam {
1466
+ const chainId =
1467
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1468
+ const address = this.context.address;
1469
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1470
+ if (overrides?.blockTag) {
1471
+ blockTag =
1472
+ typeof overrides.blockTag == "string"
1473
+ ? overrides.blockTag
1474
+ : "0x" + overrides.blockTag.toString(16);
1475
+ }
1476
+
1477
+ return this.view.encodeCall.supportsInterface(interfaceId, {
1478
+ chainId,
1479
+ address,
1480
+ blockTag,
1481
+ });
1482
+ },
1483
+ symbol(overrides?: Overrides): EthCallParam {
1484
+ const chainId =
1485
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1486
+ const address = this.context.address;
1487
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1488
+ if (overrides?.blockTag) {
1489
+ blockTag =
1490
+ typeof overrides.blockTag == "string"
1491
+ ? overrides.blockTag
1492
+ : "0x" + overrides.blockTag.toString(16);
1493
+ }
1494
+
1495
+ return this.view.encodeCall.symbol({ chainId, address, blockTag });
1496
+ },
1497
+ tokenURI(tokenId: BigNumberish, overrides?: Overrides): EthCallParam {
1498
+ const chainId =
1499
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1500
+ const address = this.context.address;
1501
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1502
+ if (overrides?.blockTag) {
1503
+ blockTag =
1504
+ typeof overrides.blockTag == "string"
1505
+ ? overrides.blockTag
1506
+ : "0x" + overrides.blockTag.toString(16);
1507
+ }
1508
+
1509
+ return this.view.encodeCall.tokenURI(tokenId, {
1510
+ chainId,
1511
+ address,
1512
+ blockTag,
1513
+ });
1514
+ },
1515
+ transferFrom(
1516
+ from: string,
1517
+ to: string,
1518
+ tokenId: BigNumberish,
1519
+ overrides?: Overrides
1520
+ ): EthCallParam {
1521
+ const chainId =
1522
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
1523
+ const address = this.context.address;
1524
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
1525
+ if (overrides?.blockTag) {
1526
+ blockTag =
1527
+ typeof overrides.blockTag == "string"
1528
+ ? overrides.blockTag
1529
+ : "0x" + overrides.blockTag.toString(16);
1530
+ }
1531
+
1532
+ return this.view.encodeCall.transferFrom(from, to, tokenId, {
1533
+ chainId,
1534
+ address,
1535
+ blockTag,
496
1536
  });
497
1537
  },
498
1538
  };
@@ -510,7 +1550,8 @@ export class ERC721Processor extends BaseProcessor<
510
1550
  fetchConfig?: Partial<EthFetchConfig>,
511
1551
  preprocessHandler?: (
512
1552
  event: ApprovalEvent,
513
- ctx: ERC721Context
1553
+ ctx: ERC721Context,
1554
+ preprocessStore: { [k: string]: any }
514
1555
  ) => Promise<PreprocessResult>
515
1556
  ): this {
516
1557
  if (!filter) {
@@ -529,7 +1570,8 @@ export class ERC721Processor extends BaseProcessor<
529
1570
  fetchConfig?: Partial<EthFetchConfig>,
530
1571
  preprocessHandler?: (
531
1572
  event: ApprovalForAllEvent,
532
- ctx: ERC721Context
1573
+ ctx: ERC721Context,
1574
+ preprocessStore: { [k: string]: any }
533
1575
  ) => Promise<PreprocessResult>
534
1576
  ): this {
535
1577
  if (!filter) {
@@ -548,7 +1590,8 @@ export class ERC721Processor extends BaseProcessor<
548
1590
  fetchConfig?: Partial<EthFetchConfig>,
549
1591
  preprocessHandler?: (
550
1592
  event: TransferEvent,
551
- ctx: ERC721Context
1593
+ ctx: ERC721Context,
1594
+ preprocessStore: { [k: string]: any }
552
1595
  ) => Promise<PreprocessResult>
553
1596
  ): this {
554
1597
  if (!filter) {
@@ -867,7 +1910,8 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
867
1910
  fetchConfig?: Partial<EthFetchConfig>,
868
1911
  preprocessHandler?: (
869
1912
  event: ApprovalEvent,
870
- ctx: ERC721Context
1913
+ ctx: ERC721Context,
1914
+ preprocessStore: { [k: string]: any }
871
1915
  ) => Promise<PreprocessResult>
872
1916
  ): this {
873
1917
  if (!filter) {
@@ -886,7 +1930,8 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
886
1930
  fetchConfig?: Partial<EthFetchConfig>,
887
1931
  preprocessHandler?: (
888
1932
  event: ApprovalForAllEvent,
889
- ctx: ERC721Context
1933
+ ctx: ERC721Context,
1934
+ preprocessStore: { [k: string]: any }
890
1935
  ) => Promise<PreprocessResult>
891
1936
  ): this {
892
1937
  if (!filter) {
@@ -905,7 +1950,8 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
905
1950
  fetchConfig?: Partial<EthFetchConfig>,
906
1951
  preprocessHandler?: (
907
1952
  event: TransferEvent,
908
- ctx: ERC721Context
1953
+ ctx: ERC721Context,
1954
+ preprocessStore: { [k: string]: any }
909
1955
  ) => Promise<PreprocessResult>
910
1956
  ): this {
911
1957
  if (!filter) {