@sentio/sdk 2.15.7-rc.2 → 2.16.0-rc.2

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 (45) hide show
  1. package/lib/aptos/aptos-plugin.js +3 -14
  2. package/lib/aptos/aptos-plugin.js.map +1 -1
  3. package/lib/core/core-plugin.js +3 -0
  4. package/lib/core/core-plugin.js.map +1 -1
  5. package/lib/core/template.d.ts +5 -0
  6. package/lib/core/template.js +6 -0
  7. package/lib/core/template.js.map +1 -0
  8. package/lib/eth/base-processor-template.d.ts +1 -4
  9. package/lib/eth/base-processor-template.js +2 -7
  10. package/lib/eth/base-processor-template.js.map +1 -1
  11. package/lib/eth/eth-plugin.js +6 -3
  12. package/lib/eth/eth-plugin.js.map +1 -1
  13. package/lib/sui/context.d.ts +7 -1
  14. package/lib/sui/context.js +12 -2
  15. package/lib/sui/context.js.map +1 -1
  16. package/lib/sui/ext/move-dex.d.ts +2 -2
  17. package/lib/sui/ext/move-dex.js.map +1 -1
  18. package/lib/sui/index.d.ts +3 -1
  19. package/lib/sui/index.js +5 -1
  20. package/lib/sui/index.js.map +1 -1
  21. package/lib/sui/sui-object-processor-template.d.ts +34 -0
  22. package/lib/sui/sui-object-processor-template.js +88 -0
  23. package/lib/sui/sui-object-processor-template.js.map +1 -0
  24. package/lib/sui/sui-object-processor.d.ts +54 -0
  25. package/lib/sui/sui-object-processor.js +93 -0
  26. package/lib/sui/sui-object-processor.js.map +1 -0
  27. package/lib/sui/sui-plugin.d.ts +1 -1
  28. package/lib/sui/sui-plugin.js +21 -2
  29. package/lib/sui/sui-plugin.js.map +1 -1
  30. package/lib/sui/sui-processor.d.ts +8 -56
  31. package/lib/sui/sui-processor.js +9 -122
  32. package/lib/sui/sui-processor.js.map +1 -1
  33. package/package.json +4 -3
  34. package/src/aptos/aptos-plugin.ts +3 -15
  35. package/src/core/core-plugin.ts +4 -0
  36. package/src/core/template.ts +6 -0
  37. package/src/eth/base-processor-template.ts +2 -7
  38. package/src/eth/eth-plugin.ts +8 -3
  39. package/src/sui/context.ts +15 -2
  40. package/src/sui/ext/move-dex.ts +2 -2
  41. package/src/sui/index.ts +13 -1
  42. package/src/sui/sui-object-processor-template.ts +153 -0
  43. package/src/sui/sui-object-processor.ts +186 -0
  44. package/src/sui/sui-plugin.ts +32 -2
  45. package/src/sui/sui-processor.ts +14 -196
