@sentio/sdk 2.9.0-rc.3 → 2.9.0-rc.4
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.
- package/lib/eth/index.d.ts +1 -0
- package/lib/eth/index.js +1 -0
- package/lib/eth/index.js.map +1 -1
- package/lib/sui/sui-plugin.js +3 -1
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +12 -7
- package/lib/sui/sui-processor.js +14 -7
- package/lib/sui/sui-processor.js.map +1 -1
- package/package.json +4 -4
- package/src/eth/index.ts +1 -0
- package/src/sui/sui-plugin.ts +3 -1
- package/src/sui/sui-processor.ts +28 -10
package/lib/eth/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export { BaseProcessor } from './base-processor.js';
|
2
2
|
export { GenericProcessor } from './generic-processor.js';
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js';
|
4
|
+
export { AccountProcessor } from './account-processor.js';
|
4
5
|
export { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js';
|
5
6
|
export type { TypedCallTrace, Trace } from './trace.js';
|
6
7
|
export * from './eth.js';
|
package/lib/eth/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export { BaseProcessor } from './base-processor.js';
|
2
2
|
export { GenericProcessor } from './generic-processor.js';
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js';
|
4
|
+
export { AccountProcessor } from './account-processor.js';
|
4
5
|
export { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js';
|
5
6
|
export * from './eth.js';
|
6
7
|
export { BindOptions, AccountBindOptions } from './bind-options.js';
|
package/lib/eth/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAEzF,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA","sourcesContent":["export { BaseProcessor } from './base-processor.js'\nexport { GenericProcessor } from './generic-processor.js'\nexport { BaseProcessorTemplate } from './base-processor-template.js'\nexport { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js'\nexport type { TypedCallTrace, Trace } from './trace.js'\nexport * from './eth.js'\nexport { BindOptions, AccountBindOptions } from './bind-options.js'\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'\nexport { ContractContext, ContractView, BoundContractView } from './context.js'\n\nexport { EthPlugin } from './eth-plugin.js'\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAEzF,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA","sourcesContent":["export { BaseProcessor } from './base-processor.js'\nexport { GenericProcessor } from './generic-processor.js'\nexport { BaseProcessorTemplate } from './base-processor-template.js'\nexport { AccountProcessor } from './account-processor.js'\nexport { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js'\nexport type { TypedCallTrace, Trace } from './trace.js'\nexport * from './eth.js'\nexport { BindOptions, AccountBindOptions } from './bind-options.js'\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'\nexport { ContractContext, ContractView, BoundContractView } from './context.js'\n\nexport { EthPlugin } from './eth-plugin.js'\n"]}
|
package/lib/sui/sui-plugin.js
CHANGED
@@ -61,7 +61,7 @@ export class SuiPlugin extends Plugin {
|
|
61
61
|
});
|
62
62
|
for (const handler of processor.objectHandlers) {
|
63
63
|
const handlerId = this.suiObjectHandlers.push(handler.handler) - 1;
|
64
|
-
accountConfig.
|
64
|
+
accountConfig.moveIntervalConfigs.push({
|
65
65
|
intervalConfig: {
|
66
66
|
handlerId: handlerId,
|
67
67
|
minutes: 0,
|
@@ -69,6 +69,8 @@ export class SuiPlugin extends Plugin {
|
|
69
69
|
slot: 0,
|
70
70
|
slotInterval: handler.versionInterval,
|
71
71
|
},
|
72
|
+
type: handler.type || '',
|
73
|
+
ownerType: processor.ownerType,
|
72
74
|
});
|
73
75
|
}
|
74
76
|
config.accountConfigs.push(accountConfig);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/sui/sui-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,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AAS,IAAI,OAAO,CAAC,UAAU,EAAE;YAC1C,QAAQ,CAAC,IAAI,CACX,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACpD,MAAM,IAAI,WAAW,CACnB,MAAM,CAAC,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","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} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js'\nimport { getChainId } from './network.js'\n\nexport class SuiPlugin extends Plugin {\n name: string = 'SuiPlugin'\n\n private suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[] = []\n private suiCallHandlers: ((func: Data_SuiCall) => Promise<ProcessResult>)[] = []\n private suiObjectHandlers: ((object: Data_SuiObject) => Promise<ProcessResult>)[] = []\n\n async configure(config: ProcessConfigResponse) {\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: getChainId(suiProcessor.config.network),\n address: suiProcessor.config.address,\n abi: '',\n },\n startBlock: BigInt(suiProcessor.config.startTimestamp),\n })\n for (const handler of suiProcessor.eventHandlers) {\n const handlerId = this.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 = this.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: processor.config.address,\n chainId: processor.getChainId(),\n startBlock: BigInt(processor.config.startTimestamp), // TODO maybe use another field\n })\n for (const handler of processor.objectHandlers) {\n const handlerId = this.suiObjectHandlers.push(handler.handler) - 1\n accountConfig.suiIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.versionInterval,\n },\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.SUI_EVENT, HandlerType.SUI_CALL]\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.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.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.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,GAKZ,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,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,IAAI,GAAW,WAAW,CAAA;IAElB,gBAAgB,GAAyD,EAAE,CAAA;IAC3E,eAAe,GAAuD,EAAE,CAAA;IACxE,iBAAiB,GAA2D,EAAE,CAAA;IAEtF,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,KAAK,MAAM,YAAY,IAAI,iBAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACjE,MAAM,cAAc,GAAG,cAAc,CAAC,WAAW,CAAC;gBAChD,iBAAiB,EAAE,EAAE;gBACrB,aAAa,EAAE,cAAc;gBAC7B,QAAQ,EAAE;oBACR,IAAI,EAAE,YAAY,CAAC,UAAU;oBAC7B,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,OA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AAO,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} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { SuiAccountProcessorState, SuiProcessorState } from './sui-processor.js'\nimport { getChainId } from './network.js'\n\nexport class SuiPlugin extends Plugin {\n name: string = 'SuiPlugin'\n\n private suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[] = []\n private suiCallHandlers: ((func: Data_SuiCall) => Promise<ProcessResult>)[] = []\n private suiObjectHandlers: ((object: Data_SuiObject) => Promise<ProcessResult>)[] = []\n\n async configure(config: ProcessConfigResponse) {\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: getChainId(suiProcessor.config.network),\n address: suiProcessor.config.address,\n abi: '',\n },\n startBlock: BigInt(suiProcessor.config.startTimestamp),\n })\n for (const handler of suiProcessor.eventHandlers) {\n const handlerId = this.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 = this.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: processor.config.address,\n chainId: processor.getChainId(),\n startBlock: BigInt(processor.config.startTimestamp), // TODO maybe use another field\n })\n for (const handler of processor.objectHandlers) {\n const handlerId = this.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 },\n type: handler.type || '',\n ownerType: processor.ownerType,\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.SUI_EVENT, HandlerType.SUI_CALL]\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.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.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.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,4 +1,4 @@
|
|
1
|
-
import { Data_SuiCall, Data_SuiEvent, MoveFetchConfig, Data_SuiObject, ProcessResult, HandleInterval } from '@sentio/protos';
|
1
|
+
import { Data_SuiCall, Data_SuiEvent, MoveFetchConfig, Data_SuiObject, ProcessResult, HandleInterval, MoveOnIntervalConfig_OwnerType } from '@sentio/protos';
|
2
2
|
import { ListStateStorage } from '@sentio/runtime';
|
3
3
|
import { SuiNetwork } from './network.js';
|
4
4
|
import { SuiContext, SuiObjectContext } from './context.js';
|
@@ -28,21 +28,26 @@ export declare class SuiBaseProcessor {
|
|
28
28
|
onEntryFunctionCall(handler: (call: MoveCall, ctx: SuiContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: MoveFetchConfig): SuiBaseProcessor;
|
29
29
|
}
|
30
30
|
declare class ObjectHandler {
|
31
|
+
type?: string;
|
31
32
|
versionInterval?: HandleInterval;
|
32
33
|
timeIntervalInMinutes?: HandleInterval;
|
33
34
|
handler: (resource: Data_SuiObject) => Promise<ProcessResult>;
|
34
35
|
}
|
35
|
-
export declare class SuiAccountProcessorState extends ListStateStorage<
|
36
|
+
export declare class SuiAccountProcessorState extends ListStateStorage<SuiObjectsProcessor> {
|
36
37
|
static INSTANCE: SuiAccountProcessorState;
|
37
38
|
}
|
38
|
-
|
39
|
+
declare class SuiObjectBindOptions extends SuiBindOptions {
|
40
|
+
ownerType: MoveOnIntervalConfig_OwnerType;
|
41
|
+
}
|
42
|
+
export declare class SuiObjectsProcessor {
|
39
43
|
config: IndexConfigure;
|
44
|
+
ownerType: MoveOnIntervalConfig_OwnerType;
|
40
45
|
objectHandlers: ObjectHandler[];
|
41
|
-
static bind(options:
|
42
|
-
protected constructor(options:
|
46
|
+
static bind(options: SuiObjectBindOptions): SuiObjectsProcessor;
|
47
|
+
protected constructor(options: SuiObjectBindOptions);
|
43
48
|
getChainId(): string;
|
44
49
|
private onInterval;
|
45
|
-
onTimeInterval(handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number): this;
|
46
|
-
onSlotInterval(handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void, slotInterval?: number, backfillSlotInterval?: number): this;
|
50
|
+
onTimeInterval(handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, type?: string): this;
|
51
|
+
onSlotInterval(handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void, slotInterval?: number, backfillSlotInterval?: number, type?: string): this;
|
47
52
|
}
|
48
53
|
export {};
|
package/lib/sui/sui-processor.js
CHANGED
@@ -106,6 +106,7 @@ export class SuiBaseProcessor {
|
|
106
106
|
}
|
107
107
|
}
|
108
108
|
class ObjectHandler {
|
109
|
+
type;
|
109
110
|
versionInterval;
|
110
111
|
timeIntervalInMinutes;
|
111
112
|
handler;
|
@@ -113,20 +114,25 @@ class ObjectHandler {
|
|
113
114
|
export class SuiAccountProcessorState extends ListStateStorage {
|
114
115
|
static INSTANCE = new SuiAccountProcessorState();
|
115
116
|
}
|
116
|
-
|
117
|
+
class SuiObjectBindOptions extends SuiBindOptions {
|
118
|
+
ownerType;
|
119
|
+
}
|
120
|
+
export class SuiObjectsProcessor {
|
117
121
|
config;
|
122
|
+
ownerType;
|
118
123
|
objectHandlers = [];
|
119
124
|
static bind(options) {
|
120
|
-
return new
|
125
|
+
return new SuiObjectsProcessor(options);
|
121
126
|
}
|
122
127
|
constructor(options) {
|
123
128
|
this.config = configure(options);
|
129
|
+
this.ownerType = options.ownerType;
|
124
130
|
SuiAccountProcessorState.INSTANCE.addValue(this);
|
125
131
|
}
|
126
132
|
getChainId() {
|
127
133
|
return getChainId(this.config.network);
|
128
134
|
}
|
129
|
-
onInterval(handler, timeInterval, versionInterval) {
|
135
|
+
onInterval(handler, timeInterval, versionInterval, type) {
|
130
136
|
const processor = this;
|
131
137
|
this.objectHandlers.push({
|
132
138
|
handler: async function (data) {
|
@@ -136,17 +142,18 @@ export class SuiAccountProcessor {
|
|
136
142
|
},
|
137
143
|
timeIntervalInMinutes: timeInterval,
|
138
144
|
versionInterval: versionInterval,
|
145
|
+
type,
|
139
146
|
});
|
140
147
|
return this;
|
141
148
|
}
|
142
|
-
onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240) {
|
149
|
+
onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type) {
|
143
150
|
return this.onInterval(handler, {
|
144
151
|
recentInterval: timeIntervalInMinutes,
|
145
152
|
backfillInterval: backfillTimeIntervalInMinutes,
|
146
|
-
}, undefined);
|
153
|
+
}, undefined, type);
|
147
154
|
}
|
148
|
-
onSlotInterval(handler, slotInterval = 100000, backfillSlotInterval = 400000) {
|
149
|
-
return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval });
|
155
|
+
onSlotInterval(handler, slotInterval = 100000, backfillSlotInterval = 400000, type) {
|
156
|
+
return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval }, type);
|
150
157
|
}
|
151
158
|
}
|
152
159
|
function configure(options) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,GAIhB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,cAAc;IAClB,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,cAAc,CAAQ;CACvB;AAED,MAAM,OAAO,cAAc;IACzB,OAAO,CAAQ;IACf,OAAO,CAAa;IACpB,cAAc,CAAS;CACxB;AAED,MAAM,OAAO,iBAAkB,SAAQ,gBAAkC;IACvE,MAAM,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAA;;AAG3C,MAAM,OAAO,gBAAgB;IAClB,UAAU,CAAQ;IAC3B,MAAM,CAAgB;IAEtB,aAAa,GAAkC,EAAE,CAAA;IACjD,YAAY,GAAgC,EAAE,CAAA;IAE9C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AG,MAAM;QAE7B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC,CAAA;IACtH,CAAC;CACF;AAED,SAAS,SAAS,CAAC,OAAuB;IACxC,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC;QAC3C,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,QAAQ;KAChD,CAAA;AACH,CAAC","sourcesContent":["import {\n Data_SuiCall,\n Data_SuiEvent,\n MoveFetchConfig,\n Data_SuiObject,\n ProcessResult,\n HandleInterval,\n} from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { SuiNetwork, getChainId } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext, SuiObjectContext } from './context.js'\nimport { MoveEvent, SuiTransactionResponse, MoveCall, SuiMoveObject } from '@mysten/sui.js'\nimport { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder } from './move-coder.js'\n\nclass IndexConfigure {\n address: string\n network: SuiNetwork\n startTimestamp: number\n}\n\nexport class SuiBindOptions {\n address: string\n network?: SuiNetwork\n startTimestamp?: number\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\n constructor(name: string, options: SuiBindOptions) {\n this.moduleName = name\n this.config = configure(options)\n SuiProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return getChainId(this.config.network)\n }\n\n public onMoveEvent(\n handler: (event: MoveEvent, ctx: SuiContext) => void,\n filter: EventFilter | EventFilter[],\n fetchConfig?: MoveFetchConfig\n ): SuiBaseProcessor {\n let _filters: EventFilter[] = []\n const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})\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\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 SuiTransactionResponse\n if (!txn.effects.events || !txn.effects.events.length) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\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 )\n\n const events = txn.effects.events\n txn.effects.events = []\n for (const evt of events) {\n if ('moveEvent' in evt) {\n const eventInstance = evt.moveEvent as MoveEvent\n const decoded = defaultMoveCoder().decodeEvent<any>(eventInstance)\n await handler(decoded || eventInstance, ctx)\n }\n }\n\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: MoveCall, ctx: SuiContext) => void,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n fetchConfig?: MoveFetchConfig\n ): SuiBaseProcessor {\n let _filters: FunctionNameAndCallFilter[] = []\n const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})\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\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 SuiTransactionResponse\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 )\n if (tx) {\n const calls: MoveCall[] = getMoveCalls(tx)\n if (calls.length !== 1) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected number of call transactions ' + calls.length)\n }\n const payload = calls[0]\n const decoded = defaultMoveCoder().decodeFunctionPayload(payload)\n await handler(decoded, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n\nclass ObjectHandler {\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (resource: Data_SuiObject) => Promise<ProcessResult>\n}\n\nexport class SuiAccountProcessorState extends ListStateStorage<SuiAccountProcessor> {\n static INSTANCE = new SuiAccountProcessorState()\n}\n\nexport class SuiAccountProcessor {\n config: IndexConfigure\n\n objectHandlers: ObjectHandler[] = []\n\n static bind(options: SuiBindOptions): SuiAccountProcessor {\n return new SuiAccountProcessor(options)\n }\n\n protected constructor(options: SuiBindOptions) {\n this.config = configure(options)\n SuiAccountProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return getChainId(this.config.network)\n }\n\n private onInterval(\n handler: (resources: SuiMoveObject[], ctx: SuiObjectContext) => void,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | 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 )\n await handler(data.objects as SuiMoveObject[], ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n })\n return this\n }\n\n public onTimeInterval(\n handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240\n ): this {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined\n )\n }\n\n public onSlotInterval(\n handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,\n slotInterval = 100000,\n backfillSlotInterval = 400000\n ): this {\n return this.onInterval(handler, undefined, { recentInterval: slotInterval, backfillInterval: backfillSlotInterval })\n }\n}\n\nfunction configure(options: SuiBindOptions): IndexConfigure {\n return {\n startTimestamp: options.startTimestamp || 0,\n address: options.address,\n network: options.network || SuiNetwork.MAIN_NET,\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,GAKhB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,MAAM,cAAc;IAClB,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,cAAc,CAAQ;CACvB;AAED,MAAM,OAAO,cAAc;IACzB,OAAO,CAAQ;IACf,OAAO,CAAa;IACpB,cAAc,CAAS;CACxB;AAED,MAAM,OAAO,iBAAkB,SAAQ,gBAAkC;IACvE,MAAM,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAA;;AAG3C,MAAM,OAAO,gBAAgB;IAClB,UAAU,CAAQ;IAC3B,MAAM,CAAgB;IAEtB,aAAa,GAAkC,EAAE,CAAA;IACjD,YAAY,GAAgC,EAAE,CAAA;IAE9C,YAAY,IAAY,EAAE,OAAuB;QAC/C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;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AEM,cAAc,CACnB,OAAkE,EAClE,YAAY,GAAG,MAAM,EACrB,oBAAoB,GAAG,MAAM,EAC7B,IAAa;QAEb,OAAO,IAAI,CAAC,UAAU,CACpB,OAAO,EACP,SAAS,EACT,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,EACxE,IAAI,CACL,CAAA;IACH,CAAC;CACF;AAED,SAAS,SAAS,CAAC,OAAuB;IACxC,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC;QAC3C,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,QAAQ;KAChD,CAAA;AACH,CAAC","sourcesContent":["import {\n Data_SuiCall,\n Data_SuiEvent,\n MoveFetchConfig,\n Data_SuiObject,\n ProcessResult,\n HandleInterval,\n MoveOnIntervalConfig_OwnerType,\n} from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { SuiNetwork, getChainId } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext, SuiObjectContext } from './context.js'\nimport { MoveEvent, SuiTransactionResponse, MoveCall, SuiMoveObject } from '@mysten/sui.js'\nimport { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder } from './move-coder.js'\n\nclass IndexConfigure {\n address: string\n network: SuiNetwork\n startTimestamp: number\n}\n\nexport class SuiBindOptions {\n address: string\n network?: SuiNetwork\n startTimestamp?: number\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\n constructor(name: string, options: SuiBindOptions) {\n this.moduleName = name\n this.config = configure(options)\n SuiProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return getChainId(this.config.network)\n }\n\n public onMoveEvent(\n handler: (event: MoveEvent, ctx: SuiContext) => void,\n filter: EventFilter | EventFilter[],\n fetchConfig?: MoveFetchConfig\n ): SuiBaseProcessor {\n let _filters: EventFilter[] = []\n const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})\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\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 SuiTransactionResponse\n if (!txn.effects.events || !txn.effects.events.length) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\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 )\n\n const events = txn.effects.events\n txn.effects.events = []\n for (const evt of events) {\n if ('moveEvent' in evt) {\n const eventInstance = evt.moveEvent as MoveEvent\n const decoded = defaultMoveCoder().decodeEvent<any>(eventInstance)\n await handler(decoded || eventInstance, ctx)\n }\n }\n\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: MoveCall, ctx: SuiContext) => void,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n fetchConfig?: MoveFetchConfig\n ): SuiBaseProcessor {\n let _filters: FunctionNameAndCallFilter[] = []\n const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})\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\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 SuiTransactionResponse\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 )\n if (tx) {\n const calls: MoveCall[] = getMoveCalls(tx)\n if (calls.length !== 1) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected number of call transactions ' + calls.length)\n }\n const payload = calls[0]\n const decoded = defaultMoveCoder().decodeFunctionPayload(payload)\n await handler(decoded, ctx)\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<SuiObjectsProcessor> {\n static INSTANCE = new SuiAccountProcessorState()\n}\n\nclass SuiObjectBindOptions extends SuiBindOptions {\n ownerType: MoveOnIntervalConfig_OwnerType\n}\n\nexport class SuiObjectsProcessor {\n config: IndexConfigure\n ownerType: MoveOnIntervalConfig_OwnerType\n\n objectHandlers: ObjectHandler[] = []\n\n static bind(options: SuiObjectBindOptions): SuiObjectsProcessor {\n return new SuiObjectsProcessor(options)\n }\n\n protected constructor(options: SuiObjectBindOptions) {\n this.config = configure(options)\n this.ownerType = options.ownerType\n SuiAccountProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return getChainId(this.config.network)\n }\n\n private onInterval(\n handler: (resources: SuiMoveObject[], ctx: SuiObjectContext) => void,\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 SuiObjectContext(\n processor.config.network,\n processor.config.address,\n data.slot,\n data.timestamp || new Date(0)\n )\n await handler(data.objects as SuiMoveObject[], 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: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,\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: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,\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 startTimestamp: options.startTimestamp || 0,\n address: options.address,\n network: options.network || SuiNetwork.MAIN_NET,\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
3
|
"license": "Apache-2.0",
|
4
|
-
"version": "2.9.0-rc.
|
4
|
+
"version": "2.9.0-rc.4",
|
5
5
|
"type": "module",
|
6
6
|
"scripts": {
|
7
7
|
"compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
|
@@ -23,8 +23,8 @@
|
|
23
23
|
"@project-serum/anchor": "^0.26.0",
|
24
24
|
"@sentio/bigdecimal": "^9.1.1-patch.3",
|
25
25
|
"@sentio/ethers-v6": "^1.0.25",
|
26
|
-
"@sentio/protos": "^2.9.0-rc.
|
27
|
-
"@sentio/runtime": "^2.9.0-rc.
|
26
|
+
"@sentio/protos": "^2.9.0-rc.4",
|
27
|
+
"@sentio/runtime": "^2.9.0-rc.4",
|
28
28
|
"@solana/web3.js": "^1.73.2",
|
29
29
|
"@types/prettier": "^2.7.2",
|
30
30
|
"aptos-sdk": "npm:aptos@^1.7.1",
|
@@ -80,5 +80,5 @@
|
|
80
80
|
"engines": {
|
81
81
|
"node": ">=16"
|
82
82
|
},
|
83
|
-
"gitHead": "
|
83
|
+
"gitHead": "2f04fb5aa85d0ec68ddbb03913e7271f7fadd5e1"
|
84
84
|
}
|
package/src/eth/index.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export { BaseProcessor } from './base-processor.js'
|
2
2
|
export { GenericProcessor } from './generic-processor.js'
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js'
|
4
|
+
export { AccountProcessor } from './account-processor.js'
|
4
5
|
export { getProvider, DummyProvider, getNetworkFromCtxOrNetworkish } from './provider.js'
|
5
6
|
export type { TypedCallTrace, Trace } from './trace.js'
|
6
7
|
export * from './eth.js'
|
package/src/sui/sui-plugin.ts
CHANGED
@@ -79,7 +79,7 @@ export class SuiPlugin extends Plugin {
|
|
79
79
|
})
|
80
80
|
for (const handler of processor.objectHandlers) {
|
81
81
|
const handlerId = this.suiObjectHandlers.push(handler.handler) - 1
|
82
|
-
accountConfig.
|
82
|
+
accountConfig.moveIntervalConfigs.push({
|
83
83
|
intervalConfig: {
|
84
84
|
handlerId: handlerId,
|
85
85
|
minutes: 0,
|
@@ -87,6 +87,8 @@ export class SuiPlugin extends Plugin {
|
|
87
87
|
slot: 0,
|
88
88
|
slotInterval: handler.versionInterval,
|
89
89
|
},
|
90
|
+
type: handler.type || '',
|
91
|
+
ownerType: processor.ownerType,
|
90
92
|
})
|
91
93
|
}
|
92
94
|
config.accountConfigs.push(accountConfig)
|
package/src/sui/sui-processor.ts
CHANGED
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
Data_SuiObject,
|
6
6
|
ProcessResult,
|
7
7
|
HandleInterval,
|
8
|
+
MoveOnIntervalConfig_OwnerType,
|
8
9
|
} from '@sentio/protos'
|
9
10
|
import { ListStateStorage } from '@sentio/runtime'
|
10
11
|
import { SuiNetwork, getChainId } from './network.js'
|
@@ -156,26 +157,33 @@ export class SuiBaseProcessor {
|
|
156
157
|
}
|
157
158
|
|
158
159
|
class ObjectHandler {
|
160
|
+
type?: string
|
159
161
|
versionInterval?: HandleInterval
|
160
162
|
timeIntervalInMinutes?: HandleInterval
|
161
163
|
handler: (resource: Data_SuiObject) => Promise<ProcessResult>
|
162
164
|
}
|
163
165
|
|
164
|
-
export class SuiAccountProcessorState extends ListStateStorage<
|
166
|
+
export class SuiAccountProcessorState extends ListStateStorage<SuiObjectsProcessor> {
|
165
167
|
static INSTANCE = new SuiAccountProcessorState()
|
166
168
|
}
|
167
169
|
|
168
|
-
|
170
|
+
class SuiObjectBindOptions extends SuiBindOptions {
|
171
|
+
ownerType: MoveOnIntervalConfig_OwnerType
|
172
|
+
}
|
173
|
+
|
174
|
+
export class SuiObjectsProcessor {
|
169
175
|
config: IndexConfigure
|
176
|
+
ownerType: MoveOnIntervalConfig_OwnerType
|
170
177
|
|
171
178
|
objectHandlers: ObjectHandler[] = []
|
172
179
|
|
173
|
-
static bind(options:
|
174
|
-
return new
|
180
|
+
static bind(options: SuiObjectBindOptions): SuiObjectsProcessor {
|
181
|
+
return new SuiObjectsProcessor(options)
|
175
182
|
}
|
176
183
|
|
177
|
-
protected constructor(options:
|
184
|
+
protected constructor(options: SuiObjectBindOptions) {
|
178
185
|
this.config = configure(options)
|
186
|
+
this.ownerType = options.ownerType
|
179
187
|
SuiAccountProcessorState.INSTANCE.addValue(this)
|
180
188
|
}
|
181
189
|
|
@@ -186,7 +194,8 @@ export class SuiAccountProcessor {
|
|
186
194
|
private onInterval(
|
187
195
|
handler: (resources: SuiMoveObject[], ctx: SuiObjectContext) => void,
|
188
196
|
timeInterval: HandleInterval | undefined,
|
189
|
-
versionInterval: HandleInterval | undefined
|
197
|
+
versionInterval: HandleInterval | undefined,
|
198
|
+
type: string | undefined
|
190
199
|
): this {
|
191
200
|
const processor = this
|
192
201
|
this.objectHandlers.push({
|
@@ -202,6 +211,7 @@ export class SuiAccountProcessor {
|
|
202
211
|
},
|
203
212
|
timeIntervalInMinutes: timeInterval,
|
204
213
|
versionInterval: versionInterval,
|
214
|
+
type,
|
205
215
|
})
|
206
216
|
return this
|
207
217
|
}
|
@@ -209,7 +219,8 @@ export class SuiAccountProcessor {
|
|
209
219
|
public onTimeInterval(
|
210
220
|
handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,
|
211
221
|
timeIntervalInMinutes = 60,
|
212
|
-
backfillTimeIntervalInMinutes = 240
|
222
|
+
backfillTimeIntervalInMinutes = 240,
|
223
|
+
type?: string
|
213
224
|
): this {
|
214
225
|
return this.onInterval(
|
215
226
|
handler,
|
@@ -217,16 +228,23 @@ export class SuiAccountProcessor {
|
|
217
228
|
recentInterval: timeIntervalInMinutes,
|
218
229
|
backfillInterval: backfillTimeIntervalInMinutes,
|
219
230
|
},
|
220
|
-
undefined
|
231
|
+
undefined,
|
232
|
+
type
|
221
233
|
)
|
222
234
|
}
|
223
235
|
|
224
236
|
public onSlotInterval(
|
225
237
|
handler: (objects: SuiMoveObject[], ctx: SuiObjectContext) => void,
|
226
238
|
slotInterval = 100000,
|
227
|
-
backfillSlotInterval = 400000
|
239
|
+
backfillSlotInterval = 400000,
|
240
|
+
type?: string
|
228
241
|
): this {
|
229
|
-
return this.onInterval(
|
242
|
+
return this.onInterval(
|
243
|
+
handler,
|
244
|
+
undefined,
|
245
|
+
{ recentInterval: slotInterval, backfillInterval: backfillSlotInterval },
|
246
|
+
type
|
247
|
+
)
|
230
248
|
}
|
231
249
|
}
|
232
250
|
|