@sentio/sdk 2.40.0 → 2.40.1-rc.10

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 (56) hide show
  1. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  2. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +71 -115
  3. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  4. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  5. package/lib/eth/builtin/internal/erc1155-processor.js +26 -40
  6. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  7. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  8. package/lib/eth/builtin/internal/erc20-processor.js +56 -88
  9. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  10. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  11. package/lib/eth/builtin/internal/erc20bytes-processor.js +29 -43
  12. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  13. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  14. package/lib/eth/builtin/internal/erc721-processor.js +44 -68
  15. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  16. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  17. package/lib/eth/builtin/internal/weth9-processor.js +35 -53
  18. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  19. package/lib/eth/codegen/file.d.ts.map +1 -1
  20. package/lib/eth/codegen/file.js +5 -1
  21. package/lib/eth/codegen/file.js.map +1 -1
  22. package/lib/eth/codegen/function-calls.d.ts +1 -0
  23. package/lib/eth/codegen/function-calls.d.ts.map +1 -1
  24. package/lib/eth/codegen/function-calls.js +5 -3
  25. package/lib/eth/codegen/function-calls.js.map +1 -1
  26. package/lib/eth/codegen/types.d.ts.map +1 -1
  27. package/lib/eth/codegen/types.js +23 -6
  28. package/lib/eth/codegen/types.js.map +1 -1
  29. package/lib/store/cache.d.ts +0 -3
  30. package/lib/store/cache.d.ts.map +1 -1
  31. package/lib/store/cache.js.map +1 -1
  32. package/lib/store/codegen.d.ts.map +1 -1
  33. package/lib/store/codegen.js +51 -34
  34. package/lib/store/codegen.js.map +1 -1
  35. package/lib/store/store.d.ts +3 -3
  36. package/lib/store/store.d.ts.map +1 -1
  37. package/lib/store/store.js +2 -2
  38. package/lib/store/store.js.map +1 -1
  39. package/lib/store/types.d.ts +6 -0
  40. package/lib/store/types.d.ts.map +1 -1
  41. package/lib/store/types.js +49 -1
  42. package/lib/store/types.js.map +1 -1
  43. package/package.json +5 -8
  44. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +72 -115
  45. package/src/eth/builtin/internal/erc1155-processor.ts +27 -40
  46. package/src/eth/builtin/internal/erc20-processor.ts +57 -88
  47. package/src/eth/builtin/internal/erc20bytes-processor.ts +30 -43
  48. package/src/eth/builtin/internal/erc721-processor.ts +45 -68
  49. package/src/eth/builtin/internal/weth9-processor.ts +36 -53
  50. package/src/eth/codegen/file.ts +5 -0
  51. package/src/eth/codegen/function-calls.ts +6 -3
  52. package/src/eth/codegen/types.ts +32 -7
  53. package/src/store/cache.ts +0 -4
  54. package/src/store/codegen.ts +53 -34
  55. package/src/store/store.ts +5 -5
  56. package/src/store/types.ts +57 -0
@@ -167,6 +167,27 @@ export type TransferOwnershipCallTrace = TypedCallTrace<
167
167
 
168
168
  const templateContract = ERC20__factory.connect("0x0", DummyProvider);
169
169
 
