@sentio/sdk 2.18.4-rc.3 → 2.19.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.
@@ -56,6 +56,7 @@ export class AptosPlugin extends Plugin {
56
56
  typeArguments: filter.typeArguments || [],
57
57
  withTypeArguments: !!filter.typeArguments,
58
58
  includeFailed: filter.includeFailed || false,
59
+ publicKeyPrefix: filter.publicKeyPrefix || '',
59
60
  };
60
61
  }),
61
62
  fetchConfig: handler.fetchConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"aptos-plugin.js","sourceRoot":"","sources":["../../src/aptos/aptos-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,EAGX,aAAa,GAId,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAOxD,MAAM,OAAO,WAAY,SAAQ,MAAM;IACrC,IAAI,GAAW,aAAa,CAAA;IAC5B,QAAQ,GAAa;QACnB,kBAAkB,EAAE,EAAE;QACtB,iBAAiB,EAAE,EAAE;QACrB,qBAAqB,EAAE,EAAE;KAC1B,CAAA;IAED,KAAK,CAAC,KAAK,CAAC,KAAmB;QAC7B,MAAM,YAAY,EAAE,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,MAAM,QAAQ,GAAa;YACzB,kBAAkB,EAAE,EAAE;YACtB,iBAAiB,EAAE,EAAE;YACrB,qBAAqB,E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,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAA;SACtE;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;QAEjC,MAAM,QAAQ,GAA6B,EAAE,CAAA;QAC7C,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE;YAC1C,kCAAkC;YAClC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC3E,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;YAClH,CAAC,CAAC,CAAA;YACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACvB;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA","sourcesContent":["import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport {\n AccountConfig,\n ContractConfig,\n Data_AptCall,\n Data_AptEvent,\n Data_AptResource,\n DataBinding,\n HandlerType,\n MoveCallHandlerConfig,\n MoveEventHandlerConfig,\n MoveOwnerType,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest,\n} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { AptosAccountProcessorState, AptosProcessorState } from './aptos-processor.js'\n\nimport { initCoinList } from './ext/coin.js'\nimport { validateAndNormalizeAddress } from './utils.js'\n\ninterface Handlers {\n aptosEventHandlers: ((event: Data_AptEvent) => Promise<ProcessResult>)[]\n aptosCallHandlers: ((func: Data_AptCall) => Promise<ProcessResult>)[]\n aptosResourceHandlers: ((resourceWithVersion: Data_AptResource) => Promise<ProcessResult>)[]\n}\nexport class AptosPlugin extends Plugin {\n name: string = 'AptosPlugin'\n handlers: Handlers = {\n aptosEventHandlers: [],\n aptosCallHandlers: [],\n aptosResourceHandlers: [],\n }\n\n async start(start: StartRequest) {\n await initCoinList()\n }\n\n async configure(config: ProcessConfigResponse) {\n const handlers: Handlers = {\n aptosEventHandlers: [],\n aptosCallHandlers: [],\n aptosResourceHandlers: [],\n }\n for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {\n const contractConfig = ContractConfig.fromPartial({\n processorType: USER_PROCESSOR,\n contract: {\n name: aptosProcessor.moduleName,\n chainId: aptosProcessor.getChainId(),\n address: validateAndNormalizeAddress(aptosProcessor.config.address),\n abi: '',\n },\n startBlock: aptosProcessor.config.startVersion,\n })\n // 1. Prepare event handlers\n for (const handler of aptosProcessor.eventHandlers) {\n const handlerId = handlers.aptosEventHandlers.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\n // 2. Prepare function handlers\n for (const handler of aptosProcessor.callHandlers) {\n const handlerId = handlers.aptosCallHandlers.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 aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig = AccountConfig.fromPartial({\n address: validateAndNormalizeAddress(aptosProcessor.config.address),\n chainId: aptosProcessor.getChainId(),\n startBlock: aptosProcessor.config.startVersion,\n })\n for (const handler of aptosProcessor.resourcesHandlers) {\n const handlerId = handlers.aptosResourceHandlers.push(handler.handler) - 1\n accountConfig.moveIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.versionInterval,\n fetchConfig: undefined,\n },\n type: handler.type || '',\n ownerType: MoveOwnerType.ADDRESS,\n fetchConfig: undefined,\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n this.handlers = handlers\n }\n\n supportedHandlers = [HandlerType.APT_CALL, HandlerType.APT_RESOURCE, HandlerType.APT_EVENT]\n\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.APT_CALL:\n return this.processAptosFunctionCall(request)\n case HandlerType.APT_EVENT:\n return this.processAptosEvent(request)\n case HandlerType.APT_RESOURCE:\n return this.processAptosResource(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.aptEvent) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const promises: Promise<ProcessResult>[] = []\n const event = binding.data.aptEvent\n\n for (const handlerId of binding.handlerIds) {\n // only support aptos event for now\n promises.push(\n this.handlers.aptosEventHandlers[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 processAptosResource(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.aptResource) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Resource can't be empty\")\n }\n const resource = binding.data.aptResource\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.handlers.aptosResourceHandlers[handlerId](resource).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing resource: ' + JSON.stringify(resource) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.aptCall) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Call can't be empty\")\n }\n const call = binding.data.aptCall\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n // only support aptos call for now\n const promise = this.handlers.aptosCallHandlers[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\nPluginManager.INSTANCE.register(new AptosPlugin())\n"]}
