@sentio/sdk 2.59.0-rc.22 → 2.59.0-rc.24

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 (67) hide show
  1. package/lib/aptos/aptos-plugin.d.ts +5 -2
  2. package/lib/aptos/aptos-plugin.d.ts.map +1 -1
  3. package/lib/aptos/aptos-plugin.js +41 -2
  4. package/lib/aptos/aptos-plugin.js.map +1 -1
  5. package/lib/aptos/aptos-processor.d.ts +6 -5
  6. package/lib/aptos/aptos-processor.d.ts.map +1 -1
  7. package/lib/aptos/aptos-processor.js +18 -12
  8. package/lib/aptos/aptos-processor.js.map +1 -1
  9. package/lib/aptos/builtin/0x1.d.ts +159 -159
  10. package/lib/aptos/builtin/0x1.d.ts.map +1 -1
  11. package/lib/aptos/builtin/0x1.js +316 -316
  12. package/lib/aptos/builtin/0x1.js.map +1 -1
  13. package/lib/aptos/builtin/0x3.d.ts +52 -52
  14. package/lib/aptos/builtin/0x3.d.ts.map +1 -1
  15. package/lib/aptos/builtin/0x3.js +102 -102
  16. package/lib/aptos/builtin/0x3.js.map +1 -1
  17. package/lib/aptos/builtin/0x4.d.ts +12 -12
  18. package/lib/aptos/builtin/0x4.d.ts.map +1 -1
  19. package/lib/aptos/builtin/0x4.js +22 -22
  20. package/lib/aptos/builtin/0x4.js.map +1 -1
  21. package/lib/aptos/codegen/codegen.js +10 -0
  22. package/lib/aptos/codegen/codegen.js.map +1 -1
  23. package/lib/aptos/data.d.ts +20 -0
  24. package/lib/aptos/data.d.ts.map +1 -0
  25. package/lib/aptos/data.js +38 -0
  26. package/lib/aptos/data.js.map +1 -0
  27. package/lib/aptos/index.d.ts +1 -0
  28. package/lib/aptos/index.d.ts.map +1 -1
  29. package/lib/aptos/index.js.map +1 -1
  30. package/lib/aptos/models.d.ts +5 -0
  31. package/lib/aptos/models.d.ts.map +1 -1
  32. package/lib/eth/base-processor.d.ts +6 -2
  33. package/lib/eth/base-processor.d.ts.map +1 -1
  34. package/lib/eth/base-processor.js +5 -1
  35. package/lib/eth/base-processor.js.map +1 -1
  36. package/lib/move/filter.d.ts +1 -0
  37. package/lib/move/filter.d.ts.map +1 -1
  38. package/lib/move/filter.js +1 -0
  39. package/lib/move/filter.js.map +1 -1
  40. package/lib/move/shared-network-codegen.d.ts.map +1 -1
  41. package/lib/move/shared-network-codegen.js +1 -0
  42. package/lib/move/shared-network-codegen.js.map +1 -1
  43. package/lib/sui/builtin/0x1.d.ts.map +1 -1
  44. package/lib/sui/builtin/0x1.js.map +1 -1
  45. package/lib/sui/builtin/0x2.d.ts.map +1 -1
  46. package/lib/sui/builtin/0x2.js.map +1 -1
  47. package/lib/sui/builtin/0x3.d.ts.map +1 -1
  48. package/lib/sui/builtin/0x3.js.map +1 -1
  49. package/lib/sui/models.d.ts +5 -0
  50. package/lib/sui/models.d.ts.map +1 -1
  51. package/package.json +3 -3
  52. package/src/aptos/aptos-plugin.ts +50 -3
  53. package/src/aptos/aptos-processor.ts +22 -24
  54. package/src/aptos/builtin/0x1.ts +317 -316
  55. package/src/aptos/builtin/0x3.ts +103 -102
  56. package/src/aptos/builtin/0x4.ts +23 -22
  57. package/src/aptos/codegen/codegen.ts +13 -1
  58. package/src/aptos/data.ts +48 -0
  59. package/src/aptos/index.ts +2 -0
  60. package/src/aptos/models.ts +7 -0
  61. package/src/eth/base-processor.ts +7 -2
  62. package/src/move/filter.ts +1 -0
  63. package/src/move/shared-network-codegen.ts +1 -0
  64. package/src/sui/builtin/0x1.ts +1 -0
  65. package/src/sui/builtin/0x2.ts +1 -0
  66. package/src/sui/builtin/0x3.ts +1 -0
  67. package/src/sui/models.ts +7 -0
