@sentio/sdk 2.0.0-rc.13 → 2.0.0-rc.15

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 (240) hide show
  1. package/lib/aptos/api.d.ts +5 -0
  2. package/lib/aptos/api.js +21 -0
  3. package/lib/aptos/api.js.map +1 -0
  4. package/lib/aptos/aptos-plugin.d.ts +14 -0
  5. package/lib/aptos/aptos-plugin.js +146 -0
  6. package/lib/aptos/aptos-plugin.js.map +1 -0
  7. package/lib/aptos/aptos-processor.d.ts +72 -0
  8. package/lib/aptos/aptos-processor.js +201 -0
  9. package/lib/aptos/aptos-processor.js.map +1 -0
  10. package/lib/aptos/builtin/0x1.d.ts +2140 -0
  11. package/lib/aptos/builtin/0x1.js +2727 -0
  12. package/lib/aptos/builtin/0x1.js.map +1 -0
  13. package/lib/aptos/builtin/0x3.d.ts +573 -0
  14. package/lib/aptos/builtin/0x3.js +496 -0
  15. package/lib/aptos/builtin/0x3.js.map +1 -0
  16. package/lib/aptos/builtin/index.d.ts +2 -0
  17. package/lib/aptos/builtin/index.js +6 -0
  18. package/lib/aptos/builtin/index.js.map +1 -0
  19. package/lib/aptos/codegen/codegen.d.ts +23 -0
  20. package/lib/aptos/codegen/codegen.js +388 -0
  21. package/lib/aptos/codegen/codegen.js.map +1 -0
  22. package/lib/aptos/codegen/index.d.ts +1 -0
  23. package/lib/aptos/codegen/index.js +2 -0
  24. package/lib/aptos/codegen/index.js.map +1 -0
  25. package/lib/aptos/codegen/typegen.d.ts +18 -0
  26. package/lib/aptos/codegen/typegen.js +145 -0
  27. package/lib/aptos/codegen/typegen.js.map +1 -0
  28. package/lib/aptos/codegen/typegen.test.d.ts +1 -0
  29. package/lib/aptos/codegen/typegen.test.js.map +1 -0
  30. package/lib/aptos/context.d.ts +21 -0
  31. package/lib/aptos/context.js +59 -0
  32. package/lib/aptos/context.js.map +1 -0
  33. package/lib/aptos/index.d.ts +9 -0
  34. package/lib/aptos/index.js +8 -0
  35. package/lib/aptos/index.js.map +1 -0
  36. package/lib/aptos/models.d.ts +37 -0
  37. package/lib/aptos/models.js +2 -0
  38. package/lib/aptos/models.js.map +1 -0
  39. package/lib/aptos/move-coder.d.ts +22 -0
  40. package/lib/aptos/move-coder.js +164 -0
  41. package/lib/aptos/move-coder.js.map +1 -0
  42. package/lib/aptos/move-types.d.ts +10 -0
  43. package/lib/aptos/move-types.js +2 -0
  44. package/lib/aptos/move-types.js.map +1 -0
  45. package/lib/aptos/network.d.ts +11 -0
  46. package/lib/aptos/network.js +27 -0
  47. package/lib/aptos/network.js.map +1 -0
  48. package/lib/aptos/run-codegen.d.ts +1 -0
  49. package/lib/aptos/run-codegen.js +12 -0
  50. package/lib/aptos/run-codegen.js.map +1 -0
  51. package/lib/aptos/tests/aptos.test.d.ts +1 -0
  52. package/lib/aptos/tests/aptos.test.js.map +1 -0
  53. package/lib/aptos/tests/souffl3.d.ts +1 -0
  54. package/lib/aptos/tests/souffl3.js +44 -0
  55. package/lib/aptos/tests/souffl3.js.map +1 -0
  56. package/lib/aptos/tests/types/index.d.ts +3 -0
  57. package/lib/aptos/tests/types/index.js +7 -0
  58. package/lib/aptos/tests/types/index.js.map +1 -0
  59. package/lib/aptos/tests/types/reserved.d.ts +445 -0
  60. package/lib/aptos/tests/types/reserved.js +301 -0
  61. package/lib/aptos/tests/types/reserved.js.map +1 -0
  62. package/lib/aptos/tests/types/soffl3.d.ts +1065 -0
  63. package/lib/aptos/tests/types/soffl3.js +548 -0
  64. package/lib/aptos/tests/types/soffl3.js.map +1 -0
  65. package/lib/aptos/tests/types/souffle.d.ts +440 -0
  66. package/lib/aptos/tests/types/souffle.js +295 -0
  67. package/lib/aptos/tests/types/souffle.js.map +1 -0
  68. package/lib/aptos/types.d.ts +9 -0
  69. package/lib/aptos/types.js +130 -0
  70. package/lib/aptos/types.js.map +1 -0
  71. package/lib/aptos/types.test.d.ts +1 -0
  72. package/lib/aptos/types.test.js.map +1 -0
  73. package/lib/aptos/utils.d.ts +7 -0
  74. package/lib/aptos/utils.js +20 -0
  75. package/lib/aptos/utils.js.map +1 -0
  76. package/lib/builtin/internal/eacaggregatorproxy_processor.js +90 -180
  77. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
  78. package/lib/builtin/internal/erc1155_processor.js +25 -50
  79. package/lib/builtin/internal/erc1155_processor.js.map +1 -1
  80. package/lib/builtin/internal/erc20_processor.js +40 -80
  81. package/lib/builtin/internal/erc20_processor.js.map +1 -1
  82. package/lib/builtin/internal/erc20bytes_processor.js +30 -60
  83. package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
  84. package/lib/builtin/internal/erc721_processor.js +45 -90
  85. package/lib/builtin/internal/erc721_processor.js.map +1 -1
  86. package/lib/builtin/internal/weth9_processor.js +30 -60
  87. package/lib/builtin/internal/weth9_processor.js.map +1 -1
  88. package/lib/{utils/chain.d.ts → chain.d.ts} +0 -0
  89. package/lib/{utils/chain.js → chain.js} +0 -0
  90. package/lib/chain.js.map +1 -0
  91. package/lib/core/context.js +1 -1
  92. package/lib/core/context.js.map +1 -1
  93. package/lib/core/sui-plugin.js +1 -1
  94. package/lib/core/sui-plugin.js.map +1 -1
  95. package/lib/error.d.ts +1 -1
  96. package/lib/error.js +10 -12
  97. package/lib/error.js.map +1 -1
  98. package/lib/eth/base-processor-template.d.ts +3 -3
  99. package/lib/eth/base-processor-template.js.map +1 -1
  100. package/lib/eth/base-processor.d.ts +3 -3
  101. package/lib/eth/base-processor.js.map +1 -1
  102. package/lib/eth/{eth-event.d.ts → eth.d.ts} +1 -1
  103. package/lib/eth/eth.js +2 -0
  104. package/lib/eth/eth.js.map +1 -0
  105. package/lib/eth/index.d.ts +1 -0
  106. package/lib/eth/index.js +1 -0
  107. package/lib/eth/index.js.map +1 -1
  108. package/lib/index.d.ts +2 -2
  109. package/lib/index.js +2 -2
  110. package/lib/index.js.map +1 -1
  111. package/lib/solana/builtin/index.d.ts +1 -0
  112. package/lib/solana/builtin/index.js +2 -0
  113. package/lib/solana/builtin/index.js.map +1 -0
  114. package/lib/solana/builtin/spl-token-processor.d.ts +39 -0
  115. package/lib/solana/builtin/spl-token-processor.js +254 -0
  116. package/lib/solana/builtin/spl-token-processor.js.map +1 -0
  117. package/lib/solana/builtin/types.d.ts +427 -0
  118. package/lib/solana/builtin/types.js +200 -0
  119. package/lib/solana/builtin/types.js.map +1 -0
  120. package/lib/solana/codegen/codegen.d.ts +1 -0
  121. package/lib/solana/codegen/codegen.js +122 -0
  122. package/lib/solana/codegen/codegen.js.map +1 -0
  123. package/lib/solana/codegen/index.d.ts +1 -0
  124. package/lib/solana/codegen/index.js +2 -0
  125. package/lib/solana/codegen/index.js.map +1 -0
  126. package/lib/solana/index.d.ts +4 -0
  127. package/lib/solana/index.js +5 -0
  128. package/lib/solana/index.js.map +1 -0
  129. package/lib/solana/run-codegen.d.ts +2 -0
  130. package/lib/solana/run-codegen.js +12 -0
  131. package/lib/solana/run-codegen.js.map +1 -0
  132. package/lib/solana/solana-context.d.ts +9 -0
  133. package/lib/solana/solana-context.js +28 -0
  134. package/lib/solana/solana-context.js.map +1 -0
  135. package/lib/solana/solana-options.d.ts +10 -0
  136. package/lib/solana/solana-options.js +10 -0
  137. package/lib/solana/solana-options.js.map +1 -0
  138. package/lib/solana/solana-plugin.d.ts +9 -0
  139. package/lib/solana/solana-plugin.js +87 -0
  140. package/lib/solana/solana-plugin.js.map +1 -0
  141. package/lib/solana/solana-processor.d.ts +43 -0
  142. package/lib/solana/solana-processor.js +72 -0
  143. package/lib/solana/solana-processor.js.map +1 -0
  144. package/lib/solana/tests/solana.test.d.ts +1 -0
  145. package/lib/solana/tests/solana.test.js.map +1 -0
  146. package/lib/solana/tests/types/basic_1.d.ts +26 -0
  147. package/lib/solana/tests/types/basic_1.js +63 -0
  148. package/lib/solana/tests/types/basic_1.js.map +1 -0
  149. package/lib/solana/tests/types/basic_1_processor.d.ts +21 -0
  150. package/lib/solana/tests/types/basic_1_processor.js +35 -0
  151. package/lib/solana/tests/types/basic_1_processor.js.map +1 -0
  152. package/lib/solana/tests/types/token_bridge.d.ts +29 -0
  153. package/lib/solana/tests/types/token_bridge.js +938 -0
  154. package/lib/solana/tests/types/token_bridge.js.map +1 -0
  155. package/lib/solana/tests/types/token_bridge_processor.d.ts +212 -0
  156. package/lib/solana/tests/types/token_bridge_processor.js +134 -0
  157. package/lib/solana/tests/types/token_bridge_processor.js.map +1 -0
  158. package/lib/solana/tests/wormhole-token-bridge.d.ts +15 -0
  159. package/lib/solana/tests/wormhole-token-bridge.js +79 -0
  160. package/lib/solana/tests/wormhole-token-bridge.js.map +1 -0
  161. package/lib/target-ethers-sentio/view-function.cjs +4 -9
  162. package/lib/target-ethers-sentio/view-function.cjs.map +1 -1
  163. package/lib/testing/test-processor-server.js +1 -1
  164. package/lib/testing/test-processor-server.js.map +1 -1
  165. package/lib/testing/test-provider.js +1 -1
  166. package/lib/testing/test-provider.js.map +1 -1
  167. package/lib/utils/index.d.ts +0 -1
  168. package/lib/utils/index.js +0 -1
  169. package/lib/utils/index.js.map +1 -1
  170. package/package.json +34 -11
  171. package/src/aptos/abis/0x1.json +9205 -0
  172. package/src/aptos/abis/0x3.json +1515 -0
  173. package/src/aptos/api.ts +23 -0
  174. package/src/aptos/aptos-plugin.ts +183 -0
  175. package/src/aptos/aptos-processor.ts +331 -0
  176. package/src/aptos/builtin/0x1.ts +4911 -0
  177. package/src/aptos/builtin/0x3.ts +1092 -0
  178. package/src/aptos/builtin/index.ts +5 -0
  179. package/src/aptos/codegen/codegen.ts +470 -0
  180. package/src/aptos/codegen/index.ts +1 -0
  181. package/src/aptos/codegen/tsconfig.json +8 -0
  182. package/src/aptos/codegen/typegen.ts +165 -0
  183. package/src/aptos/context.ts +72 -0
  184. package/src/aptos/index.ts +10 -0
  185. package/src/aptos/models.ts +47 -0
  186. package/src/aptos/move-coder.ts +201 -0
  187. package/src/aptos/move-types.ts +11 -0
  188. package/src/aptos/network.ts +29 -0
  189. package/src/aptos/run-codegen.ts +13 -0
  190. package/src/aptos/tests/abis/reserved.json +402 -0
  191. package/src/aptos/tests/abis/soffl3.json +1411 -0
  192. package/src/aptos/tests/abis/souffle.json +389 -0
  193. package/src/aptos/tests/souffl3.ts +57 -0
  194. package/src/aptos/tests/types/index.ts +6 -0
  195. package/src/aptos/tests/types/reserved.ts +881 -0
  196. package/src/aptos/tests/types/soffl3.ts +1820 -0
  197. package/src/aptos/tests/types/souffle.ts +880 -0
  198. package/src/aptos/types.ts +149 -0
  199. package/src/aptos/utils.ts +26 -0
  200. package/src/builtin/internal/eacaggregatorproxy_processor.ts +90 -162
  201. package/src/builtin/internal/erc1155_processor.ts +25 -49
  202. package/src/builtin/internal/erc20_processor.ts +40 -72
  203. package/src/builtin/internal/erc20bytes_processor.ts +30 -54
  204. package/src/builtin/internal/erc721_processor.ts +45 -81
  205. package/src/builtin/internal/weth9_processor.ts +30 -54
  206. package/src/{utils/chain.ts → chain.ts} +0 -0
  207. package/src/core/context.ts +1 -1
  208. package/src/core/sui-plugin.ts +1 -1
  209. package/src/error.ts +12 -14
  210. package/src/eth/base-processor-template.ts +3 -3
  211. package/src/eth/base-processor.ts +4 -4
  212. package/src/eth/{eth-event.ts → eth.ts} +1 -1
  213. package/src/eth/index.ts +2 -0
  214. package/src/index.ts +2 -2
  215. package/src/solana/builtin/index.ts +1 -0
  216. package/src/solana/builtin/spl-token-processor.ts +298 -0
  217. package/src/solana/builtin/types.ts +279 -0
  218. package/src/solana/codegen/codegen.ts +140 -0
  219. package/src/solana/codegen/index.ts +1 -0
  220. package/src/solana/codegen/tsconfig.json +8 -0
  221. package/src/solana/index.ts +4 -0
  222. package/src/solana/run-codegen.ts +13 -0
  223. package/src/solana/solana-context.ts +30 -0
  224. package/src/solana/solana-options.ts +11 -0
  225. package/src/solana/solana-plugin.ts +103 -0
  226. package/src/solana/solana-processor.ts +102 -0
  227. package/src/solana/tests/abis/basic_1.json +62 -0
  228. package/src/solana/tests/abis/token_bridge.json +937 -0
  229. package/src/solana/tests/types/basic_1.ts +62 -0
  230. package/src/solana/tests/types/basic_1_processor.ts +42 -0
  231. package/src/solana/tests/types/token_bridge.ts +937 -0
  232. package/src/solana/tests/types/token_bridge_processor.ts +150 -0
  233. package/src/solana/tests/wormhole-token-bridge.ts +96 -0
  234. package/src/target-ethers-sentio/view-function.cts +4 -11
  235. package/src/testing/test-processor-server.ts +1 -1
  236. package/src/testing/test-provider.ts +1 -1
  237. package/src/utils/index.ts +0 -1
  238. package/lib/eth/eth-event.js +0 -2
  239. package/lib/eth/eth-event.js.map +0 -1
  240. package/lib/utils/chain.js.map +0 -1
