@sentio/sdk 2.11.0 → 2.11.1-rc.1

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 (32) hide show
  1. package/lib/eth/builtin/internal/common.d.ts +10 -2
  2. package/lib/eth/builtin/internal/common.js.map +1 -1
  3. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +24 -24
  4. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  5. package/lib/eth/builtin/internal/erc1155-processor.d.ts +9 -9
  6. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  7. package/lib/eth/builtin/internal/erc20-processor.d.ts +19 -19
  8. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  9. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +10 -10
  10. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  11. package/lib/eth/builtin/internal/erc721-processor.d.ts +15 -15
  12. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  13. package/lib/eth/builtin/internal/weth9-processor.d.ts +12 -12
  14. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  15. package/lib/eth/codegen/ethers-sentio.js +35 -0
  16. package/lib/eth/codegen/ethers-sentio.js.map +1 -1
  17. package/lib/eth/codegen/functions-handler.js +2 -2
  18. package/lib/eth/codegen/functions-handler.js.map +1 -1
  19. package/lib/eth/trace.d.ts +16 -1
  20. package/lib/eth/trace.js +1 -0
  21. package/lib/eth/trace.js.map +1 -1
  22. package/package.json +5 -5
  23. package/src/eth/builtin/internal/common.ts +10 -1
  24. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +46 -66
  25. package/src/eth/builtin/internal/erc1155-processor.ts +16 -24
  26. package/src/eth/builtin/internal/erc20-processor.ts +36 -49
  27. package/src/eth/builtin/internal/erc20bytes-processor.ts +18 -25
  28. package/src/eth/builtin/internal/erc721-processor.ts +28 -41
  29. package/src/eth/builtin/internal/weth9-processor.ts +22 -30
  30. package/src/eth/codegen/ethers-sentio.ts +36 -0
  31. package/src/eth/codegen/functions-handler.ts +2 -2
  32. package/src/eth/trace.ts +17 -1