@@ -10,6 +10,7 @@ import {
10
10
  AptosBaseProcessor,
11
11
  AptosNetwork,
12
12
  TypedFunctionPayload,
13
+ HandlerOptions,
13
14
  AptosContext,
14
15
  } from "@sentio/sdk/aptos";
15
16
 
@@ -45,26 +46,26 @@ export class token extends AptosBaseProcessor {
45
46
 
46
47
  onEventMutation(
47
48
  func: (event: token.MutationInstance, ctx: AptosContext) => void,
48
- fetchConfig?: Partial<MoveFetchConfig>,
49
+ handlerOptions?: HandlerOptions<token.MutationInstance>,
49
50
  eventFilter?: Omit<EventFilter, "type" | "account">,
50
51
  ): token {
51
52
  this.onMoveEvent(
52
53
  func,
53
54
  { ...(eventFilter ?? {}), type: "token::Mutation" },
54
- fetchConfig,
55
+ handlerOptions,
55
56
  );
56
57
  return this;
57
58
  }
58
59
 
59
60
  onEventMutationEvent(
60
61
  func: (event: token.MutationEventInstance, ctx: AptosContext) => void,
61
- fetchConfig?: Partial<MoveFetchConfig>,
62
+ handlerOptions?: HandlerOptions<token.MutationEventInstance>,
62
63
  eventFilter?: Omit<EventFilter, "type" | "account">,
63
64
  ): token {
64
65
  this.onMoveEvent(
65
66
  func,
66
67
  { ...(eventFilter ?? {}), type: "token::MutationEvent" },
67
- fetchConfig,
68
+ handlerOptions,
68
69
  );
69
70
  return this;
70
71
  }
@@ -446,26 +447,26 @@ export class collection extends AptosBaseProcessor {
446
447
 
447
448
  onEventBurn(
448
449
  func: (event: collection.BurnInstance, ctx: AptosContext) => void,
449
- fetchConfig?: Partial<MoveFetchConfig>,
450
+ handlerOptions?: HandlerOptions<collection.BurnInstance>,
450
451
  eventFilter?: Omit<EventFilter, "type" | "account">,
451
452
  ): collection {
452
453
  this.onMoveEvent(
453
454
  func,
454
455
  { ...(eventFilter ?? {}), type: "collection::Burn" },
455
- fetchConfig,
456
+ handlerOptions,
456
457
  );
457
458
  return this;
458
459
  }
459
460
 
460
461
  onEventBurnEvent(
461
462
  func: (event: collection.BurnEventInstance, ctx: AptosContext) => void,
462
- fetchConfig?: Partial<MoveFetchConfig>,
463
+ handlerOptions?: HandlerOptions<collection.BurnEventInstance>,
463
464
  eventFilter?: Omit<EventFilter, "type" | "account">,
464
465
  ): collection {
465
466
  this.onMoveEvent(
466
467
  func,
467
468
  { ...(eventFilter ?? {}), type: "collection::BurnEvent" },
468
- fetchConfig,
469
+ handlerOptions,
469
470
  );
470
471
  return this;
471
472
  }
@@ -475,13 +476,13 @@ export class collection extends AptosBaseProcessor {
475
476
  event: collection.ConcurrentBurnEventInstance,
476
477
  ctx: AptosContext,
477
478
  ) => void,
478
- fetchConfig?: Partial<MoveFetchConfig>,
479
+ handlerOptions?: HandlerOptions<collection.ConcurrentBurnEventInstance>,
479
480
  eventFilter?: Omit<EventFilter, "type" | "account">,
480
481
  ): collection {
481
482
  this.onMoveEvent(
482
483
  func,
483
484
  { ...(eventFilter ?? {}), type: "collection::ConcurrentBurnEvent" },
484
- fetchConfig,
485
+ handlerOptions,
485
486
  );
486
487
  return this;
487
488
  }
@@ -491,78 +492,78 @@ export class collection extends AptosBaseProcessor {
491
492
  event: collection.ConcurrentMintEventInstance,
492
493
  ctx: AptosContext,
493
494
  ) => void,
494
- fetchConfig?: Partial<MoveFetchConfig>,
495
+ handlerOptions?: HandlerOptions<collection.ConcurrentMintEventInstance>,
495
496
  eventFilter?: Omit<EventFilter, "type" | "account">,
496
497
  ): collection {
497
498
  this.onMoveEvent(
498
499
  func,
499
500
  { ...(eventFilter ?? {}), type: "collection::ConcurrentMintEvent" },
500
- fetchConfig,
501
+ handlerOptions,
501
502
  );
502
503
  return this;
503
504
  }
