@sentio/sdk 2.20.1 → 2.21.0-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.
@@ -1,6 +1,6 @@
1
1
  export { SuiBaseProcessor, SuiGlobalProcessor, SuiModulesProcessor, type SuiBindOptions } from './sui-processor.js';
2
2
  export { SuiAddressProcessor, SuiObjectProcessor, SuiWrappedObjectProcessor, type SuiObjectBindOptions, } from './sui-object-processor.js';
3
- export { SuiObjectProcessorTemplate, SuiWrappedObjectProcessorTemplate, } from './sui-object-processor-template.js';
3
+ export { SuiAddressProcessorTemplate, SuiObjectProcessorTemplate, SuiWrappedObjectProcessorTemplate, } from './sui-object-processor-template.js';
4
4
  export * from './network.js';
5
5
  export * from './context.js';
6
6
  export * from './models.js';
package/lib/sui/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  export { SuiBaseProcessor, SuiGlobalProcessor, SuiModulesProcessor } from './sui-processor.js';
2
2
  export { SuiAddressProcessor, SuiObjectProcessor, SuiWrappedObjectProcessor, } from './sui-object-processor.js';
3
- export {
4
- // SuiAddressProcessorTemplate,
5
- SuiObjectProcessorTemplate, SuiWrappedObjectProcessorTemplate, } from './sui-object-processor-template.js';
3
+ export { SuiAddressProcessorTemplate, SuiObjectProcessorTemplate, SuiWrappedObjectProcessorTemplate, } from './sui-object-processor-template.js';
6
4
  export * from './network.js';
7
5
  export * from './context.js';
8
6
  export * from './models.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAuB,MAAM,oBAAoB,CAAA;AACnH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,2BAA2B,CAAA;AAElC,OAAO;AACL,+BAA+B;AAC/B,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,oCAAoC,CAAA;AAE3C,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { SuiBaseProcessor, SuiGlobalProcessor, SuiModulesProcessor, type SuiBindOptions } from './sui-processor.js'\nexport {\n SuiAddressProcessor,\n SuiObjectProcessor,\n SuiWrappedObjectProcessor,\n type SuiObjectBindOptions,\n} from './sui-object-processor.js'\n\nexport {\n // SuiAddressProcessorTemplate,\n SuiObjectProcessorTemplate,\n SuiWrappedObjectProcessorTemplate,\n} from './sui-object-processor-template.js'\n\nexport * from './network.js'\nexport * from './context.js'\nexport * from './models.js'\n\nexport type { SuiAddress } from './move-types.js'\nexport { BUILTIN_TYPES } from '../move/types.js'\n\nexport * from './move-coder.js'\n\nexport { SuiPlugin } from './sui-plugin.js'\n\nexport { ModuleClient } from './module-client.js'\n\nexport { validateAndNormalizeAddress, isValidSuiAddress } from './utils.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAuB,MAAM,oBAAoB,CAAA;AACnH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,oCAAoC,CAAA;AAE3C,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { SuiBaseProcessor, SuiGlobalProcessor, SuiModulesProcessor, type SuiBindOptions } from './sui-processor.js'\nexport {\n SuiAddressProcessor,\n SuiObjectProcessor,\n SuiWrappedObjectProcessor,\n type SuiObjectBindOptions,\n} from './sui-object-processor.js'\n\nexport {\n SuiAddressProcessorTemplate,\n SuiObjectProcessorTemplate,\n SuiWrappedObjectProcessorTemplate,\n} from './sui-object-processor-template.js'\n\nexport * from './network.js'\nexport * from './context.js'\nexport * from './models.js'\n\nexport type { SuiAddress } from './move-types.js'\nexport { BUILTIN_TYPES } from '../move/types.js'\n\nexport * from './move-coder.js'\n\nexport { SuiPlugin } from './sui-plugin.js'\n\nexport { ModuleClient } from './module-client.js'\n\nexport { validateAndNormalizeAddress, isValidSuiAddress } from './utils.js'\n"]}
@@ -3,7 +3,8 @@ import { ListStateStorage } from '@sentio/runtime';
3
3
  import { SuiContext, SuiObjectContext } from './context.js';
4
4
  import { SuiMoveObject } from '@mysten/sui.js';
