@sentio/sdk 2.16.2-rc.1 → 2.16.2-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 (49) hide show
  1. package/lib/aptos/aptos-processor.d.ts +6 -2
  2. package/lib/aptos/aptos-processor.js +27 -23
  3. package/lib/aptos/aptos-processor.js.map +1 -1
  4. package/lib/aptos/index.d.ts +1 -1
  5. package/lib/aptos/index.js +1 -1
  6. package/lib/aptos/index.js.map +1 -1
  7. package/lib/eth/base-processor-template.d.ts +1 -1
  8. package/lib/eth/base-processor-template.js +5 -3
  9. package/lib/eth/base-processor-template.js.map +1 -1
  10. package/lib/eth/base-processor.d.ts +4 -4
  11. package/lib/eth/base-processor.js +17 -17
  12. package/lib/eth/base-processor.js.map +1 -1
  13. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +31 -31
  14. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  15. package/lib/eth/builtin/internal/erc1155-processor.js +16 -16
  16. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  17. package/lib/eth/builtin/internal/erc20-processor.js +24 -24
  18. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  19. package/lib/eth/builtin/internal/erc20bytes-processor.js +13 -13
  20. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  21. package/lib/eth/builtin/internal/erc721-processor.js +20 -20
  22. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  23. package/lib/eth/builtin/internal/weth9-processor.js +19 -19
  24. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  25. package/lib/eth/codegen/ethers-sentio.js +11 -11
  26. package/lib/eth/codegen/ethers-sentio.js.map +1 -1
  27. package/lib/eth/codegen/event-handler.js +1 -1
  28. package/lib/eth/codegen/event-handler.js.map +1 -1
  29. package/lib/eth/codegen/functions-handler.js +1 -1
  30. package/lib/eth/codegen/functions-handler.js.map +1 -1
  31. package/lib/eth/generic-processor.test.js.map +1 -1
  32. package/lib/sui/sui-processor.d.ts +8 -3
  33. package/lib/sui/sui-processor.js +29 -2
  34. package/lib/sui/sui-processor.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/aptos/aptos-processor.ts +44 -51
  37. package/src/aptos/index.ts +1 -1
  38. package/src/eth/base-processor-template.ts +5 -3
  39. package/src/eth/base-processor.ts +25 -25
  40. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +31 -31
  41. package/src/eth/builtin/internal/erc1155-processor.ts +16 -16
  42. package/src/eth/builtin/internal/erc20-processor.ts +24 -24
  43. package/src/eth/builtin/internal/erc20bytes-processor.ts +13 -13
  44. package/src/eth/builtin/internal/erc721-processor.ts +20 -20
  45. package/src/eth/builtin/internal/weth9-processor.ts +19 -19
  46. package/src/eth/codegen/ethers-sentio.ts +11 -11
  47. package/src/eth/codegen/event-handler.ts +1 -1
  48. package/src/eth/codegen/functions-handler.ts +1 -1
  49. package/src/sui/sui-processor.ts +50 -4
@@ -239,7 +239,7 @@ export class WETH9Processor extends BaseProcessor<
239
239
  null
240
240
  );
241
241
  }
242
- return super.onEvent(handler, filter!, fetchConfig);
242
+ return super.onEthEvent(handler, filter!, fetchConfig);
243
243
  }
244
244
 
245
245
  onEventTransfer(
@@ -254,7 +254,7 @@ export class WETH9Processor extends BaseProcessor<
254
254
  null
255
255
  );
256
256
  }
257
- return super.onEvent(handler, filter!, fetchConfig);
257
+ return super.onEthEvent(handler, filter!, fetchConfig);
258
258
  }
259
259
 
260
260
  onEventDeposit(
@@ -265,7 +265,7 @@ export class WETH9Processor extends BaseProcessor<
265
265
  if (!filter) {
266
266
  filter = templateContract.filters["Deposit(address,uint256)"](null, null);
267
267
  }
268
- return super.onEvent(handler, filter!, fetchConfig);
268
+ return super.onEthEvent(handler, filter!, fetchConfig);
269
269
  }
270
270
 
271
271
  onEventWithdrawal(
@@ -279,84 +279,84 @@ export class WETH9Processor extends BaseProcessor<
279
279
  null
280
280
  );
281
281
  }
282
- return super.onEvent(handler, filter!, fetchConfig);
282
+ return super.onEthEvent(handler, filter!, fetchConfig);
283
283
  }
284
284
 
285
285
  onCallName(
286
286
  handler: (call: NameCallTrace, ctx: WETH9Context) => void,
287
287
  fetchConfig?: Partial<EthFetchConfig>
288
288
  ): this {
289
- return super.onTrace("0x06fdde03", handler as any, fetchConfig);
289
+ return super.onEthTrace("0x06fdde03", handler as any, fetchConfig);
290
290
  }
291
291
 
