@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
@@ -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) 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) returns ()",
163
+ "function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) returns ()",
164
+ "function setApprovalForAll(address operator, bool _approved) 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) returns ()",
169
+ ]);
170
+
154
171
  export class ERC721ContractView extends ContractView<ERC721> {
155
172
  constructor(contract: ERC721) {
156
173
  super(contract);
@@ -164,15 +181,12 @@ 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
- const key = makeEthCallKey({
185
+ const ethCallKey = makeEthCallKey({
172
186
  context: ethCallContext,
173
187
  calldata,
174
188
  });
175
- const ret = preparedData.ethCallResults[key];
189
+ const ret = preparedData.ethCallResults[ethCallKey];
176
190
  if (ret) {
177
191
  const result = iface
178
192
  .decodeFunctionResult("totalSupply", ret)
@@ -195,15 +209,12 @@ 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
- const key = makeEthCallKey({
213
+ const ethCallKey = makeEthCallKey({
203
214
  context: ethCallContext,
204
215
  calldata,
205
216
  });
206
- const ret = preparedData.ethCallResults[key];
217
+ const ret = preparedData.ethCallResults[ethCallKey];
207
218
  if (ret) {
208
219
  const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
209
220
  return result.length == 1 ? result[0] : result;
@@ -227,15 +238,12 @@ 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
- const key = makeEthCallKey({
242
+ const ethCallKey = makeEthCallKey({
235
243
  context: ethCallContext,
236
244
  calldata,
237
245
  });
238
- const ret = preparedData.ethCallResults[key];
246
+ const ret = preparedData.ethCallResults[ethCallKey];
239
247
  if (ret) {
240
248
  const result = iface
241
249
  .decodeFunctionResult("getApproved", ret)
@@ -262,18 +270,15 @@ 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,
271
276
  ]);
272
- const key = makeEthCallKey({
277
+ const ethCallKey = makeEthCallKey({
273
278
  context: ethCallContext,
274
279
  calldata,
275
280
  });
276
- const ret = preparedData.ethCallResults[key];
281
+ const ret = preparedData.ethCallResults[ethCallKey];
277
282
  if (ret) {
278
283
  const result = iface
279
284
  .decodeFunctionResult("isApprovedForAll", ret)
@@ -297,13 +302,12 @@ 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
- const key = makeEthCallKey({
306
+ const ethCallKey = makeEthCallKey({
303
307
  context: ethCallContext,
304
308
  calldata,
305
309
  });
306
- const ret = preparedData.ethCallResults[key];
310
+ const ret = preparedData.ethCallResults[ethCallKey];
307
311
  if (ret) {
308
312
  const result = iface.decodeFunctionResult("name", ret).toArray();
309
313
  return result.length == 1 ? result[0] : result;
@@ -324,15 +328,12 @@ 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
- const key = makeEthCallKey({
332
+ const ethCallKey = makeEthCallKey({
332
333
  context: ethCallContext,
333
334
  calldata,
334
335
  });
335
- const ret = preparedData.ethCallResults[key];
336
+ const ret = preparedData.ethCallResults[ethCallKey];
336
337
  if (ret) {
337
338
  const result = iface.decodeFunctionResult("ownerOf", ret).toArray();
338
339
  return result.length == 1 ? result[0] : result;
@@ -356,17 +357,14 @@ 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
  ]);
365
- const key = makeEthCallKey({
363
+ const ethCallKey = makeEthCallKey({
366
364
  context: ethCallContext,
367
365
  calldata,
368
366
  });
369
- const ret = preparedData.ethCallResults[key];
367
+ const ret = preparedData.ethCallResults[ethCallKey];
370
368
  if (ret) {
371
369
  const result = iface
372
370
  .decodeFunctionResult("supportsInterface", ret)
@@ -391,15 +389,12 @@ 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
- const key = makeEthCallKey({
393
+ const ethCallKey = makeEthCallKey({
399
394
  context: ethCallContext,
400
395
  calldata,
401
396
  });
402
- const ret = preparedData.ethCallResults[key];
397
+ const ret = preparedData.ethCallResults[ethCallKey];
403
398
  if (ret) {
404
399
  const result = iface.decodeFunctionResult("symbol", ret).toArray();
405
400
  return result.length == 1 ? result[0] : result;
@@ -420,15 +415,12 @@ 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
- const key = makeEthCallKey({
419
+ const ethCallKey = makeEthCallKey({
428
420
  context: ethCallContext,
429
421
  calldata,
430
422
  });
431
- const ret = preparedData.ethCallResults[key];
423
+ const ret = preparedData.ethCallResults[ethCallKey];
432
424
  if (ret) {
433
425
  const result = iface.decodeFunctionResult("tokenURI", ret).toArray();
434
426
  return result.length == 1 ? result[0] : result;
@@ -456,15 +448,12 @@ 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
- const key = makeEthCallKey({
452
+ const ethCallKey = makeEthCallKey({
464
453
  context: ethCallContext,
465
454
  calldata,
466
455
  });
467
- const ret = preparedData.ethCallResults[key];
456
+ const ret = preparedData.ethCallResults[ethCallKey];
468
457
  if (ret) {
469
458
  const result = iface.decodeFunctionResult("approve", ret).toArray();
470
459
  return result.length == 1 ? result[0] : result;
@@ -488,19 +477,16 @@ 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,
497
483
  tokenId,
498
484
  ]);
499
- const key = makeEthCallKey({
485
+ const ethCallKey = makeEthCallKey({
500
486
  context: ethCallContext,
501
487
  calldata,
502
488
  });
503
- const ret = preparedData.ethCallResults[key];
489
+ const ret = preparedData.ethCallResults[ethCallKey];
504
490
  if (ret) {
505
491
  const result = iface
506
492
  .decodeFunctionResult("safeTransferFrom", ret)
@@ -527,20 +513,17 @@ 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,
536
519
  tokenId,
537
520
  data,
538
521
  ]);
539
- const key = makeEthCallKey({
522
+ const ethCallKey = makeEthCallKey({
540
523
  context: ethCallContext,
541
524
  calldata,
542
525
  });
543
- const ret = preparedData.ethCallResults[key];
526
+ const ret = preparedData.ethCallResults[ethCallKey];
544
527
  if (ret) {
545
528
  const result = iface
546
529
  .decodeFunctionResult("safeTransferFrom", ret)
@@ -565,18 +548,15 @@ 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,
574
554
  ]);
575
- const key = makeEthCallKey({
555
+ const ethCallKey = makeEthCallKey({
576
556
  context: ethCallContext,
577
557
  calldata,
578
558
  });
579
- const ret = preparedData.ethCallResults[key];
559
+ const ret = preparedData.ethCallResults[ethCallKey];
580
560
  if (ret) {
581
561
  const result = iface
582
562
  .decodeFunctionResult("setApprovalForAll", ret)
@@ -602,19 +582,16 @@ 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,
611
588
  tokenId,
612
589
  ]);
613
- const key = makeEthCallKey({
590
+ const ethCallKey = makeEthCallKey({
614
591
  context: ethCallContext,
615
592
  calldata,
616
593
  });
617
- const ret = preparedData.ethCallResults[key];
594
+ const ret = preparedData.ethCallResults[ethCallKey];
618
595
  if (ret) {
619
596
  const result = iface
620
597
  .decodeFunctionResult("transferFrom", ret)
@@ -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) returns (bool)",
114
+ "function totalSupply() view returns (uint256)",
115
+ "function transferFrom(address src, address dst, uint256 wad) returns (bool)",
116
+ "function withdraw(uint256 wad) 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) 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,13 +135,12 @@ 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
- const key = makeEthCallKey({
139
+ const ethCallKey = makeEthCallKey({
127
140
  context: ethCallContext,
128
141
  calldata,
129
142
  });
130
- const ret = preparedData.ethCallResults[key];
143
+ const ret = preparedData.ethCallResults[ethCallKey];
131
144
  if (ret) {
132
145
  const result = iface.decodeFunctionResult("name", ret).toArray();
133
146
  return result.length == 1 ? result[0] : result;
@@ -147,15 +160,12 @@ 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
- const key = makeEthCallKey({
164
+ const ethCallKey = makeEthCallKey({
155
165
  context: ethCallContext,
156
166
  calldata,
157
167
  });
158
- const ret = preparedData.ethCallResults[key];
168
+ const ret = preparedData.ethCallResults[ethCallKey];
159
169
  if (ret) {
160
170
  const result = iface
161
171
  .decodeFunctionResult("totalSupply", ret)
@@ -177,15 +187,12 @@ 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
- const key = makeEthCallKey({
191
+ const ethCallKey = makeEthCallKey({
185
192
  context: ethCallContext,
186
193
  calldata,
187
194
  });
188
- const ret = preparedData.ethCallResults[key];
195
+ const ret = preparedData.ethCallResults[ethCallKey];
189
196
  if (ret) {
190
197
  const result = iface.decodeFunctionResult("decimals", ret).toArray();
191
198
  return result.length == 1 ? result[0] : result;
@@ -206,15 +213,12 @@ 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
- const key = makeEthCallKey({
217
+ const ethCallKey = makeEthCallKey({
214
218
  context: ethCallContext,
215
219
  calldata,
216
220
  });
217
- const ret = preparedData.ethCallResults[key];
221
+ const ret = preparedData.ethCallResults[ethCallKey];
218
222
  if (ret) {
219
223
  const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
220
224
  return result.length == 1 ? result[0] : result;
@@ -237,15 +241,12 @@ 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
- const key = makeEthCallKey({
245
+ const ethCallKey = makeEthCallKey({
245
246
  context: ethCallContext,
246
247
  calldata,
247
248
  });
248
- const ret = preparedData.ethCallResults[key];
249
+ const ret = preparedData.ethCallResults[ethCallKey];
249
250
  if (ret) {
250
251
  const result = iface.decodeFunctionResult("symbol", ret).toArray();
251
252
  return result.length == 1 ? result[0] : result;
@@ -267,15 +268,12 @@ 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
- const key = makeEthCallKey({
272
+ const ethCallKey = makeEthCallKey({
275
273
  context: ethCallContext,
276
274
  calldata,
277
275
  });
278
- const ret = preparedData.ethCallResults[key];
276
+ const ret = preparedData.ethCallResults[ethCallKey];
279
277
  if (ret) {
280
278
  const result = iface.decodeFunctionResult("allowance", ret).toArray();
281
279
  return result.length == 1 ? result[0] : result;
@@ -304,15 +302,12 @@ 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
- const key = makeEthCallKey({
306
+ const ethCallKey = makeEthCallKey({
312
307
  context: ethCallContext,
313
308
  calldata,
314
309
  });
315
- const ret = preparedData.ethCallResults[key];
310
+ const ret = preparedData.ethCallResults[ethCallKey];
316
311
  if (ret) {
317
312
  const result = iface.decodeFunctionResult("approve", ret).toArray();
318
313
  return result.length == 1 ? result[0] : result;
@@ -336,19 +331,16 @@ 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,
345
337
  wad,
346
338
  ]);
347
- const key = makeEthCallKey({
339
+ const ethCallKey = makeEthCallKey({
348
340
  context: ethCallContext,
349
341
  calldata,
350
342
  });
351
- const ret = preparedData.ethCallResults[key];
343
+ const ret = preparedData.ethCallResults[ethCallKey];
352
344
  if (ret) {
353
345
  const result = iface
354
346
  .decodeFunctionResult("transferFrom", ret)
@@ -372,15 +364,12 @@ 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
- const key = makeEthCallKey({
368
+ const ethCallKey = makeEthCallKey({
380
369
  context: ethCallContext,
381
370
  calldata,
382
371
  });
383
- const ret = preparedData.ethCallResults[key];
372
+ const ret = preparedData.ethCallResults[ethCallKey];
384
373
  if (ret) {
385
374
  const result = iface
386
375
  .decodeFunctionResult("withdraw", ret)
@@ -405,15 +394,12 @@ 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
- const key = makeEthCallKey({
398
+ const ethCallKey = makeEthCallKey({
413
399
  context: ethCallContext,
414
400
  calldata,
415
401
  });
416
- const ret = preparedData.ethCallResults[key];
402
+ const ret = preparedData.ethCallResults[ethCallKey];
417
403
  if (ret) {
418
404
  const result = iface
419
405
  .decodeFunctionResult("transfer", ret)
@@ -436,15 +422,12 @@ 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
- const key = makeEthCallKey({
426
+ const ethCallKey = makeEthCallKey({
444
427
  context: ethCallContext,
445
428
  calldata,
446
429
  });
447
- const ret = preparedData.ethCallResults[key];
430
+ const ret = preparedData.ethCallResults[ethCallKey];
448
431
  if (ret) {
449
432
  const result = iface.decodeFunctionResult("deposit", ret).toArray();
450
433
  return result.length == 1 ? result[0] : result;
@@ -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,17 +45,16 @@ 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(',') + ',' : ''
48
51
  }]
49
52
  )
50
- const key = makeEthCallKey({
53
+ const ethCallKey = makeEthCallKey({
51
54
  context: ethCallContext,
52
55
  calldata
53
56
  })
54
- const ret = preparedData.ethCallResults[key]
57
+ const ret = preparedData.ethCallResults[ethCallKey]
55
58
  if (ret) {
56
59
  const result = iface.decodeFunctionResult("${fn.name}", ret).toArray()
57
60
  return result.length == 1? result[0]: result
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  AbiOutputParameter,
3
3
  AbiParameter,
4
+ ArrayType,
5
+ EventArgDeclaration,
4
6
  EventDeclaration,
5
7
  FunctionDeclaration,
6
- getArgumentForSignature,
7
- getSignatureForFn
8
+ TupleType
8
9
  } from 'typechain'
9
10
  import { EvmType } from 'typechain/dist/parser/parseEvmType.js'
10
11
 
@@ -48,6 +49,13 @@ export function getFullSignatureForFunction(fn: FunctionDeclaration): string {
48
49
  .join(',')})`
49
50
  }
50
51
 
52
+ export function getFullSignatureWithOutputForFn(fn: FunctionDeclaration) {
53
+ return `${fn.name}(${fn.inputs.map((i) => getArgumentForSignature(i)).join(', ')}) ${fn.stateMutability != 'nonpayable' ? fn.stateMutability + ' ' : ''}returns (${fn.outputs
54
+ .map((i) => getOutputArgumentForSignature(i))
55
+ .filter((s) => s != '')
56
+ .join(', ')})`
57
+ }
58
+
51
59
  function getOutputArgumentForSignature(argument: AbiOutputParameter) {
52
60
  if (argument.type.type == 'void') {
53
61
  return ''
@@ -55,9 +63,26 @@ function getOutputArgumentForSignature(argument: AbiOutputParameter) {
55
63
  return getArgumentForSignature(argument as AbiParameter)
56
64
  }
57
65
 
58
- export function getFullSignatureWithOutputForFn(fn: FunctionDeclaration) {
59
- return `${getSignatureForFn(fn)} ${fn.stateMutability} returns (${fn.outputs
60
- .map((i) => getOutputArgumentForSignature(i))
61
- .filter((s) => s != '')
62
- .join(',')})`
66
+ function getArgumentForSignature(argument: EventArgDeclaration | AbiParameter): string {
67
+ if (argument.type.originalType === 'tuple') {
68
+ return getTypeWithName(
69
+ `(${(argument.type as TupleType).components.map((i) => getArgumentForSignature(i)).join(', ')})`,
70
+ argument.name
71
+ )
72
+ } else if (argument.type.originalType.startsWith('tuple')) {
73
+ const arr = argument.type as ArrayType
74
+ return getTypeWithName(
75
+ `${getArgumentForSignature({
76
+ name: '',
77
+ type: arr.itemType
78
+ })}[${arr.size?.toString() || ''}]`,
79
+ argument.name
80
+ )
81
+ } else {
82
+ return getTypeWithName(argument.type.originalType, argument.name)
83
+ }
84
+ }
85
+
86
+ function getTypeWithName(type: string, name?: string) {
87
+ return (name ?? '').length > 0 ? `${type} ${name}` : type
63
88
  }
@@ -1,10 +1,6 @@
1
1
  import { ID } from './types.js'
2
2
  import type { Entity as EntityStruct } from '@sentio/protos'
3
3
 
4
- export interface Entity {
5
- id: ID
6
- }
7
-
8
4
  export class LocalCache {
9
5
  private cache: Map<string, EntityStruct> = new Map()
10
6