5
5
  import { PromiseOrVoid } from '../core/index.js';
6
- import { SuiBaseObjectOrAddressProcessor, SuiObjectBindOptions, SuiObjectProcessor, SuiWrappedObjectProcessor } from './sui-object-processor.js';
6
+ import { SuiAddressProcessor, SuiBaseObjectOrAddressProcessor, SuiObjectBindOptions, SuiObjectProcessor, SuiWrappedObjectProcessor } from './sui-object-processor.js';
7
+ import { SuiBindOptions } from './sui-processor.js';
7
8
  declare class ObjectHandler<HandlerType> {
8
9
  type?: string;
9
10
  checkpointInterval?: HandleInterval;
@@ -11,24 +12,27 @@ declare class ObjectHandler<HandlerType> {
11
12
  handler: HandlerType;
12
13
  fetchConfig: MoveAccountFetchConfig;
13
14
  }
14
- export declare class SuiAccountProcessorTemplateState extends ListStateStorage<SuiObjectOrAddressProcessorTemplate<any, any>> {
15
+ export declare class SuiAccountProcessorTemplateState extends ListStateStorage<SuiObjectOrAddressProcessorTemplate<any, any, any>> {
15
16
  static INSTANCE: SuiAccountProcessorTemplateState;
16
17
  }
17
- export declare abstract class SuiObjectOrAddressProcessorTemplate<HandlerType, ProcessorType extends SuiBaseObjectOrAddressProcessor<HandlerType>> {
18
+ export declare abstract class SuiObjectOrAddressProcessorTemplate<HandlerType, OptionType extends SuiObjectBindOptions | SuiBindOptions, ProcessorType extends SuiBaseObjectOrAddressProcessor<HandlerType>> {
18
19
  id: number;
19
20
  objectHandlers: ObjectHandler<HandlerType>[];
20
21
  binds: Set<string>;
21
22
  constructor();
22
- protected abstract createProcessor(options: SuiObjectBindOptions): ProcessorType;
23
- bind(options: SuiObjectBindOptions, ctx: SuiContext): void;
23
+ protected abstract createProcessor(options: SuiObjectBindOptions | SuiBindOptions): ProcessorType;
24
+ bind(options: OptionType, ctx: SuiContext): void;
24
25
  protected onInterval(handler: HandlerType, timeInterval: HandleInterval | undefined, checkpointInterval: HandleInterval | undefined, type: string | undefined, fetchConfig: Partial<MoveAccountFetchConfig> | undefined): this;
25
26
  onTimeInterval(handler: HandlerType, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, type?: string, fetchConfig?: Partial<MoveAccountFetchConfig>): this;
26
27
  onCheckpointInterval(handler: HandlerType, checkpointInterval?: number, backfillCheckpointInterval?: number, type?: string, fetchConfig?: Partial<MoveAccountFetchConfig>): this;
27
28
  }
28
- export declare class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, SuiObjectProcessor> {
29
+ export declare class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<(objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, SuiBindOptions, SuiAddressProcessor> {
30
+ createProcessor(options: SuiBindOptions): SuiAddressProcessor;
31
+ }
32
+ export declare class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<(self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, SuiObjectBindOptions, SuiObjectProcessor> {
29
33
  createProcessor(options: SuiObjectBindOptions): SuiObjectProcessor;
30
34
  }
31
- export declare class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<(dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, SuiWrappedObjectProcessor> {
35
+ export declare class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<(dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid, SuiObjectBindOptions, SuiWrappedObjectProcessor> {
32
36
  createProcessor(options: SuiObjectBindOptions): SuiWrappedObjectProcessor;
33
37
  }
34
38
  export {};
@@ -1,5 +1,5 @@
1
1
  import { ListStateStorage } from '@sentio/runtime';
2
- import { DEFAULT_FETCH_CONFIG, SuiObjectProcessor, SuiWrappedObjectProcessor, } from './sui-object-processor.js';
2
+ import { DEFAULT_FETCH_CONFIG, SuiAddressProcessor, SuiObjectProcessor, SuiWrappedObjectProcessor, } from './sui-object-processor.js';
3
3
  import { TemplateInstanceState } from '../core/template.js';
4
4
  class ObjectHandler {
5
5
  type;
@@ -23,7 +23,8 @@ export class SuiObjectOrAddressProcessorTemplate {
23
23
  bind(options, ctx) {
24
24
  options.network = options.network || ctx.network;
25
25
  options.startCheckpoint = options.startCheckpoint || ctx.checkpoint;
26
- const sig = [options.network, options.objectId].join('_');
26
+ const id = options.objectId || options.address;
27
+ const sig = [options.network, id].join('_');
27
28
  if (this.binds.has(sig)) {
28
29
  console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`);
29
30
  return;
@@ -71,15 +72,11 @@ export class SuiObjectOrAddressProcessorTemplate {
71
72
  return this.onInterval(handler, undefined, { recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval }, type, fetchConfig);
72
73
  }
73
74
  }
74
- // export class SuiAddressProcessorTemplate extends SuiBaseObjectsProcessorTemplate<
75
- // (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
76
- // SuiBindOptions,
77
- // SuiAddressProcessor
78
- // > {
79
- // bind(options: SuiBindOptions, ctx: SuiContext): SuiAddressProcessor {
80
- // return this.bindInternal(SuiAddressProcessorTemplate.bind(options), ctx)
81
- // }
82
- // }
75
+ export class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemplate {
76
+ createProcessor(options) {
77
+ return SuiAddressProcessor.bind(options);
78
+ }
79
+ }
83
80
  export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate {
84
81
  createProcessor(options) {
85
82
  return SuiObjectProcessor.bind(options);
@@ -1 +1 @@
1
- {"version":3,"file":"sui-object-processor-template.js","sourceRoot":"","sources":["../../src/sui/sui-object-processor-template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EACL,oBAAoB,EAGpB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAM,aAAa;IACjB,IAAI,CAAS;IACb,kBAAkB,CAAiB;IACnC,qBAAqB,CAAiB;IACtC,OAAO,CAAa;IACpB,WAAW,CAAwB;CACpC;AAED,MAAa,gCAAiC,SAAQ,gBAA+D;IACnH,MAAM,CAAC,QAAQ,GAAG,IAAI,gCAAgC,EAAE,CAAA;;SAD7C,gCAAgC;AAI7C,MAAM,OAAgB,mCAAmC;IAKvD,EAAE,CAAQ;IACV,cAAc,GAAiC,EAAE,CAAA;IACjD,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAEzB;Q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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 checkpointInterval?: 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 options.startCheckpoint = options.startCheckpoint || ctx.checkpoint\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.checkpointInterval, h.type, h.fetchConfig)\n }\n const config = processor.config\n\n ctx.update({\n states: {\n configUpdated: true,\n },\n })\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 checkpointInterval: HandleInterval | undefined,\n type: string | undefined,\n fetchConfig: Partial<MoveAccountFetchConfig> | undefined\n ): this {\n this.objectHandlers.push({\n handler: handler,\n timeIntervalInMinutes: timeInterval,\n checkpointInterval: checkpointInterval,\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 onCheckpointInterval(\n handler: HandlerType,\n checkpointInterval = 100000,\n backfillCheckpointInterval = 400000,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },\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"]}
1
+ {"version":3,"file":"sui-object-processor-template.js","sourceRoot":"","sources":["../../src/sui/sui-object-processor-template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIlD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EAGnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAG3D,MAAM,aAAa;IACjB,IAAI,CAAS;IACb,kBAAkB,CAAiB;IACnC,qBAAqB,CAAiB;IACtC,OAAO,CAAa;IACpB,WAAW,CAAwB;CACpC;AAED,MAAa,gCAAiC,SAAQ,gBAErD;IACC,MAAM,CAAC,QAAQ,GAAG,IAAI,gCAAgC,EAAE,CAAA;;SAH7C,gCAAgC;AAM7C,MAAM,OAAgB,mCAAmC;IAKvD,EAAE,CAAQ;IACV,cAAc,GAAiC,EAAE,CAAA;IACjD,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAEzB;QACE,IAAI,CAAC,EAAE,GAAG,gCAAgC,CAAC,QAAQ,CAAC,SAAS,EA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,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 SuiAddressProcessor,\n SuiBaseObjectOrAddressProcessor,\n SuiObjectBindOptions,\n SuiObjectProcessor,\n SuiWrappedObjectProcessor,\n} from './sui-object-processor.js'\nimport { TemplateInstanceState } from '../core/template.js'\nimport { SuiBindOptions } from './sui-processor.js'\n\nclass ObjectHandler<HandlerType> {\n type?: string\n checkpointInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: HandlerType\n fetchConfig: MoveAccountFetchConfig\n}\n\nexport class SuiAccountProcessorTemplateState extends ListStateStorage<\n SuiObjectOrAddressProcessorTemplate<any, any, any>\n> {\n static INSTANCE = new SuiAccountProcessorTemplateState()\n}\n\nexport abstract class SuiObjectOrAddressProcessorTemplate<\n HandlerType,\n OptionType extends SuiObjectBindOptions | SuiBindOptions,\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 | SuiBindOptions): ProcessorType\n\n bind(options: OptionType, ctx: SuiContext): void {\n options.network = options.network || ctx.network\n options.startCheckpoint = options.startCheckpoint || ctx.checkpoint\n const id = (options as SuiObjectBindOptions).objectId || (options as SuiBindOptions).address\n\n const sig = [options.network, id].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.checkpointInterval, h.type, h.fetchConfig)\n }\n const config = processor.config\n\n ctx.update({\n states: {\n configUpdated: true,\n },\n })\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 checkpointInterval: HandleInterval | undefined,\n type: string | undefined,\n fetchConfig: Partial<MoveAccountFetchConfig> | undefined\n ): this {\n this.objectHandlers.push({\n handler: handler,\n timeIntervalInMinutes: timeInterval,\n checkpointInterval: checkpointInterval,\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 onCheckpointInterval(\n handler: HandlerType,\n checkpointInterval = 100000,\n backfillCheckpointInterval = 400000,\n type?: string,\n fetchConfig?: Partial<MoveAccountFetchConfig>\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },\n type,\n fetchConfig\n )\n }\n}\n\nexport class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<\n (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,\n SuiBindOptions,\n SuiAddressProcessor\n> {\n createProcessor(options: SuiBindOptions): SuiAddressProcessor {\n return SuiAddressProcessor.bind(options)\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"]}
@@ -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,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,eAAe,CAAA;AAC1C,OAAO,EACL,gCAAgC,GAEj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C,QAAQ,EACf,2BAA2B,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAC7E,CAAA;YACH,CAAC,CAAC,CACH,CAAA;SACF;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,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;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 '@sentio/chain'\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: suiProcessor.config.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 publicKeyPrefix: filter.publicKeyPrefix || '',\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.checkPointInterval,\n fetchConfig: undefined,\n },\n type: handler.type || '',\n ownerType: processor.ownerType,\n fetchConfig: handler.fetchConfig,\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
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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 '@sentio/chain'\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, 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: suiProcessor.config.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 publicKeyPrefix: filter.publicKeyPrefix || '',\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.checkPointInterval,\n fetchConfig: undefined,\n },\n type: handler.type || '',\n ownerType: processor.ownerType,\n fetchConfig: handler.fetchConfig,\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.20.1",
3
+ "version": "2.21.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -69,8 +69,8 @@
69
69
  "typedoc": "^0.24.1",
70
70
  "utility-types": "^3.10.0",
71
71
  "yaml": "^2.2.1",
72
- "@sentio/protos": "2.20.1",
73
- "@sentio/runtime": "^2.20.1"
72
+ "@sentio/protos": "2.21.0-rc.1",
73
+ "@sentio/runtime": "^2.21.0-rc.1"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "tsup": "npm:@sentio/tsup@^6.7.0"
package/src/sui/index.ts CHANGED
@@ -7,7 +7,7 @@ export {
7
7
  } from './sui-object-processor.js'
8
8
 
9
9
  export {
10
- // SuiAddressProcessorTemplate,
10
+ SuiAddressProcessorTemplate,
11
11
  SuiObjectProcessorTemplate,
12
12
  SuiWrappedObjectProcessorTemplate,
13
13
  } from './sui-object-processor-template.js'
@@ -5,12 +5,14 @@ import { SuiMoveObject } from '@mysten/sui.js'
5
5
  import { PromiseOrVoid } from '../core/index.js'
6
6
  import {
7
7
  DEFAULT_FETCH_CONFIG,
8
+ SuiAddressProcessor,
8
9
  SuiBaseObjectOrAddressProcessor,
9
10
  SuiObjectBindOptions,
10
11
  SuiObjectProcessor,
11
12
  SuiWrappedObjectProcessor,
12
13
  } from './sui-object-processor.js'
13
14
  import { TemplateInstanceState } from '../core/template.js'
15
+ import { SuiBindOptions } from './sui-processor.js'
14
16
 
15
17
  class ObjectHandler<HandlerType> {
16
18
  type?: string
@@ -20,13 +22,15 @@ class ObjectHandler<HandlerType> {
20
22
  fetchConfig: MoveAccountFetchConfig
21
23
  }
22
24
 
23
- export class SuiAccountProcessorTemplateState extends ListStateStorage<SuiObjectOrAddressProcessorTemplate<any, any>> {
25
+ export class SuiAccountProcessorTemplateState extends ListStateStorage<
26
+ SuiObjectOrAddressProcessorTemplate<any, any, any>
27
+ > {
24
28
  static INSTANCE = new SuiAccountProcessorTemplateState()
25
29
  }
26
30
 
27
31
  export abstract class SuiObjectOrAddressProcessorTemplate<
28
32
  HandlerType,
29
- // OptionType,
33
+ OptionType extends SuiObjectBindOptions | SuiBindOptions,
30
34
  ProcessorType extends SuiBaseObjectOrAddressProcessor<HandlerType>
31
35
  > {
32
36
  id: number
@@ -38,12 +42,14 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
38
42
  SuiAccountProcessorTemplateState.INSTANCE.addValue(this)
39
43
  }
40
44
 
41
- protected abstract createProcessor(options: SuiObjectBindOptions): ProcessorType
45
+ protected abstract createProcessor(options: SuiObjectBindOptions | SuiBindOptions): ProcessorType
42
46
 
43
- bind(options: SuiObjectBindOptions, ctx: SuiContext): void {
47
+ bind(options: OptionType, ctx: SuiContext): void {
44
48
  options.network = options.network || ctx.network
45
49
  options.startCheckpoint = options.startCheckpoint || ctx.checkpoint
46
- const sig = [options.network, options.objectId].join('_')
50
+ const id = (options as SuiObjectBindOptions).objectId || (options as SuiBindOptions).address
51
+
52
+ const sig = [options.network, id].join('_')
47
53
  if (this.binds.has(sig)) {
48
54
  console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`)
49
55
  return
@@ -127,19 +133,19 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
127
133
  }
128
134
  }
129
135
 
130
- // export class SuiAddressProcessorTemplate extends SuiBaseObjectsProcessorTemplate<
131
- // (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
132
- // SuiBindOptions,
133
- // SuiAddressProcessor
134
- // > {
135
- // bind(options: SuiBindOptions, ctx: SuiContext): SuiAddressProcessor {
136
- // return this.bindInternal(SuiAddressProcessorTemplate.bind(options), ctx)
137
- // }
138
- // }
136
+ export class SuiAddressProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
137
+ (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
138
+ SuiBindOptions,
139
+ SuiAddressProcessor
140
+ > {
141
+ createProcessor(options: SuiBindOptions): SuiAddressProcessor {
142
+ return SuiAddressProcessor.bind(options)
143
+ }
144
+ }
139
145
 
140
146
  export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
141
147
  (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
142
- // SuiObjectBindOptions,
148
+ SuiObjectBindOptions,
143
149
  SuiObjectProcessor
144
150
  > {
145
151
  createProcessor(options: SuiObjectBindOptions): SuiObjectProcessor {
@@ -149,7 +155,7 @@ export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTempl
149
155
 
150
156
  export class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
151
157
  (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
152
- // SuiObjectBindOptions,
158
+ SuiObjectBindOptions,
153
159
  SuiWrappedObjectProcessor
154
160
  > {
155
161
  createProcessor(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {
@@ -50,7 +50,7 @@ export class SuiPlugin extends Plugin {
50
50
  continue
51
51
  }
52
52
 
53
- const template: SuiObjectOrAddressProcessorTemplate<any, any> =
53
+ const template: SuiObjectOrAddressProcessorTemplate<any, any, any> =
54
54
  SuiAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId]
55
55
 
56
56
  template.bind(