1
+ {"version":3,"file":"aptos-plugin.js","sourceRoot":"","sources":["../../src/aptos/aptos-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,EAGX,aAAa,GAId,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAEtF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAOxD,MAAM,OAAO,WAAY,SAAQ,MAAM;IACrC,IAAI,GAAW,aAAa,CAAA;IAC5B,QAAQ,GAAa;QACnB,kBAAkB,EAAE,EAAE;QACtB,iBAAiB,EAAE,EAAE;QACrB,qBAAqB,EAAE,EAAE;KAC1B,CAAA;IAED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AA;YACH,CAAC,CAAC,CACH,CAAA;SACF;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,OAAoB;QACjD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE;YAC1B,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAA;SACtE;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAA;QAEjC,MAAM,QAAQ,GAA6B,EAAE,CAAA;QAC7C,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE;YAC1C,kCAAkC;YAClC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC3E,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;YAClH,CAAC,CAAC,CAAA;YACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACvB;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA","sourcesContent":["import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport {\n AccountConfig,\n ContractConfig,\n Data_AptCall,\n Data_AptEvent,\n Data_AptResource,\n DataBinding,\n HandlerType,\n MoveCallHandlerConfig,\n MoveEventHandlerConfig,\n MoveOwnerType,\n ProcessConfigResponse,\n ProcessResult,\n StartRequest,\n} from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { AptosAccountProcessorState, AptosProcessorState } from './aptos-processor.js'\n\nimport { initCoinList } from './ext/coin.js'\nimport { validateAndNormalizeAddress } from './utils.js'\n\ninterface Handlers {\n aptosEventHandlers: ((event: Data_AptEvent) => Promise<ProcessResult>)[]\n aptosCallHandlers: ((func: Data_AptCall) => Promise<ProcessResult>)[]\n aptosResourceHandlers: ((resourceWithVersion: Data_AptResource) => Promise<ProcessResult>)[]\n}\nexport class AptosPlugin extends Plugin {\n name: string = 'AptosPlugin'\n handlers: Handlers = {\n aptosEventHandlers: [],\n aptosCallHandlers: [],\n aptosResourceHandlers: [],\n }\n\n async start(start: StartRequest) {\n await initCoinList()\n }\n\n async configure(config: ProcessConfigResponse) {\n const handlers: Handlers = {\n aptosEventHandlers: [],\n aptosCallHandlers: [],\n aptosResourceHandlers: [],\n }\n for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {\n const contractConfig = ContractConfig.fromPartial({\n processorType: USER_PROCESSOR,\n contract: {\n name: aptosProcessor.moduleName,\n chainId: aptosProcessor.getChainId(),\n address: validateAndNormalizeAddress(aptosProcessor.config.address),\n abi: '',\n },\n startBlock: aptosProcessor.config.startVersion,\n })\n // 1. Prepare event handlers\n for (const handler of aptosProcessor.eventHandlers) {\n const handlerId = handlers.aptosEventHandlers.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\n // 2. Prepare function handlers\n for (const handler of aptosProcessor.callHandlers) {\n const handlerId = handlers.aptosCallHandlers.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 aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig = AccountConfig.fromPartial({\n address: validateAndNormalizeAddress(aptosProcessor.config.address),\n chainId: aptosProcessor.getChainId(),\n startBlock: aptosProcessor.config.startVersion,\n })\n for (const handler of aptosProcessor.resourcesHandlers) {\n const handlerId = handlers.aptosResourceHandlers.push(handler.handler) - 1\n accountConfig.moveIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.versionInterval,\n fetchConfig: undefined,\n },\n type: handler.type || '',\n ownerType: MoveOwnerType.ADDRESS,\n fetchConfig: undefined,\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n this.handlers = handlers\n }\n\n supportedHandlers = [HandlerType.APT_CALL, HandlerType.APT_RESOURCE, HandlerType.APT_EVENT]\n\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.APT_CALL:\n return this.processAptosFunctionCall(request)\n case HandlerType.APT_EVENT:\n return this.processAptosEvent(request)\n case HandlerType.APT_RESOURCE:\n return this.processAptosResource(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.aptEvent) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const promises: Promise<ProcessResult>[] = []\n const event = binding.data.aptEvent\n\n for (const handlerId of binding.handlerIds) {\n // only support aptos event for now\n promises.push(\n this.handlers.aptosEventHandlers[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 processAptosResource(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.aptResource) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Resource can't be empty\")\n }\n const resource = binding.data.aptResource\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.handlers.aptosResourceHandlers[handlerId](resource).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing resource: ' + JSON.stringify(resource) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data?.aptCall) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Call can't be empty\")\n }\n const call = binding.data.aptCall\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n // only support aptos call for now\n const promise = this.handlers.aptosCallHandlers[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\nPluginManager.INSTANCE.register(new AptosPlugin())\n"]}
@@ -6,8 +6,11 @@ export interface EventFilter {
6
6
  export interface FunctionNameAndCallFilter extends CallFilter {
7
7
  function: string;
8
8
  }
9
- export interface CallFilter {
9
+ export interface TransactionFilter {
10
10
  includeFailed?: boolean;
11
+ publicKeyPrefix?: string;
12
+ }
13
+ export interface CallFilter extends TransactionFilter {
11
14
  typeArguments?: string[];
12
15
  }
13
16
  export interface ArgumentsFilter {
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/move/filter.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,YAAY;IACvB,OAAO,CAAe;IACtB,OAAO,CAAsC;IAC7C,WAAW,CAAiB;CAC7B;AAED,MAAM,OAAO,WAAW;IACtB,OAAO,CAA6B;IACpC,OAAO,CAAqC;IAC5C,WAAW,CAAiB;CAC7B","sourcesContent":["// TODO extends ArgumentsFilter\nimport { MoveFetchConfig, ProcessResult } from '@sentio/protos'\n\nexport interface EventFilter {\n type: string\n account?: string\n}\n\nexport interface FunctionNameAndCallFilter extends CallFilter {\n function: string\n}\n\n// TODO extends ArgumentsFilter\nexport interface CallFilter {\n includeFailed?: boolean\n typeArguments?: string[]\n}\n\nexport interface ArgumentsFilter {\n arguments?: string[]\n}\n\nexport class EventHandler<T> {\n filters: EventFilter[]\n handler: (event: T) => Promise<ProcessResult>\n fetchConfig: MoveFetchConfig\n}\n\nexport class CallHandler<T> {\n filters: FunctionNameAndCallFilter[]\n handler: (call: T) => Promise<ProcessResult>\n fetchConfig: MoveFetchConfig\n}\n"]}
1
+ {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/move/filter.ts"],"names":[],"mappings":"AA0BA,MAAM,OAAO,YAAY;IACvB,OAAO,CAAe;IACtB,OAAO,CAAsC;IAC7C,WAAW,CAAiB;CAC7B;AAED,MAAM,OAAO,WAAW;IACtB,OAAO,CAA6B;IACpC,OAAO,CAAqC;IAC5C,WAAW,CAAiB;CAC7B","sourcesContent":["// TODO extends ArgumentsFilter\nimport { MoveFetchConfig, ProcessResult } from '@sentio/protos'\n\nexport interface EventFilter {\n type: string\n account?: string\n}\n\nexport interface FunctionNameAndCallFilter extends CallFilter {\n function: string\n}\n\nexport interface TransactionFilter {\n includeFailed?: boolean\n publicKeyPrefix?: string\n}\n\n// TODO extends ArgumentsFilter\nexport interface CallFilter extends TransactionFilter {\n typeArguments?: string[]\n}\n\nexport interface ArgumentsFilter {\n arguments?: string[]\n}\n\nexport class EventHandler<T> {\n filters: EventFilter[]\n handler: (event: T) => Promise<ProcessResult>\n fetchConfig: MoveFetchConfig\n}\n\nexport class CallHandler<T> {\n filters: FunctionNameAndCallFilter[]\n handler: (call: T) => Promise<ProcessResult>\n fetchConfig: MoveFetchConfig\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { SuiBaseProcessor, type SuiBindOptions } from './sui-processor.js';
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
3
  export { SuiObjectProcessorTemplate, SuiWrappedObjectProcessorTemplate, } from './sui-object-processor-template.js';
4
4
  export * from './network.js';
package/lib/sui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { SuiBaseProcessor } from './sui-processor.js';
1
+ export { SuiBaseProcessor, SuiGlobalProcessor, SuiModulesProcessor } from './sui-processor.js';
2
2
  export { SuiAddressProcessor, SuiObjectProcessor, SuiWrappedObjectProcessor, } from './sui-object-processor.js';
3
3
  export {
4
4
  // SuiAddressProcessorTemplate,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,oBAAoB,CAAA;AAC1E,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, 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;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"]}
@@ -72,6 +72,7 @@ export class SuiPlugin extends Plugin {
72
72
  typeArguments: filter.typeArguments || [],
73
73
  withTypeArguments: !!filter.typeArguments,
74
74
  includeFailed: filter.includeFailed || false,
75
+ publicKeyPrefix: filter.publicKeyPrefix || '',
75
76
  };
76
77
  }),
77
78
  fetchConfig: handler.fetchConfig,
@@ -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,GAEjC,MAAM,oCAAoC,CAAA;AAC3C,OAAO,E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AAC,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: validateAndNormalizeAddress(suiProcessor.config.address),\n abi: '',\n },\n startBlock: suiProcessor.config.startCheckpoint,\n })\n for (const handler of suiProcessor.eventHandlers) {\n const handlerId = handlers.suiEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: MoveEventHandlerConfig = {\n filters: handler.filters.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\n fetchConfig: handler.fetchConfig,\n handlerId,\n }\n contractConfig.moveEventConfigs.push(eventHandlerConfig)\n }\n for (const handler of suiProcessor.callHandlers) {\n const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: MoveCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments || [],\n withTypeArguments: !!filter.typeArguments,\n includeFailed: filter.includeFailed || false,\n }\n }),\n fetchConfig: handler.fetchConfig,\n handlerId,\n }\n contractConfig.moveCallConfigs.push(functionHandlerConfig)\n }\n config.contractConfigs.push(contractConfig)\n }\n\n for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig = AccountConfig.fromPartial({\n address: validateAndNormalizeAddress(processor.config.address),\n chainId: processor.getChainId(),\n startBlock: processor.config.startCheckpoint, // TODO maybe use another field\n })\n for (const handler of processor.objectHandlers) {\n const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1\n accountConfig.moveIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.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
+ {"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,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ent":["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: 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"]}
@@ -3,7 +3,7 @@ import { ListStateStorage } from '@sentio/runtime';
3
3
  import { SuiNetwork } from './network.js';
4
4
  import { SuiContext } from './context.js';
5
5
  import { MoveCallSuiTransaction, SuiEvent, SuiTransactionBlockResponse } from '@mysten/sui.js';
6
- import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js';
6
+ import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, TransactionFilter } from '../move/index.js';
7
7
  import { MoveCoder } from './move-coder.js';
8
8
  import { Labels } from '../core/index.js';
9
9
  import { Required } from 'utility-types';
@@ -29,9 +29,12 @@ export declare class SuiBaseProcessor {
29
29
  protected onMoveEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, filter: EventFilter | EventFilter[], fetchConfig?: Partial<MoveFetchConfig>): SuiBaseProcessor;
30
30
  protected onEntryFunctionCall(handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: Partial<MoveFetchConfig>): SuiBaseProcessor;
31
31
  onEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this;
32
- onTransactionBlock(handler: (call: SuiTransactionBlockResponse, ctx: SuiContext) => void, includeFailed?: boolean, fetchConfig?: Partial<MoveFetchConfig>): this;
32
+ onTransactionBlock(handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void, filter?: TransactionFilter, fetchConfig?: Partial<MoveFetchConfig>): this;
33
33
  }