@@ -10,7 +10,6 @@ import {
10
10
  getProcessor,
11
11
  getProvider,
12
12
  transformEtherError,
13
- Trace,
14
13
  BindOptions,
15
14
  BaseProcessor,
16
15
  BaseProcessorTemplate,
@@ -38,7 +37,7 @@ import {
38
37
 
39
38
  export interface NameCallObject {}
40
39
 
41
- export type NameCallTrace = TypedCallTrace<[], NameCallObject> & Trace;
40
+ export type NameCallTrace = TypedCallTrace<[], NameCallObject>;
42
41
 
43
42
  export interface ApproveCallObject {
44
43
  guy: string;
@@ -48,13 +47,11 @@ export interface ApproveCallObject {
48
47
  export type ApproveCallTrace = TypedCallTrace<
49
48
  [string, bigint],
50
49
  ApproveCallObject
51
- > &
52
- Trace;
50
+ >;
53
51
 
54
52
  export interface TotalSupplyCallObject {}
55
53
 
56
- export type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject> &
57
- Trace;
54
+ export type TotalSupplyCallTrace = TypedCallTrace<[], TotalSupplyCallObject>;
58
55
 
59
56
  export interface TransferFromCallObject {
60
57
  src: string;
@@ -65,28 +62,25 @@ export interface TransferFromCallObject {
65
62
  export type TransferFromCallTrace = TypedCallTrace<
66
63
  [string, string, bigint],
67
64
  TransferFromCallObject
68
- > &
69
- Trace;
65
+ >;
70
66
 
71
67
  export interface WithdrawCallObject {
72
68
  wad: bigint;
73
69
  }
74
70
 
75
- export type WithdrawCallTrace = TypedCallTrace<[bigint], WithdrawCallObject> &
76
- Trace;
71
+ export type WithdrawCallTrace = TypedCallTrace<[bigint], WithdrawCallObject>;
77
72
 
78
73
  export interface DecimalsCallObject {}
79
74
 
80
- export type DecimalsCallTrace = TypedCallTrace<[], DecimalsCallObject> & Trace;
75
+ export type DecimalsCallTrace = TypedCallTrace<[], DecimalsCallObject>;
81
76
 
82
77
  export interface BalanceOfCallObject {}
83
78
 
84
- export type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject> &
85
- Trace;
79
+ export type BalanceOfCallTrace = TypedCallTrace<[string], BalanceOfCallObject>;
86
80
 
87
81
  export interface SymbolCallObject {}
88
82
 
89
- export type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject> & Trace;
83
+ export type SymbolCallTrace = TypedCallTrace<[], SymbolCallObject>;
90
84
 
91
85
  export interface TransferCallObject {
92
86
  dst: string;
@@ -96,20 +90,18 @@ export interface TransferCallObject {
96
90
  export type TransferCallTrace = TypedCallTrace<
97
91
  [string, bigint],
98
92
  TransferCallObject
99
- > &
100
- Trace;
93
+ >;
101
94
 
102
95
  export interface DepositCallObject {}
103
96
 
104
- export type DepositCallTrace = TypedCallTrace<[], DepositCallObject> & Trace;
97
+ export type DepositCallTrace = TypedCallTrace<[], DepositCallObject>;
105
98
 
106
99
  export interface AllowanceCallObject {}
107
100
 
108
101
  export type AllowanceCallTrace = TypedCallTrace<
109
102
  [string, string],
110
103
  AllowanceCallObject
111
- > &
112
- Trace;
104
+ >;
113
105
 
114
106
  const templateContract = WETH9__factory.connect("0x0", DummyProvider);
115
107
 
@@ -306,77 +298,77 @@ export class WETH9Processor extends BaseProcessor<
306
298
  handler: (call: NameCallTrace, ctx: WETH9Context) => void,
307
299
  fetchConfig?: Partial<EthFetchConfig>
308
300
  ): this {
309
- return super.onTrace("0x06fdde03", handler, fetchConfig);
301
+ return super.onTrace("0x06fdde03", handler as any, fetchConfig);
310
302
  }
311
303
 
312
304
  onCallApprove(
313
305
  handler: (call: ApproveCallTrace, ctx: WETH9Context) => void,
314
306
  fetchConfig?: Partial<EthFetchConfig>
315
307
  ): this {
316
- return super.onTrace("0x095ea7b3", handler, fetchConfig);
308
+ return super.onTrace("0x095ea7b3", handler as any, fetchConfig);
317
309
  }
318
310
 
319
311
  onCallTotalSupply(
320
312
  handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void,
321
313
  fetchConfig?: Partial<EthFetchConfig>
322
314
  ): this {
323
- return super.onTrace("0x18160ddd", handler, fetchConfig);
315
+ return super.onTrace("0x18160ddd", handler as any, fetchConfig);
324
316
  }
325
317
 
326
318
  onCallTransferFrom(
327
319
  handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void,
328
320
  fetchConfig?: Partial<EthFetchConfig>
329
321
  ): this {
330
- return super.onTrace("0x23b872dd", handler, fetchConfig);
322
+ return super.onTrace("0x23b872dd", handler as any, fetchConfig);
331
323
  }
332
324
 
333
325
  onCallWithdraw(
334
326
  handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void,
335
327
  fetchConfig?: Partial<EthFetchConfig>
336
328
  ): this {
337
- return super.onTrace("0x2e1a7d4d", handler, fetchConfig);
329
+ return super.onTrace("0x2e1a7d4d", handler as any, fetchConfig);
338
330
  }
339
331
 
340
332
  onCallDecimals(
341
333
  handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void,
342
334
  fetchConfig?: Partial<EthFetchConfig>
343
335
  ): this {
344
- return super.onTrace("0x313ce567", handler, fetchConfig);
336
+ return super.onTrace("0x313ce567", handler as any, fetchConfig);
345
337
  }
346
338
 
347
339
  onCallBalanceOf(
348
340
  handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void,
349
341
  fetchConfig?: Partial<EthFetchConfig>
350
342
  ): this {
351
- return super.onTrace("0x70a08231", handler, fetchConfig);
343
+ return super.onTrace("0x70a08231", handler as any, fetchConfig);
352
344
  }
353
345
 
354
346
  onCallSymbol(
355
347
  handler: (call: SymbolCallTrace, ctx: WETH9Context) => void,
356
348
  fetchConfig?: Partial<EthFetchConfig>
357
349
  ): this {
358
- return super.onTrace("0x95d89b41", handler, fetchConfig);
350
+ return super.onTrace("0x95d89b41", handler as any, fetchConfig);
359
351
  }
360
352
 
361
353
  onCallTransfer(
362
354
  handler: (call: TransferCallTrace, ctx: WETH9Context) => void,
363
355
  fetchConfig?: Partial<EthFetchConfig>
364
356
  ): this {
365
- return super.onTrace("0xa9059cbb", handler, fetchConfig);
357
+ return super.onTrace("0xa9059cbb", handler as any, fetchConfig);
366
358
  }
367
359
 
368
360
  onCallDeposit(
369
361
  handler: (call: DepositCallTrace, ctx: WETH9Context) => void,
370
362
  fetchConfig?: Partial<EthFetchConfig>
371
363
  ): this {
372
- return super.onTrace("0xd0e30db0", handler, fetchConfig);
364
+ return super.onTrace("0xd0e30db0", handler as any, fetchConfig);
373
365
  }
374
366
 
375
367
  onCallAllowance(
376
368
  handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void,
377
369
  fetchConfig?: Partial<EthFetchConfig>
378
370
  ): this {
379
- return super.onTrace("0xdd62ed3e", handler, fetchConfig);
371
+ return super.onTrace("0xdd62ed3e", handler as any, fetchConfig);
380
372
  }
381
373
 
382
374
  public static filters = {
@@ -65,6 +65,7 @@ export default class EthersSentio extends Ethers.default {
65
65
  }
66
66
 
67
67
  override afterRun() {
68
+ const commonPath = join('internal', 'common.ts')
68
69
  const files = super.afterRun()
69
70
  for (const [idx, file] of files.entries()) {
70
71
  if (file.path.endsWith('__factory.ts')) {
@@ -72,8 +73,11 @@ export default class EthersSentio extends Ethers.default {
72
73
  } else if (file.path.endsWith('factories/index.ts')) {
73
74
  file.contents = file.contents.replaceAll("__factory'", "__factory.js'")
74
75
  } else if (file.path.endsWith('_processor.ts')) {
76
+ } else if (file.path.endsWith(commonPath)) {
77
+ file.contents = COMMON_CONTENT
75
78
  }
76
79
  }
80
+
77
81
  let indexContent = ''
78
82
  for (const contract of this.processedABIs) {
79
83
  const content = `
@@ -130,3 +134,35 @@ ${contract.name}Processor.bind({ address: '${contract.address}', network: ${cont
130
134
  return files
131
135
  }
132
136
  }
137
+
138
+ const COMMON_CONTENT = `/* Autogenerated file. Do not edit manually. */
139
+ /* tslint:disable */
140
+ /* eslint-disable */
141
+
142
+ import type { DeferredTopicFilter } from "ethers";
143
+ import { LogParams } from "ethers/providers";
144
+ import { Result } from "ethers";
145
+
146
+ export interface TypedEvent<
147
+ TArgsArray extends Array<any> = any,
148
+ TArgsObject = any
149
+ > extends LogParams {
150
+ args: TArgsObject & {
151
+ /**
152
+ * Returns the Result as a normal Array.
153
+ */
154
+ toArray(): Array<any>;
155
+ /**
156
+ * Returns the Result as an Object with each name-value pair.
157
+ */
158
+ toObject(): Record<string, any>;
159
+ };
160
+ name: string
161
+ }
162
+
163
+ export interface TypedEventFilter<_TEvent extends TypedEvent>
164
+ extends DeferredTopicFilter {}
165
+
166
+ export type PromiseOrValue<T> = T | Promise<T>;
167
+
168
+ `
@@ -33,7 +33,7 @@ function codegenCallTraceType(fn: FunctionDeclaration, overloadedName?: string):
33
33
  return `
34
34
  export interface ${identifier}CallObject ${objectOutput}
35
35
 
36
- export type ${identifier}CallTrace = TypedCallTrace<${arrayOutput}, ${identifier}CallObject> & Trace
36
+ export type ${identifier}CallTrace = TypedCallTrace<${arrayOutput}, ${identifier}CallObject>
37
37
  `
38
38
  }
39
39
 
@@ -47,7 +47,7 @@ function generateCallHandler(fn: FunctionDeclaration, contractName: string, over
47
47
  handler: (call: ${upperFirst(overloadedName ?? fn.name)}CallTrace, ctx: ${contractName}Context) => void,
48
48
  fetchConfig?: Partial<EthFetchConfig>
49
49
  ): this {
50
- return super.onTrace("${sighash}", handler, fetchConfig);
50
+ return super.onTrace("${sighash}", handler as any, fetchConfig);
51
51
  }
52
52
  `
53
53
  }
package/src/eth/trace.ts CHANGED
@@ -1,8 +1,24 @@
1
1
  // https://github.com/openethereum/parity-ethereum/blob/55c90d4016505317034e3e98f699af07f5404b63/rpc/src/v1/types/trace.rs#L482
2
+
2
3
  import { Result } from 'ethers'
3
4
 
4
5
  export interface TypedCallTrace<TArgsArray extends Array<any> = any, TArgsObject = any> {
5
- args: TArgsArray & TArgsObject
6
+ args: TArgsObject & {
7
+ /**
8
+ * Returns the Result as a normal Array.
9
+ *
10
+ * This will throw if there are any outstanding deferred
11
+ * errors.
12
+ */
13
+ toArray(): Array<any>
14
+ /**
15
+ * Returns the Result as an Object with each name-value pair.
16
+ *
17
+ * This will throw if any value is unnamed, or if there are
18
+ * any outstanding deferred errors.
19
+ */
20
+ toObject(): Record<string, any>
21
+ }
6
22
  }
7
23
 
8
24
  export interface Trace {