504
505
 
505
506
  onEventMint(
506
507
  func: (event: collection.MintInstance, ctx: AptosContext) => void,
507
- fetchConfig?: Partial<MoveFetchConfig>,
508
+ handlerOptions?: HandlerOptions<collection.MintInstance>,
508
509
  eventFilter?: Omit<EventFilter, "type" | "account">,
509
510
  ): collection {
510
511
  this.onMoveEvent(
511
512
  func,
512
513
  { ...(eventFilter ?? {}), type: "collection::Mint" },
513
- fetchConfig,
514
+ handlerOptions,
514
515
  );
515
516
  return this;
516
517
  }
517
518
 
518
519
  onEventMintEvent(
519
520
  func: (event: collection.MintEventInstance, ctx: AptosContext) => void,
520
- fetchConfig?: Partial<MoveFetchConfig>,
521
+ handlerOptions?: HandlerOptions<collection.MintEventInstance>,
521
522
  eventFilter?: Omit<EventFilter, "type" | "account">,
522
523
  ): collection {
523
524
  this.onMoveEvent(
524
525
  func,
525
526
  { ...(eventFilter ?? {}), type: "collection::MintEvent" },
526
- fetchConfig,
527
+ handlerOptions,
527
528
  );
528
529
  return this;
529
530
  }
530
531
 
531
532
  onEventMutation(
532
533
  func: (event: collection.MutationInstance, ctx: AptosContext) => void,
533
- fetchConfig?: Partial<MoveFetchConfig>,
534
+ handlerOptions?: HandlerOptions<collection.MutationInstance>,
534
535
  eventFilter?: Omit<EventFilter, "type" | "account">,
535
536
  ): collection {
536
537
  this.onMoveEvent(
537
538
  func,
538
539
  { ...(eventFilter ?? {}), type: "collection::Mutation" },
539
- fetchConfig,
540
+ handlerOptions,
540
541
  );
541
542
  return this;
542
543
  }
543
544
 
544
545
  onEventMutationEvent(
545
546
  func: (event: collection.MutationEventInstance, ctx: AptosContext) => void,
546
- fetchConfig?: Partial<MoveFetchConfig>,
547
+ handlerOptions?: HandlerOptions<collection.MutationEventInstance>,
547
548
  eventFilter?: Omit<EventFilter, "type" | "account">,
548
549
  ): collection {
549
550
  this.onMoveEvent(
550
551
  func,
551
552
  { ...(eventFilter ?? {}), type: "collection::MutationEvent" },
552
- fetchConfig,
553
+ handlerOptions,
553
554
  );
554
555
  return this;
555
556
  }
556
557
 
557
558
  onEventSetMaxSupply(
558
559
  func: (event: collection.SetMaxSupplyInstance, ctx: AptosContext) => void,
559
- fetchConfig?: Partial<MoveFetchConfig>,
560
+ handlerOptions?: HandlerOptions<collection.SetMaxSupplyInstance>,
560
561
  eventFilter?: Omit<EventFilter, "type" | "account">,
561
562
  ): collection {
562
563
  this.onMoveEvent(
563
564
  func,
564
565
  { ...(eventFilter ?? {}), type: "collection::SetMaxSupply" },
565
- fetchConfig,
566
+ handlerOptions,
566
567
  );
567
568
  return this;
568
569
  }
@@ -2,7 +2,7 @@ import * as fs from 'fs'
2
2
  import chalk from 'chalk'
3
3
  import path, { join } from 'path'
4
4
  import { AptosCodegen as BaseAptosCodegen } from '@typemove/aptos/codegen'
5
- import { InternalMoveModule, InternalMoveStruct } from '@typemove/move'
5
+ import { InternalMoveModule, InternalMoveStruct, normalizeToJSName } from '@typemove/move'
6
6
  import { AptosNetwork, getRpcEndpoint } from '../network.js'
7
7
  import { Event, MoveModuleBytecode, MoveResource } from '@aptos-labs/ts-sdk'
8
8
  import { SharedNetworkCodegen } from '../../move/shared-network-codegen.js'