34
34
  export declare class SuiModulesProcessor extends SuiBaseProcessor {
35
- protected constructor(options: SuiBindOptions);
36
35
  static bind(options: SuiBindOptions): SuiModulesProcessor;
37
36
  }
37
+ export declare class SuiGlobalProcessor extends SuiBaseProcessor {
38
+ static bind(options: Omit<SuiBindOptions, 'address'>): SuiModulesProcessor;
39
+ onTransactionBlock(handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void, filter: TransactionFilter, fetchConfig?: Partial<MoveFetchConfig>): this;
40
+ }
@@ -135,13 +135,13 @@ export class SuiBaseProcessor {
135
135
  this.onMoveEvent(handler, { type: '' }, fetchConfig);
136
136
  return this;
137
137
  }
138
- onTransactionBlock(handler, includeFailed = false, fetchConfig) {
138
+ onTransactionBlock(handler, filter, fetchConfig) {
139
139
  const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig });
140
140
  const processor = this;
141
141
  this.callHandlers.push({
142
142
  handler: async function (data) {
143
143
  if (!data.transaction) {
144
- throw new ServerError(Status.INVALID_ARGUMENT, 'call is null');
144
+ throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null');
145
145
  }
146
146
  const tx = data.transaction;
147
147
  const ctx = new SuiContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, tx, 0, processor.config.baseLabels);
@@ -150,18 +150,26 @@ export class SuiBaseProcessor {
150
150
  }
151
151
  return ctx.getProcessResult();
152
152
  },
153
- filters: [{ function: '', includeFailed }],
153
+ filters: [{ ...filter, function: '' }],
154
154
  fetchConfig: _fetchConfig,
155
155
  });
