@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
@@ -1 +1 @@
1
- {"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,eAAe,EACf,8BAA8B,GAE/B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAKnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAKL,aAAa,EACb,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;AAE7D,mDAAmD;AAEnD,MAAM,oBAAoB,GAAoB;IAC5C,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,IAAI;CAChB,CAAA;AAED,MAAM,cAAc;IAClB,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,eAAe,CAAQ;IACvB,UAAU,CAAS;CACpB;AAED,MAAM,OAAO,cAAc;IACzB,OAAO,CAAQ;IACf,OAAO,CAAa;IACpB,eAAe,CAAS;IACxB,UAAU,CAAS;CACpB;AAED,MAAM,OAAO,oBAAoB;IAC/B,QAAQ,CAAQ;IAChB,OAA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AE,OAAO,CAAC,QAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,SAAS,EAAE,8BAA8B,CAAC,MAAM;YAChD,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAA;IACJ,CAAC;IAES,QAAQ,CAChB,OAA6G,EAC7G,IAAoB,EACpB,GAAsB;QAEtB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,6BAA6B,GAAG,CAAC,IAAI,gCAAgC,CAAC,CAAA;YAClF,OAAM;SACP;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAqB,EAAE,IAAI,CAAC,OAA0B,EAAE,GAAG,CAAC,CAAA;IAClF,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,uBAE9C;IACC,MAAM,CAAC,IAAI,CAAC,OAA6B;QACvC,OAAO,IAAI,yBAAyB,CAAC;YACnC,OAAO,EAAE,OAAO,CAAC,QAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,SAAS,EAAE,8BAA8B,CAAC,cAAc;YACxD,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAA;IACJ,CAAC;IAES,QAAQ,CAChB,OAAwF,EACxF,IAAoB,EACpB,GAAsB;QAEtB,OAAO,OAAO,CAAC,IAAI,CAAC,OAA0B,EAAE,GAAG,CAAC,CAAA;IACtD,CAAC;CACF","sourcesContent":["import {\n Data_SuiCall,\n Data_SuiEvent,\n Data_SuiObject,\n HandleInterval,\n MoveFetchConfig,\n MoveOnIntervalConfig_OwnerType,\n ProcessResult,\n} from '@sentio/protos'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport { SuiNetwork } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext, SuiObjectsContext } from './context.js'\nimport {\n getProgrammableTransaction,\n getTransactionKind,\n MoveCallSuiTransaction,\n SuiEvent,\n SuiMoveObject,\n SuiTransactionBlockResponse,\n} from '@mysten/sui.js'\nimport {\n CallHandler,\n EventFilter,\n EventHandler,\n FunctionNameAndCallFilter,\n parseMoveType,\n SPLITTER,\n} from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { Labels, PromiseOrVoid } from '../core/index.js'\n// import { dynamic_field } from './builtin/0x2.js'\n\nconst DEFAULT_FETCH_CONFIG: MoveFetchConfig = {\n resourceChanges: false,\n allEvents: true,\n}\n\nclass IndexConfigure {\n address: string\n network: SuiNetwork\n startCheckpoint: bigint\n baseLabels?: Labels\n}\n\nexport class SuiBindOptions {\n address: string\n network?: SuiNetwork\n startCheckpoint?: bigint\n baseLabels?: Labels\n}\n\nexport class SuiObjectBindOptions {\n objectId: string\n network?: SuiNetwork\n startCheckpoint?: bigint\n baseLabels?: { [key: string]: string }\n}\n\nexport class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {\n static INSTANCE = new SuiProcessorState()\n}\n\nexport class SuiBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n\n eventHandlers: EventHandler<Data_SuiEvent>[] = []\n callHandlers: CallHandler<Data_SuiCall>[] = []\n coder: MoveCoder\n\n constructor(name: string, options: SuiBindOptions) {\n this.moduleName = name\n this.config = configure(options)\n SuiProcessorState.INSTANCE.addValue(this)\n this.coder = defaultMoveCoder(this.config.network)\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n public onMoveEvent(\n handler: (event: SuiEvent, ctx: SuiContext) => void,\n filter: EventFilter | EventFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): SuiBaseProcessor {\n let _filters: EventFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n\n const processor = this\n const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))\n\n this.eventHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')\n }\n const txn = data.transaction as SuiTransactionBlockResponse\n if (!txn.events || !txn.events.length) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\n }\n\n const processResults = []\n for (const [idx, evt] of (txn.events as SuiEvent[]).entries()) {\n const typeQname = parseMoveType(evt.type).qname\n if (!allEventType.has(typeQname)) {\n continue\n }\n\n const ctx = new SuiContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n data.timestamp || new Date(0),\n data.slot,\n txn,\n idx,\n processor.config.baseLabels\n )\n\n const decoded = await processor.coder.decodeEvent<any>(evt)\n await handler(decoded || evt, ctx)\n processResults.push(ctx.getProcessResult())\n }\n\n return mergeProcessResults(processResults)\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): SuiBaseProcessor {\n let _filters: FunctionNameAndCallFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n const processor = this\n const allFunctionType = new Set(_filters.map((f) => processor.config.address + '::' + f.function))\n\n this.callHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n }\n const tx = data.transaction as SuiTransactionBlockResponse\n\n const ctx = new SuiContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n data.timestamp || new Date(0),\n data.slot,\n tx,\n 0,\n processor.config.baseLabels\n )\n if (tx) {\n const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)\n const txKind = getTransactionKind(tx)\n if (!txKind) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty')\n }\n const programmableTx = getProgrammableTransaction(txKind)\n\n // TODO potential pass index\n for (const call of calls) {\n const functionType = [call.package, call.module, call.function].join(SPLITTER)\n if (!allFunctionType.has(functionType)) {\n continue\n }\n\n // TODO maybe do in parallel\n const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || [])\n await handler(decoded, ctx)\n }\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n\nclass ObjectHandler {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (resource: Data_SuiObject) => Promise<ProcessResult>\n}\n\nexport class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectsProcessor<any>> {\n static INSTANCE = new SuiAccountProcessorState()\n}\n\nclass SuiObjectsBindOptions extends SuiBindOptions {\n ownerType: MoveOnIntervalConfig_OwnerType\n}\n\nabstract class SuiBaseObjectsProcessor<HandlerType> {\n config: IndexConfigure\n ownerType: MoveOnIntervalConfig_OwnerType\n\n objectHandlers: ObjectHandler[] = []\n\n // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {\n // return new SuiBaseObjectsProcessor(options)\n // }\n\n protected constructor(options: SuiObjectsBindOptions) {\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: SuiObjectsContext): PromiseOrVoid\n\n protected onInterval(\n handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined\n ): this {\n const processor = this\n this.objectHandlers.push({\n handler: async function (data) {\n const ctx = new SuiObjectsContext(\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 })\n return this\n }\n\n public onTimeInterval(\n handler: HandlerType,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type\n )\n }\n\n public onSlotInterval(\n handler: HandlerType,\n slotInterval = 100000,\n backfillSlotInterval = 400000,\n type?: string\n ): this {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },\n type\n )\n }\n}\n\nfunction configure(options: SuiBindOptions): IndexConfigure {\n return {\n startCheckpoint: options.startCheckpoint || 0n,\n address: options.address,\n network: options.network || SuiNetwork.MAIN_NET,\n baseLabels: options.baseLabels,\n }\n}\n\nexport class SuiAddressProcessor extends SuiBaseObjectsProcessor<\n (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid\n> {\n static bind(options: SuiBindOptions): SuiAddressProcessor {\n return new SuiAddressProcessor({ ...options, ownerType: MoveOnIntervalConfig_OwnerType.ADDRESS })\n }\n\n protected doHandle(\n handler: (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n data: Data_SuiObject,\n ctx: SuiObjectsContext\n ): PromiseOrVoid {\n return handler(data.objects as SuiMoveObject[], ctx)\n }\n}\n// export class SuiDynamicFieldObjectsProcessor extends SuiBaseObjectsProcessor<dynamic_field.Field<any, any>> {\nexport class SuiObjectProcessor extends SuiBaseObjectsProcessor<\n (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => 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: MoveOnIntervalConfig_OwnerType.OBJECT,\n baseLabels: options.baseLabels,\n })\n }\n\n protected doHandle(\n handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n data: Data_SuiObject,\n ctx: SuiObjectsContext\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 SuiBaseObjectsProcessor<\n (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => 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: MoveOnIntervalConfig_OwnerType.WRAPPED_OBJECT,\n baseLabels: options.baseLabels,\n })\n }\n\n protected doHandle(\n handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,\n data: Data_SuiObject,\n ctx: SuiObjectsContext\n ): PromiseOrVoid {\n return handler(data.objects as SuiMoveObject[], ctx)\n }\n}\n"]}
1
+ {"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EA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AAC,GAAG,CAAC,YAAY,CAAC,EAAE;4BACtC,SAAQ;yBACT;wBAED,4BAA4B;wBAC5B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,IAAI,EAAE,CAAC,CAAA;wBAC/F,MAAM,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;qBAC5B;iBACF;gBACD,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;YAC/B,CAAC;YACD,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,YAAY;SAC1B,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { Data_SuiCall, Data_SuiEvent, MoveFetchConfig } from '@sentio/protos'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport { SuiNetwork } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext } from './context.js'\nimport {\n getProgrammableTransaction,\n getTransactionKind,\n MoveCallSuiTransaction,\n SuiEvent,\n SuiTransactionBlockResponse,\n} from '@mysten/sui.js'\nimport {\n CallHandler,\n EventFilter,\n EventHandler,\n FunctionNameAndCallFilter,\n parseMoveType,\n SPLITTER,\n} from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { Labels } from '../core/index.js'\nimport { Required } from 'utility-types'\n\nconst DEFAULT_FETCH_CONFIG: MoveFetchConfig = {\n resourceChanges: false,\n allEvents: true,\n}\n\nexport type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'network'>\n\nexport function configure(options: SuiBindOptions): IndexConfigure {\n return {\n startCheckpoint: options.startCheckpoint || 0n,\n address: options.address,\n network: options.network || SuiNetwork.MAIN_NET,\n baseLabels: options.baseLabels,\n }\n}\n\nexport interface SuiBindOptions {\n address: string\n network?: SuiNetwork\n startCheckpoint?: bigint\n baseLabels?: Labels\n}\n\nexport class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {\n static INSTANCE = new SuiProcessorState()\n}\n\nexport class SuiBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n\n eventHandlers: EventHandler<Data_SuiEvent>[] = []\n callHandlers: CallHandler<Data_SuiCall>[] = []\n coder: MoveCoder\n\n constructor(name: string, options: SuiBindOptions) {\n this.moduleName = name\n this.config = configure(options)\n SuiProcessorState.INSTANCE.addValue(this)\n this.coder = defaultMoveCoder(this.config.network)\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n public onMoveEvent(\n handler: (event: SuiEvent, ctx: SuiContext) => void,\n filter: EventFilter | EventFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): SuiBaseProcessor {\n let _filters: EventFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n\n const processor = this\n const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))\n\n this.eventHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')\n }\n const txn = data.transaction as SuiTransactionBlockResponse\n if (!txn.events || !txn.events.length) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\n }\n\n const processResults = []\n for (const [idx, evt] of (txn.events as SuiEvent[]).entries()) {\n const typeQname = parseMoveType(evt.type).qname\n if (!allEventType.has(typeQname)) {\n continue\n }\n\n const ctx = new SuiContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n data.timestamp || new Date(0),\n data.slot,\n txn,\n idx,\n processor.config.baseLabels\n )\n\n const decoded = await processor.coder.decodeEvent<any>(evt)\n await handler(decoded || evt, ctx)\n processResults.push(ctx.getProcessResult())\n }\n\n return mergeProcessResults(processResults)\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n fetchConfig?: Partial<MoveFetchConfig>\n ): SuiBaseProcessor {\n let _filters: FunctionNameAndCallFilter[] = []\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n const processor = this\n const allFunctionType = new Set(_filters.map((f) => processor.config.address + '::' + f.function))\n\n this.callHandlers.push({\n handler: async function (data) {\n if (!data.transaction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n }\n const tx = data.transaction as SuiTransactionBlockResponse\n\n const ctx = new SuiContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n data.timestamp || new Date(0),\n data.slot,\n tx,\n 0,\n processor.config.baseLabels\n )\n if (tx) {\n const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)\n const txKind = getTransactionKind(tx)\n if (!txKind) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty')\n }\n const programmableTx = getProgrammableTransaction(txKind)\n\n // TODO potential pass index\n for (const call of calls) {\n const functionType = [call.package, call.module, call.function].join(SPLITTER)\n if (!allFunctionType.has(functionType)) {\n continue\n }\n\n // TODO maybe do in parallel\n const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || [])\n await handler(decoded, ctx)\n }\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.15.7-rc.2",
3
+ "version": "2.16.0-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -69,9 +69,10 @@
69
69
  "superstruct_solana": "npm:superstruct@^0.14.2",
70
70
  "typechain": "^8.0.0",
71
71
  "typedoc": "^0.24.1",
72
+ "utility-types": "^3.10.0",
72
73
  "yaml": "^2.2.1",
73
- "@sentio/protos": "^2.15.7-rc.2",
74
- "@sentio/runtime": "^2.15.7-rc.2"
74
+ "@sentio/protos": "^2.16.0-rc.2",
75
+ "@sentio/runtime": "^2.16.0-rc.2"
75
76
  },