170
+ const iface = new Interface([
171
+ "function allowance(address owner, address spender) view returns (uint256)",
172
+ "function approve(address spender, uint256 amount) returns (bool)",
173
+ "function balanceOf(address account) view returns (uint256)",
174
+ "function burn(uint256 amount) returns ()",
175
+ "function burnFrom(address account, uint256 amount) returns ()",
176
+ "function decimals() view returns (uint8)",
177
+ "function decreaseAllowance(address spender, uint256 subtractedValue) returns (bool)",
178
+ "function increaseAllowance(address spender, uint256 addedValue) returns (bool)",
179
+ "function locker() view returns (address)",
180
+ "function name() view returns (string)",
181
+ "function owner() view returns (address)",
182
+ "function renounceOwnership() returns ()",
183
+ "function setLocker(address _locker) returns ()",
184
+ "function symbol() view returns (string)",
185
+ "function totalSupply() view returns (uint256)",
186
+ "function transfer(address recipient, uint256 amount) returns (bool)",
187
+ "function transferFrom(address sender, address recipient, uint256 amount) returns (bool)",
188
+ "function transferOwnership(address newOwner) returns ()",
189
+ ]);
190
+
170
191
  export class ERC20ContractView extends ContractView<ERC20> {
171
192
  constructor(contract: ERC20) {
172
193
  super(contract);
@@ -182,18 +203,15 @@ export class ERC20ContractView extends ContractView<ERC20> {
182
203
  ): Promise<bigint> {
183
204
  try {
184
205
  if (preparedData?.ethCallResults && ethCallContext) {
185
- const iface = new Interface([
186
- "function allowance(address,address) view returns (uint256)",
187
- ]);
188
206
  const calldata = iface.encodeFunctionData("allowance", [
189
207
  owner,
190
208
  spender,
191
209
  ]);
192
- const key = makeEthCallKey({
210
+ const ethCallKey = makeEthCallKey({
193
211
  context: ethCallContext,
194
212
  calldata,
195
213
  });
196
- const ret = preparedData.ethCallResults[key];
214
+ const ret = preparedData.ethCallResults[ethCallKey];
197
215
  if (ret) {
198
216
  const result = iface.decodeFunctionResult("allowance", ret).toArray();
199
217
  return result.length == 1 ? result[0] : result;
@@ -218,15 +236,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
218
236
  ): Promise<bigint> {
219
237
  try {
220
238
  if (preparedData?.ethCallResults && ethCallContext) {
221
- const iface = new Interface([
222
- "function balanceOf(address) view returns (uint256)",
223
- ]);
224
239
  const calldata = iface.encodeFunctionData("balanceOf", [account]);
225
- const key = makeEthCallKey({
240
+ const ethCallKey = makeEthCallKey({
226
241
  context: ethCallContext,
227
242
  calldata,
228
243
  });
229
- const ret = preparedData.ethCallResults[key];
244
+ const ret = preparedData.ethCallResults[ethCallKey];
230
245
  if (ret) {
231
246
  const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
232
247
  return result.length == 1 ? result[0] : result;
@@ -249,15 +264,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
249
264
  ): Promise<bigint> {
250
265
  try {
251
266
  if (preparedData?.ethCallResults && ethCallContext) {
252
- const iface = new Interface([
253
- "function decimals() view returns (uint8)",
254
- ]);
255
267
  const calldata = iface.encodeFunctionData("decimals", []);
256
- const key = makeEthCallKey({
268
+ const ethCallKey = makeEthCallKey({
257
269
  context: ethCallContext,
258
270
  calldata,
259
271
  });
260
- const ret = preparedData.ethCallResults[key];
272
+ const ret = preparedData.ethCallResults[ethCallKey];
261
273
  if (ret) {
262
274
  const result = iface.decodeFunctionResult("decimals", ret).toArray();
263
275
  return result.length == 1 ? result[0] : result;
@@ -277,15 +289,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
277
289
  ): Promise<string> {
278
290
  try {
279
291
  if (preparedData?.ethCallResults && ethCallContext) {
280
- const iface = new Interface([
281
- "function locker() view returns (address)",
282
- ]);
283
292
  const calldata = iface.encodeFunctionData("locker", []);
284
- const key = makeEthCallKey({
293
+ const ethCallKey = makeEthCallKey({
285
294
  context: ethCallContext,
286
295
  calldata,
287
296
  });
288
- const ret = preparedData.ethCallResults[key];
297
+ const ret = preparedData.ethCallResults[ethCallKey];
289
298
  if (ret) {
290
299
  const result = iface.decodeFunctionResult("locker", ret).toArray();
291
300
  return result.length == 1 ? result[0] : result;
@@ -305,13 +314,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
305
314
  ): Promise<string> {
306
315
  try {
307
316
  if (preparedData?.ethCallResults && ethCallContext) {
308
- const iface = new Interface(["function name() view returns (string)"]);
309
317
  const calldata = iface.encodeFunctionData("name", []);
310
- const key = makeEthCallKey({
318
+ const ethCallKey = makeEthCallKey({
311
319
  context: ethCallContext,
312
320
  calldata,
313
321
  });
314
- const ret = preparedData.ethCallResults[key];
322
+ const ret = preparedData.ethCallResults[ethCallKey];
315
323
  if (ret) {
316
324
  const result = iface.decodeFunctionResult("name", ret).toArray();
317
325
  return result.length == 1 ? result[0] : result;
@@ -331,15 +339,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
331
339
  ): Promise<string> {
332
340
  try {
333
341
  if (preparedData?.ethCallResults && ethCallContext) {
334
- const iface = new Interface([
335
- "function owner() view returns (address)",
336
- ]);
337
342
  const calldata = iface.encodeFunctionData("owner", []);
338
- const key = makeEthCallKey({
343
+ const ethCallKey = makeEthCallKey({
339
344
  context: ethCallContext,
340
345
  calldata,
341
346
  });
342
- const ret = preparedData.ethCallResults[key];
347
+ const ret = preparedData.ethCallResults[ethCallKey];
343
348
  if (ret) {
344
349
  const result = iface.decodeFunctionResult("owner", ret).toArray();
345
350
  return result.length == 1 ? result[0] : result;
@@ -359,15 +364,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
359
364
  ): Promise<string> {
360
365
  try {
361
366
  if (preparedData?.ethCallResults && ethCallContext) {
362
- const iface = new Interface([
363
- "function symbol() view returns (string)",
364
- ]);
365
367
  const calldata = iface.encodeFunctionData("symbol", []);
366
- const key = makeEthCallKey({
368
+ const ethCallKey = makeEthCallKey({
367
369
  context: ethCallContext,
368
370
  calldata,
369
371
  });
370
- const ret = preparedData.ethCallResults[key];
372
+ const ret = preparedData.ethCallResults[ethCallKey];
371
373
  if (ret) {
372
374
  const result = iface.decodeFunctionResult("symbol", ret).toArray();
373
375
  return result.length == 1 ? result[0] : result;
@@ -387,15 +389,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
387
389
  ): Promise<bigint> {
388
390
  try {
389
391
  if (preparedData?.ethCallResults && ethCallContext) {
390
- const iface = new Interface([
391
- "function totalSupply() view returns (uint256)",
392
- ]);
393
392
  const calldata = iface.encodeFunctionData("totalSupply", []);
394
- const key = makeEthCallKey({
393
+ const ethCallKey = makeEthCallKey({
395
394
  context: ethCallContext,
396
395
  calldata,
397
396
  });
398
- const ret = preparedData.ethCallResults[key];
397
+ const ret = preparedData.ethCallResults[ethCallKey];
399
398
  if (ret) {
400
399
  const result = iface
401
400
  .decodeFunctionResult("totalSupply", ret)
@@ -422,18 +421,15 @@ export class ERC20ContractView extends ContractView<ERC20> {
422
421
  ): Promise<boolean> {
423
422
  try {
424
423
  if (preparedData?.ethCallResults && ethCallContext) {
425
- const iface = new Interface([
426
- "function approve(address,uint256) nonpayable returns (bool)",
427
- ]);
428
424
  const calldata = iface.encodeFunctionData("approve", [
429
425
  spender,
430
426
  amount,
431
427
  ]);
432
- const key = makeEthCallKey({
428
+ const ethCallKey = makeEthCallKey({
433
429
  context: ethCallContext,
434
430
  calldata,
435
431
  });
436
- const ret = preparedData.ethCallResults[key];
432
+ const ret = preparedData.ethCallResults[ethCallKey];
437
433
  if (ret) {
438
434
  const result = iface.decodeFunctionResult("approve", ret).toArray();
439
435
  return result.length == 1 ? result[0] : result;
@@ -455,15 +451,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
455
451
  ): Promise<void> {
456
452
  try {
457
453
  if (preparedData?.ethCallResults && ethCallContext) {
458
- const iface = new Interface([
459
- "function burn(uint256) nonpayable returns ()",
460
- ]);
461
454
  const calldata = iface.encodeFunctionData("burn", [amount]);
462
- const key = makeEthCallKey({
455
+ const ethCallKey = makeEthCallKey({
463
456
  context: ethCallContext,
464
457
  calldata,
465
458
  });
466
- const ret = preparedData.ethCallResults[key];
459
+ const ret = preparedData.ethCallResults[ethCallKey];
467
460
  if (ret) {
468
461
  const result = iface.decodeFunctionResult("burn", ret).toArray();
469
462
  return result.length == 1 ? result[0] : result;
@@ -486,18 +479,15 @@ export class ERC20ContractView extends ContractView<ERC20> {
486
479
  ): Promise<void> {
487
480
  try {
488
481
  if (preparedData?.ethCallResults && ethCallContext) {
489
- const iface = new Interface([
490
- "function burnFrom(address,uint256) nonpayable returns ()",
491
- ]);
492
482
  const calldata = iface.encodeFunctionData("burnFrom", [
493
483
  account,
494
484
  amount,
495
485
  ]);
496
- const key = makeEthCallKey({
486
+ const ethCallKey = makeEthCallKey({
497
487
  context: ethCallContext,
498
488
  calldata,
499
489
  });
500
- const ret = preparedData.ethCallResults[key];
490
+ const ret = preparedData.ethCallResults[ethCallKey];
501
491
  if (ret) {
502
492
  const result = iface
503
493
  .decodeFunctionResult("burnFrom", ret)
@@ -522,18 +512,15 @@ export class ERC20ContractView extends ContractView<ERC20> {
522
512
  ): Promise<boolean> {
523
513
  try {
524
514
  if (preparedData?.ethCallResults && ethCallContext) {
525
- const iface = new Interface([
526
- "function decreaseAllowance(address,uint256) nonpayable returns (bool)",
527
- ]);
528
515
  const calldata = iface.encodeFunctionData("decreaseAllowance", [
529
516
  spender,
530
517
  subtractedValue,
531
518
  ]);
532
- const key = makeEthCallKey({
519
+ const ethCallKey = makeEthCallKey({
533
520
  context: ethCallContext,
534
521
  calldata,
535
522
  });
536
- const ret = preparedData.ethCallResults[key];
523
+ const ret = preparedData.ethCallResults[ethCallKey];
537
524
  if (ret) {
538
525
  const result = iface
539
526
  .decodeFunctionResult("decreaseAllowance", ret)
@@ -558,18 +545,15 @@ export class ERC20ContractView extends ContractView<ERC20> {
558
545
  ): Promise<boolean> {
559
546
  try {
560
547
  if (preparedData?.ethCallResults && ethCallContext) {
561
- const iface = new Interface([
562
- "function increaseAllowance(address,uint256) nonpayable returns (bool)",
563
- ]);
564
548
  const calldata = iface.encodeFunctionData("increaseAllowance", [
565
549
  spender,
566
550
  addedValue,
567
551
  ]);
568
- const key = makeEthCallKey({
552
+ const ethCallKey = makeEthCallKey({
569
553
  context: ethCallContext,
570
554
  calldata,
571
555
  });
572
- const ret = preparedData.ethCallResults[key];
556
+ const ret = preparedData.ethCallResults[ethCallKey];
573
557
  if (ret) {
574
558
  const result = iface
575
559
  .decodeFunctionResult("increaseAllowance", ret)
@@ -592,15 +576,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
592
576
  ): Promise<void> {
593
577
  try {
594
578
  if (preparedData?.ethCallResults && ethCallContext) {
595
- const iface = new Interface([
596
- "function renounceOwnership() nonpayable returns ()",
597
- ]);
598
579
  const calldata = iface.encodeFunctionData("renounceOwnership", []);
599
- const key = makeEthCallKey({
580
+ const ethCallKey = makeEthCallKey({
600
581
  context: ethCallContext,
601
582
  calldata,
602
583
  });
603
- const ret = preparedData.ethCallResults[key];
584
+ const ret = preparedData.ethCallResults[ethCallKey];
604
585
  if (ret) {
605
586
  const result = iface
606
587
  .decodeFunctionResult("renounceOwnership", ret)
@@ -624,15 +605,12 @@ export class ERC20ContractView extends ContractView<ERC20> {
624
605
  ): Promise<void> {
625
606
  try {
626
607
  if (preparedData?.ethCallResults && ethCallContext) {
627
- const iface = new Interface([
628
- "function setLocker(address) nonpayable returns ()",
629
- ]);
630
608
  const calldata = iface.encodeFunctionData("setLocker", [_locker]);
631
- const key = makeEthCallKey({
609
+ const ethCallKey = makeEthCallKey({
632
610
  context: ethCallContext,
633
611
  calldata,
634
612
  });
635
- const ret = preparedData.ethCallResults[key];
613
+ const ret = preparedData.ethCallResults[ethCallKey];
636
614
  if (ret) {
637
615
  const result = iface
638
616
  .decodeFunctionResult("setLocker", ret)
@@ -657,18 +635,15 @@ export class ERC20ContractView extends ContractView<ERC20> {
657
635
  ): Promise<boolean> {
658
636
  try {
659
637
  if (preparedData?.ethCallResults && ethCallContext) {
660
- const iface = new Interface([
661
- "function transfer(address,uint256) nonpayable returns (bool)",
662
- ]);
663
638
  const calldata = iface.encodeFunctionData("transfer", [
664
639
  recipient,
665
640
  amount,
666
641
  ]);
667
- const key = makeEthCallKey({
642
+ const ethCallKey = makeEthCallKey({
668
643
  context: ethCallContext,
669
644
  calldata,
670
645
  });
671
- const ret = preparedData.ethCallResults[key];
646
+ const ret = preparedData.ethCallResults[ethCallKey];
672
647
  if (ret) {
673
648
  const result = iface
674
649
  .decodeFunctionResult("transfer", ret)
@@ -694,19 +669,16 @@ export class ERC20ContractView extends ContractView<ERC20> {
694
669
  ): Promise<boolean> {
695
670
  try {
696
671
  if (preparedData?.ethCallResults && ethCallContext) {
697
- const iface = new Interface([
698
- "function transferFrom(address,address,uint256) nonpayable returns (bool)",
699
- ]);
700
672
  const calldata = iface.encodeFunctionData("transferFrom", [
701
673
  sender,
702
674
  recipient,
703
675
  amount,
704
676
  ]);
705
- const key = makeEthCallKey({
677
+ const ethCallKey = makeEthCallKey({
706
678
  context: ethCallContext,
707
679
  calldata,
708
680
  });
709
- const ret = preparedData.ethCallResults[key];
681
+ const ret = preparedData.ethCallResults[ethCallKey];
710
682
  if (ret) {
711
683
  const result = iface
712
684
  .decodeFunctionResult("transferFrom", ret)
@@ -730,17 +702,14 @@ export class ERC20ContractView extends ContractView<ERC20> {
730
702
  ): Promise<void> {
731
703
  try {
732
704
  if (preparedData?.ethCallResults && ethCallContext) {
733
- const iface = new Interface([
734
- "function transferOwnership(address) nonpayable returns ()",
735
- ]);
736
705
  const calldata = iface.encodeFunctionData("transferOwnership", [
737
706
  newOwner,
738
707
  ]);
739
- const key = makeEthCallKey({
708
+ const ethCallKey = makeEthCallKey({
740
709
  context: ethCallContext,
741
710
  calldata,
742
711
  });
743
- const ret = preparedData.ethCallResults[key];
712
+ const ret = preparedData.ethCallResults[ethCallKey];
744
713
  if (ret) {
745
714
  const result = iface
746
715
  .decodeFunctionResult("transferOwnership", ret)
@@ -99,6 +99,18 @@ export type AllowanceCallTrace = TypedCallTrace<
99
99
 
100
100
  const templateContract = ERC20Bytes__factory.connect("0x0", DummyProvider);
101
101
 
102
+ const iface = new Interface([
103
+ "function name() view returns (bytes32)",
104
+ "function approve(address spender, uint256 value) returns (bool)",
105
+ "function totalSupply() view returns (uint256)",
106
+ "function transferFrom(address from, address to, uint256 value) returns (bool)",
107
+ "function decimals() view returns (uint8)",
108
+ "function balanceOf(address who) view returns (uint256)",
109
+ "function symbol() view returns (bytes32)",
110
+ "function transfer(address to, uint256 value) returns (bool)",
111
+ "function allowance(address owner, address spender) view returns (uint256)",
112
+ ]);
113
+
102
114
  export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
103
115
  constructor(contract: ERC20Bytes) {
104
116
  super(contract);
@@ -112,13 +124,12 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
112
124
  ): Promise<string> {
113
125
  try {
114
126
  if (preparedData?.ethCallResults && ethCallContext) {
115
- const iface = new Interface(["function name() view returns (bytes32)"]);
116
127
  const calldata = iface.encodeFunctionData("name", []);
117
- const key = makeEthCallKey({
128
+ const ethCallKey = makeEthCallKey({
118
129
  context: ethCallContext,
119
130
  calldata,
120
131
  });
121
- const ret = preparedData.ethCallResults[key];
132
+ const ret = preparedData.ethCallResults[ethCallKey];
122
133
  if (ret) {
123
134
  const result = iface.decodeFunctionResult("name", ret).toArray();
124
135
  return result.length == 1 ? result[0] : result;
@@ -138,15 +149,12 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
138
149
  ): Promise<bigint> {
139
150
  try {
140
151
  if (preparedData?.ethCallResults && ethCallContext) {
141
- const iface = new Interface([
142
- "function totalSupply() view returns (uint256)",
143
- ]);
144
152
  const calldata = iface.encodeFunctionData("totalSupply", []);
145
- const key = makeEthCallKey({
153
+ const ethCallKey = makeEthCallKey({
146
154
  context: ethCallContext,
147
155
  calldata,
148
156
  });
149
- const ret = preparedData.ethCallResults[key];
157
+ const ret = preparedData.ethCallResults[ethCallKey];
150
158
  if (ret) {
151
159
  const result = iface
152
160
  .decodeFunctionResult("totalSupply", ret)
@@ -168,15 +176,12 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
168
176
  ): Promise<bigint> {
169
177
  try {
170
178
  if (preparedData?.ethCallResults && ethCallContext) {
171
- const iface = new Interface([
172
- "function decimals() view returns (uint8)",
173
- ]);
174
179
  const calldata = iface.encodeFunctionData("decimals", []);
175
- const key = makeEthCallKey({
180
+ const ethCallKey = makeEthCallKey({
176
181
  context: ethCallContext,
177
182
  calldata,
178
183
  });
179
- const ret = preparedData.ethCallResults[key];
184
+ const ret = preparedData.ethCallResults[ethCallKey];
180
185
  if (ret) {
181
186
  const result = iface.decodeFunctionResult("decimals", ret).toArray();
182
187
  return result.length == 1 ? result[0] : result;
@@ -197,15 +202,12 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
197
202
  ): Promise<bigint> {
198
203
  try {
199
204
  if (preparedData?.ethCallResults && ethCallContext) {
200
- const iface = new Interface([
201
- "function balanceOf(address) view returns (uint256)",
202
- ]);
203
205
  const calldata = iface.encodeFunctionData("balanceOf", [who]);
204
- const key = makeEthCallKey({
206
+ const ethCallKey = makeEthCallKey({
205
207
  context: ethCallContext,
206
208
  calldata,
207
209
  });
208
- const ret = preparedData.ethCallResults[key];
210
+ const ret = preparedData.ethCallResults[ethCallKey];
209
211
  if (ret) {
210
212
  const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
211
213
  return result.length == 1 ? result[0] : result;
@@ -228,15 +230,12 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
228
230
  ): Promise<string> {
229
231
  try {
230
232
  if (preparedData?.ethCallResults && ethCallContext) {
231
- const iface = new Interface([
232
- "function symbol() view returns (bytes32)",
233
- ]);
234
233
  const calldata = iface.encodeFunctionData("symbol", []);
235
- const key = makeEthCallKey({
234
+ const ethCallKey = makeEthCallKey({
236
235
  context: ethCallContext,
237
236
  calldata,
238
237
  });
239
- const ret = preparedData.ethCallResults[key];
238
+ const ret = preparedData.ethCallResults[ethCallKey];
240
239
  if (ret) {
241
240
  const result = iface.decodeFunctionResult("symbol", ret).toArray();
242
241
  return result.length == 1 ? result[0] : result;
@@ -258,18 +257,15 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
258
257
  ): Promise<bigint> {
259
258
  try {
260
259
  if (preparedData?.ethCallResults && ethCallContext) {
261
- const iface = new Interface([
262
- "function allowance(address,address) view returns (uint256)",
263
- ]);
264
260
  const calldata = iface.encodeFunctionData("allowance", [
265
261
  owner,
266
262
  spender,
267
263
  ]);
268
- const key = makeEthCallKey({
264
+ const ethCallKey = makeEthCallKey({
269
265
  context: ethCallContext,
270
266
  calldata,
271
267
  });
272
- const ret = preparedData.ethCallResults[key];
268
+ const ret = preparedData.ethCallResults[ethCallKey];
273
269
  if (ret) {
274
270
  const result = iface.decodeFunctionResult("allowance", ret).toArray();
275
271
  return result.length == 1 ? result[0] : result;
@@ -298,18 +294,15 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
298
294
  ): Promise<boolean> {
299
295
  try {
300
296
  if (preparedData?.ethCallResults && ethCallContext) {
301
- const iface = new Interface([
302
- "function approve(address,uint256) nonpayable returns (bool)",
303
- ]);
304
297
  const calldata = iface.encodeFunctionData("approve", [
305
298
  spender,
306
299
  value,
307
300
  ]);
308
- const key = makeEthCallKey({
301
+ const ethCallKey = makeEthCallKey({
309
302
  context: ethCallContext,
310
303
  calldata,
311
304
  });
312
- const ret = preparedData.ethCallResults[key];
305
+ const ret = preparedData.ethCallResults[ethCallKey];
313
306
  if (ret) {
314
307
  const result = iface.decodeFunctionResult("approve", ret).toArray();
315
308
  return result.length == 1 ? result[0] : result;
@@ -333,19 +326,16 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
333
326
  ): Promise<boolean> {
334
327
  try {
335
328
  if (preparedData?.ethCallResults && ethCallContext) {
336
- const iface = new Interface([
337
- "function transferFrom(address,address,uint256) nonpayable returns (bool)",
338
- ]);
339
329
  const calldata = iface.encodeFunctionData("transferFrom", [
340
330
  from,
341
331
  to,
342
332
  value,
343
333
  ]);
344
- const key = makeEthCallKey({
334
+ const ethCallKey = makeEthCallKey({
345
335
  context: ethCallContext,
346
336
  calldata,
347
337
  });
348
- const ret = preparedData.ethCallResults[key];
338
+ const ret = preparedData.ethCallResults[ethCallKey];
349
339
  if (ret) {
350
340
  const result = iface
351
341
  .decodeFunctionResult("transferFrom", ret)
@@ -370,15 +360,12 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
370
360
  ): Promise<boolean> {
371
361
  try {
372
362
  if (preparedData?.ethCallResults && ethCallContext) {
373
- const iface = new Interface([
374
- "function transfer(address,uint256) nonpayable returns (bool)",
375
- ]);
376
363
  const calldata = iface.encodeFunctionData("transfer", [to, value]);
377
- const key = makeEthCallKey({
364
+ const ethCallKey = makeEthCallKey({
378
365
  context: ethCallContext,
379
366
  calldata,
380
367
  });
381
- const ret = preparedData.ethCallResults[key];
368
+ const ret = preparedData.ethCallResults[ethCallKey];
382
369
  if (ret) {
383
370
  const result = iface
384
371
  .decodeFunctionResult("transfer", ret)