@@ -266,107 +266,75 @@ export class ERC20BoundContractView extends BoundContractView<
266
266
  spender: string,
267
267
  overrides?: Overrides
268
268
  ): Promise<bigint> {
269
- try {
270
- if (!overrides && this.context) {
271
- overrides = {
272
- blockTag: toBlockTag(this.context.blockNumber),
273
- };
274
- }
275
- return await this.view.allowance(owner, spender, overrides || {});
276
- } catch (e) {
277
- throw transformEtherError(e, this.context);
269
+ if (!overrides && this.context) {
270
+ overrides = {
271
+ blockTag: toBlockTag(this.context.blockNumber),
272
+ };
278
273
  }
274
+ return await this.view.allowance(owner, spender, overrides || {});
279
275
  }
280
276
 
281
277
  async balanceOf(account: string, overrides?: Overrides): Promise<bigint> {
282
- try {
283
- if (!overrides && this.context) {
284
- overrides = {
285
- blockTag: toBlockTag(this.context.blockNumber),
286
- };
287
- }
288
- return await this.view.balanceOf(account, overrides || {});
289
- } catch (e) {
290
- throw transformEtherError(e, this.context);
278
+ if (!overrides && this.context) {
279
+ overrides = {
280
+ blockTag: toBlockTag(this.context.blockNumber),
281
+ };
291
282
  }
283
+ return await this.view.balanceOf(account, overrides || {});
292
284
  }
293
285
 
294
286
  async decimals(overrides?: Overrides): Promise<bigint> {
295
- try {
296
- if (!overrides && this.context) {
297
- overrides = {
298
- blockTag: toBlockTag(this.context.blockNumber),
299
- };
300
- }
301
- return await this.view.decimals(overrides || {});
302
- } catch (e) {
303
- throw transformEtherError(e, this.context);
287
+ if (!overrides && this.context) {
288
+ overrides = {
289
+ blockTag: toBlockTag(this.context.blockNumber),
290
+ };
304
291
  }
292
+ return await this.view.decimals(overrides || {});
305
293
  }
306
294
 
307
295
  async locker(overrides?: Overrides): Promise<string> {
308
- try {
309
- if (!overrides && this.context) {
310
- overrides = {
311
- blockTag: toBlockTag(this.context.blockNumber),
312
- };
313
- }
314
- return await this.view.locker(overrides || {});
315
- } catch (e) {
316
- throw transformEtherError(e, this.context);
296
+ if (!overrides && this.context) {
297
+ overrides = {
298
+ blockTag: toBlockTag(this.context.blockNumber),
299
+ };
317
300
  }
301
+ return await this.view.locker(overrides || {});
318
302
  }
319
303
 
320
304
  async name(overrides?: Overrides): Promise<string> {
321
- try {
322
- if (!overrides && this.context) {
323
- overrides = {
324
- blockTag: toBlockTag(this.context.blockNumber),
325
- };
326
- }
327
- return await this.view.name(overrides || {});
328
- } catch (e) {
329
- throw transformEtherError(e, this.context);
305
+ if (!overrides && this.context) {
306
+ overrides = {
307
+ blockTag: toBlockTag(this.context.blockNumber),
308
+ };
330
309
  }
310
+ return await this.view.name(overrides || {});
331
311
  }
332
312
 
333
313
  async owner(overrides?: Overrides): Promise<string> {
334
- try {
335
- if (!overrides && this.context) {
336
- overrides = {
337
- blockTag: toBlockTag(this.context.blockNumber),
338
- };
339
- }
340
- return await this.view.owner(overrides || {});
341
- } catch (e) {
342
- throw transformEtherError(e, this.context);
314
+ if (!overrides && this.context) {
315
+ overrides = {
316
+ blockTag: toBlockTag(this.context.blockNumber),
317
+ };
343
318
  }
319
+ return await this.view.owner(overrides || {});
344
320
  }
345
321
 
346
322
  async symbol(overrides?: Overrides): Promise<string> {
347
- try {
348
- if (!overrides && this.context) {
349
- overrides = {
350
- blockTag: toBlockTag(this.context.blockNumber),
351
- };
352
- }
353
- return await this.view.symbol(overrides || {});
354
- } catch (e) {
355
- throw transformEtherError(e, this.context);
323
+ if (!overrides && this.context) {
324
+ overrides = {
325
+ blockTag: toBlockTag(this.context.blockNumber),
326
+ };
356
327
  }
328
+ return await this.view.symbol(overrides || {});
357
329
  }
358
330
 
359
331
  async totalSupply(overrides?: Overrides): Promise<bigint> {
360
- try {
361
- if (!overrides && this.context) {
362
- overrides = {
363
- blockTag: toBlockTag(this.context.blockNumber),
364
- };
365
- }
366
- return await this.view.totalSupply(overrides || {});
367
- } catch (e) {
368
- throw transformEtherError(e, this.context);
332
+ if (!overrides && this.context) {
333
+ overrides = {
334
+ blockTag: toBlockTag(this.context.blockNumber),
335
+ };
369
336
  }
337
+ return await this.view.totalSupply(overrides || {});
370
338
  }
371
339
  }
372
340
 
@@ -172,68 +172,48 @@ export class ERC20BytesBoundContractView extends BoundContractView<
172
172
  ERC20BytesContractView
173
173
  > {
174
174
  async name(overrides?: Overrides): Promise<string> {
175
- try {
176
- if (!overrides && this.context) {
177
- overrides = {
178
- blockTag: toBlockTag(this.context.blockNumber),
179
- };
180
- }
181
- return await this.view.name(overrides || {});
182
- } catch (e) {
183
- throw transformEtherError(e, this.context);
175
+ if (!overrides && this.context) {
176
+ overrides = {
177
+ blockTag: toBlockTag(this.context.blockNumber),
178
+ };
184
179
  }
180
+ return await this.view.name(overrides || {});
185
181
  }
186
182
 
187
183
  async totalSupply(overrides?: Overrides): Promise<bigint> {
188
- try {
189
- if (!overrides && this.context) {
190
- overrides = {
191
- blockTag: toBlockTag(this.context.blockNumber),
192
- };
193
- }
194
- return await this.view.totalSupply(overrides || {});
195
- } catch (e) {
196
- throw transformEtherError(e, this.context);
184
+ if (!overrides && this.context) {
185
+ overrides = {
186
+ blockTag: toBlockTag(this.context.blockNumber),
187
+ };
197
188
  }
189
+ return await this.view.totalSupply(overrides || {});
198
190
  }
199
191
 
200
192
  async decimals(overrides?: Overrides): Promise<bigint> {
201
- try {
202
- if (!overrides && this.context) {
203
- overrides = {
204
- blockTag: toBlockTag(this.context.blockNumber),
205
- };
206
- }
207
- return await this.view.decimals(overrides || {});
208
- } catch (e) {
209
- throw transformEtherError(e, this.context);
193
+ if (!overrides && this.context) {
194
+ overrides = {
195
+ blockTag: toBlockTag(this.context.blockNumber),
196
+ };
210
197
  }
198
+ return await this.view.decimals(overrides || {});
211
199
  }
212
200
 
213
201
  async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
214
- try {
215
- if (!overrides && this.context) {
216
- overrides = {
217
- blockTag: toBlockTag(this.context.blockNumber),
218
- };
219
- }
220
- return await this.view.balanceOf(who, overrides || {});
221
- } catch (e) {
222
- throw transformEtherError(e, this.context);
202
+ if (!overrides && this.context) {
203
+ overrides = {
204
+ blockTag: toBlockTag(this.context.blockNumber),
205
+ };
223
206
  }
207
+ return await this.view.balanceOf(who, overrides || {});
224
208
  }
225
209
 
226
210
  async symbol(overrides?: Overrides): Promise<string> {
227
- try {
228
- if (!overrides && this.context) {
229
- overrides = {
230
- blockTag: toBlockTag(this.context.blockNumber),
231
- };
232
- }
233
- return await this.view.symbol(overrides || {});
234
- } catch (e) {
235
- throw transformEtherError(e, this.context);
211
+ if (!overrides && this.context) {
212
+ overrides = {
213
+ blockTag: toBlockTag(this.context.blockNumber),
214
+ };
236
215
  }
216
+ return await this.view.symbol(overrides || {});
237
217
  }
238
218
 
239
219
  async allowance(
@@ -241,16 +221,12 @@ export class ERC20BytesBoundContractView extends BoundContractView<
241
221
  spender: string,
242
222
  overrides?: Overrides
243
223
  ): Promise<bigint> {
244
- try {
245
- if (!overrides && this.context) {
246
- overrides = {
247
- blockTag: toBlockTag(this.context.blockNumber),
248
- };
249
- }
250
- return await this.view.allowance(owner, spender, overrides || {});
251
- } catch (e) {
252
- throw transformEtherError(e, this.context);
224
+ if (!overrides && this.context) {
225
+ overrides = {
226
+ blockTag: toBlockTag(this.context.blockNumber),
227
+ };
253
228
  }
229
+ return await this.view.allowance(owner, spender, overrides || {});
254
230
  }
255
231
  }
256
232
 
@@ -273,45 +273,33 @@ export class ERC721BoundContractView extends BoundContractView<
273
273
  ERC721ContractView
274
274
  > {
275
275
  async totalSupply(overrides?: Overrides): Promise<bigint> {
276
- try {
277
- if (!overrides && this.context) {
278
- overrides = {
279
- blockTag: toBlockTag(this.context.blockNumber),
280
- };
281
- }
282
- return await this.view.totalSupply(overrides || {});
283
- } catch (e) {
284
- throw transformEtherError(e, this.context);
276
+ if (!overrides && this.context) {
277
+ overrides = {
278
+ blockTag: toBlockTag(this.context.blockNumber),
279
+ };
285
280
  }
281
+ return await this.view.totalSupply(overrides || {});
286
282
  }
287
283
 
288
284
  async balanceOf(owner: string, overrides?: Overrides): Promise<bigint> {
289
- try {
290
- if (!overrides && this.context) {
291
- overrides = {
292
- blockTag: toBlockTag(this.context.blockNumber),
293
- };
294
- }
295
- return await this.view.balanceOf(owner, overrides || {});
296
- } catch (e) {
297
- throw transformEtherError(e, this.context);
285
+ if (!overrides && this.context) {
286
+ overrides = {
287
+ blockTag: toBlockTag(this.context.blockNumber),
288
+ };
298
289
  }
290
+ return await this.view.balanceOf(owner, overrides || {});
299
291
  }
300
292
 
301
293
  async getApproved(
302
294
  tokenId: BigNumberish,
303
295
  overrides?: Overrides
304
296
  ): Promise<string> {
305
- try {
306
- if (!overrides && this.context) {
307
- overrides = {
308
- blockTag: toBlockTag(this.context.blockNumber),
309
- };
310
- }
311
- return await this.view.getApproved(tokenId, overrides || {});
312
- } catch (e) {
313
- throw transformEtherError(e, this.context);
297
+ if (!overrides && this.context) {
298
+ overrides = {
299
+ blockTag: toBlockTag(this.context.blockNumber),
300
+ };
314
301
  }
302
+ return await this.view.getApproved(tokenId, overrides || {});
315
303
  }
316
304
 
317
305
  async isApprovedForAll(
@@ -319,87 +307,63 @@ export class ERC721BoundContractView extends BoundContractView<
319
307
  operator: string,
320
308
  overrides?: Overrides
321
309
  ): Promise<boolean> {
322
- try {
323
- if (!overrides && this.context) {
324
- overrides = {
325
- blockTag: toBlockTag(this.context.blockNumber),
326
- };
327
- }
328
- return await this.view.isApprovedForAll(owner, operator, overrides || {});
329
- } catch (e) {
330
- throw transformEtherError(e, this.context);
310
+ if (!overrides && this.context) {
311
+ overrides = {
312
+ blockTag: toBlockTag(this.context.blockNumber),
313
+ };
331
314
  }
315
+ return await this.view.isApprovedForAll(owner, operator, overrides || {});
332
316
  }
333
317
 
334
318
  async name(overrides?: Overrides): Promise<string> {
335
- try {
336
- if (!overrides && this.context) {
337
- overrides = {
338
- blockTag: toBlockTag(this.context.blockNumber),
339
- };
340
- }
341
- return await this.view.name(overrides || {});
342
- } catch (e) {
343
- throw transformEtherError(e, this.context);
319
+ if (!overrides && this.context) {
320
+ overrides = {
321
+ blockTag: toBlockTag(this.context.blockNumber),
322
+ };
344
323
  }
324
+ return await this.view.name(overrides || {});
345
325
  }
346
326
 
347
327
  async ownerOf(tokenId: BigNumberish, overrides?: Overrides): Promise<string> {
348
- try {
349
- if (!overrides && this.context) {
350
- overrides = {
351
- blockTag: toBlockTag(this.context.blockNumber),
352
- };
353
- }
354
- return await this.view.ownerOf(tokenId, overrides || {});
355
- } catch (e) {
356
- throw transformEtherError(e, this.context);
328
+ if (!overrides && this.context) {
329
+ overrides = {
330
+ blockTag: toBlockTag(this.context.blockNumber),
331
+ };
357
332
  }
333
+ return await this.view.ownerOf(tokenId, overrides || {});
358
334
  }
359
335
 
360
336
  async supportsInterface(
361
337
  interfaceId: BytesLike,
362
338
  overrides?: Overrides
363
339
  ): Promise<boolean> {
364
- try {
365
- if (!overrides && this.context) {
366
- overrides = {
367
- blockTag: toBlockTag(this.context.blockNumber),
368
- };
369
- }
370
- return await this.view.supportsInterface(interfaceId, overrides || {});
371
- } catch (e) {
372
- throw transformEtherError(e, this.context);
340
+ if (!overrides && this.context) {
341
+ overrides = {
342
+ blockTag: toBlockTag(this.context.blockNumber),
343
+ };
373
344
  }
345
+ return await this.view.supportsInterface(interfaceId, overrides || {});
374
346
  }
375
347
 
376
348
  async symbol(overrides?: Overrides): Promise<string> {
377
- try {
378
- if (!overrides && this.context) {
379
- overrides = {
380
- blockTag: toBlockTag(this.context.blockNumber),
381
- };
382
- }
383
- return await this.view.symbol(overrides || {});
384
- } catch (e) {
385
- throw transformEtherError(e, this.context);
349
+ if (!overrides && this.context) {
350
+ overrides = {
351
+ blockTag: toBlockTag(this.context.blockNumber),
352
+ };
386
353
  }
354
+ return await this.view.symbol(overrides || {});
387
355
  }
388
356
 
389
357
  async tokenURI(
390
358
  tokenId: BigNumberish,
391
359
  overrides?: Overrides
392
360
  ): Promise<string> {
393
- try {
394
- if (!overrides && this.context) {
395
- overrides = {
396
- blockTag: toBlockTag(this.context.blockNumber),
397
- };
398
- }
399
- return await this.view.tokenURI(tokenId, overrides || {});
400
- } catch (e) {
401
- throw transformEtherError(e, this.context);
361
+ if (!overrides && this.context) {
362
+ overrides = {
363
+ blockTag: toBlockTag(this.context.blockNumber),
364
+ };
402
365
  }
366
+ return await this.view.tokenURI(tokenId, overrides || {});
403
367
  }
404
368
  }
405
369
 
@@ -182,68 +182,48 @@ export class WETH9BoundContractView extends BoundContractView<
182
182
  WETH9ContractView
183
183
  > {
184
184
  async name(overrides?: Overrides): Promise<string> {
185
- try {
186
- if (!overrides && this.context) {
187
- overrides = {
188
- blockTag: toBlockTag(this.context.blockNumber),
189
- };
190
- }
191
- return await this.view.name(overrides || {});
192
- } catch (e) {
193
- throw transformEtherError(e, this.context);
185
+ if (!overrides && this.context) {
186
+ overrides = {
187
+ blockTag: toBlockTag(this.context.blockNumber),
188
+ };
194
189
  }
190
+ return await this.view.name(overrides || {});
195
191
  }
196
192
 
197
193
  async totalSupply(overrides?: Overrides): Promise<bigint> {
198
- try {
199
- if (!overrides && this.context) {
200
- overrides = {
201
- blockTag: toBlockTag(this.context.blockNumber),
202
- };
203
- }
204
- return await this.view.totalSupply(overrides || {});
205
- } catch (e) {
206
- throw transformEtherError(e, this.context);
194
+ if (!overrides && this.context) {
195
+ overrides = {
196
+ blockTag: toBlockTag(this.context.blockNumber),
197
+ };
207
198
  }
199
+ return await this.view.totalSupply(overrides || {});
208
200
  }
209
201
 
210
202
  async decimals(overrides?: Overrides): Promise<bigint> {
211
- try {
212
- if (!overrides && this.context) {
213
- overrides = {
214
- blockTag: toBlockTag(this.context.blockNumber),
215
- };
216
- }
217
- return await this.view.decimals(overrides || {});
218
- } catch (e) {
219
- throw transformEtherError(e, this.context);
203
+ if (!overrides && this.context) {
204
+ overrides = {
205
+ blockTag: toBlockTag(this.context.blockNumber),
206
+ };
220
207
  }
208
+ return await this.view.decimals(overrides || {});
221
209
  }
222
210
 
223
211
  async balanceOf(arg0: string, overrides?: Overrides): Promise<bigint> {
224
- try {
225
- if (!overrides && this.context) {
226
- overrides = {
227
- blockTag: toBlockTag(this.context.blockNumber),
228
- };
229
- }
230
- return await this.view.balanceOf(arg0, overrides || {});
231
- } catch (e) {
232
- throw transformEtherError(e, this.context);
212
+ if (!overrides && this.context) {
213
+ overrides = {
214
+ blockTag: toBlockTag(this.context.blockNumber),
215
+ };
233
216
  }
217
+ return await this.view.balanceOf(arg0, overrides || {});
234
218
  }
235
219
 
236
220
  async symbol(overrides?: Overrides): Promise<string> {
237
- try {
238
- if (!overrides && this.context) {
239
- overrides = {
240
- blockTag: toBlockTag(this.context.blockNumber),
241
- };
242
- }
243
- return await this.view.symbol(overrides || {});
244
- } catch (e) {
245
- throw transformEtherError(e, this.context);
221
+ if (!overrides && this.context) {
222
+ overrides = {
223
+ blockTag: toBlockTag(this.context.blockNumber),
224
+ };
246
225
  }
226
+ return await this.view.symbol(overrides || {});
247
227
  }
248
228
 
249
229
  async allowance(
@@ -251,16 +231,12 @@ export class WETH9BoundContractView extends BoundContractView<
251
231
  arg1: string,
252
232
  overrides?: Overrides
253
233
  ): Promise<bigint> {
254
- try {
255
- if (!overrides && this.context) {
256
- overrides = {
257
- blockTag: toBlockTag(this.context.blockNumber),
258
- };
259
- }
260
- return await this.view.allowance(arg0, arg1, overrides || {});
261
- } catch (e) {
262
- throw transformEtherError(e, this.context);
234
+ if (!overrides && this.context) {
235
+ overrides = {
236
+ blockTag: toBlockTag(this.context.blockNumber),
237
+ };
263
238
  }
239
+ return await this.view.allowance(arg0, arg1, overrides || {});
264
240
  }
265
241
  }
266
242
 
File without changes
@@ -4,7 +4,7 @@ import { LogParams } from 'ethers/providers'
4
4
  import { RecordMetaData } from '@sentio/protos'
5
5
  import { Trace } from '../eth/trace.js'
6
6
  import { Labels, normalizeLabels } from './metadata.js'
7
- import { CHAIN_IDS } from '../utils/chain.js'
7
+ import { CHAIN_IDS } from '../chain.js'
8
8
  import { BaseContext } from './base-context.js'
9
9
 
10
10
  export abstract class EthContext extends BaseContext {
@@ -3,7 +3,7 @@ import { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, Proces
3
3
 
4
4
  import { ServerError, Status } from 'nice-grpc'
5
5
 
6
- import { CHAIN_IDS } from '../utils/chain.js'
6
+ import { CHAIN_IDS } from '../chain.js'
7
7
  import { SuiProcessorState } from './sui-processor.js'
8
8
 
9
9
  export class SuiPlugin extends Plugin {
package/src/error.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  // Transform error in more readable format
2
2
  import { ContractContext } from './core/context.js'
3
+ import { CallExceptionError } from 'ethers'
3
4
  // import { errors } from 'ethers/providers'
4
5
 
5
- export class EthersError extends Error {
6
+ export class SimpleEthersError extends Error {
6
7
  e: Error
7
8
 
8
9
  constructor(message: string, e: Error) {
@@ -16,11 +17,14 @@ export class EthersError extends Error {
16
17
  }
17
18
 
18
19
  export function transformEtherError(e: Error, ctx: ContractContext<any, any> | undefined): Error {
20
+ if (e instanceof SimpleEthersError) {
21
+ return e
22
+ }
23
+
19
24
  let msg = ''
20
- // @ts-ignore expected error fields
21
- if (e.code === errors.CALL_EXCEPTION) {
22
- // @ts-ignore expected error fields
23
- if (e.data === '0x') {
25
+ const err = e as CallExceptionError
26
+ if (err.code === 'CALL_EXCEPTION') {
27
+ if (err.data === '0x') {
24
28
  if (ctx) {
25
29
  msg =
26
30
  "jsonrpc eth_call return '0x' (likely contract not existed) at chain " +
@@ -28,18 +32,12 @@ export function transformEtherError(e: Error, ctx: ContractContext<any, any> | u
28
32
  ': ' +
29
33
  JSON.stringify(e)
30
34
  } else {
31
- msg = "jsonrpc eth_call return '0x' (likely contract not existed): " + JSON.stringify(e)
35
+ msg = "jsonrpc eth_call return '0x' (likely contract not existed): " + JSON.stringify(err)
32
36
  }
37
+ return new SimpleEthersError(msg, err)
33
38
  }
34
- return new EthersError(msg, e)
35
39
  }
36
40
 
37
- if (e instanceof EthersError) {
38
- return e
39
- }
40
-
41
- // TODO gracefully handle more errors
42
-
43
- msg = 'ethers call error\n' + e.message + '\n' + e.stack?.toString()
41
+ msg = 'ethers call error\n' + JSON.stringify(e) + '\n' + e.stack?.toString()
44
42
  return new Error(msg)
45
43
  }
@@ -8,7 +8,7 @@ import { Trace } from './trace.js'
8
8
  import { ListStateStorage } from '@sentio/runtime'
9
9
  import { EventFilter, LogParams, Network } from 'ethers/providers'
10
10
  import { DeferredTopicFilter } from 'ethers/contract'
11
- import { EthEvent } from './eth-event.js'
11
+ import { Eth } from './eth.js'
12
12
 
13
13
  export class ProcessorTemplateProcessorState extends ListStateStorage<
14
14
  BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
@@ -37,7 +37,7 @@ export abstract class BaseProcessorTemplate<
37
37
  fetchConfig?: EthFetchConfig
38
38
  }[] = []
39
39
  eventHandlers: {
40
- handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
40
+ handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
41
41
  filter: DeferredTopicFilter | DeferredTopicFilter[]
42
42
  fetchConfig?: EthFetchConfig
43
43
  }[] = []
@@ -88,7 +88,7 @@ export abstract class BaseProcessorTemplate<
88
88
  }
89
89
 
90
90
  public onEvent(
91
- handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
91
+ handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
92
92
  filter: DeferredTopicFilter | DeferredTopicFilter[],
93
93
  fetchConfig?: EthFetchConfig
94
94
  ) {