@@ -0,0 +1,88 @@
1
+ import { ListStateStorage } from '@sentio/runtime';
2
+ import { DEFAULT_FETCH_CONFIG, SuiObjectProcessor, SuiWrappedObjectProcessor, } from './sui-object-processor.js';
3
+ import { TemplateInstanceState } from '../core/template.js';
4
+ class ObjectHandler {
5
+ type;
6
+ versionInterval;
7
+ timeIntervalInMinutes;
8
+ handler;
9
+ fetchConfig;
10
+ }
11
+ class SuiAccountProcessorTemplateState extends ListStateStorage {
12
+ static INSTANCE = new SuiAccountProcessorTemplateState();
13
+ }
14
+ export { SuiAccountProcessorTemplateState };
15
+ export class SuiObjectOrAddressProcessorTemplate {
16
+ id;
17
+ objectHandlers = [];
18
+ binds = new Set();
19
+ constructor() {
20
+ this.id = SuiAccountProcessorTemplateState.INSTANCE.getValues().length;
21
+ SuiAccountProcessorTemplateState.INSTANCE.addValue(this);
22
+ }
23
+ bind(options, ctx) {
24
+ options.network = options.network || ctx.network;
25
+ const sig = [options.network, options.objectId].join('_');
26
+ if (this.binds.has(sig)) {
27
+ console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`);
28
+ return;
29
+ }
30
+ this.binds.add(sig);
31
+ const processor = this.createProcessor(options);
32
+ for (const h of this.objectHandlers) {
33
+ processor.onInterval(h.handler, h.timeIntervalInMinutes, h.versionInterval, h.type, h.fetchConfig);
34
+ }
35
+ const config = processor.config;
36
+ ctx._res.states.configUpdated = true;
37
+ TemplateInstanceState.INSTANCE.addValue({
38
+ templateId: this.id,
39
+ contract: {
40
+ name: '',
41
+ chainId: config.network,
42
+ address: config.address,
43
+ abi: '',
44
+ },
45
+ startBlock: config.startCheckpoint,
46
+ endBlock: 0n,
47
+ });
48
+ }
49
+ onInterval(handler, timeInterval, versionInterval, type, fetchConfig) {
50
+ this.objectHandlers.push({
51
+ handler: handler,
52
+ timeIntervalInMinutes: timeInterval,
53
+ versionInterval: versionInterval,
54
+ type,
55
+ fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },
56
+ });
57
+ return this;
58
+ }
59
+ onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type, fetchConfig) {
60
+ return this.onInterval(handler, {
61
+ recentInterval: timeIntervalInMinutes,
62
+ backfillInterval: backfillTimeIntervalInMinutes,
63
+ }, undefined, type, fetchConfig);
64
+ }
65
+ onSlotInterval(handler, slotInterval = 100000, backfillSlotInterval = 400000, type, fetchConfig) {
66
+ return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval }, type, fetchConfig);
67
+ }
68
+ }
69
+ // export class SuiAddressProcessorTemplate extends SuiBaseObjectsProcessorTemplate<
70
+ // (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
71
+ // SuiBindOptions,
72
+ // SuiAddressProcessor
73
+ // > {
74
+ // bind(options: SuiBindOptions, ctx: SuiContext): SuiAddressProcessor {
75
+ // return this.bindInternal(SuiAddressProcessorTemplate.bind(options), ctx)
76
+ // }
77
+ // }
78
+ export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate {
79
+ createProcessor(options) {
80
+ return SuiObjectProcessor.bind(options);
81
+ }
82
+ }
83
+ export class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate {
84
+ createProcessor(options) {
85
+ return SuiWrappedObjectProcessor.bind(options);
86
+ }
87
+ }
88
+ //# sourceMappingURL=sui-object-processor-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sui-object-processor-template.js","sourceRoot":"","sources":["../../src/sui/sui-object-processor-template.ts"],"names":[],"mappings":"AACA,O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ACnB,OAAoB,EACpB,YAAY,GAAG,MAAM,EACrB,oBAAoB,GAAG,MAAM,EAC7B,IAAa,EACb,WAA6C;QAE7C,OAAO,IAAI,CAAC,UAAU,CACpB,OAAO,EACP,SAAS,EACT,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,EACxE,IAAI,EACJ,WAAW,CACZ,CAAA;IACH,CAAC;CACF;AAED,oFAAoF;AACpF,yEAAyE;AACzE,oBAAoB;AACpB,wBAAwB;AACxB,MAAM;AACN,0EAA0E;AAC1E,+EAA+E;AAC/E,MAAM;AACN,IAAI;AAEJ,MAAM,OAAO,0BAA2B,SAAQ,mCAI/C;IACC,eAAe,CAAC,OAA6B;QAC3C,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACzC,CAAC;CACF;AAED,MAAM,OAAO,iCAAkC,SAAQ,mCAItD;IACC,eAAe,CAAC,OAA6B;QAC3C,OAAO,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;CACF","sourcesContent":["import { HandleInterval, MoveAccountFetchConfig } from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { SuiContext, SuiObjectContext } from './context.js'\nimport { SuiMoveObject } from '@mysten/sui.js'\nimport { PromiseOrVoid } from '../core/index.js'\nimport {\n DEFAULT_FETCH_CONFIG,\n SuiBaseObjectOrAddressProcessor,\n SuiObjectBindOptions,\n SuiObjectProcessor,\n SuiWrappedObjectProcessor,\n} from './sui-object-processor.js'\nimport { TemplateInstanceState } from '../core/template.js'\n\nclass ObjectHandler<HandlerType> {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: HandlerType\n fetchConfig: MoveAccountFetchConfig\n}\n\nexport class SuiAccountProcessorTemplateState extends ListStateStorage<SuiObjectOrAddressProcessorTemplate<any, any>> {\n static INSTANCE = new SuiAccountProcessorTemplateState()\n}\n\nexport abstract class SuiObjectOrAddressProcessorTemplate<\n HandlerType,\n // OptionType,\n ProcessorType extends SuiBaseObjectOrAddressProcessor<HandlerType>\n> {\n id: number\n objectHandlers: ObjectHandler<HandlerType>[] = []\n binds = new Set<string>()\n\n constructor() {\n this.id = SuiAccountProcessorTemplateState.INSTANCE.getValues().length\n SuiAccountProcessorTemplateState.INSTANCE.addValue(this)\n }\n\n protected abstract createProcessor(options: SuiObjectBindOptions): ProcessorType\n\n bind(options: SuiObjectBindOptions, ctx: SuiContext): void {\n options.network = options.network || ctx.network\n const sig = [options.network, options.objectId].join('_')\n if (this.binds.has(sig)) {\n console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`)\n return\n }\n this.binds.add(sig)\n\n const processor = this.createProcessor(options)\n for (const h of this.objectHandlers) {\n processor.onInterval(h.handler, h.timeIntervalInMinutes, h.versionInterval, h.type, h.fetchConfig)\n }\n const config = processor.config\n\n ctx._res.states.configUpdated = true\n TemplateInstanceState.INSTANCE.addValue({\n templateId: this.id,\n contract: {\n name: '',\n chainId: config.network,\n address: config.address,\n abi: '',\n },\n startBlock: config.startCheckpoint,\n endBlock: 0n,\n })\n }\n\n protected onInterval(\n handler: HandlerType,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined,\n fetchConfig: Partial<MoveAccountFetchConfig> | undefined\n ): this {\n this.objectHandlers.push({\n handler: handler,\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n type,\n fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },\n })\n return this\n }\n\n public onTimeInterval(\n handler: HandlerType,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type,\n fetchConfig\n )\n }\n\n public onSlotInterval(\n handler: HandlerType,\n slotInterval = 100000,\n backfillSlotInterval = 400000,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },\n type,\n fetchConfig\n )\n }\n}\n\n// export class SuiAddressProcessorTemplate extends SuiBaseObjectsProcessorTemplate<\n// (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n// SuiBindOptions,\n// SuiAddressProcessor\n// > {\n// bind(options: SuiBindOptions, ctx: SuiContext): SuiAddressProcessor {\n// return this.bindInternal(SuiAddressProcessorTemplate.bind(options), ctx)\n// }\n// }\n\nexport class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<\n (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,\n // SuiObjectBindOptions,\n SuiObjectProcessor\n> {\n createProcessor(options: SuiObjectBindOptions): SuiObjectProcessor {\n return SuiObjectProcessor.bind(options)\n }\n}\n\nexport class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<\n (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,\n // SuiObjectBindOptions,\n SuiWrappedObjectProcessor\n> {\n createProcessor(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {\n return SuiWrappedObjectProcessor.bind(options)\n }\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import { Data_SuiObject, HandleInterval, MoveAccountFetchConfig, MoveOwnerType, ProcessResult } from '@sentio/protos';
2
+ import { ListStateStorage } from '@sentio/runtime';
3
+ import { SuiNetwork } from './network.js';
4
+ import { SuiObjectContext } from './context.js';
5
+ import { SuiMoveObject } from '@mysten/sui.js';
6
+ import { PromiseOrVoid } from '../core/index.js';
7
+ import { IndexConfigure, SuiBindOptions } from './sui-processor.js';
8
+ export interface SuiObjectBindOptions {
9
+ objectId: string;
10
+ network?: SuiNetwork;
11
+ startCheckpoint?: bigint;
12
+ baseLabels?: {
13
+ [key: string]: string;
14
+ };
15
+ }
16
+ interface ObjectHandler {
17
+ type?: string;
18
+ versionInterval?: HandleInterval;
19
+ timeIntervalInMinutes?: HandleInterval;
20
+ fetchConfig: MoveAccountFetchConfig;
21
+ handler: (resource: Data_SuiObject) => Promise<ProcessResult>;
22
+ }
23
+ export declare const DEFAULT_FETCH_CONFIG: MoveAccountFetchConfig;
24
+ export declare class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectOrAddressProcessor<any>> {
25
+ static INSTANCE: SuiAccountProcessorState;
26
+ }
27
+ export interface SuiInternalObjectsBindOptions extends SuiBindOptions {
28
+ ownerType: MoveOwnerType;
29
+ }
30
+ export declare abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
31
+ config: IndexConfigure;
32
+ ownerType: MoveOwnerType;
33
+ objectHandlers: ObjectHandler[];
34
+ protected constructor(options: SuiInternalObjectsBindOptions);
35
+ getChainId(): string;
36
+ protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid;
37
+ onInterval(handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
38
+ timeInterval: HandleInterval | undefined, versionInterval: HandleInterval | undefined, type: string | undefined, fetchConfig: Partial<MoveAccountFetchConfig> | undefined): this;
39
+ onTimeInterval(handler: HandlerType, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, type?: string, fetchConfig?: Partial<MoveAccountFetchConfig>): this;
40
+ onSlotInterval(handler: HandlerType, slotInterval?: number, backfillSlotInterval?: number, type?: string, fetchConfig?: Partial<MoveAccountFetchConfig>): this;
41
+ }
42
+ export declare class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor<(objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid> {
43
+ static bind(options: SuiBindOptions): SuiAddressProcessor;
44
+ protected doHandle(handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid;
45
+ }
46
+ export declare class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessor<(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid> {
47
+ static bind(options: SuiObjectBindOptions): SuiObjectProcessor;
48
+ protected doHandle(handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid;
49
+ }
50
+ export declare class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessor<(dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid> {
51
+ static bind(options: SuiObjectBindOptions): SuiWrappedObjectProcessor;
52
+ protected doHandle(handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid;
53
+ }
54
+ export {};
@@ -0,0 +1,93 @@
1
+ import { MoveOwnerType } from '@sentio/protos';
2
+ import { ListStateStorage } from '@sentio/runtime';
3
+ import { SuiObjectContext } from './context.js';
4
+ import { configure } from './sui-processor.js';
5
+ export const DEFAULT_FETCH_CONFIG = {
6
+ owned: true,
7
+ };
8
+ class SuiAccountProcessorState extends ListStateStorage {
9
+ static INSTANCE = new SuiAccountProcessorState();
10
+ }
11
+ export { SuiAccountProcessorState };
12
+ export class SuiBaseObjectOrAddressProcessor {
13
+ config;
14
+ ownerType;
15
+ objectHandlers = [];
16
+ // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {
17
+ // return new SuiBaseObjectsProcessor(options)
18
+ // }
19
+ constructor(options) {
20
+ this.config = configure(options);
21
+ this.ownerType = options.ownerType;
22
+ SuiAccountProcessorState.INSTANCE.addValue(this);
23
+ }
24
+ getChainId() {
25
+ return this.config.network;
26
+ }
27
+ onInterval(handler, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
28
+ timeInterval, versionInterval, type, fetchConfig) {
29
+ const processor = this;
30
+ this.objectHandlers.push({
31
+ handler: async function (data) {
32
+ const ctx = new SuiObjectContext(processor.config.network, processor.config.address, data.slot, data.timestamp || new Date(0), processor.config.baseLabels);
33
+ await processor.doHandle(handler, data, ctx);
34
+ return ctx.getProcessResult();
35
+ },
36
+ timeIntervalInMinutes: timeInterval,
37
+ versionInterval: versionInterval,
38
+ type,
39
+ fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },
40
+ });
41
+ return this;
42
+ }
43
+ onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type, fetchConfig) {
44
+ return this.onInterval(handler, {
45
+ recentInterval: timeIntervalInMinutes,
46
+ backfillInterval: backfillTimeIntervalInMinutes,
47
+ }, undefined, type, fetchConfig);
48
+ }
49
+ onSlotInterval(handler, slotInterval = 100000, backfillSlotInterval = 400000, type, fetchConfig) {
50
+ return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval }, type, fetchConfig);
51
+ }
52
+ }
53
+ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor {
54
+ static bind(options) {
55
+ return new SuiAddressProcessor({ ...options, ownerType: MoveOwnerType.ADDRESS });
56
+ }
57
+ doHandle(handler, data, ctx) {
58
+ return handler(data.objects, ctx);
59
+ }
60
+ }
61
+ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessor {
62
+ static bind(options) {
63
+ return new SuiObjectProcessor({
64
+ address: options.objectId,
65
+ network: options.network,
66
+ startCheckpoint: options.startCheckpoint,
67
+ ownerType: MoveOwnerType.OBJECT,
68
+ baseLabels: options.baseLabels,
69
+ });
70
+ }
71
+ doHandle(handler, data, ctx) {
72
+ if (!data.self) {
73
+ console.log(`Sui object not existed in ${ctx.slot}, please specific a start time`);
74
+ return;
75
+ }
76
+ return handler(data.self, data.objects, ctx);
77
+ }
78
+ }
79
+ export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessor {
80
+ static bind(options) {
81
+ return new SuiWrappedObjectProcessor({
82
+ address: options.objectId,
83
+ network: options.network,
84
+ startCheckpoint: options.startCheckpoint,
85
+ ownerType: MoveOwnerType.WRAPPED_OBJECT,
86
+ baseLabels: options.baseLabels,
87
+ });
88
+ }
89
+ doHandle(handler, data, ctx) {
90
+ return handler(data.objects, ctx);
91
+ }
92
+ }
93
+ //# sourceMappingURL=sui-object-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sui-object-processor.js","sourceRoot":"","sources":["../../src/sui/sui-object-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0D,aAAa,EAAiB,MAAM,gBAAgB,CAAA;AACrH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,OAAO,EAAE,SAAS,EAAkC,MAAM,oBAAoB,CAAA;AAiB9E,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,KAAK,EAAE,IAAI;CACZ,CAAA;AAED,MAAa,wBAAyB,SAAQ,gBAAsD;IAClG,MAAM,CAAC,QAAQ,GAAG,IAAI,wBAAwB,EAAE,CAAA;;SADrC,wBAAwB;AAQrC,MAAM,OAAgB,+BAA+B;IACnD,MAAM,CAAgB;IACtB,SAAS,CAAe;IAExB,cAAc,GAAoB,EAAE,CAAA;IAEpC,8EAA8E;IAC9E,gDAAgD;IAChD,IAAI;IAEJ,YAAsB,OAAsC;QAC1D,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;QAChC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAClD,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAA;IAC5B,CAAC;IAMM,U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C,eAAe;YACxC,SAAS,EAAE,aAAa,CAAC,cAAc;YACvC,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAA;IACJ,CAAC;IAES,QAAQ,CAChB,OAAuF,EACvF,IAAoB,EACpB,GAAqB;QAErB,OAAO,OAAO,CAAC,IAAI,CAAC,OAA0B,EAAE,GAAG,CAAC,CAAA;IACtD,CAAC;CACF","sourcesContent":["import { Data_SuiObject, HandleInterval, MoveAccountFetchConfig, MoveOwnerType, ProcessResult } from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { SuiNetwork } from './network.js'\nimport { SuiObjectContext } from './context.js'\nimport { SuiMoveObject } from '@mysten/sui.js'\nimport { PromiseOrVoid } from '../core/index.js'\nimport { configure, IndexConfigure, SuiBindOptions } from './sui-processor.js'\n\nexport interface SuiObjectBindOptions {\n objectId: string\n network?: SuiNetwork\n startCheckpoint?: bigint\n baseLabels?: { [key: string]: string }\n}\n\ninterface ObjectHandler {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n fetchConfig: MoveAccountFetchConfig\n handler: (resource: Data_SuiObject) => Promise<ProcessResult>\n}\n\nexport const DEFAULT_FETCH_CONFIG: MoveAccountFetchConfig = {\n owned: true,\n}\n\nexport class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectOrAddressProcessor<any>> {\n static INSTANCE = new SuiAccountProcessorState()\n}\n\nexport interface SuiInternalObjectsBindOptions extends SuiBindOptions {\n ownerType: MoveOwnerType\n}\n\nexport abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {\n config: IndexConfigure\n ownerType: MoveOwnerType\n\n objectHandlers: ObjectHandler[] = []\n\n // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {\n // return new SuiBaseObjectsProcessor(options)\n // }\n\n protected constructor(options: SuiInternalObjectsBindOptions) {\n this.config = configure(options)\n this.ownerType = options.ownerType\n SuiAccountProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n // protected abstract transformObjects(objects: SuiMoveObject[]): SuiMoveObject[]\n\n protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid\n\n public onInterval(\n handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined,\n fetchConfig: Partial<MoveAccountFetchConfig> | undefined\n ): this {\n const processor = this\n this.objectHandlers.push({\n handler: async function (data) {\n const ctx = new SuiObjectContext(\n processor.config.network,\n processor.config.address,\n data.slot,\n data.timestamp || new Date(0),\n processor.config.baseLabels\n )\n await processor.doHandle(handler, data, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n type,\n fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },\n })\n return this\n }\n\n public onTimeInterval(\n handler: HandlerType,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type,\n fetchConfig\n )\n }\n\n public onSlotInterval(\n handler: HandlerType,\n slotInterval = 100000,\n backfillSlotInterval = 400000,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },\n type,\n fetchConfig\n )\n }\n}\n\nexport class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor<\n (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid\n> {\n static bind(options: SuiBindOptions): SuiAddressProcessor {\n return new SuiAddressProcessor({ ...options, ownerType: MoveOwnerType.ADDRESS })\n }\n\n protected doHandle(\n handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,\n data: Data_SuiObject,\n ctx: SuiObjectContext\n ): PromiseOrVoid {\n return handler(data.objects as SuiMoveObject[], ctx)\n }\n}\n\nexport class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessor<\n (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid\n> {\n static bind(options: SuiObjectBindOptions): SuiObjectProcessor {\n return new SuiObjectProcessor({\n address: options.objectId,\n network: options.network,\n startCheckpoint: options.startCheckpoint,\n ownerType: MoveOwnerType.OBJECT,\n baseLabels: options.baseLabels,\n })\n }\n\n protected doHandle(\n handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,\n data: Data_SuiObject,\n ctx: SuiObjectContext\n ): PromiseOrVoid {\n if (!data.self) {\n console.log(`Sui object not existed in ${ctx.slot}, please specific a start time`)\n return\n }\n return handler(data.self as SuiMoveObject, data.objects as SuiMoveObject[], ctx)\n }\n}\n\nexport class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessor<\n (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid\n> {\n static bind(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {\n return new SuiWrappedObjectProcessor({\n address: options.objectId,\n network: options.network,\n startCheckpoint: options.startCheckpoint,\n ownerType: MoveOwnerType.WRAPPED_OBJECT,\n baseLabels: options.baseLabels,\n })\n }\n\n protected doHandle(\n handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,\n data: Data_SuiObject,\n ctx: SuiObjectContext\n ): PromiseOrVoid {\n return handler(data.objects as SuiMoveObject[], ctx)\n }\n}\n"]}
@@ -8,7 +8,7 @@ interface Handlers {
8
8
  export declare class SuiPlugin extends Plugin {
9
9
  name: string;
10
10
  handlers: Handlers;
11
- start(start: StartRequest): Promise<void>;
11
+ start(request: StartRequest): Promise<void>;
12
12
  configure(config: ProcessConfigResponse): Promise<void>;
13
13
  supportedHandlers: HandlerType[];
14
14
  processSuiEvent(binding: DataBinding): Promise<ProcessResult>;
@@ -1,9 +1,14 @@
1
1
  import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime';
2
2
  import { AccountConfig, ContractConfig, HandlerType, } from '@sentio/protos';
3
3
  import { ServerError, Status } from 'nice-grpc';
4
- import { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js';
4
+ import { SuiProcessorState } from './sui-processor.js';
5
+ import { SuiAccountProcessorState } from './sui-object-processor.js';
5
6
  import { validateAndNormalizeAddress } from './utils.js';
6
7
  import { initCoinList } from './ext/coin.js';
8
+ import { SuiChainId } from '../core/chain.js';
9
+ import { SuiAccountProcessorTemplateState, } from './sui-object-processor-template.js';
10
+ import { SuiNetwork } from './network.js';
11
+ import { SuiContext } from './context.js';
7
12
  export class SuiPlugin extends Plugin {
8
13
  name = 'SuiPlugin';
9
14
  handlers = {
@@ -11,8 +16,20 @@ export class SuiPlugin extends Plugin {
11
16
  suiEventHandlers: [],
12
17
  suiObjectHandlers: [],
13
18
  };
14
- async start(start) {
19
+ async start(request) {
15
20
  await initCoinList();
21
+ const allowedChainIds = new Set(Object.values(SuiChainId));
22
+ for (const instance of request.templateInstances) {
23
+ if (!allowedChainIds.has(instance.contract?.chainId || '')) {
24
+ continue;
25
+ }
26
+ const template = SuiAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId];
27
+ template.bind({
28
+ objectId: instance.contract?.address || '',
29
+ network: instance.contract?.chainId || SuiNetwork.MAIN_NET,
30
+ startCheckpoint: instance.startBlock || 0n,
31
+ }, NoopContext);
32
+ }
16
33
  }
17
34
  async configure(config) {
18
35
  const handlers = {
@@ -83,6 +100,7 @@ export class SuiPlugin extends Plugin {
83
100
  },
84
101
  type: handler.type || '',
85
102
  ownerType: processor.ownerType,
103
+ fetchConfig: undefined,
86
104
  });
87
105
  }
88
106
  config.accountConfigs.push(accountConfig);
@@ -144,4 +162,5 @@ export class SuiPlugin extends Plugin {
144
162
  }
145
163
  }
146
164
  PluginManager.INSTANCE.register(new SuiPlugin());
165
+ const NoopContext = new SuiContext('', SuiChainId.SUI_MAINNET, '', new Date(), 0n, {}, 0, {});
147
166
  //# sourceMappingURL=sui-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/sui/sui-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACzG,OAAO,EACL,aAAa,EACb,cAAc,EAKd,WAAW,GAMZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAQ5C,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,IAAI,GAAW,WAAW,CAAA;IAC1B,QAAQ,GAAa;QACnB,eAAe,EAAE,EAAE;QACnB,gBAAgB,EAAE,EAAE;QACpB,iBAAiB,EAAE,EAAE;KACtB,CAAA;IACD,KAAK,CAAC,KAAK,CAAC,KAAmB;QAC7B,MAAM,YAAY,EAAE,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,MAAM,QAAQ,GAAa;YACzB,eAAe,EAAE,EAAE;YACnB,gBAAgB,EAAE,EAAE;YACpB,iBAAiB,EAAE,EAAE;SACtB,CAAA;QACD,KAAK,MAAM,YAAY,IAAI,iBAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACjE,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,CA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C,CAAC,CAAA;IACzD,CAAC;IAED,cAAc,CAAC,OAAoB;QACjC,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,WAAW,CAAC,SAAS;gBACxB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;YACtC,KAAK,WAAW,CAAC,QAAQ;gBACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAA;YAC7C,KAAK,WAAW,CAAC,UAAU;gBACzB,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;YACvC;gBACE,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;SACrG;IACH,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport {\n AccountConfig,\n ContractConfig,\n Data_SuiCall,\n Data_SuiEvent,\n Data_SuiObject,\n DataBinding,\n HandlerType,\n MoveCallHandlerConfig,\n MoveEventHandlerConfig,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest,\n} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js'\nimport { validateAndNormalizeAddress } from './utils.js'\nimport { initCoinList } from './ext/coin.js'\n\ninterface Handlers {\n suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[]\n suiCallHandlers: ((func: Data_SuiCall) => Promise<ProcessResult>)[]\n suiObjectHandlers: ((object: Data_SuiObject) => Promise<ProcessResult>)[]\n}\n\nexport class SuiPlugin extends Plugin {\n name: string = 'SuiPlugin'\n handlers: Handlers = {\n suiCallHandlers: [],\n suiEventHandlers: [],\n suiObjectHandlers: [],\n }\n async start(start: StartRequest): Promise<void> {\n await initCoinList()\n }\n\n async configure(config: ProcessConfigResponse) {\n const handlers: Handlers = {\n suiCallHandlers: [],\n suiEventHandlers: [],\n suiObjectHandlers: [],\n }\n for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {\n const contractConfig = ContractConfig.fromPartial({\n transactionConfig: [],\n processorType: USER_PROCESSOR,\n contract: {\n name: suiProcessor.moduleName,\n chainId: suiProcessor.config.network,\n address: validateAndNormalizeAddress(suiProcessor.config.address),\n abi: '',\n },\n startBlock: suiProcessor.config.startCheckpoint,\n })\n for (const handler of suiProcessor.eventHandlers) {\n const handlerId = handlers.suiEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: MoveEventHandlerConfig = {\n filters: handler.filters.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\n fetchConfig: handler.fetchConfig,\n handlerId,\n }\n contractConfig.moveEventConfigs.push(eventHandlerConfig)\n }\n for (const handler of suiProcessor.callHandlers) {\n const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: MoveCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments || [],\n withTypeArguments: !!filter.typeArguments,\n includeFailed: filter.includeFailed || false,\n }\n }),\n fetchConfig: handler.fetchConfig,\n handlerId,\n }\n contractConfig.moveCallConfigs.push(functionHandlerConfig)\n }\n config.contractConfigs.push(contractConfig)\n }\n\n for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig = AccountConfig.fromPartial({\n address: validateAndNormalizeAddress(processor.config.address),\n chainId: processor.getChainId(),\n startBlock: processor.config.startCheckpoint, // TODO maybe use another field\n })\n for (const handler of processor.objectHandlers) {\n const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1\n accountConfig.moveIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.versionInterval,\n fetchConfig: undefined,\n },\n type: handler.type || '',\n ownerType: processor.ownerType,\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n this.handlers = handlers\n }\n\n supportedHandlers = [HandlerType.SUI_EVENT, HandlerType.SUI_CALL, HandlerType.SUI_OBJECT]\n\n async processSuiEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.suiEvent) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const promises: Promise<ProcessResult>[] = []\n const event = binding.data.suiEvent\n\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.handlers.suiEventHandlers[handlerId](event).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing event: ' + JSON.stringify(event) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processSuiFunctionCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.suiCall) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Call can't be empty\")\n }\n const call = binding.data.suiCall\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n const promise = this.handlers.suiCallHandlers[handlerId](call).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\\n' + errorString(e))\n })\n promises.push(promise)\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processSuiObject(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.suiObject) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Object can't be empty\")\n }\n const object = binding.data.suiObject\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.handlers.suiObjectHandlers[handlerId](object).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing object: ' + JSON.stringify(object) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SUI_EVENT:\n return this.processSuiEvent(request)\n case HandlerType.SUI_CALL:\n return this.processSuiFunctionCall(request)\n case HandlerType.SUI_OBJECT:\n return this.processSuiObject(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n}\n\nPluginManager.INSTANCE.register(new SuiPlugin())\n"]}
1
+ {"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/sui/sui-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACzG,OAAO,EACL,aAAa,EACb,cAAc,EAKd,WAAW,GAMZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EACL,gCAAgC,GAEjC,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAQzC,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,IAAI,GAAW,WAAW,CAAA;IAC1B,QAAQ,GAAa;QACnB,eAAe,EAAE,EAAE;QACnB,gBAAgB,EAAE,EAAE;QACpB,iBAAiB,EAAE,EAAE;KACtB,CAAA;IACD,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,MAAM,YAAY,EAAE,CAAA;QAEpB,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC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;YACvC;gBACE,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;SACrG;IACH,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA;AAEhD,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,EAAE,EAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA","sourcesContent":["import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport {\n AccountConfig,\n ContractConfig,\n Data_SuiCall,\n Data_SuiEvent,\n Data_SuiObject,\n DataBinding,\n HandlerType,\n MoveCallHandlerConfig,\n MoveEventHandlerConfig,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest,\n} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { SuiProcessorState } from './sui-processor.js'\nimport { SuiAccountProcessorState } from './sui-object-processor.js'\nimport { validateAndNormalizeAddress } from './utils.js'\nimport { initCoinList } from './ext/coin.js'\nimport { SuiChainId } from '../core/chain.js'\nimport {\n SuiAccountProcessorTemplateState,\n SuiObjectOrAddressProcessorTemplate,\n} from './sui-object-processor-template.js'\nimport { SuiNetwork } from './network.js'\nimport { SuiContext } from './context.js'\n\ninterface Handlers {\n suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[]\n suiCallHandlers: ((func: Data_SuiCall) => Promise<ProcessResult>)[]\n suiObjectHandlers: ((object: Data_SuiObject) => Promise<ProcessResult>)[]\n}\n\nexport class SuiPlugin extends Plugin {\n name: string = 'SuiPlugin'\n handlers: Handlers = {\n suiCallHandlers: [],\n suiEventHandlers: [],\n suiObjectHandlers: [],\n }\n async start(request: StartRequest): Promise<void> {\n await initCoinList()\n\n const allowedChainIds = new Set<string>(Object.values(SuiChainId))\n for (const instance of request.templateInstances) {\n if (!allowedChainIds.has(instance.contract?.chainId || '')) {\n continue\n }\n\n const template: SuiObjectOrAddressProcessorTemplate<any, any> =\n SuiAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId]\n\n template.bind(\n {\n objectId: instance.contract?.address || '',\n network: <SuiNetwork>instance.contract?.chainId || SuiNetwork.MAIN_NET,\n startCheckpoint: instance.startBlock || 0n,\n },\n NoopContext\n )\n }\n }\n\n async configure(config: ProcessConfigResponse) {\n const handlers: Handlers = {\n suiCallHandlers: [],\n suiEventHandlers: [],\n suiObjectHandlers: [],\n }\n for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {\n const contractConfig = ContractConfig.fromPartial({\n transactionConfig: [],\n processorType: USER_PROCESSOR,\n contract: {\n name: suiProcessor.moduleName,\n chainId: suiProcessor.config.network,\n address: validateAndNormalizeAddress(suiProcessor.config.address),\n abi: '',\n },\n startBlock: suiProcessor.config.startCheckpoint,\n })\n for (const handler of suiProcessor.eventHandlers) {\n const handlerId = handlers.suiEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: MoveEventHandlerConfig = {\n filters: handler.filters.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\n fetchConfig: handler.fetchConfig,\n handlerId,\n }\n contractConfig.moveEventConfigs.push(eventHandlerConfig)\n }\n for (const handler of suiProcessor.callHandlers) {\n const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: MoveCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments || [],\n withTypeArguments: !!filter.typeArguments,\n includeFailed: filter.includeFailed || false,\n }\n }),\n fetchConfig: handler.fetchConfig,\n handlerId,\n }\n contractConfig.moveCallConfigs.push(functionHandlerConfig)\n }\n config.contractConfigs.push(contractConfig)\n }\n\n for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig = AccountConfig.fromPartial({\n address: validateAndNormalizeAddress(processor.config.address),\n chainId: processor.getChainId(),\n startBlock: processor.config.startCheckpoint, // TODO maybe use another field\n })\n for (const handler of processor.objectHandlers) {\n const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1\n accountConfig.moveIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.versionInterval,\n fetchConfig: undefined,\n },\n type: handler.type || '',\n ownerType: processor.ownerType,\n fetchConfig: undefined,\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n this.handlers = handlers\n }\n\n supportedHandlers = [HandlerType.SUI_EVENT, HandlerType.SUI_CALL, HandlerType.SUI_OBJECT]\n\n async processSuiEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.suiEvent) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const promises: Promise<ProcessResult>[] = []\n const event = binding.data.suiEvent\n\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.handlers.suiEventHandlers[handlerId](event).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing event: ' + JSON.stringify(event) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processSuiFunctionCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.suiCall) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Call can't be empty\")\n }\n const call = binding.data.suiCall\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n const promise = this.handlers.suiCallHandlers[handlerId](call).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\\n' + errorString(e))\n })\n promises.push(promise)\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processSuiObject(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.suiObject) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Object can't be empty\")\n }\n const object = binding.data.suiObject\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.handlers.suiObjectHandlers[handlerId](object).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing object: ' + JSON.stringify(object) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SUI_EVENT:\n return this.processSuiEvent(request)\n case HandlerType.SUI_CALL:\n return this.processSuiFunctionCall(request)\n case HandlerType.SUI_OBJECT:\n return this.processSuiObject(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n}\n\nPluginManager.INSTANCE.register(new SuiPlugin())\n\nconst NoopContext = new SuiContext('', SuiChainId.SUI_MAINNET, '', new Date(), 0n, {} as any, 0, {})\n"]}
@@ -1,31 +1,20 @@
1
- import { Data_SuiCall, Data_SuiEvent, Data_SuiObject, HandleInterval, MoveFetchConfig, MoveOnIntervalConfig_OwnerType, ProcessResult } from '@sentio/protos';
1
+ import { Data_SuiCall, Data_SuiEvent, MoveFetchConfig } from '@sentio/protos';
2
2
  import { ListStateStorage } from '@sentio/runtime';
3
3
  import { SuiNetwork } from './network.js';
4
- import { SuiContext, SuiObjectsContext } from './context.js';
5
- import { MoveCallSuiTransaction, SuiEvent, SuiMoveObject } from '@mysten/sui.js';
4
+ import { SuiContext } from './context.js';
5
+ import { MoveCallSuiTransaction, SuiEvent } from '@mysten/sui.js';
6
6
  import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js';
7
7
  import { MoveCoder } from './move-coder.js';
8
- import { Labels, PromiseOrVoid } from '../core/index.js';
9
- declare class IndexConfigure {
10
- address: string;
11
- network: SuiNetwork;
12
- startCheckpoint: bigint;
13
- baseLabels?: Labels;
14
- }
15
- export declare class SuiBindOptions {
8
+ import { Labels } from '../core/index.js';
9
+ import { Required } from 'utility-types';
10
+ export type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'network'>;
11
+ export declare function configure(options: SuiBindOptions): IndexConfigure;
12
+ export interface SuiBindOptions {
16
13
  address: string;
17
14
  network?: SuiNetwork;
18
15
  startCheckpoint?: bigint;
19
16
  baseLabels?: Labels;
20
17
  }
21
- export declare class SuiObjectBindOptions {
22
- objectId: string;
23
- network?: SuiNetwork;
24
- startCheckpoint?: bigint;
25
- baseLabels?: {
26
- [key: string]: string;
27
- };
28
- }
29
18
  export declare class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {
30
19
  static INSTANCE: SuiProcessorState;
31
20
  }
@@ -40,40 +29,3 @@ export declare class SuiBaseProcessor {
40
29
  onMoveEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, filter: EventFilter | EventFilter[], fetchConfig?: Partial<MoveFetchConfig>): SuiBaseProcessor;
41
30
  onEntryFunctionCall(handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: Partial<MoveFetchConfig>): SuiBaseProcessor;
42
31
  }
43
- declare class ObjectHandler {
44
- type?: string;
45
- versionInterval?: HandleInterval;
46
- timeIntervalInMinutes?: HandleInterval;
47
- handler: (resource: Data_SuiObject) => Promise<ProcessResult>;
48
- }
49
- export declare class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectsProcessor<any>> {
50
- static INSTANCE: SuiAccountProcessorState;
51
- }
52
- declare class SuiObjectsBindOptions extends SuiBindOptions {
53
- ownerType: MoveOnIntervalConfig_OwnerType;
54
- }
55
- declare abstract class SuiBaseObjectsProcessor<HandlerType> {
56
- config: IndexConfigure;
57
- ownerType: MoveOnIntervalConfig_OwnerType;
58
- objectHandlers: ObjectHandler[];
59
- protected constructor(options: SuiObjectsBindOptions);
60
- getChainId(): string;
61
- protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx: SuiObjectsContext): PromiseOrVoid;
62
- protected onInterval(handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
63
- timeInterval: HandleInterval | undefined, versionInterval: HandleInterval | undefined, type: string | undefined): this;
64
- onTimeInterval(handler: HandlerType, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, type?: string): this;
65
- onSlotInterval(handler: HandlerType, slotInterval?: number, backfillSlotInterval?: number, type?: string): this;
66
- }
67
- export declare class SuiAddressProcessor extends SuiBaseObjectsProcessor<(objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid> {
68
- static bind(options: SuiBindOptions): SuiAddressProcessor;
69
- protected doHandle(handler: (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid, data: Data_SuiObject, ctx: SuiObjectsContext): PromiseOrVoid;
70
- }
71
- export declare class SuiObjectProcessor extends SuiBaseObjectsProcessor<(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid> {
72
- static bind(options: SuiObjectBindOptions): SuiObjectProcessor;
73
- protected doHandle(handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid, data: Data_SuiObject, ctx: SuiObjectsContext): PromiseOrVoid;
74
- }
75
- export declare class SuiWrappedObjectProcessor extends SuiBaseObjectsProcessor<(dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid> {
76
- static bind(options: SuiObjectBindOptions): SuiWrappedObjectProcessor;
77
- protected doHandle(handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid, data: Data_SuiObject, ctx: SuiObjectsContext): PromiseOrVoid;
78
- }
79
- export {};
@@ -1,34 +1,23 @@
1
- import { MoveFetchConfig, MoveOnIntervalConfig_OwnerType, } from '@sentio/protos';
1
+ import { MoveFetchConfig } from '@sentio/protos';
2
2
  import { ListStateStorage, mergeProcessResults } from '@sentio/runtime';
3
3
  import { SuiNetwork } from './network.js';
4
4
  import { ServerError, Status } from 'nice-grpc';
5
- import { SuiContext, SuiObjectsContext } from './context.js';
5
+ import { SuiContext } from './context.js';
6
6
  import { getProgrammableTransaction, getTransactionKind, } from '@mysten/sui.js';
7
7
  import { parseMoveType, SPLITTER, } from '../move/index.js';
8
8
  import { getMoveCalls } from './utils.js';
9
9
  import { defaultMoveCoder } from './move-coder.js';
10
- // import { dynamic_field } from './builtin/0x2.js'
11
10
  const DEFAULT_FETCH_CONFIG = {
12
11
  resourceChanges: false,
13
12
  allEvents: true,
14
13
  };
15
- class IndexConfigure {
16
- address;
17
- network;
18
- startCheckpoint;
19
- baseLabels;
20
- }
21
- export class SuiBindOptions {
22
- address;
23
- network;
24
- startCheckpoint;
25
- baseLabels;
26
- }
27
- export class SuiObjectBindOptions {
28
- objectId;
29
- network;
30
- startCheckpoint;
31
- baseLabels;
14
+ export function configure(options) {
15
+ return {
16
+ startCheckpoint: options.startCheckpoint || 0n,
17
+ address: options.address,
18
+ network: options.network || SuiNetwork.MAIN_NET,
19
+ baseLabels: options.baseLabels,
20
+ };
32
21
  }
33
22
  class SuiProcessorState extends ListStateStorage {
34
23
  static INSTANCE = new SuiProcessorState();
@@ -135,106 +124,4 @@ export class SuiBaseProcessor {
135
124
  return this;
136
125
  }
137
126
  }
138
- class ObjectHandler {
139
- type;
140
- versionInterval;
141
- timeIntervalInMinutes;
142
- handler;
143
- }
144
- class SuiAccountProcessorState extends ListStateStorage {
145
- static INSTANCE = new SuiAccountProcessorState();
146
- }
147
- export { SuiAccountProcessorState };
148
- class SuiObjectsBindOptions extends SuiBindOptions {
149
- ownerType;
150
- }
151
- class SuiBaseObjectsProcessor {
152
- config;
153
- ownerType;
154
- objectHandlers = [];
155
- // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {
156
- // return new SuiBaseObjectsProcessor(options)
157
- // }
158
- constructor(options) {
159
- this.config = configure(options);
160
- this.ownerType = options.ownerType;
161
- SuiAccountProcessorState.INSTANCE.addValue(this);
162
- }
163
- getChainId() {
164
- return this.config.network;
165
- }
166
- onInterval(handler, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
167
- timeInterval, versionInterval, type) {
168
- const processor = this;
169
- this.objectHandlers.push({
170
- handler: async function (data) {
171
- const ctx = new SuiObjectsContext(processor.config.network, processor.config.address, data.slot, data.timestamp || new Date(0), processor.config.baseLabels);
172
- await processor.doHandle(handler, data, ctx);
173
- return ctx.getProcessResult();
174
- },
175
- timeIntervalInMinutes: timeInterval,
176
- versionInterval: versionInterval,
177
- type,
178
- });
179
- return this;
180
- }
181
- onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type) {
182
- return this.onInterval(handler, {
183
- recentInterval: timeIntervalInMinutes,
184
- backfillInterval: backfillTimeIntervalInMinutes,
185
- }, undefined, type);
186
- }
187
- onSlotInterval(handler, slotInterval = 100000, backfillSlotInterval = 400000, type) {
188
- return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval }, type);
189
- }
190
- }
191
- function configure(options) {
192
- return {
193
- startCheckpoint: options.startCheckpoint || 0n,
194
- address: options.address,
195
- network: options.network || SuiNetwork.MAIN_NET,
196
- baseLabels: options.baseLabels,
197
- };
198
- }
199
- export class SuiAddressProcessor extends SuiBaseObjectsProcessor {
200
- static bind(options) {
201
- return new SuiAddressProcessor({ ...options, ownerType: MoveOnIntervalConfig_OwnerType.ADDRESS });
202
- }
203
- doHandle(handler, data, ctx) {
204
- return handler(data.objects, ctx);
205
- }
206
- }
207
- // export class SuiDynamicFieldObjectsProcessor extends SuiBaseObjectsProcessor<dynamic_field.Field<any, any>> {
208
- export class SuiObjectProcessor extends SuiBaseObjectsProcessor {
209
- static bind(options) {
210
- return new SuiObjectProcessor({
211
- address: options.objectId,
212
- network: options.network,
213
- startCheckpoint: options.startCheckpoint,
214
- ownerType: MoveOnIntervalConfig_OwnerType.OBJECT,
215
- baseLabels: options.baseLabels,
216
- });
217
- }
218
- doHandle(handler, data, ctx) {
219
- if (!data.self) {
220
- console.log(`Sui object not existed in ${ctx.slot}, please specific a start time`);
221
- return;
222
- }
223
- return handler(data.self, data.objects, ctx);
224
- }
225
- }
226
- export class SuiWrappedObjectProcessor extends SuiBaseObjectsProcessor {
227
- static bind(options) {
228
- return new SuiWrappedObjectProcessor({
229
- address: options.objectId,
230
- network: options.network,
231
- startCheckpoint: options.startCheckpoint,
232
- ownerType: MoveOnIntervalConfig_OwnerType.WRAPPED_OBJECT,
233
- baseLabels: options.baseLabels,
234
- });
235
- }
236
- doHandle(handler, data, ctx) {
237
- return handler(data.objects, ctx);
238
- }
239
- }
240
127
  //# sourceMappingURL=sui-processor.js.map