@sentio/sdk 1.36.3 → 1.36.4-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/lib/aptos/aptos-plugin.d.ts +14 -0
- package/lib/aptos/aptos-plugin.js +190 -0
- package/lib/aptos/aptos-plugin.js.map +1 -0
- package/lib/aptos/index.d.ts +1 -0
- package/lib/aptos/index.js +3 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/core/eth-plugin.d.ts +14 -0
- package/lib/core/eth-plugin.js +221 -0
- package/lib/core/eth-plugin.js.map +1 -0
- package/lib/core/index.d.ts +3 -0
- package/lib/core/index.js +7 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/solana-plugin.d.ts +9 -0
- package/lib/core/solana-plugin.js +79 -0
- package/lib/core/solana-plugin.js.map +1 -0
- package/lib/core/sui-plugin.d.ts +8 -0
- package/lib/core/sui-plugin.js +46 -0
- package/lib/core/sui-plugin.js.map +1 -0
- package/lib/gen/index.d.ts +2 -1
- package/lib/gen/index.js +2 -1
- package/lib/gen/index.js.map +1 -1
- package/lib/plugin.d.ts +15 -0
- package/lib/plugin.js +32 -0
- package/lib/plugin.js.map +1 -0
- package/lib/processor-runner.js +0 -0
- package/lib/service.d.ts +7 -19
- package/lib/service.js +36 -486
- package/lib/service.js.map +1 -1
- package/package.json +6 -12
- package/src/aptos/aptos-plugin.ts +217 -0
- package/src/aptos/index.ts +2 -0
- package/src/core/eth-plugin.ts +255 -0
- package/src/core/index.ts +4 -0
- package/src/core/solana-plugin.ts +97 -0
- package/src/core/sui-plugin.ts +54 -0
- package/src/gen/index.ts +3 -1
- package/src/plugin.ts +41 -0
- package/src/service.ts +32 -563
- package/src/target-ethers-sentio/tsconfig.json +1 -1
- package/src/types/global.d.ts +15 -0
- package/lib/release.config.js +0 -39
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"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K,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC","sourcesContent":["import { Block, Log } from '@ethersproject/abstract-provider'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { CHAIN_IDS } from './utils/chain'\n\nimport {\n AccountConfig,\n AptosCallHandlerConfig,\n AptosEventHandlerConfig,\n ContractConfig,\n Data_SolInstruction,\n DataBinding,\n EventTrackingConfig,\n ExportConfig,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n MetricConfig,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n TemplateInstance,\n} from './gen'\n\nimport { Empty } from './gen/google/protobuf/empty'\nimport Long from 'long'\nimport { Trace } from './core'\nimport { Instruction as SolInstruction } from '@project-serum/anchor'\nimport { MetricState } from './core/meter'\nimport { ExporterState } from './core/exporter'\nimport { EventTrackerState } from './core/event-tracker'\nimport {\n AptosAccountProcessorState,\n AptosProcessorState,\n MoveResourcesWithVersionPayload,\n} from './aptos/aptos-processor'\nimport { AccountProcessorState } from './core/account-processor'\nimport { SuiProcessorState } from './core/sui-processor'\nimport { SolanaProcessorState } from './core/solana-processor'\nimport { ProcessorState } from './binds'\nimport { ProcessorTemplateProcessorState, TemplateInstanceState } from './core/base-processor-template'\nimport { toBigInt } from './core/numberish'\nimport { MoveResource, Transaction_UserTransaction } from 'aptos-sdk/src/generated'\n\n// (Long.prototype as any).toBigInt = function() {\n// return BigInt(this.toString())\n// };\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\n\nconst DEFAULT_MAX_BLOCK = Long.ZERO\n\nconst USER_PROCESSOR = 'user_processor'\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n // eth handlers\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n // aptos handlers\n private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []\n private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []\n private aptosResourceHandlers: ((resourceWithVersion: MoveResourcesWithVersionPayload) => Promise<ProcessResult>)[] =\n []\n\n // map from chain id to list of processors\n // private blockHandlers = new Map<string, ((block: Block) => Promise<ProcessResult>)[]>()\n // private processorsByChainId = new Map<string, BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>>()\n\n private started = false\n private contractConfigs: ContractConfig[]\n private accountConfigs: AccountConfig[]\n private templateInstances: TemplateInstance[]\n private metricConfigs: MetricConfig[]\n private eventTrackingConfigs: EventTrackingConfig[]\n private exportConfigs: ExportConfig[]\n private readonly loader: () => void\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => void, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n return {\n // TODO project setting\n config: undefined,\n contractConfigs: this.contractConfigs,\n accountConfigs: this.accountConfigs,\n templateInstances: this.templateInstances,\n eventTrackingConfigs: this.eventTrackingConfigs,\n metricConfigs: this.metricConfigs,\n exportConfigs: this.exportConfigs,\n }\n }\n\n async configure() {\n this.eventHandlers = []\n this.templateInstances = []\n // this.processorsByChainId.clear()\n this.contractConfigs = []\n this.accountConfigs = []\n\n // This syntax is to copy values instead of using references\n this.templateInstances = [...TemplateInstanceState.INSTANCE.getValues()]\n this.eventTrackingConfigs = []\n this.metricConfigs = []\n this.exportConfigs = []\n\n // part 0, prepare metrics and event tracking configs\n for (const metric of MetricState.INSTANCE.getValues()) {\n this.metricConfigs.push({\n ...metric.config,\n })\n }\n\n for (const eventTracker of EventTrackerState.INSTANCE.getValues()) {\n this.eventTrackingConfigs.push({\n distinctAggregationByDays: eventTracker.options.distinctByDays || [],\n eventName: eventTracker.name,\n retentionConfig: undefined,\n totalByDay: eventTracker.options.totalByDay || false,\n totalPerEntity: undefined,\n unique: eventTracker.options.unique || false,\n })\n }\n\n for (const exporter of ExporterState.INSTANCE.getValues()) {\n this.exportConfigs.push({\n name: exporter.name,\n channel: exporter.channel,\n })\n }\n\n // Part 1.a, prepare EVM processors\n for (const processor of ProcessorState.INSTANCE.getValues()) {\n // If server favor incremental update this need to change\n // Start basic config for contract\n const chainId = processor.getChainId()\n // this.processorsByChainId.set(chainId, processor)\n\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: processor.config.name,\n chainId: chainId.toString(),\n address: processor.config.address,\n abi: '',\n },\n intervalConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: processor.config.startBlock,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n if (processor.config.endBlock) {\n contractConfig.endBlock = processor.config.endBlock\n }\n\n // Step 1. Prepare all the block handlers\n for (const blockHandler of processor.blockHandlers) {\n const handlerId = this.blockHandlers.push(blockHandler.handler) - 1\n // TODO wrap the block handler into one\n\n contractConfig.intervalConfigs.push({\n slot: 0,\n slotInterval: blockHandler.blockInterval,\n minutes: 0,\n minutesInterval: blockHandler.timeIntervalInMinutes,\n handlerId: handlerId,\n })\n }\n\n // Step 2. Prepare all trace handlers\n for (const traceHandler of processor.traceHandlers) {\n const handlerId = this.traceHandlers.push(traceHandler.handler) - 1\n contractConfig.traceConfigs.push({\n signature: traceHandler.signature,\n handlerId: handlerId,\n })\n }\n\n // Step 3. Prepare all the event handlers\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n addressType: undefined,\n address: contractConfig.contract?.address,\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n contractConfig.logConfigs.push(logConfig)\n }\n\n // Finish up a contract\n this.contractConfigs.push(contractConfig)\n }\n\n // part 1.b prepare EVM account processors\n for (const processor of AccountProcessorState.INSTANCE.getValues()) {\n const accountConfig: AccountConfig = {\n address: processor.config.address,\n chainId: processor.getChainId().toString(),\n startBlock: processor.config.startBlock ? Long.fromValue(processor.config.startBlock) : Long.ZERO,\n aptosIntervalConfigs: [],\n intervalConfigs: [],\n logConfigs: [],\n }\n // TODO add interval\n for (const eventsHandler of processor.eventHandlers) {\n // associate id with filter\n const handlerId = this.eventHandlers.push(eventsHandler.handler) - 1\n const logConfig: LogHandlerConfig = {\n handlerId: handlerId,\n filters: [],\n }\n\n for (const filter of eventsHandler.filters) {\n if (!filter.topics) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')\n }\n const logFilter: LogFilter = {\n addressType: filter.addressType,\n address: filter.address,\n topics: [],\n }\n\n for (const ts of filter.topics) {\n let hashes: string[] = []\n if (Array.isArray(ts)) {\n hashes = hashes.concat(ts)\n } else if (ts) {\n hashes.push(ts)\n }\n logFilter.topics.push({ hashes: hashes })\n }\n logConfig.filters.push(logFilter)\n }\n accountConfig.logConfigs.push(logConfig)\n }\n\n this.accountConfigs.push(accountConfig)\n }\n\n // Part 2, prepare solana constractors\n for (const solanaProcessor of SolanaProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: solanaProcessor.contractName,\n chainId: solanaProcessor.network,\n address: solanaProcessor.address,\n abi: '',\n },\n logConfigs: [],\n traceConfigs: [],\n intervalConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 3, prepare sui constractors\n for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: 'sui contract',\n chainId: CHAIN_IDS.SUI_DEVNET,\n address: suiProcessor.address,\n abi: '',\n },\n logConfigs: [],\n intervalConfigs: [],\n traceConfigs: [],\n startBlock: suiProcessor.config.startSeqNumber,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n this.contractConfigs.push(contractConfig)\n }\n\n // Part 4, prepare aptos constractors\n for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: aptosProcessor.moduleName,\n chainId: aptosProcessor.getChainId(),\n address: aptosProcessor.config.address,\n abi: '',\n },\n intervalConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: Long.fromString(aptosProcessor.config.startVersion.toString()),\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n // 1. Prepare event handlers\n for (const handler of aptosProcessor.eventHandlers) {\n const handlerId = this.aptosEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: AptosEventHandlerConfig = {\n filters: handler.filters.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\n handlerId,\n }\n contractConfig.aptosEventConfigs.push(eventHandlerConfig)\n }\n\n // 2. Prepare function handlers\n for (const handler of aptosProcessor.callHandlers) {\n const handlerId = this.aptosCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: AptosCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments || [],\n withTypeArguments: filter.typeArguments ? true : false,\n includeFailed: filter.includeFailed || false,\n }\n }),\n handlerId,\n }\n contractConfig.aptosCallConfigs.push(functionHandlerConfig)\n }\n this.contractConfigs.push(contractConfig)\n }\n\n for (const aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig: AccountConfig = {\n address: aptosProcessor.config.address,\n chainId: aptosProcessor.getChainId(),\n startBlock: Long.fromValue(aptosProcessor.config.startVersion.toString()),\n aptosIntervalConfigs: [],\n intervalConfigs: [],\n logConfigs: [],\n }\n for (const handler of aptosProcessor.resourcesHandlers) {\n const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1\n accountConfig.aptosIntervalConfigs.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 })\n }\n this.accountConfigs.push(accountConfig)\n }\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n for (const instance of request.templateInstances) {\n const template = ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId]\n if (!template) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance)\n }\n if (!instance.contract) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance)\n }\n template.bind({\n name: instance.contract.name,\n address: instance.contract.address,\n network: Number(instance.contract.chainId),\n startBlock: instance.startBlock,\n endBlock: instance.endBlock,\n })\n }\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n let updated = false\n const t = TemplateInstanceState.INSTANCE.getValues()\n if (TemplateInstanceState.INSTANCE.getValues().length !== this.templateInstances.length) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n const processBindingInternal = (request: DataBinding) => {\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 case HandlerType.ETH_LOG:\n return this.processLog(request)\n case HandlerType.ETH_TRACE:\n return this.processTrace(request)\n case HandlerType.ETH_BLOCK:\n return this.processBlock(request)\n case HandlerType.SOL_INSTRUCTION:\n return this.processSolInstruction(request)\n // TODO migrate SUI cases\n // case HandlerType.INSTRUCTION:\n // return this.processInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n const result = await processBindingInternal(request)\n recordRuntimeInfo(result, request.handlerType)\n return result\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n for await (const request of requests) {\n const result = await this.processBinding(request)\n let updated = false\n if (TemplateInstanceState.INSTANCE.getValues().length !== this.templateInstances.length) {\n await this.configure()\n updated = true\n }\n yield {\n result,\n configUpdated: updated,\n }\n }\n }\n\n async processLog(request: DataBinding): Promise<ProcessResult> {\n if (!request.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\n }\n\n const promises: Promise<ProcessResult>[] = []\n let log: Log\n if (request.data.ethLog) {\n log = request.data.ethLog.log as Log\n } else {\n const jsonString = Utf8ArrayToStr(request.data.raw)\n log = JSON.parse(jsonString)\n }\n\n for (const handlerId of request.handlerIds) {\n const handler = this.eventHandlers[handlerId]\n promises.push(\n handler(log).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\\n' + errorString(e))\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processSolInstruction(request: DataBinding): Promise<ProcessResult> {\n if (!request.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')\n }\n\n const instruction = request.data.solInstruction || Data_SolInstruction.decode(request.data.raw) // JSON.parse(jsonString)\n const promises: Promise<ProcessResult>[] = []\n\n // Only have instruction handlers for solana processors\n for (const processor of SolanaProcessorState.INSTANCE.getValues()) {\n if (processor.address === instruction.programAccountId) {\n let parsedInstruction: SolInstruction | null = null\n if (instruction.parsed) {\n parsedInstruction = processor.getParsedInstruction(instruction.parsed as { type: string; info: any })\n } else if (instruction.instructionData) {\n parsedInstruction = processor.getParsedInstruction(instruction.instructionData)\n }\n if (parsedInstruction == null) {\n continue\n }\n const insHandler = processor.getInstructionHandler(parsedInstruction)\n if (insHandler == null) {\n continue\n }\n const res = await processor.handleInstruction(\n parsedInstruction,\n instruction.accounts,\n insHandler,\n instruction.slot\n )\n\n promises.push(Promise.resolve(res))\n }\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processBlock(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\n }\n let block: Block\n if (binding.data.ethBlock?.block) {\n block = binding.data.ethBlock.block as Block\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n block = JSON.parse(jsonString)\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.blockHandlers[handlerId](block).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\\n' + errorString(e))\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processTrace(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be empty\")\n }\n let trace: Trace\n if (binding.data.ethTrace?.trace) {\n trace = binding.data.ethTrace.trace as Trace\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n trace = JSON.parse(jsonString)\n }\n\n const promises: Promise<ProcessResult>[] = []\n\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.traceHandlers[handlerId](trace).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing trace: ' + JSON.stringify(trace) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const promises: Promise<ProcessResult>[] = []\n let event: Transaction_UserTransaction\n if (binding.data.aptEvent?.event) {\n event = binding.data.aptEvent?.event as Transaction_UserTransaction\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n event = JSON.parse(jsonString)\n }\n\n for (const handlerId of binding.handlerIds) {\n // only support aptos event for now\n promises.push(\n this.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) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n\n const resource: MoveResourcesWithVersionPayload = {\n resources: [],\n version: 0n,\n timestamp: 0,\n }\n if (binding.data.aptResource?.resources) {\n if (binding.data.aptResource.timestampMicros.greaterThan(Number.MAX_SAFE_INTEGER)) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n resource.timestamp = binding.data.aptResource.timestampMicros.toNumber()\n resource.version = toBigInt(binding.data.aptResource.version)\n resource.resources = binding.data.aptResource.resources as MoveResource[]\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const json = JSON.parse(jsonString)\n if (Long.fromString(json.timestamp).greaterThan(Number.MAX_SAFE_INTEGER)) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n resource.timestamp = parseInt(json.timestamp)\n resource.version = toBigInt(json.version)\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.aptosResourceHandlers[handlerId](resource).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing event: ' + 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) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n let call: Transaction_UserTransaction\n if (binding.data.aptCall?.call) {\n call = binding.data.aptCall?.call as Transaction_UserTransaction\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n call = JSON.parse(jsonString)\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n // only support aptos call for now\n const promise = this.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\n// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript\n/* eslint-disable */\nfunction Utf8ArrayToStr(array: Uint8Array) {\n let out, i, len, c\n let char2, char3\n\n out = ''\n len = array.length\n i = 0\n while (i < len) {\n c = array[i++]\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c)\n break\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++]\n out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))\n break\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++]\n char3 = array[i++]\n out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))\n break\n }\n }\n\n return out\n}\n\nfunction mergeProcessResults(results: ProcessResult[]): ProcessResult {\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n res.logs = res.logs.concat(r.logs)\n res.events = res.events.concat(r.events)\n res.exports = res.exports.concat(r.exports)\n }\n return res\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {\n list.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n }\n}\n\nfunction errorString(e: Error): string {\n return e.stack || e.message\n}\n"]}
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA4D;AAE5D,+BAUc;AAGd,gDAAuB;AACvB,wCAA0C;AAC1C,8CAA+C;AAC/C,wDAAwD;AACxD,4EAAuG;AAEvG,kDAAkD;AAClD,mCAAmC;AACnC,KAAK;AACL,qCACC;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAEY,QAAA,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAA;AAE7B,QAAA,cAAc,GAAG,gBAAgB,CAAA;AAE9C,MAAa,oBAAoB;IACvB,O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O,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACpG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC;AAED,SAAgB,WAAW,CAAC,CAAQ;IAClC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC;AAFD,kCAEC","sourcesContent":["import { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n} from './gen'\n\nimport { Empty } from './gen/google/protobuf/empty'\nimport Long from 'long'\nimport { MetricState } from './core/meter'\nimport { ExporterState } from './core/exporter'\nimport { EventTrackerState } from './core/event-tracker'\nimport { ProcessorTemplateProcessorState, TemplateInstanceState } from './core/base-processor-template'\n\n// (Long.prototype as any).toBigInt = function() {\n// return BigInt(this.toString())\n// };\nimport { PluginManager } from './plugin'\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\n\nexport const DEFAULT_MAX_BLOCK = Long.ZERO\n\nexport const USER_PROCESSOR = 'user_processor'\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private started = false\n private processorConfig: ProcessConfigResponse\n\n private readonly loader: () => void\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => void, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n if (!this.processorConfig) {\n throw new ServerError(Status.INTERNAL, 'Process config empty.')\n }\n return this.processorConfig\n }\n\n async configure() {\n this.processorConfig = ProcessConfigResponse.fromPartial({})\n // This syntax is to copy values instead of using references\n this.processorConfig.templateInstances = [...TemplateInstanceState.INSTANCE.getValues()]\n\n // part 0, prepare metrics and event tracking configs\n for (const metric of MetricState.INSTANCE.getValues()) {\n this.processorConfig.metricConfigs.push({\n ...metric.config,\n })\n }\n\n for (const eventTracker of EventTrackerState.INSTANCE.getValues()) {\n this.processorConfig.eventTrackingConfigs.push({\n distinctAggregationByDays: eventTracker.options.distinctByDays || [],\n eventName: eventTracker.name,\n retentionConfig: undefined,\n totalByDay: eventTracker.options.totalByDay || false,\n totalPerEntity: undefined,\n unique: eventTracker.options.unique || false,\n })\n }\n\n for (const exporter of ExporterState.INSTANCE.getValues()) {\n this.processorConfig.exportConfigs.push({\n name: exporter.name,\n channel: exporter.channel,\n })\n }\n\n PluginManager.INSTANCE.configure(this.processorConfig)\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n try {\n require('./core/eth-plugin')\n require('./core/sui-plugin')\n require('./aptos/aptos-plugin')\n require('./core/solana-plugin')\n } catch (e) {\n require('@sentio/sdk/lib/core/eth-plugin')\n require('@sentio/sdk/lib/core/sui-plugin')\n require('@sentio/sdk/lib/aptos/aptos-plugin')\n require('@sentio/sdk/lib/core/solana-plugin')\n }\n\n this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n for (const instance of request.templateInstances) {\n const template = ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId]\n if (!template) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Invalid template contract:' + instance)\n }\n if (!instance.contract) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Contract Empty from:' + instance)\n }\n template.bind({\n name: instance.contract.name,\n address: instance.contract.address,\n network: Number(instance.contract.chainId),\n startBlock: instance.startBlock,\n endBlock: instance.endBlock,\n })\n }\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n const result = mergeProcessResults(await Promise.all(promises))\n\n let updated = false\n const t = TemplateInstanceState.INSTANCE.getValues()\n if (TemplateInstanceState.INSTANCE.getValues().length !== this.processorConfig.templateInstances.length) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n const result = await PluginManager.INSTANCE.processBinding(request)\n recordRuntimeInfo(result, request.handlerType)\n return result\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n for await (const request of requests) {\n const result = await this.processBinding(request)\n let updated = false\n if (TemplateInstanceState.INSTANCE.getValues().length !== this.processorConfig.templateInstances.length) {\n await this.configure()\n updated = true\n }\n yield {\n result,\n configUpdated: updated,\n }\n }\n }\n}\n\n// https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript\n/* eslint-disable */\nexport function Utf8ArrayToStr(array: Uint8Array) {\n let out, i, len, c\n let char2, char3\n\n out = ''\n len = array.length\n i = 0\n while (i < len) {\n c = array[i++]\n switch (c >> 4) {\n case 0:\n case 1:\n case 2:\n case 3:\n case 4:\n case 5:\n case 6:\n case 7:\n // 0xxxxxxx\n out += String.fromCharCode(c)\n break\n case 12:\n case 13:\n // 110x xxxx 10xx xxxx\n char2 = array[i++]\n out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))\n break\n case 14:\n // 1110 xxxx 10xx xxxx 10xx xxxx\n char2 = array[i++]\n char3 = array[i++]\n out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))\n break\n }\n }\n\n return out\n}\n\nexport function mergeProcessResults(results: ProcessResult[]): ProcessResult {\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n res.logs = res.logs.concat(r.logs)\n res.events = res.events.concat(r.events)\n res.exports = res.exports.concat(r.exports)\n }\n return res\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {\n list.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n }\n}\n\nexport function errorString(e: Error): string {\n return e.stack || e.message\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.36.
|
|
4
|
+
"version": "1.36.4-rc.1",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/utils/*.csv lib/utils",
|
|
8
8
|
"build": "yarn gen && yarn compile",
|
|
9
|
+
"build_all": "yarn lerna run --scope=@sentio/sdk build --include-dependencies",
|
|
9
10
|
"start_ts": "ts-node --files src/processor-runner.ts --log-format=json ../examples/x2y2/src/processor.ts",
|
|
10
11
|
"start": "ts-node --files src/processor-runner.ts ../examples/aptos/dist/lib.js",
|
|
11
12
|
"start_js": "node lib/processor-runner.js ../examples/aptos/dist/lib.js",
|
|
@@ -16,18 +17,16 @@
|
|
|
16
17
|
"gen_test_abi": "ts-node src/test-abi-code-gen.ts src/tests/abis src/tests/types",
|
|
17
18
|
"gen_bultin_evm": "typechain --target lib/target-ethers-sentio --out-dir src/builtin/internal 'src/abis/*.json'",
|
|
18
19
|
"gen_bultin_others": "ts-node src/test-abi-code-gen.ts src/abis src/builtin",
|
|
19
|
-
"postbuild": "echo || clear-package-json package.json -o ./lib/package.json && cp release.config.js ./lib",
|
|
20
20
|
"docs": "typedoc --options typedoc.json"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@sentio/cli": "^1.0.0",
|
|
24
|
-
"@types/bs58": "^4.0.1",
|
|
25
23
|
"@ethersproject/providers": "~5.7.0",
|
|
26
24
|
"@project-serum/anchor": "^0.26.0",
|
|
25
|
+
"@sentio/cli": "^1.0.0",
|
|
27
26
|
"@solana/web3.js": "^1.47.3",
|
|
28
27
|
"@typechain/ethers-v5": "^10.0.0",
|
|
29
28
|
"@types/bn.js": "^5.1.0",
|
|
30
|
-
"@types/
|
|
29
|
+
"@types/bs58": "^4.0.1",
|
|
31
30
|
"aptos-sdk": "npm:aptos@^1.3.17",
|
|
32
31
|
"bignumber.js": "^9.1.0",
|
|
33
32
|
"bn.js": "^5.2.1",
|
|
@@ -36,14 +35,12 @@
|
|
|
36
35
|
"command-line-usage": "^6.1.3",
|
|
37
36
|
"csv-parse": "^5.3.0",
|
|
38
37
|
"ethers": "~5.7.1",
|
|
39
|
-
"form-data": "^4.0.0",
|
|
40
38
|
"fs-extra": "^11.0.0",
|
|
41
39
|
"google-protobuf": "^3.15.8",
|
|
42
40
|
"js-yaml": "^4.1.0",
|
|
43
41
|
"nice-grpc": "^2.0.0",
|
|
44
42
|
"nice-grpc-client-middleware-retry": "^2.0.1",
|
|
45
43
|
"nice-grpc-error-details": "^0.1.4",
|
|
46
|
-
"node-fetch": "2",
|
|
47
44
|
"p-queue": "^6.6.2",
|
|
48
45
|
"typechain": "^8.0.0",
|
|
49
46
|
"winston": "^3.8.2"
|
|
@@ -60,10 +57,6 @@
|
|
|
60
57
|
"@types/google-protobuf": "^3.15.6",
|
|
61
58
|
"@types/js-yaml": "^4.0.5",
|
|
62
59
|
"@types/node": "^18.0.4",
|
|
63
|
-
"chai": "^4.3.6",
|
|
64
|
-
"jest": "^29.0.3",
|
|
65
|
-
"ts-jest": "^29.0.3",
|
|
66
|
-
"ts-node": "^10.9.1",
|
|
67
60
|
"typedoc": "^0.23.15"
|
|
68
61
|
},
|
|
69
62
|
"bin": {
|
|
@@ -79,5 +72,6 @@
|
|
|
79
72
|
],
|
|
80
73
|
"engines": {
|
|
81
74
|
"node": ">=16"
|
|
82
|
-
}
|
|
75
|
+
},
|
|
76
|
+
"gitHead": "3c87b72d75f7d9313dbedeecb33101723d5a2c58"
|
|
83
77
|
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Plugin, PluginManager } from '../plugin'
|
|
2
|
+
import {
|
|
3
|
+
AccountConfig,
|
|
4
|
+
AptosCallHandlerConfig,
|
|
5
|
+
AptosEventHandlerConfig,
|
|
6
|
+
ContractConfig,
|
|
7
|
+
DataBinding,
|
|
8
|
+
HandlerType,
|
|
9
|
+
ProcessConfigResponse,
|
|
10
|
+
ProcessResult,
|
|
11
|
+
} from '../gen/processor/protos/processor'
|
|
12
|
+
import { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'
|
|
13
|
+
|
|
14
|
+
import { ServerError, Status } from 'nice-grpc'
|
|
15
|
+
|
|
16
|
+
import { MoveResource, Transaction_UserTransaction } from 'aptos-sdk/src/generated'
|
|
17
|
+
import { AptosAccountProcessorState, AptosProcessorState, MoveResourcesWithVersionPayload } from './aptos-processor'
|
|
18
|
+
import { toBigInt } from '../core/numberish'
|
|
19
|
+
import Long from 'long'
|
|
20
|
+
|
|
21
|
+
export class AptosPlugin implements Plugin {
|
|
22
|
+
name: string = 'AptosPlugin'
|
|
23
|
+
|
|
24
|
+
private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []
|
|
25
|
+
private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []
|
|
26
|
+
private aptosResourceHandlers: ((resourceWithVersion: MoveResourcesWithVersionPayload) => Promise<ProcessResult>)[] =
|
|
27
|
+
[]
|
|
28
|
+
|
|
29
|
+
configure(config: ProcessConfigResponse): void {
|
|
30
|
+
for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {
|
|
31
|
+
const contractConfig: ContractConfig = {
|
|
32
|
+
processorType: USER_PROCESSOR,
|
|
33
|
+
contract: {
|
|
34
|
+
name: aptosProcessor.moduleName,
|
|
35
|
+
chainId: aptosProcessor.getChainId(),
|
|
36
|
+
address: aptosProcessor.config.address,
|
|
37
|
+
abi: '',
|
|
38
|
+
},
|
|
39
|
+
intervalConfigs: [],
|
|
40
|
+
logConfigs: [],
|
|
41
|
+
traceConfigs: [],
|
|
42
|
+
startBlock: Long.fromString(aptosProcessor.config.startVersion.toString()),
|
|
43
|
+
endBlock: DEFAULT_MAX_BLOCK,
|
|
44
|
+
instructionConfig: undefined,
|
|
45
|
+
aptosEventConfigs: [],
|
|
46
|
+
aptosCallConfigs: [],
|
|
47
|
+
}
|
|
48
|
+
// 1. Prepare event handlers
|
|
49
|
+
for (const handler of aptosProcessor.eventHandlers) {
|
|
50
|
+
const handlerId = this.aptosEventHandlers.push(handler.handler) - 1
|
|
51
|
+
const eventHandlerConfig: AptosEventHandlerConfig = {
|
|
52
|
+
filters: handler.filters.map((f) => {
|
|
53
|
+
return {
|
|
54
|
+
type: f.type,
|
|
55
|
+
account: f.account || '',
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
handlerId,
|
|
59
|
+
}
|
|
60
|
+
contractConfig.aptosEventConfigs.push(eventHandlerConfig)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 2. Prepare function handlers
|
|
64
|
+
for (const handler of aptosProcessor.callHandlers) {
|
|
65
|
+
const handlerId = this.aptosCallHandlers.push(handler.handler) - 1
|
|
66
|
+
const functionHandlerConfig: AptosCallHandlerConfig = {
|
|
67
|
+
filters: handler.filters.map((filter) => {
|
|
68
|
+
return {
|
|
69
|
+
function: filter.function,
|
|
70
|
+
typeArguments: filter.typeArguments || [],
|
|
71
|
+
withTypeArguments: filter.typeArguments ? true : false,
|
|
72
|
+
includeFailed: filter.includeFailed || false,
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
handlerId,
|
|
76
|
+
}
|
|
77
|
+
contractConfig.aptosCallConfigs.push(functionHandlerConfig)
|
|
78
|
+
}
|
|
79
|
+
config.contractConfigs.push(contractConfig)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (const aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {
|
|
83
|
+
const accountConfig: AccountConfig = {
|
|
84
|
+
address: aptosProcessor.config.address,
|
|
85
|
+
chainId: aptosProcessor.getChainId(),
|
|
86
|
+
startBlock: Long.fromValue(aptosProcessor.config.startVersion.toString()),
|
|
87
|
+
aptosIntervalConfigs: [],
|
|
88
|
+
intervalConfigs: [],
|
|
89
|
+
logConfigs: [],
|
|
90
|
+
}
|
|
91
|
+
for (const handler of aptosProcessor.resourcesHandlers) {
|
|
92
|
+
const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1
|
|
93
|
+
accountConfig.aptosIntervalConfigs.push({
|
|
94
|
+
intervalConfig: {
|
|
95
|
+
handlerId: handlerId,
|
|
96
|
+
minutes: 0,
|
|
97
|
+
minutesInterval: handler.timeIntervalInMinutes,
|
|
98
|
+
slot: 0,
|
|
99
|
+
slotInterval: handler.versionInterval,
|
|
100
|
+
},
|
|
101
|
+
type: handler.type || '',
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
config.accountConfigs.push(accountConfig)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
supportedHandlers = [HandlerType.APT_CALL, HandlerType.APT_RESOURCE, HandlerType.APT_EVENT]
|
|
109
|
+
|
|
110
|
+
processBinding(request: DataBinding): Promise<ProcessResult> {
|
|
111
|
+
switch (request.handlerType) {
|
|
112
|
+
case HandlerType.APT_CALL:
|
|
113
|
+
return this.processAptosFunctionCall(request)
|
|
114
|
+
case HandlerType.APT_EVENT:
|
|
115
|
+
return this.processAptosEvent(request)
|
|
116
|
+
case HandlerType.APT_RESOURCE:
|
|
117
|
+
return this.processAptosResource(request)
|
|
118
|
+
// case HandlerType.INSTRUCTION:
|
|
119
|
+
// return this.processInstruction(request)
|
|
120
|
+
default:
|
|
121
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {
|
|
126
|
+
if (!binding.data) {
|
|
127
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
128
|
+
}
|
|
129
|
+
const promises: Promise<ProcessResult>[] = []
|
|
130
|
+
let event: Transaction_UserTransaction
|
|
131
|
+
if (binding.data.aptEvent?.event) {
|
|
132
|
+
event = binding.data.aptEvent?.event as Transaction_UserTransaction
|
|
133
|
+
} else {
|
|
134
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
135
|
+
event = JSON.parse(jsonString)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (const handlerId of binding.handlerIds) {
|
|
139
|
+
// only support aptos event for now
|
|
140
|
+
promises.push(
|
|
141
|
+
this.aptosEventHandlers[handlerId](event).catch((e) => {
|
|
142
|
+
throw new ServerError(
|
|
143
|
+
Status.INTERNAL,
|
|
144
|
+
'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
|
|
145
|
+
)
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async processAptosResource(binding: DataBinding): Promise<ProcessResult> {
|
|
153
|
+
if (!binding.data) {
|
|
154
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const resource: MoveResourcesWithVersionPayload = {
|
|
158
|
+
resources: [],
|
|
159
|
+
version: 0n,
|
|
160
|
+
timestamp: 0,
|
|
161
|
+
}
|
|
162
|
+
if (binding.data.aptResource?.resources) {
|
|
163
|
+
if (binding.data.aptResource.timestampMicros.greaterThan(Number.MAX_SAFE_INTEGER)) {
|
|
164
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
|
|
165
|
+
}
|
|
166
|
+
resource.timestamp = binding.data.aptResource.timestampMicros.toNumber()
|
|
167
|
+
resource.version = toBigInt(binding.data.aptResource.version)
|
|
168
|
+
resource.resources = binding.data.aptResource.resources as MoveResource[]
|
|
169
|
+
} else {
|
|
170
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
171
|
+
const json = JSON.parse(jsonString)
|
|
172
|
+
if (Long.fromString(json.timestamp).greaterThan(Number.MAX_SAFE_INTEGER)) {
|
|
173
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
|
|
174
|
+
}
|
|
175
|
+
resource.timestamp = parseInt(json.timestamp)
|
|
176
|
+
resource.version = toBigInt(json.version)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const promises: Promise<ProcessResult>[] = []
|
|
180
|
+
for (const handlerId of binding.handlerIds) {
|
|
181
|
+
promises.push(
|
|
182
|
+
this.aptosResourceHandlers[handlerId](resource).catch((e) => {
|
|
183
|
+
throw new ServerError(
|
|
184
|
+
Status.INTERNAL,
|
|
185
|
+
'error processing event: ' + JSON.stringify(resource) + '\n' + errorString(e)
|
|
186
|
+
)
|
|
187
|
+
})
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {
|
|
194
|
+
if (!binding.data) {
|
|
195
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
196
|
+
}
|
|
197
|
+
let call: Transaction_UserTransaction
|
|
198
|
+
if (binding.data.aptCall?.call) {
|
|
199
|
+
call = binding.data.aptCall?.call as Transaction_UserTransaction
|
|
200
|
+
} else {
|
|
201
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
202
|
+
call = JSON.parse(jsonString)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const promises: Promise<ProcessResult>[] = []
|
|
206
|
+
for (const handlerId of binding.handlerIds) {
|
|
207
|
+
// only support aptos call for now
|
|
208
|
+
const promise = this.aptosCallHandlers[handlerId](call).catch((e) => {
|
|
209
|
+
throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e))
|
|
210
|
+
})
|
|
211
|
+
promises.push(promise)
|
|
212
|
+
}
|
|
213
|
+
return mergeProcessResults(await Promise.all(promises))
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
PluginManager.INSTANCE.register(new AptosPlugin())
|
package/src/aptos/index.ts
CHANGED
|
@@ -6,3 +6,5 @@ export { AptosBaseProcessor, AptosAccountProcessor } from './aptos-processor'
|
|
|
6
6
|
export { AptosContext, AptosResourceContext } from './context'
|
|
7
7
|
export { AptosBindOptions, AptosNetwork, getRpcClient } from './network'
|
|
8
8
|
export * from './api'
|
|
9
|
+
|
|
10
|
+
export { AptosPlugin } from './aptos-plugin'
|