156
156
  return this;
157
157
  }
158
158
  }
159
159
  export class SuiModulesProcessor extends SuiBaseProcessor {
160
- constructor(options) {
161
- super('*', options);
160
+ static bind(options) {
161
+ return new SuiModulesProcessor('*', options);
162
162
  }
163
+ }
164
+ export class SuiGlobalProcessor extends SuiBaseProcessor {
163
165
  static bind(options) {
164
- return new SuiModulesProcessor(options);
166
+ return new SuiGlobalProcessor('*', { ...options, address: '*' });
167
+ }
168
+ onTransactionBlock(handler, filter, fetchConfig) {
169
+ if (!filter.publicKeyPrefix || filter.publicKeyPrefix.length < 4) {
170
+ throw new ServerError(Status.INVALID_ARGUMENT, 'restriction too low for global processor');
171
+ }
172
+ return super.onTransactionBlock(handler, filter, fetchConfig);
165
173
  }
166
174
  }
167
175
  //# sourceMappingURL=sui-processor.js.map
@@ -1 +1 @@
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,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAInB,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;AAI7D,MAAM,oBAAoB,GAAoB;IAC5C,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,IAAI;CAChB,CAAA;AAID,MAAM,UAAU,SAAS,CAAC,OAAuB;IAC/C,IAAI,eAAe,GAAG,OAAO,CAAC,OAAO,CAAA;IAErC,IAAI,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACpC,eAAe,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KAC3C;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/C,IAAI,eAAe,CAAC,CAAC,CAAC,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EAAE,CAAC;YAC1C,WAAW,EAAE,YAAY;SAC1B,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,gBAAgB;IACvD,YAAsB,OAAuB;QAC3C,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACrB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAuB;QACjC,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACzC,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 let addressNoPrefix = options.address\n\n if (addressNoPrefix.startsWith('0x')) {\n addressNoPrefix = addressNoPrefix.slice(2)\n }\n for (let i = 0; i < addressNoPrefix.length; i++) {\n if (addressNoPrefix[i] !== '0') {\n addressNoPrefix = addressNoPrefix.slice(i)\n break\n }\n }\n\n return {\n startCheckpoint: options.startCheckpoint || 0n,\n address: '0x' + addressNoPrefix,\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 protected 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 protected 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 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 onEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this {\n this.onMoveEvent(handler, { type: '' }, fetchConfig)\n return this\n }\n\n onTransactionBlock(\n handler: (call: SuiTransactionBlockResponse, ctx: SuiContext) => void,\n includeFailed = false,\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\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 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 await handler(tx, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: [{ function: '', includeFailed }],\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n\nexport class SuiModulesProcessor extends SuiBaseProcessor {\n protected constructor(options: SuiBindOptions) {\n super('*', options)\n }\n\n static bind(options: SuiBindOptions): SuiModulesProcessor {\n return new SuiModulesProcessor(options)\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,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAInB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAKL,aAAa,EACb,QAAQ,GAET,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;AA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vent, 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 TransactionFilter,\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 let addressNoPrefix = options.address\n\n if (addressNoPrefix.startsWith('0x')) {\n addressNoPrefix = addressNoPrefix.slice(2)\n }\n for (let i = 0; i < addressNoPrefix.length; i++) {\n if (addressNoPrefix[i] !== '0') {\n addressNoPrefix = addressNoPrefix.slice(i)\n break\n }\n }\n\n return {\n startCheckpoint: options.startCheckpoint || 0n,\n address: '0x' + addressNoPrefix,\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 protected 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 protected 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 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 onEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this {\n this.onMoveEvent(handler, { type: '' }, fetchConfig)\n return this\n }\n\n onTransactionBlock(\n handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,\n filter?: TransactionFilter,\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\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, 'transaction 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 await handler(tx, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: [{ ...filter, function: '' }],\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n\nexport class SuiModulesProcessor extends SuiBaseProcessor {\n static bind(options: SuiBindOptions): SuiModulesProcessor {\n return new SuiModulesProcessor('*', options)\n }\n}\n\nexport class SuiGlobalProcessor extends SuiBaseProcessor {\n static bind(options: Omit<SuiBindOptions, 'address'>): SuiModulesProcessor {\n return new SuiGlobalProcessor('*', { ...options, address: '*' })\n }\n onTransactionBlock(\n handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,\n filter: TransactionFilter,\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n if (!filter.publicKeyPrefix || filter.publicKeyPrefix.length < 4) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'restriction too low for global processor')\n }\n return super.onTransactionBlock(handler, filter, fetchConfig)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.18.4-rc.3",
3
+ "version": "2.19.0-rc.2",
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.18.4-rc.3",
73
- "@sentio/runtime": "^2.18.4-rc.3"
72
+ "@sentio/protos": "2.19.0-rc.2",
73
+ "@sentio/runtime": "^2.19.0-rc.2"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "tsup": "npm:@sentio/tsup@^6.7.0"
@@ -82,6 +82,7 @@ export class AptosPlugin extends Plugin {
82
82
  typeArguments: filter.typeArguments || [],
83
83
  withTypeArguments: !!filter.typeArguments,
84
84
  includeFailed: filter.includeFailed || false,
85
+ publicKeyPrefix: filter.publicKeyPrefix || '',
85
86
  }
86
87
  }),
87
88
  fetchConfig: handler.fetchConfig,
@@ -10,9 +10,13 @@ export interface FunctionNameAndCallFilter extends CallFilter {
10
10
  function: string
11
11
  }
12
12
 
13
- // TODO extends ArgumentsFilter
14
- export interface CallFilter {
13
+ export interface TransactionFilter {
15
14
  includeFailed?: boolean
15
+ publicKeyPrefix?: string
16
+ }
17
+
18
+ // TODO extends ArgumentsFilter
19
+ export interface CallFilter extends TransactionFilter {
16
20
  typeArguments?: string[]
17
21
  }
18
22
 
package/src/sui/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { SuiBaseProcessor, type SuiBindOptions } from './sui-processor.js'
1
+ export { SuiBaseProcessor, SuiGlobalProcessor, SuiModulesProcessor, type SuiBindOptions } from './sui-processor.js'
2
2
  export {
3
3
  SuiAddressProcessor,
4
4
  SuiObjectProcessor,
@@ -105,6 +105,7 @@ export class SuiPlugin extends Plugin {
105
105
  typeArguments: filter.typeArguments || [],
106
106
  withTypeArguments: !!filter.typeArguments,
107
107
  includeFailed: filter.includeFailed || false,
108
+ publicKeyPrefix: filter.publicKeyPrefix || '',
108
109
  }
109
110
  }),
110
111
  fetchConfig: handler.fetchConfig,
@@ -17,6 +17,7 @@ import {
17
17
  FunctionNameAndCallFilter,
18
18
  parseMoveType,
19
19
  SPLITTER,
20
+ TransactionFilter,
20
21
  } from '../move/index.js'
21
22
  import { getMoveCalls } from './utils.js'
22
23
  import { defaultMoveCoder, MoveCoder } from './move-coder.js'
@@ -210,8 +211,8 @@ export class SuiBaseProcessor {
210
211
  }
211
212
 
212
213
  onTransactionBlock(
213
- handler: (call: SuiTransactionBlockResponse, ctx: SuiContext) => void,
214
- includeFailed = false,
214
+ handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,
215
+ filter?: TransactionFilter,
215
216
  fetchConfig?: Partial<MoveFetchConfig>
216
217
  ): this {
217
218
  const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
@@ -221,7 +222,7 @@ export class SuiBaseProcessor {
221
222
  this.callHandlers.push({
222
223
  handler: async function (data) {
223
224
  if (!data.transaction) {
224
- throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
225
+ throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
225
226
  }
226
227
  const tx = data.transaction as SuiTransactionBlockResponse
227
228
 
@@ -240,7 +241,7 @@ export class SuiBaseProcessor {
240
241
  }
241
242
  return ctx.getProcessResult()
242
243
  },
243
- filters: [{ function: '', includeFailed }],
244
+ filters: [{ ...filter, function: '' }],
244
245
  fetchConfig: _fetchConfig,
245
246
  })
246
247
  return this
@@ -248,11 +249,23 @@ export class SuiBaseProcessor {
248
249
  }
249
250
 
250
251
  export class SuiModulesProcessor extends SuiBaseProcessor {
251
- protected constructor(options: SuiBindOptions) {
252
- super('*', options)
252
+ static bind(options: SuiBindOptions): SuiModulesProcessor {
253
+ return new SuiModulesProcessor('*', options)
253
254
  }
255
+ }
254
256
 
255
- static bind(options: SuiBindOptions): SuiModulesProcessor {
256
- return new SuiModulesProcessor(options)
257
+ export class SuiGlobalProcessor extends SuiBaseProcessor {
258
+ static bind(options: Omit<SuiBindOptions, 'address'>): SuiModulesProcessor {
259
+ return new SuiGlobalProcessor('*', { ...options, address: '*' })
260
+ }
261
+ onTransactionBlock(
262
+ handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => void,
263
+ filter: TransactionFilter,
264
+ fetchConfig?: Partial<MoveFetchConfig>
265
+ ): this {
266
+ if (!filter.publicKeyPrefix || filter.publicKeyPrefix.length < 4) {
267
+ throw new ServerError(Status.INVALID_ARGUMENT, 'restriction too low for global processor')
268
+ }
269
+ return super.onTransactionBlock(handler, filter, fetchConfig)
257
270
  }
258
271
  }