76
77
  "peerDependencies": {
77
78
  "tsup": "npm:@sentio/tsup@^6.7.0"
@@ -9,10 +9,10 @@ import {
9
9
  HandlerType,
10
10
  MoveCallHandlerConfig,
11
11
  MoveEventHandlerConfig,
12
+ MoveOwnerType,
12
13
  ProcessConfigResponse,
13
14
  ProcessResult,
14
15
  StartRequest,
15
- MoveOnIntervalConfig_OwnerType,
16
16
  } from '@sentio/protos'
17
17
 
18
18
  import { ServerError, Status } from 'nice-grpc'
@@ -100,19 +100,6 @@ export class AptosPlugin extends Plugin {
100
100
  })
101
101
  for (const handler of aptosProcessor.resourcesHandlers) {
102
102
  const handlerId = handlers.aptosResourceHandlers.push(handler.handler) - 1
103
- // TODO move to only use moveIntervalConfigs
104
- accountConfig.aptosIntervalConfigs.push({
105
- intervalConfig: {
106
- handlerId: handlerId,
107
- minutes: 0,
108
- minutesInterval: handler.timeIntervalInMinutes,
109
- slot: 0,
110
- slotInterval: handler.versionInterval,
111
- fetchConfig: undefined,
112
- },
113
- type: handler.type || '',
114
- })
115
-
116
103
  accountConfig.moveIntervalConfigs.push({
117
104
  intervalConfig: {
118
105
  handlerId: handlerId,
@@ -123,7 +110,8 @@ export class AptosPlugin extends Plugin {
123
110
  fetchConfig: undefined,
124
111
  },
125
112
  type: handler.type || '',
126
- ownerType: MoveOnIntervalConfig_OwnerType.ADDRESS,
113
+ ownerType: MoveOwnerType.ADDRESS,
114
+ fetchConfig: undefined,
127
115
  })
128
116
  }
129
117
  config.accountConfigs.push(accountConfig)
@@ -4,11 +4,15 @@ import { ProcessConfigResponse } from '@sentio/protos'
4
4
  import { MetricState } from './meter.js'
5
5
  import { ExporterState } from './exporter.js'
6
6
  import { EventTrackerState } from './event-tracker.js'
7
+ import { TemplateInstanceState } from './template.js'
7
8
 
8
9
  export class CorePlugin extends Plugin {
9
10
  name: string = 'CorePlugin'
10
11
 
11
12
  async configure(config: ProcessConfigResponse): Promise<void> {
13
+ // This syntax is to copy values instead of using references
14
+ config.templateInstances = [...TemplateInstanceState.INSTANCE.getValues()]
15
+
12
16
  for (const metric of MetricState.INSTANCE.getValues()) {
13
17
  config.metricConfigs.push({
14
18
  ...metric.config,
@@ -0,0 +1,6 @@
1
+ import { ListStateStorage } from '@sentio/runtime'
2
+ import { TemplateInstance } from '@sentio/protos'
3
+
4
+ export class TemplateInstanceState extends ListStateStorage<TemplateInstance> {
5
+ static INSTANCE = new TemplateInstanceState()
6
+ }
@@ -8,6 +8,7 @@ import { ListStateStorage } from '@sentio/runtime'
8
8
  import { BlockParams } from 'ethers/providers'
9
9
  import { DeferredTopicFilter } from 'ethers/contract'
10
10
  import { TypedEvent, TypedCallTrace } from './eth.js'
11
+ import { TemplateInstanceState } from '../core/template.js'
11
12
 
12
13
  export class ProcessorTemplateProcessorState extends ListStateStorage<
13
14
  BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
@@ -15,10 +16,6 @@ export class ProcessorTemplateProcessorState extends ListStateStorage<
15
16
  static INSTANCE = new ProcessorTemplateProcessorState()
16
17
  }
17
18
 
18
- export class TemplateInstanceState extends ListStateStorage<TemplateInstance> {
19
- static INSTANCE = new TemplateInstanceState()
20
- }
21
-
22
19
  export abstract class BaseProcessorTemplate<
23
20
  TContract extends BaseContract,
24
21
  TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>
@@ -53,9 +50,7 @@ export abstract class BaseProcessorTemplate<
53
50
  * @param ctx
54
51
  */
55
52
  public bind(options: BindOptions, ctx: EthContext): void {
56
- if (!options.network) {
57
- options.network = ctx.getChainId()
58
- }
53
+ options.network = options.network || ctx.chainId
59
54
  const sig = getOptionsSignature({
60
55
  address: options.address,
61
56
  network: options.network,
@@ -18,11 +18,12 @@ import {
18
18
  import { ServerError, Status } from 'nice-grpc'
19
19
  import { ProcessorState } from './binds.js'
20
20
  import { AccountProcessorState } from './account-processor-state.js'
21
- import { ProcessorTemplateProcessorState, TemplateInstanceState } from './base-processor-template.js'
21
+ import { ProcessorTemplateProcessorState } from './base-processor-template.js'
22
22
  import { GlobalProcessorState } from './base-processor.js'
23
23
  import { validateAndNormalizeAddress } from './eth.js'
24
24
  import { EthChainId } from '../core/chain.js'
25
25
  import { EthContext } from './context.js'
26
+ import { TemplateInstanceState } from '../core/template.js'
26
27
 
27
28
  interface Handlers {
28
29
  eventHandlers: ((event: Data_EthLog) => Promise<ProcessResult>)[]
@@ -47,8 +48,6 @@ export class EthPlugin extends Plugin {
47
48
  traceHandlers: [],
48
49
  transactionHandlers: [],
49
50
  }
50
- // This syntax is to copy values instead of using references
51
- config.templateInstances = [...TemplateInstanceState.INSTANCE.getValues()]
52
51
 
53
52
  for (const processor of ProcessorState.INSTANCE.getValues()) {
54
53
  // If server favor incremental update this need to change
@@ -244,7 +243,13 @@ export class EthPlugin extends Plugin {
244
243
 
245
244
  async start(request: StartRequest) {
246
245
  const ctx = new NoopContext()
246
+ const allowedChainIds = new Set<string>(Object.values(EthChainId))
247
+
247
248
  for (const instance of request.templateInstances) {
249
+ if (!allowedChainIds.has(instance.contract?.chainId || '')) {
250
+ continue
251
+ }
252
+
248
253
  const template = ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId]
249
254
  if (!template) {
250
255
  throw new ServerError(Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance)
@@ -69,7 +69,8 @@ export class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule,
69
69
  }
70
70
  }
71
71
 
72
- export class SuiObjectsContext extends MoveAccountContext<
72
+ // TODO address handler should use this context
73
+ export class SuiAddressContext extends MoveAccountContext<
73
74
  SuiNetwork,
74
75
  SuiMoveNormalizedModule,
75
76
  SuiEvent | SuiMoveObject
@@ -80,6 +81,8 @@ export class SuiObjectsContext extends MoveAccountContext<
80
81
  timestamp: Date
81
82
  coder: MoveCoder
82
83
 
84
+ protected contractName = 'address'
85
+
83
86
  constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date, baseLabels: Labels | undefined) {
84
87
  super(baseLabels)
85
88
  this.address = address
@@ -96,7 +99,7 @@ export class SuiObjectsContext extends MoveAccountContext<
96
99
  getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
97
100
  return {
98
101
  address: this.address,
99
- contractName: 'objects',
102
+ contractName: this.contractName,
100
103
  blockNumber: this.slot,
101
104
  transactionIndex: 0,
102
105
  transactionHash: '',
@@ -115,3 +118,13 @@ export class SuiObjectsContext extends MoveAccountContext<
115
118
  return this.timestamp.getDate()
116
119
  }
117
120
  }
121
+
122
+ export class SuiObjectContext extends SuiAddressContext {
123
+ contractName = 'object'
124
+ objectId: string
125
+
126
+ constructor(network: SuiNetwork, objectId: string, slot: bigint, timestamp: Date, baseLabels: Labels | undefined) {
127
+ super(network, objectId, slot, timestamp, baseLabels)
128
+ this.objectId = objectId
129
+ }
130
+ }
@@ -3,7 +3,7 @@ import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from '.
3
3
  import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor, SimpleCoinInfo } from '../../move/ext/index.js'
4
4
  import { SuiMoveObject, SuiMovePackage } from '@mysten/sui.js'
5
5
  import { SuiNetwork } from '../network.js'
6
- import { SuiContext, SuiObjectsContext } from '../context.js'
6
+ import { SuiContext, SuiObjectContext } from '../context.js'
7
7
 
8
8
  export type PoolAdaptor<T> = MovePoolAdaptor<SuiMoveObject, T>
9
9
 
@@ -33,7 +33,7 @@ export class SuiDex<T> extends MoveDex<
33
33
  SuiMoveObject,
34
34
  Event,
35
35
  SuiContext,
36
- SuiObjectsContext,
36
+ SuiObjectContext,
37
37
  T
38
38
  > {
39
39
  coinList = SuiCoinList
package/src/sui/index.ts CHANGED
@@ -1,4 +1,16 @@
1
- export * from './sui-processor.js'
1
+ export { SuiBaseProcessor, type SuiBindOptions } from './sui-processor.js'
2
+ export {
3
+ SuiAddressProcessor,
4
+ SuiObjectProcessor,
5
+ SuiWrappedObjectProcessor,
6
+ type SuiObjectBindOptions,
7
+ } from './sui-object-processor.js'
8
+
9
+ export {
10
+ // SuiAddressProcessorTemplate,
11
+ SuiObjectProcessorTemplate,
12
+ SuiWrappedObjectProcessorTemplate,
13
+ } from './sui-object-processor-template.js'
2
14
 
3
15
  export * from './network.js'
4
16
  export * from './context.js'
@@ -0,0 +1,153 @@
1
+ import { HandleInterval, MoveAccountFetchConfig } from '@sentio/protos'
2
+ import { ListStateStorage } from '@sentio/runtime'
3
+ import { SuiContext, SuiObjectContext } from './context.js'
4
+ import { SuiMoveObject } from '@mysten/sui.js'
5
+ import { PromiseOrVoid } from '../core/index.js'
6
+ import {
7
+ DEFAULT_FETCH_CONFIG,
8
+ SuiBaseObjectOrAddressProcessor,
9
+ SuiObjectBindOptions,
10
+ SuiObjectProcessor,
11
+ SuiWrappedObjectProcessor,
12
+ } from './sui-object-processor.js'
13
+ import { TemplateInstanceState } from '../core/template.js'
14
+
15
+ class ObjectHandler<HandlerType> {
16
+ type?: string
17
+ versionInterval?: HandleInterval
18
+ timeIntervalInMinutes?: HandleInterval
19
+ handler: HandlerType
20
+ fetchConfig: MoveAccountFetchConfig
21
+ }
22
+
23
+ export class SuiAccountProcessorTemplateState extends ListStateStorage<SuiObjectOrAddressProcessorTemplate<any, any>> {
24
+ static INSTANCE = new SuiAccountProcessorTemplateState()
25
+ }
26
+
27
+ export abstract class SuiObjectOrAddressProcessorTemplate<
28
+ HandlerType,
29
+ // OptionType,
30
+ ProcessorType extends SuiBaseObjectOrAddressProcessor<HandlerType>
31
+ > {
32
+ id: number
33
+ objectHandlers: ObjectHandler<HandlerType>[] = []
34
+ binds = new Set<string>()
35
+
36
+ constructor() {
37
+ this.id = SuiAccountProcessorTemplateState.INSTANCE.getValues().length
38
+ SuiAccountProcessorTemplateState.INSTANCE.addValue(this)
39
+ }
40
+
41
+ protected abstract createProcessor(options: SuiObjectBindOptions): ProcessorType
42
+
43
+ bind(options: SuiObjectBindOptions, ctx: SuiContext): void {
44
+ options.network = options.network || ctx.network
45
+ const sig = [options.network, options.objectId].join('_')
46
+ if (this.binds.has(sig)) {
47
+ console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${sig}`)
48
+ return
49
+ }
50
+ this.binds.add(sig)
51
+
52
+ const processor = this.createProcessor(options)
53
+ for (const h of this.objectHandlers) {
54
+ processor.onInterval(h.handler, h.timeIntervalInMinutes, h.versionInterval, h.type, h.fetchConfig)
55
+ }
56
+ const config = processor.config
57
+
58
+ ctx._res.states.configUpdated = true
59
+ TemplateInstanceState.INSTANCE.addValue({
60
+ templateId: this.id,
61
+ contract: {
62
+ name: '',
63
+ chainId: config.network,
64
+ address: config.address,
65
+ abi: '',
66
+ },
67
+ startBlock: config.startCheckpoint,
68
+ endBlock: 0n,
69
+ })
70
+ }
71
+
72
+ protected onInterval(
73
+ handler: HandlerType,
74
+ timeInterval: HandleInterval | undefined,
75
+ versionInterval: HandleInterval | undefined,
76
+ type: string | undefined,
77
+ fetchConfig: Partial<MoveAccountFetchConfig> | undefined
78
+ ): this {
79
+ this.objectHandlers.push({
80
+ handler: handler,
81
+ timeIntervalInMinutes: timeInterval,
82
+ versionInterval: versionInterval,
83
+ type,
84
+ fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },
85
+ })
86
+ return this
87
+ }
88
+
89
+ public onTimeInterval(
90
+ handler: HandlerType,
91
+ timeIntervalInMinutes = 60,
92
+ backfillTimeIntervalInMinutes = 240,
93
+ type?: string,
94
+ fetchConfig?: Partial<MoveAccountFetchConfig>
95
+ ): this {
96
+ return this.onInterval(
97
+ handler,
98
+ {
99
+ recentInterval: timeIntervalInMinutes,
100
+ backfillInterval: backfillTimeIntervalInMinutes,
101
+ },
102
+ undefined,
103
+ type,
104
+ fetchConfig
105
+ )
106
+ }
107
+
108
+ public onSlotInterval(
109
+ handler: HandlerType,
110
+ slotInterval = 100000,
111
+ backfillSlotInterval = 400000,
112
+ type?: string,
113
+ fetchConfig?: Partial<MoveAccountFetchConfig>
114
+ ): this {
115
+ return this.onInterval(
116
+ handler,
117
+ undefined,
118
+ { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },
119
+ type,
120
+ fetchConfig
121
+ )
122
+ }
123
+ }
124
+
125
+ // export class SuiAddressProcessorTemplate extends SuiBaseObjectsProcessorTemplate<
126
+ // (objects: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
127
+ // SuiBindOptions,
128
+ // SuiAddressProcessor
129
+ // > {
130
+ // bind(options: SuiBindOptions, ctx: SuiContext): SuiAddressProcessor {
131
+ // return this.bindInternal(SuiAddressProcessorTemplate.bind(options), ctx)
132
+ // }
133
+ // }
134
+
135
+ export class SuiObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
136
+ (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
137
+ // SuiObjectBindOptions,
138
+ SuiObjectProcessor
139
+ > {
140
+ createProcessor(options: SuiObjectBindOptions): SuiObjectProcessor {
141
+ return SuiObjectProcessor.bind(options)
142
+ }
143
+ }
144
+
145
+ export class SuiWrappedObjectProcessorTemplate extends SuiObjectOrAddressProcessorTemplate<
146
+ (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
147
+ // SuiObjectBindOptions,
148
+ SuiWrappedObjectProcessor
149
+ > {
150
+ createProcessor(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {
151
+ return SuiWrappedObjectProcessor.bind(options)
152
+ }
153
+ }
@@ -0,0 +1,186 @@
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 { configure, IndexConfigure, SuiBindOptions } from './sui-processor.js'
8
+
9
+ export interface SuiObjectBindOptions {
10
+ objectId: string
11
+ network?: SuiNetwork
12
+ startCheckpoint?: bigint
13
+ baseLabels?: { [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
+
24
+ export const DEFAULT_FETCH_CONFIG: MoveAccountFetchConfig = {
25
+ owned: true,
26
+ }
27
+
28
+ export class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectOrAddressProcessor<any>> {
29
+ static INSTANCE = new SuiAccountProcessorState()
30
+ }
31
+
32
+ export interface SuiInternalObjectsBindOptions extends SuiBindOptions {
33
+ ownerType: MoveOwnerType
34
+ }
35
+
36
+ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
37
+ config: IndexConfigure
38
+ ownerType: MoveOwnerType
39
+
40
+ objectHandlers: ObjectHandler[] = []
41
+
42
+ // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {
43
+ // return new SuiBaseObjectsProcessor(options)
44
+ // }
45
+
46
+ protected constructor(options: SuiInternalObjectsBindOptions) {
47
+ this.config = configure(options)
48
+ this.ownerType = options.ownerType
49
+ SuiAccountProcessorState.INSTANCE.addValue(this)
50
+ }
51
+
52
+ getChainId(): string {
53
+ return this.config.network
54
+ }
55
+
56
+ // protected abstract transformObjects(objects: SuiMoveObject[]): SuiMoveObject[]
57
+
58
+ protected abstract doHandle(handler: HandlerType, data: Data_SuiObject, ctx: SuiObjectContext): PromiseOrVoid
59
+
60
+ public onInterval(
61
+ handler: HandlerType, //(resources: SuiMoveObject[], ctx: SuiObjectsContext) => PromiseOrVoid,
62
+ timeInterval: HandleInterval | undefined,
63
+ versionInterval: HandleInterval | undefined,
64
+ type: string | undefined,
65
+ fetchConfig: Partial<MoveAccountFetchConfig> | undefined
66
+ ): this {
67
+ const processor = this
68
+ this.objectHandlers.push({
69
+ handler: async function (data) {
70
+ const ctx = new SuiObjectContext(
71
+ processor.config.network,
72
+ processor.config.address,
73
+ data.slot,
74
+ data.timestamp || new Date(0),
75
+ processor.config.baseLabels
76
+ )
77
+ await processor.doHandle(handler, data, ctx)
78
+ return ctx.getProcessResult()
79
+ },
80
+ timeIntervalInMinutes: timeInterval,
81
+ versionInterval: versionInterval,
82
+ type,
83
+ fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...fetchConfig },
84
+ })
85
+ return this
86
+ }
87
+
88
+ public onTimeInterval(
89
+ handler: HandlerType,
90
+ timeIntervalInMinutes = 60,
91
+ backfillTimeIntervalInMinutes = 240,
92
+ type?: string,
93
+ fetchConfig?: Partial<MoveAccountFetchConfig>
94
+ ): this {
95
+ return this.onInterval(
96
+ handler,
97
+ {
98
+ recentInterval: timeIntervalInMinutes,
99
+ backfillInterval: backfillTimeIntervalInMinutes,
100
+ },
101
+ undefined,
102
+ type,
103
+ fetchConfig
104
+ )
105
+ }
106
+
107
+ public onSlotInterval(
108
+ handler: HandlerType,
109
+ slotInterval = 100000,
110
+ backfillSlotInterval = 400000,
111
+ type?: string,
112
+ fetchConfig?: Partial<MoveAccountFetchConfig>
113
+ ): this {
114
+ return this.onInterval(
115
+ handler,
116
+ undefined,
117
+ { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },
118
+ type,
119
+ fetchConfig
120
+ )
121
+ }
122
+ }
123
+
124
+ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessor<
125
+ (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
126
+ > {
127
+ static bind(options: SuiBindOptions): SuiAddressProcessor {
128
+ return new SuiAddressProcessor({ ...options, ownerType: MoveOwnerType.ADDRESS })
129
+ }
130
+
131
+ protected doHandle(
132
+ handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
133
+ data: Data_SuiObject,
134
+ ctx: SuiObjectContext
135
+ ): PromiseOrVoid {
136
+ return handler(data.objects as SuiMoveObject[], ctx)
137
+ }
138
+ }
139
+
140
+ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessor<
141
+ (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
142
+ > {
143
+ static bind(options: SuiObjectBindOptions): SuiObjectProcessor {
144
+ return new SuiObjectProcessor({
145
+ address: options.objectId,
146
+ network: options.network,
147
+ startCheckpoint: options.startCheckpoint,
148
+ ownerType: MoveOwnerType.OBJECT,
149
+ baseLabels: options.baseLabels,
150
+ })
151
+ }
152
+
153
+ protected doHandle(
154
+ handler: (self: SuiMoveObject, dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
155
+ data: Data_SuiObject,
156
+ ctx: SuiObjectContext
157
+ ): PromiseOrVoid {
158
+ if (!data.self) {
159
+ console.log(`Sui object not existed in ${ctx.slot}, please specific a start time`)
160
+ return
161
+ }
162
+ return handler(data.self as SuiMoveObject, data.objects as SuiMoveObject[], ctx)
163
+ }
164
+ }
165
+
166
+ export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessor<
167
+ (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid
168
+ > {
169
+ static bind(options: SuiObjectBindOptions): SuiWrappedObjectProcessor {
170
+ return new SuiWrappedObjectProcessor({
171
+ address: options.objectId,
172
+ network: options.network,
173
+ startCheckpoint: options.startCheckpoint,
174
+ ownerType: MoveOwnerType.WRAPPED_OBJECT,
175
+ baseLabels: options.baseLabels,
176
+ })
177
+ }
178
+
179
+ protected doHandle(
180
+ handler: (dynamicFieldObjects: SuiMoveObject[], ctx: SuiObjectContext) => PromiseOrVoid,
181
+ data: Data_SuiObject,
182
+ ctx: SuiObjectContext
183
+ ): PromiseOrVoid {
184
+ return handler(data.objects as SuiMoveObject[], ctx)
185
+ }
186
+ }