292
292
  onCallApprove(
293
293
  handler: (call: ApproveCallTrace, ctx: WETH9Context) => void,
294
294
  fetchConfig?: Partial<EthFetchConfig>
295
295
  ): this {
296
- return super.onTrace("0x095ea7b3", handler as any, fetchConfig);
296
+ return super.onEthTrace("0x095ea7b3", handler as any, fetchConfig);
297
297
  }
298
298
 
299
299
  onCallTotalSupply(
300
300
  handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void,
301
301
  fetchConfig?: Partial<EthFetchConfig>
302
302
  ): this {
303
- return super.onTrace("0x18160ddd", handler as any, fetchConfig);
303
+ return super.onEthTrace("0x18160ddd", handler as any, fetchConfig);
304
304
  }
305
305
 
306
306
  onCallTransferFrom(
307
307
  handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void,
308
308
  fetchConfig?: Partial<EthFetchConfig>
309
309
  ): this {
310
- return super.onTrace("0x23b872dd", handler as any, fetchConfig);
310
+ return super.onEthTrace("0x23b872dd", handler as any, fetchConfig);
311
311
  }
312
312
 
313
313
  onCallWithdraw(
314
314
  handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void,
315
315
  fetchConfig?: Partial<EthFetchConfig>
316
316
  ): this {
317
- return super.onTrace("0x2e1a7d4d", handler as any, fetchConfig);
317
+ return super.onEthTrace("0x2e1a7d4d", handler as any, fetchConfig);
318
318
  }
319
319
 
320
320
  onCallDecimals(
321
321
  handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void,
322
322
  fetchConfig?: Partial<EthFetchConfig>
323
323
  ): this {
324
- return super.onTrace("0x313ce567", handler as any, fetchConfig);
324
+ return super.onEthTrace("0x313ce567", handler as any, fetchConfig);
325
325
  }
326
326
 
327
327
  onCallBalanceOf(
328
328
  handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void,
329
329
  fetchConfig?: Partial<EthFetchConfig>
330
330
  ): this {
331
- return super.onTrace("0x70a08231", handler as any, fetchConfig);
331
+ return super.onEthTrace("0x70a08231", handler as any, fetchConfig);
332
332
  }
333
333
 
334
334
  onCallSymbol(
335
335
  handler: (call: SymbolCallTrace, ctx: WETH9Context) => void,
336
336
  fetchConfig?: Partial<EthFetchConfig>
337
337
  ): this {
338
- return super.onTrace("0x95d89b41", handler as any, fetchConfig);
338
+ return super.onEthTrace("0x95d89b41", handler as any, fetchConfig);
339
339
  }
340
340
 
341
341
  onCallTransfer(
342
342
  handler: (call: TransferCallTrace, ctx: WETH9Context) => void,
343
343
  fetchConfig?: Partial<EthFetchConfig>
344
344
  ): this {
345
- return super.onTrace("0xa9059cbb", handler as any, fetchConfig);
345
+ return super.onEthTrace("0xa9059cbb", handler as any, fetchConfig);
346
346
  }
347
347
 
348
348
  onCallDeposit(
349
349
  handler: (call: DepositCallTrace, ctx: WETH9Context) => void,
350
350
  fetchConfig?: Partial<EthFetchConfig>
351
351
  ): this {
352
- return super.onTrace("0xd0e30db0", handler as any, fetchConfig);
352
+ return super.onEthTrace("0xd0e30db0", handler as any, fetchConfig);
353
353
  }
354
354
 
355
355
  onCallAllowance(
356
356
  handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void,
357
357
  fetchConfig?: Partial<EthFetchConfig>
358
358
  ): this {
359
- return super.onTrace("0xdd62ed3e", handler as any, fetchConfig);
359
+ return super.onEthTrace("0xdd62ed3e", handler as any, fetchConfig);
360
360
  }
361
361
 
362
362
  public static filters = {
@@ -428,7 +428,7 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
428
428
  null
429
429
  );
430
430
  }
431
- return super.onEvent(handler, filter!, fetchConfig);
431
+ return super.onEthEvent(handler, filter!, fetchConfig);
432
432
  }
433
433
 
434
434
  onEventTransfer(
@@ -443,7 +443,7 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
443
443
  null
444
444
  );
445
445
  }
446
- return super.onEvent(handler, filter!, fetchConfig);
446
+ return super.onEthEvent(handler, filter!, fetchConfig);
447
447
  }
448
448
 
449
449
  onEventDeposit(
@@ -454,7 +454,7 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
454
454
  if (!filter) {
455
455
  filter = templateContract.filters["Deposit(address,uint256)"](null, null);
456
456
  }
457
- return super.onEvent(handler, filter!, fetchConfig);
457
+ return super.onEthEvent(handler, filter!, fetchConfig);
458
458
  }
459
459
 
460
460
  onEventWithdrawal(
@@ -468,7 +468,7 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
468
468
  null
469
469
  );
470
470
  }
471
- return super.onEvent(handler, filter!, fetchConfig);
471
+ return super.onEthEvent(handler, filter!, fetchConfig);
472
472
  }
473
473
  }
474
474
 