@@ -48,6 +48,18 @@ class AptosNetworkCodegen extends BaseAptosCodegen {
48
48
  generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>) {
49
49
  return generator.generateStructs(module, struct, events)
50
50
  }
51
+
52
+ generateForOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {
53
+ const moduleName = normalizeToJSName(module.name)
54
+ const source = `
55
+ onEvent${struct.name}(func: (event: ${moduleName}.${normalizeToJSName(struct.name)}Instance, ctx: ${
56
+ this.PREFIX
57
+ }Context) => void, handlerOptions?: HandlerOptions<${moduleName}.${normalizeToJSName(struct.name)}Instance>, eventFilter?: Omit<EventFilter, "type"|"account">): ${moduleName} {
58
+ this.onMoveEvent(func, {...eventFilter ?? {}, type: '${module.name}::${struct.name}' }, handlerOptions)
59
+ return this
60
+ }`
61
+ return source
62
+ }
51
63
  })(network, this.chainAdapter)
52
64
  }
53
65
 
@@ -0,0 +1,48 @@
1
+ import { Data_AptEvent } from '@sentio/protos'
2
+ import { UserTransactionResponse } from '@aptos-labs/ts-sdk'
3
+ import { MoveCoder } from '@typemove/aptos'
4
+
5
+ type Data_AptEvent_Ext = Data_AptEvent & {
6
+ _tx?: UserTransactionResponse
7
+ _event?: any
8
+ _decodedEvent?: any
9
+ }
10
+
11
+ export class AptEvent implements Data_AptEvent {
12
+ constructor(readonly data: Data_AptEvent_Ext) {}
13
+
14
+ get rawEvent(): string {
15
+ return this.data.rawEvent
16
+ }
17
+ get eventIndex(): number {
18
+ return this.data.eventIndex
19
+ }
20
+ get rawTransaction(): string {
21
+ return this.data.rawTransaction
22
+ }
23
+
24
+ get transaction() {
25
+ if (!this.data._tx) {
26
+ this.data._tx = JSON.parse(this.data.rawTransaction) as UserTransactionResponse
27
+ if (this.data._tx.events == null) {
28
+ this.data._tx.events = []
29
+ }
30
+ }
31
+ return this.data._tx
32
+ }
33
+
34
+ get event() {
35
+ if (!this.data._event) {
36
+ this.data._event = JSON.parse(this.data.rawEvent)
37
+ }
38
+ return this.data._event
39
+ }
40
+
41
+ async decodeEvent(coder: MoveCoder) {
42
+ if (!this.data._decodedEvent) {
43
+ this.data._decodedEvent = await coder.decodeEvent<any>(this.event)
44
+ return this.data._decodedEvent
45
+ }
46
+ return this.data._decodedEvent
47
+ }
48
+ }
@@ -20,4 +20,6 @@ export { MoveCoder } from '@typemove/aptos'
20
20
 
21
21
  export { BUILTIN_TYPES } from '@typemove/move'
22
22
 
23
+ export { type HandlerOptions, type PartitionHandler } from './models.js'
24
+
23
25
  // export * from './utils.js'
@@ -9,6 +9,7 @@ import {
9
9
  ValidatorTransactionResponse,
10
10
  BlockEpilogueTransactionResponse
11
11
  } from '@aptos-labs/ts-sdk'
12
+ import { MoveFetchConfig } from '@sentio/protos'
12
13
 
13
14
  export type GeneralTransactionResponse =
14
15
  | UserTransactionResponse
@@ -27,3 +28,9 @@ export type TypedFunctionPayload<T extends Array<any>> = EntryFunctionPayloadRes
27
28
  */
28
29
  arguments_decoded: T
29
30
  }
