@sentio/sdk 2.40.1-rc.2 → 2.40.1-rc.3

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 (38) hide show
  1. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  2. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +25 -69
  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 +10 -24
  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 +20 -52
  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 +11 -25
  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 +16 -40
  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 +13 -31
  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 +3 -1
  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/package.json +3 -3
  30. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +26 -69
  31. package/src/eth/builtin/internal/erc1155-processor.ts +11 -24
  32. package/src/eth/builtin/internal/erc20-processor.ts +21 -52
  33. package/src/eth/builtin/internal/erc20bytes-processor.ts +12 -25
  34. package/src/eth/builtin/internal/erc721-processor.ts +17 -40
  35. package/src/eth/builtin/internal/weth9-processor.ts +14 -31
  36. package/src/eth/codegen/file.ts +5 -0
  37. package/src/eth/codegen/function-calls.ts +4 -1
  38. package/src/eth/codegen/types.ts +29 -7
@@ -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) nonpayable returns (bool)",
173
+ "function balanceOf(address account) view returns (uint256)",
174
+ "function burn(uint256 amount) nonpayable returns ()",
175
+ "function burnFrom(address account, uint256 amount) nonpayable returns ()",
176
+ "function decimals() view returns (uint8)",
177
+ "function decreaseAllowance(address spender, uint256 subtractedValue) nonpayable returns (bool)",
178
+ "function increaseAllowance(address spender, uint256 addedValue) nonpayable returns (bool)",
179
+ "function locker() view returns (address)",
180
+ "function name() view returns (string)",
181
+ "function owner() view returns (address)",
182
+ "function renounceOwnership() nonpayable returns ()",
183
+ "function setLocker(address _locker) nonpayable returns ()",
184
+ "function symbol() view returns (string)",
185
+ "function totalSupply() view returns (uint256)",
186
+ "function transfer(address recipient, uint256 amount) nonpayable returns (bool)",
187
+ "function transferFrom(address sender, address recipient, uint256 amount) nonpayable returns (bool)",
188
+ "function transferOwnership(address newOwner) nonpayable returns ()",
189
+ ]);
190
+
170
191
  export class ERC20ContractView extends ContractView<ERC20> {
171
192
  constructor(contract: ERC20) {
172
193
  super(contract);
@@ -182,9 +203,6 @@ 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,
@@ -218,9 +236,6 @@ 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
240
  const ethCallKey = makeEthCallKey({
226
241
  context: ethCallContext,
@@ -249,9 +264,6 @@ 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
268
  const ethCallKey = makeEthCallKey({
257
269
  context: ethCallContext,
@@ -277,9 +289,6 @@ 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
293
  const ethCallKey = makeEthCallKey({
285
294
  context: ethCallContext,
@@ -305,7 +314,6 @@ 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
318
  const ethCallKey = makeEthCallKey({
311
319
  context: ethCallContext,
@@ -331,9 +339,6 @@ 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
343
  const ethCallKey = makeEthCallKey({
339
344
  context: ethCallContext,
@@ -359,9 +364,6 @@ 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
368
  const ethCallKey = makeEthCallKey({
367
369
  context: ethCallContext,
@@ -387,9 +389,6 @@ 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
393
  const ethCallKey = makeEthCallKey({
395
394
  context: ethCallContext,
@@ -422,9 +421,6 @@ 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,
@@ -455,9 +451,6 @@ 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
455
  const ethCallKey = makeEthCallKey({
463
456
  context: ethCallContext,
@@ -486,9 +479,6 @@ 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,
@@ -522,9 +512,6 @@ 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,
@@ -558,9 +545,6 @@ 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,
@@ -592,9 +576,6 @@ 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
580
  const ethCallKey = makeEthCallKey({
600
581
  context: ethCallContext,
@@ -624,9 +605,6 @@ 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
609
  const ethCallKey = makeEthCallKey({
632
610
  context: ethCallContext,
@@ -657,9 +635,6 @@ 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,
@@ -694,9 +669,6 @@ 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,
@@ -730,9 +702,6 @@ 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
  ]);
@@ -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) nonpayable returns (bool)",
105
+ "function totalSupply() view returns (uint256)",
106
+ "function transferFrom(address from, address to, uint256 value) nonpayable 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) nonpayable 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,7 +124,6 @@ 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
128
  const ethCallKey = makeEthCallKey({
118
129
  context: ethCallContext,
@@ -138,9 +149,6 @@ 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
153
  const ethCallKey = makeEthCallKey({
146
154
  context: ethCallContext,
@@ -168,9 +176,6 @@ 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
180
  const ethCallKey = makeEthCallKey({
176
181
  context: ethCallContext,
@@ -197,9 +202,6 @@ 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
206
  const ethCallKey = makeEthCallKey({
205
207
  context: ethCallContext,
@@ -228,9 +230,6 @@ 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
234
  const ethCallKey = makeEthCallKey({
236
235
  context: ethCallContext,
@@ -258,9 +257,6 @@ 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,
@@ -298,9 +294,6 @@ 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,
@@ -333,9 +326,6 @@ 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,
@@ -370,9 +360,6 @@ 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
364
  const ethCallKey = makeEthCallKey({
378
365
  context: ethCallContext,
@@ -151,6 +151,23 @@ export type TransferFromCallTrace = TypedCallTrace<
151
151
 
152
152
  const templateContract = ERC721__factory.connect("0x0", DummyProvider);
153
153
 
154
+ const iface = new Interface([
155
+ "function approve(address to, uint256 tokenId) nonpayable returns ()",
156
+ "function totalSupply() view returns (uint256)",
157
+ "function balanceOf(address owner) view returns (uint256 balance)",
158
+ "function getApproved(uint256 tokenId) view returns (address operator)",
159
+ "function isApprovedForAll(address owner, address operator) view returns (bool)",
160
+ "function name() view returns (string)",
161
+ "function ownerOf(uint256 tokenId) view returns (address owner)",
162
+ "function safeTransferFrom(address from, address to, uint256 tokenId) nonpayable returns ()",
163
+ "function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) nonpayable returns ()",
164
+ "function setApprovalForAll(address operator, bool _approved) nonpayable returns ()",
165
+ "function supportsInterface(bytes4 interfaceId) view returns (bool)",
166
+ "function symbol() view returns (string)",
167
+ "function tokenURI(uint256 tokenId) view returns (string)",
168
+ "function transferFrom(address from, address to, uint256 tokenId) nonpayable returns ()",
169
+ ]);
170
+
154
171
  export class ERC721ContractView extends ContractView<ERC721> {
155
172
  constructor(contract: ERC721) {
156
173
  super(contract);
@@ -164,9 +181,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
164
181
  ): Promise<bigint> {
165
182
  try {
166
183
  if (preparedData?.ethCallResults && ethCallContext) {
167
- const iface = new Interface([
168
- "function totalSupply() view returns (uint256)",
169
- ]);
170
184
  const calldata = iface.encodeFunctionData("totalSupply", []);
171
185
  const ethCallKey = makeEthCallKey({
172
186
  context: ethCallContext,
@@ -195,9 +209,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
195
209
  ): Promise<bigint> {
196
210
  try {
197
211
  if (preparedData?.ethCallResults && ethCallContext) {
198
- const iface = new Interface([
199
- "function balanceOf(address) view returns (uint256)",
200
- ]);
201
212
  const calldata = iface.encodeFunctionData("balanceOf", [owner]);
202
213
  const ethCallKey = makeEthCallKey({
203
214
  context: ethCallContext,
@@ -227,9 +238,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
227
238
  ): Promise<string> {
228
239
  try {
229
240
  if (preparedData?.ethCallResults && ethCallContext) {
230
- const iface = new Interface([
231
- "function getApproved(uint256) view returns (address)",
232
- ]);
233
241
  const calldata = iface.encodeFunctionData("getApproved", [tokenId]);
234
242
  const ethCallKey = makeEthCallKey({
235
243
  context: ethCallContext,
@@ -262,9 +270,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
262
270
  ): Promise<boolean> {
263
271
  try {
264
272
  if (preparedData?.ethCallResults && ethCallContext) {
265
- const iface = new Interface([
266
- "function isApprovedForAll(address,address) view returns (bool)",
267
- ]);
268
273
  const calldata = iface.encodeFunctionData("isApprovedForAll", [
269
274
  owner,
270
275
  operator,
@@ -297,7 +302,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
297
302
  ): Promise<string> {
298
303
  try {
299
304
  if (preparedData?.ethCallResults && ethCallContext) {
300
- const iface = new Interface(["function name() view returns (string)"]);
301
305
  const calldata = iface.encodeFunctionData("name", []);
302
306
  const ethCallKey = makeEthCallKey({
303
307
  context: ethCallContext,
@@ -324,9 +328,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
324
328
  ): Promise<string> {
325
329
  try {
326
330
  if (preparedData?.ethCallResults && ethCallContext) {
327
- const iface = new Interface([
328
- "function ownerOf(uint256) view returns (address)",
329
- ]);
330
331
  const calldata = iface.encodeFunctionData("ownerOf", [tokenId]);
331
332
  const ethCallKey = makeEthCallKey({
332
333
  context: ethCallContext,
@@ -356,9 +357,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
356
357
  ): Promise<boolean> {
357
358
  try {
358
359
  if (preparedData?.ethCallResults && ethCallContext) {
359
- const iface = new Interface([
360
- "function supportsInterface(bytes4) view returns (bool)",
361
- ]);
362
360
  const calldata = iface.encodeFunctionData("supportsInterface", [
363
361
  interfaceId,
364
362
  ]);
@@ -391,9 +389,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
391
389
  ): Promise<string> {
392
390
  try {
393
391
  if (preparedData?.ethCallResults && ethCallContext) {
394
- const iface = new Interface([
395
- "function symbol() view returns (string)",
396
- ]);
397
392
  const calldata = iface.encodeFunctionData("symbol", []);
398
393
  const ethCallKey = makeEthCallKey({
399
394
  context: ethCallContext,
@@ -420,9 +415,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
420
415
  ): Promise<string> {
421
416
  try {
422
417
  if (preparedData?.ethCallResults && ethCallContext) {
423
- const iface = new Interface([
424
- "function tokenURI(uint256) view returns (string)",
425
- ]);
426
418
  const calldata = iface.encodeFunctionData("tokenURI", [tokenId]);
427
419
  const ethCallKey = makeEthCallKey({
428
420
  context: ethCallContext,
@@ -456,9 +448,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
456
448
  ): Promise<void> {
457
449
  try {
458
450
  if (preparedData?.ethCallResults && ethCallContext) {
459
- const iface = new Interface([
460
- "function approve(address,uint256) nonpayable returns ()",
461
- ]);
462
451
  const calldata = iface.encodeFunctionData("approve", [to, tokenId]);
463
452
  const ethCallKey = makeEthCallKey({
464
453
  context: ethCallContext,
@@ -488,9 +477,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
488
477
  ): Promise<void> {
489
478
  try {
490
479
  if (preparedData?.ethCallResults && ethCallContext) {
491
- const iface = new Interface([
492
- "function safeTransferFrom(address,address,uint256) nonpayable returns ()",
493
- ]);
494
480
  const calldata = iface.encodeFunctionData("safeTransferFrom", [
495
481
  from,
496
482
  to,
@@ -527,9 +513,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
527
513
  ): Promise<void> {
528
514
  try {
529
515
  if (preparedData?.ethCallResults && ethCallContext) {
530
- const iface = new Interface([
531
- "function safeTransferFrom(address,address,uint256,bytes) nonpayable returns ()",
532
- ]);
533
516
  const calldata = iface.encodeFunctionData("safeTransferFrom", [
534
517
  from,
535
518
  to,
@@ -565,9 +548,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
565
548
  ): Promise<void> {
566
549
  try {
567
550
  if (preparedData?.ethCallResults && ethCallContext) {
568
- const iface = new Interface([
569
- "function setApprovalForAll(address,bool) nonpayable returns ()",
570
- ]);
571
551
  const calldata = iface.encodeFunctionData("setApprovalForAll", [
572
552
  operator,
573
553
  _approved,
@@ -602,9 +582,6 @@ export class ERC721ContractView extends ContractView<ERC721> {
602
582
  ): Promise<void> {
603
583
  try {
604
584
  if (preparedData?.ethCallResults && ethCallContext) {
605
- const iface = new Interface([
606
- "function transferFrom(address,address,uint256) nonpayable returns ()",
607
- ]);
608
585
  const calldata = iface.encodeFunctionData("transferFrom", [
609
586
  from,
610
587
  to,
@@ -108,6 +108,20 @@ export type AllowanceCallTrace = TypedCallTrace<
108
108
 
109
109
  const templateContract = WETH9__factory.connect("0x0", DummyProvider);
110
110
 
111
+ const iface = new Interface([
112
+ "function name() view returns (string)",
113
+ "function approve(address guy, uint256 wad) nonpayable returns (bool)",
114
+ "function totalSupply() view returns (uint256)",
115
+ "function transferFrom(address src, address dst, uint256 wad) nonpayable returns (bool)",
116
+ "function withdraw(uint256 wad) nonpayable returns ()",
117
+ "function decimals() view returns (uint8)",
118
+ "function balanceOf(address) view returns (uint256)",
119
+ "function symbol() view returns (string)",
120
+ "function transfer(address dst, uint256 wad) nonpayable returns (bool)",
121
+ "function deposit() payable returns ()",
122
+ "function allowance(address, address) view returns (uint256)",
123
+ ]);
124
+
111
125
  export class WETH9ContractView extends ContractView<WETH9> {
112
126
  constructor(contract: WETH9) {
113
127
  super(contract);
@@ -121,7 +135,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
121
135
  ): Promise<string> {
122
136
  try {
123
137
  if (preparedData?.ethCallResults && ethCallContext) {
124
- const iface = new Interface(["function name() view returns (string)"]);
125
138
  const calldata = iface.encodeFunctionData("name", []);
126
139
  const ethCallKey = makeEthCallKey({
127
140
  context: ethCallContext,
@@ -147,9 +160,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
147
160
  ): Promise<bigint> {
148
161
  try {
149
162
  if (preparedData?.ethCallResults && ethCallContext) {
150
- const iface = new Interface([
151
- "function totalSupply() view returns (uint256)",
152
- ]);
153
163
  const calldata = iface.encodeFunctionData("totalSupply", []);
154
164
  const ethCallKey = makeEthCallKey({
155
165
  context: ethCallContext,
@@ -177,9 +187,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
177
187
  ): Promise<bigint> {
178
188
  try {
179
189
  if (preparedData?.ethCallResults && ethCallContext) {
180
- const iface = new Interface([
181
- "function decimals() view returns (uint8)",
182
- ]);
183
190
  const calldata = iface.encodeFunctionData("decimals", []);
184
191
  const ethCallKey = makeEthCallKey({
185
192
  context: ethCallContext,
@@ -206,9 +213,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
206
213
  ): Promise<bigint> {
207
214
  try {
208
215
  if (preparedData?.ethCallResults && ethCallContext) {
209
- const iface = new Interface([
210
- "function balanceOf(address) view returns (uint256)",
211
- ]);
212
216
  const calldata = iface.encodeFunctionData("balanceOf", [arg0]);
213
217
  const ethCallKey = makeEthCallKey({
214
218
  context: ethCallContext,
@@ -237,9 +241,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
237
241
  ): Promise<string> {
238
242
  try {
239
243
  if (preparedData?.ethCallResults && ethCallContext) {
240
- const iface = new Interface([
241
- "function symbol() view returns (string)",
242
- ]);
243
244
  const calldata = iface.encodeFunctionData("symbol", []);
244
245
  const ethCallKey = makeEthCallKey({
245
246
  context: ethCallContext,
@@ -267,9 +268,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
267
268
  ): Promise<bigint> {
268
269
  try {
269
270
  if (preparedData?.ethCallResults && ethCallContext) {
270
- const iface = new Interface([
271
- "function allowance(address,address) view returns (uint256)",
272
- ]);
273
271
  const calldata = iface.encodeFunctionData("allowance", [arg0, arg1]);
274
272
  const ethCallKey = makeEthCallKey({
275
273
  context: ethCallContext,
@@ -304,9 +302,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
304
302
  ): Promise<boolean> {
305
303
  try {
306
304
  if (preparedData?.ethCallResults && ethCallContext) {
307
- const iface = new Interface([
308
- "function approve(address,uint256) nonpayable returns (bool)",
309
- ]);
310
305
  const calldata = iface.encodeFunctionData("approve", [guy, wad]);
311
306
  const ethCallKey = makeEthCallKey({
312
307
  context: ethCallContext,
@@ -336,9 +331,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
336
331
  ): Promise<boolean> {
337
332
  try {
338
333
  if (preparedData?.ethCallResults && ethCallContext) {
339
- const iface = new Interface([
340
- "function transferFrom(address,address,uint256) nonpayable returns (bool)",
341
- ]);
342
334
  const calldata = iface.encodeFunctionData("transferFrom", [
343
335
  src,
344
336
  dst,
@@ -372,9 +364,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
372
364
  ): Promise<void> {
373
365
  try {
374
366
  if (preparedData?.ethCallResults && ethCallContext) {
375
- const iface = new Interface([
376
- "function withdraw(uint256) nonpayable returns ()",
377
- ]);
378
367
  const calldata = iface.encodeFunctionData("withdraw", [wad]);
379
368
  const ethCallKey = makeEthCallKey({
380
369
  context: ethCallContext,
@@ -405,9 +394,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
405
394
  ): Promise<boolean> {
406
395
  try {
407
396
  if (preparedData?.ethCallResults && ethCallContext) {
408
- const iface = new Interface([
409
- "function transfer(address,uint256) nonpayable returns (bool)",
410
- ]);
411
397
  const calldata = iface.encodeFunctionData("transfer", [dst, wad]);
412
398
  const ethCallKey = makeEthCallKey({
413
399
  context: ethCallContext,
@@ -436,9 +422,6 @@ export class WETH9ContractView extends ContractView<WETH9> {
436
422
  ): Promise<void> {
437
423
  try {
438
424
  if (preparedData?.ethCallResults && ethCallContext) {
439
- const iface = new Interface([
440
- "function deposit() payable returns ()",
441
- ]);
442
425
  const calldata = iface.encodeFunctionData("deposit", []);
443
426
  const ethCallKey = makeEthCallKey({
444
427
  context: ethCallContext,
@@ -13,6 +13,7 @@ import {
13
13
  generateBoundFunctionCallEncoders,
14
14
  generateBoundViewFunctions,
15
15
  generateFunctionCallEncoders,
16
+ generateFunctionSignatures,
16
17
  generateViewFunctions
17
18
  } from './function-calls.js'
18
19
 
@@ -30,6 +31,10 @@ export function codeGenSentioFile(contract: Contract): string {
30
31
  ${Object.values(contract.functions).map(codegenCallTraceTypes).join('\n')}
31
32
 
32
33
  const templateContract = ${contract.name}__factory.connect("0x0", DummyProvider)
34
+
35
+ const iface = new Interface([${Object.values(contract.functions)
36
+ .filter((f) => !reservedKeywords.has(f[0].name))
37
+ .flatMap((fs) => generateFunctionSignatures(fs))}])
33
38
 
34
39
  export class ${contract.name}ContractView extends ContractView<${contract.name}> {
35
40
  constructor (contract: ${contract.name}) {
@@ -17,6 +17,10 @@ export function generateViewFunctions(view: boolean, functions: FunctionDeclarat
17
17
  return functions.flatMap((fn) => generateViewFunction(view, fn, includeArgTypes))
18
18
  }
19
19
 
20
+ export function generateFunctionSignatures(functions: FunctionDeclaration[]): string[] {
21
+ return functions.map((fn) => `"function ${getFullSignatureWithOutputForFn(fn)}"`)
22
+ }
23
+
20
24
  export function generateViewFunction(view: boolean, fn: FunctionDeclaration, includeArgTypes: boolean): string[] {
21
25
  const isView = fn.stateMutability === 'view' || fn.stateMutability === 'pure'
22
26
  if (view !== isView) {
@@ -41,7 +45,6 @@ export function generateViewFunction(view: boolean, fn: FunctionDeclaration, inc
41
45
  })}overrides?: Overrides, preparedData?: PreparedData, ethCallContext?: EthCallContext): ${generateReturnTypes(fn)} {
42
46
  try {
43
47
  if (preparedData?.ethCallResults && ethCallContext) {
44
- const iface = new Interface(["function ${getFullSignatureWithOutputForFn(fn)}"])
45
48
  const calldata = iface.encodeFunctionData(
46
49
  "${fn.name}",[${
47
50
  fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''