@@ -116,25 +116,25 @@ export default class EthersSentio extends Ethers.default {
116
116
  const content = `
117
117
 
118
118
  ${contract.name}Processor.bind({ address: '${contract.address}', network: EthChainId.${chainKey} })
119
- .onAllEvents((evt, ctx) => {
119
+ .onEvent((evt, ctx) => {
120
120
  ctx.meter.Counter('event_count').add(1, { name: evt.name })
121
121
  ctx.eventLogger.emit(evt.name, {
122
122
  ...evt.args.toObject(),
123
123
  })
124
124
  })
125
- .onAllTraces(function (trace, ctx) {
126
- const succeed = trace.error === undefined
127
- ctx.meter.Counter('trace_count').add(1, { name: trace.name, success: String(succeed) })
128
- if (succeed) {
129
- ctx.eventLogger.emit(trace.name, {
130
- distinctId: trace.action.from,
131
- ...trace.args.toObject(),
132
- })
133
- }
134
- })
135
125
  `
136
126
  exampleContent += content
137
127
  }
128
+ // .onAllTraces(function (trace, ctx) {
129
+ // const succeed = trace.error === undefined
130
+ // ctx.meter.Counter('trace_count').add(1, { name: trace.name, success: String(succeed) })
131
+ // if (succeed) {
132
+ // ctx.eventLogger.emit(trace.name, {
133
+ // distinctId: trace.action.from,
134
+ // ...trace.args.toObject(),
135
+ // })
136
+ // }
137
+ // })
138
138
 
139
139
  files.push({
140
140
  path: join(rootDir, 'processor.eth.example.ts'),
@@ -16,7 +16,7 @@ export function generateEventHandler(event: EventDeclaration, contractName: stri
16
16
  if (!filter) {
17
17
  filter = templateContract.filters['${filterName}'](${event.inputs.map(() => 'null').join(',')})
18
18
  }
19
- return super.onEvent(handler, filter!, fetchConfig)
19
+ return super.onEthEvent(handler, filter!, fetchConfig)
20
20
  }
21
21
  `
22
22
  }
@@ -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 as any, fetchConfig);
50
+ return super.onEthTrace("${sighash}", handler as any, fetchConfig);
51
51
  }
52
52
  `
53
53
  }
@@ -69,7 +69,7 @@ export class SuiBaseProcessor {
69
69
  return this.config.network
70
70
  }
71
71
 
72
- public onMoveEvent(
72
+ protected onMoveEvent(
73
73
  handler: (event: SuiEvent, ctx: SuiContext) => void,
74
74
  filter: EventFilter | EventFilter[],
75
75
  fetchConfig?: Partial<MoveFetchConfig>
@@ -130,7 +130,7 @@ export class SuiBaseProcessor {
130
130
  return this
131
131
  }
132
132
 
133
- public onEntryFunctionCall(
133
+ protected onEntryFunctionCall(
134
134
  handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,
135
135
  filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
136
136
  fetchConfig?: Partial<MoveFetchConfig>
@@ -144,8 +144,6 @@ export class SuiBaseProcessor {
144
144
  _filters.push(filter)
145
145
  }
146
146
 
147
- // const address = this.config.address
148
- // const moduleName = this.moduleName
149
147
  const processor = this
150
148
  const allFunctionType = new Set(_filters.map((f) => processor.config.address + '::' + f.function))
151
149
 
@@ -193,4 +191,52 @@ export class SuiBaseProcessor {
193
191
  })
194
192
  return this
195
193
  }
194
+
195
+ onEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this {
196
+ this.onMoveEvent(handler, { type: '' }, fetchConfig)
197
+ return this
198
+ }
199
+
200
+ onTransactionBlock(
201
+ handler: (call: SuiTransactionBlockResponse, ctx: SuiContext) => void,
202
+ includeFailed = false,
203
+ fetchConfig?: Partial<MoveFetchConfig>
204
+ ): this {
205
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
206
+
207
+ const processor = this
208
+
209
+ this.callHandlers.push({
210
+ handler: async function (data) {
211
+ if (!data.transaction) {
212
+ throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
213
+ }
214
+ const tx = data.transaction as SuiTransactionBlockResponse
215
+
216
+ const ctx = new SuiContext(
217
+ processor.moduleName,
218
+ processor.config.network,
219
+ processor.config.address,
220
+ data.timestamp || new Date(0),
221
+ data.slot,
222
+ tx,
223
+ 0,
224
+ processor.config.baseLabels
225
+ )
226
+ if (tx) {
227
+ await handler(tx, ctx)
228
+ }
229
+ return ctx.getProcessResult()
230
+ },
231
+ filters: [{ function: '', includeFailed }],
232
+ fetchConfig: _fetchConfig,
233
+ })
234
+ return this
235
+ }
236
+ }
237
+
238
+ export class SuiModulesProcessor extends SuiBaseProcessor {
239
+ constructor(options: SuiBindOptions) {
240
+ super('*', options)
241
+ }
196
242
  }