31
+
32
+ export type PartitionHandler<D> = (data: D) => string | Promise<string>
33
+
34
+ export type HandlerOptions<D> = Partial<MoveFetchConfig> & {
35
+ partitionKey?: string | PartitionHandler<D>
36
+ }
@@ -45,6 +45,7 @@ export class EventsHandler {
45
45
  handler: (event: Data_EthLog) => Promise<ProcessResult>
46
46
  preprocessHandler?: (event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
47
47
  fetchConfig: EthFetchConfig
48
+ partitionHandler?: (event: Data_EthLog) => string | undefined
48
49
  }
49
50
 
50
51
  export class TraceHandler {
@@ -53,6 +54,7 @@ export class TraceHandler {
53
54
  handler: (trace: Data_EthTrace) => Promise<ProcessResult>
54
55
  preprocessHandler?: (event: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
55
56
  fetchConfig: EthFetchConfig
57
+ partitionHandler?: (trace: Data_EthTrace) => string | undefined
56
58
  }
57
59
 
58
60
  export class BlockHandler {
@@ -62,13 +64,15 @@ export class BlockHandler {
62
64
  handler: (block: Data_EthBlock) => Promise<ProcessResult>
63
65
  preprocessHandler?: (event: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
64
66
  fetchConfig: EthFetchConfig
67
+ partitionHandler?: (block: Data_EthBlock) => string | undefined
65
68
  }
66
69
 
67
70
  export class TransactionHandler {
68
- handler: (block: Data_EthTransaction) => Promise<ProcessResult>
71
+ handler: (tx: Data_EthTransaction) => Promise<ProcessResult>
69
72
  handlerName: string
70
73
  preprocessHandler?: (event: Data_EthTransaction, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
71
74
  fetchConfig: EthFetchConfig
75
+ partitionHandler?: (tx: Data_EthTransaction) => string | undefined
72
76
  }
73
77
 
74
78
  class BindInternalOptions {
@@ -131,7 +135,8 @@ export class GlobalProcessor {
131
135
  preprocessStore: {
132
136
  [k: string]: any
133
137
  }
134
- ) => Promise<PreprocessResult> = defaultPreprocessHandler
138
+ ) => Promise<PreprocessResult> = defaultPreprocessHandler,
139
+ partitionHandler?: (block: Data_EthBlock) => string | undefined
135
140
  ): this {
136
141
  return this.onInterval(
137
142
  handler,
@@ -38,6 +38,7 @@ export class EventHandler<T> {
38
38
  handlerName: string
39
39
  handler: (event: T) => Promise<ProcessResult>
40
40
  fetchConfig: MoveFetchConfig
41
+ partitionHandler?: (event: T) => Promise<string | undefined>
41
42
  }
42
43
 
43
44
  export class CallHandler<T> {
@@ -126,6 +126,7 @@ onEvent${struct.name}(func: (event: ${moduleName}.${normalizeToJSName(struct.nam
126
126
  import {
127
127
  ${this.PREFIX}BindOptions, ${this.PREFIX}BaseProcessor,
128
128
  ${this.PREFIX}Network, TypedFunctionPayload,
129
+ HandlerOptions,
129
130
  ${this.PREFIX}Context } from "@sentio/sdk/${this.PREFIX.toLowerCase()}"
130
131
  `
131
132
  }
@@ -41,6 +41,7 @@ import {
41
41
  SuiBaseProcessor,
42
42
  SuiNetwork,
43
43
  TypedFunctionPayload,
44
+ HandlerOptions,
44
45
  SuiContext,
45
46
  } from "@sentio/sdk/sui";
46
47
 
@@ -41,6 +41,7 @@ import {
41
41
  SuiBaseProcessor,
42
42
  SuiNetwork,
43
43
  TypedFunctionPayload,
44
+ HandlerOptions,
44
45
  SuiContext,
45
46
  } from "@sentio/sdk/sui";
46
47
 
@@ -41,6 +41,7 @@ import {
41
41
  SuiBaseProcessor,
42
42
  SuiNetwork,
43
43
  TypedFunctionPayload,
44
+ HandlerOptions,
44
45
  SuiContext,
45
46
  } from "@sentio/sdk/sui";
46
47
 
package/src/sui/models.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { SuiEvent, MoveCallSuiTransaction, SuiMoveObject } from '@mysten/sui/client'
2
2
  import { DecodedStruct } from '@typemove/move'
3
+ import { MoveFetchConfig } from '@sentio/protos'
3
4
 
4
5
  export type TypedEventInstance<T> = DecodedStruct<SuiEvent, T>
5
6
  export type TypedSuiMoveObject<T> = DecodedStruct<SuiMoveObject, T>
@@ -10,3 +11,9 @@ export type TypedFunctionPayload<T extends Array<any>> = MoveCallSuiTransaction
10
11
  */
11
12
  arguments_decoded: T
12
13
  }
14
+
15
+ export type PartitionHandler<D> = (data: D) => string | Promise<string>
16
+
17
+ export type HandlerOptions<D> = Partial<MoveFetchConfig> & {
18
+ partitionKey?: string | PartitionHandler<D>
19
+ }