@sentio/sdk 1.37.0-rc.1 → 1.37.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/lib/builtin/index.d.ts +0 -2
  2. package/lib/builtin/index.js +1 -3
  3. package/lib/builtin/index.js.map +1 -1
  4. package/lib/core/eth-plugin.js +12 -15
  5. package/lib/core/eth-plugin.js.map +1 -1
  6. package/lib/core/index.d.ts +0 -4
  7. package/lib/core/index.js +1 -9
  8. package/lib/core/index.js.map +1 -1
  9. package/lib/core/numberish.d.ts +1 -1
  10. package/lib/core/numberish.js +5 -13
  11. package/lib/core/numberish.js.map +1 -1
  12. package/lib/core/sui-plugin.js +1 -1
  13. package/lib/core/sui-plugin.js.map +1 -1
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.js +3 -14
  16. package/lib/index.js.map +1 -1
  17. package/lib/service.d.ts +0 -4
  18. package/lib/service.js +40 -71
  19. package/lib/service.js.map +1 -1
  20. package/package.json +5 -15
  21. package/src/builtin/index.ts +1 -4
  22. package/src/core/eth-plugin.ts +5 -8
  23. package/src/core/index.ts +0 -5
  24. package/src/core/numberish.ts +8 -15
  25. package/src/core/sui-plugin.ts +2 -2
  26. package/src/index.ts +3 -1
  27. package/src/service.ts +13 -71
  28. package/lib/aptos/api.d.ts +0 -2
  29. package/lib/aptos/api.js +0 -14
  30. package/lib/aptos/api.js.map +0 -1
  31. package/lib/aptos/aptos-plugin.d.ts +0 -14
  32. package/lib/aptos/aptos-plugin.js +0 -185
  33. package/lib/aptos/aptos-plugin.js.map +0 -1
  34. package/lib/aptos/aptos-processor.d.ts +0 -75
  35. package/lib/aptos/aptos-processor.js +0 -193
  36. package/lib/aptos/aptos-processor.js.map +0 -1
  37. package/lib/aptos/context.d.ts +0 -22
  38. package/lib/aptos/context.js +0 -65
  39. package/lib/aptos/context.js.map +0 -1
  40. package/lib/aptos/index.d.ts +0 -9
  41. package/lib/aptos/index.js +0 -34
  42. package/lib/aptos/index.js.map +0 -1
  43. package/lib/aptos/models.d.ts +0 -23
  44. package/lib/aptos/models.js +0 -3
  45. package/lib/aptos/models.js.map +0 -1
  46. package/lib/aptos/network.d.ts +0 -14
  47. package/lib/aptos/network.js +0 -46
  48. package/lib/aptos/network.js.map +0 -1
  49. package/lib/aptos/runtime.d.ts +0 -2
  50. package/lib/aptos/runtime.js +0 -16
  51. package/lib/aptos/runtime.js.map +0 -1
  52. package/lib/aptos/type-registry.d.ts +0 -21
  53. package/lib/aptos/type-registry.js +0 -156
  54. package/lib/aptos/type-registry.js.map +0 -1
  55. package/lib/aptos/types.d.ts +0 -9
  56. package/lib/aptos/types.js +0 -135
  57. package/lib/aptos/types.js.map +0 -1
  58. package/lib/aptos/types.test.d.ts +0 -1
  59. package/lib/aptos/types.test.js.map +0 -1
  60. package/lib/aptos/utils.d.ts +0 -7
  61. package/lib/aptos/utils.js +0 -27
  62. package/lib/aptos/utils.js.map +0 -1
  63. package/lib/aptos-codegen/codegen.d.ts +0 -23
  64. package/lib/aptos-codegen/codegen.js +0 -364
  65. package/lib/aptos-codegen/codegen.js.map +0 -1
  66. package/lib/aptos-codegen/typegen.d.ts +0 -17
  67. package/lib/aptos-codegen/typegen.js +0 -142
  68. package/lib/aptos-codegen/typegen.js.map +0 -1
  69. package/lib/builtin/aptos/0x1.d.ts +0 -1913
  70. package/lib/builtin/aptos/0x1.js +0 -2748
  71. package/lib/builtin/aptos/0x1.js.map +0 -1
  72. package/lib/builtin/aptos/0x3.d.ts +0 -482
  73. package/lib/builtin/aptos/0x3.js +0 -526
  74. package/lib/builtin/aptos/0x3.js.map +0 -1
  75. package/lib/builtin/aptos/index.d.ts +0 -2
  76. package/lib/builtin/aptos/index.js +0 -29
  77. package/lib/builtin/aptos/index.js.map +0 -1
  78. package/lib/builtin/solana/index.d.ts +0 -2
  79. package/lib/builtin/solana/index.js +0 -19
  80. package/lib/builtin/solana/index.js.map +0 -1
  81. package/lib/builtin/solana/spl-token-processor.d.ts +0 -39
  82. package/lib/builtin/solana/spl-token-processor.js +0 -258
  83. package/lib/builtin/solana/spl-token-processor.js.map +0 -1
  84. package/lib/builtin/solana/types.d.ts +0 -427
  85. package/lib/builtin/solana/types.js +0 -203
  86. package/lib/builtin/solana/types.js.map +0 -1
  87. package/lib/builtin/solana/wormhole-processor.d.ts +0 -16
  88. package/lib/builtin/solana/wormhole-processor.js +0 -195
  89. package/lib/builtin/solana/wormhole-processor.js.map +0 -1
  90. package/lib/core/solana-context.d.ts +0 -11
  91. package/lib/core/solana-context.js +0 -34
  92. package/lib/core/solana-context.js.map +0 -1
  93. package/lib/core/solana-options.d.ts +0 -8
  94. package/lib/core/solana-options.js +0 -13
  95. package/lib/core/solana-options.js.map +0 -1
  96. package/lib/core/solana-plugin.d.ts +0 -9
  97. package/lib/core/solana-plugin.js +0 -79
  98. package/lib/core/solana-plugin.js.map +0 -1
  99. package/lib/core/solana-processor.d.ts +0 -40
  100. package/lib/core/solana-processor.js +0 -80
  101. package/lib/core/solana-processor.js.map +0 -1
  102. package/lib/solana-codegen/codegen.d.ts +0 -1
  103. package/lib/solana-codegen/codegen.js +0 -113
  104. package/lib/solana-codegen/codegen.js.map +0 -1
  105. package/lib/test-abi-code-gen.d.ts +0 -2
  106. package/lib/test-abi-code-gen.js +0 -20
  107. package/lib/test-abi-code-gen.js.map +0 -1
  108. package/src/abis/aptos/0x1.json +0 -9205
  109. package/src/abis/aptos/0x3.json +0 -1515
  110. package/src/aptos/api.ts +0 -11
  111. package/src/aptos/aptos-plugin.ts +0 -216
  112. package/src/aptos/aptos-processor.ts +0 -305
  113. package/src/aptos/context.ts +0 -74
  114. package/src/aptos/index.ts +0 -10
  115. package/src/aptos/models.ts +0 -34
  116. package/src/aptos/network.ts +0 -42
  117. package/src/aptos/runtime.ts +0 -13
  118. package/src/aptos/type-registry.ts +0 -187
  119. package/src/aptos/types.ts +0 -149
  120. package/src/aptos/utils.ts +0 -26
  121. package/src/aptos-codegen/codegen.ts +0 -428
  122. package/src/aptos-codegen/tsconfig.json +0 -9
  123. package/src/aptos-codegen/typegen.ts +0 -153
  124. package/src/builtin/aptos/0x1.ts +0 -4210
  125. package/src/builtin/aptos/0x3.ts +0 -888
  126. package/src/builtin/aptos/index.ts +0 -2
  127. package/src/builtin/solana/index.ts +0 -2
  128. package/src/builtin/solana/spl-token-processor.ts +0 -298
  129. package/src/builtin/solana/types.ts +0 -279
  130. package/src/builtin/solana/wormhole-processor.ts +0 -178
  131. package/src/core/solana-context.ts +0 -34
  132. package/src/core/solana-options.ts +0 -8
  133. package/src/core/solana-plugin.ts +0 -97
  134. package/src/core/solana-processor.ts +0 -102
  135. package/src/solana-codegen/codegen.ts +0 -116
  136. package/src/test-abi-code-gen.ts +0 -16
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;AAAA,yCAA4D;AAE5D,2CAUuB;AAIvB,wCAA0C;AAC1C,8CAA+C;AAC/C,wDAAwD;AACxD,4EAAuG;AAEvG,kDAAkD;AAClD,mCAAmC;AACnC,KAAK;AACL,uCACC;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAEY,QAAA,iBAAiB,GAAG,EAAE,CAAA;AAEtB,QAAA,cAAc,GAAG,gBAAgB,CAAA;AAE9C,MAAa,oBAAoB;IACvB,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAuB;IAE7B,MAAM,CAAY;IAElB,eAAe,CAAa;IAE7C,YAAY,MAAkB,EAAE,eAA4B;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE,OAAoB;QACjE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,uBA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AEC","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 '@sentio/protos'\n\nimport { Empty } from '@sentio/protos/lib/google/protobuf/empty'\n\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 '@sentio/base'\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\n\nexport const DEFAULT_MAX_BLOCK = 0n\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"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA4D;AAE5D,2CAUuB;AAIvB,wCAA0C;AAC1C,8CAA+C;AAC/C,wDAAwD;AACxD,4EAAuG;AAEvG,kDAAkD;AAClD,mCAAmC;AACnC,KAAK;AACL,uCAA8E;AAC9E,iDACC;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAEY,QAAA,cAAc,GAAG,gBAAgB,CAAA;AAE9C,MAAa,oBAAoB;IACvB,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAuB;IAE7B,MAAM,CAAY;IAElB,eAAe,CAAa;IAE7C,YAAY,MAAkB,EAAE,eAA4B;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE,OAAoB;QACjE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,uBAAW,CAAC,kBAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAA;SAClE;QACD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,MAAM,IAAI,uBAAW,CAAC,kBAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA;SAChE;QACD,OAAO,IAAI,CAAC,eAAe,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,eAAe,GA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essBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n} from '@sentio/protos'\n\nimport { Empty } from '@sentio/protos/lib/google/protobuf/empty'\n\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 { errorString, mergeProcessResults, PluginManager } from '@sentio/base'\nimport * as console from 'console'\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\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 for (const plugin of [\n '@sentio/sdk/lib/core/eth-plugin',\n '@sentio/sdk/lib/core/sui-plugin',\n '@sentio/sdk/lib/aptos/aptos-plugin',\n '@sentio/sdk-solana/lib/solana-plugin',\n ]) {\n try {\n require(plugin)\n } catch (e) {\n console.error('Failed to load plugin: ', plugin)\n }\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\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"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.37.0-rc.1",
4
+ "version": "1.37.0-rc.3",
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",
@@ -13,26 +13,17 @@
13
13
  "ts-start": "ts-node --files src/processor-runner.ts ./src/anyswap/src/processor.ts",
14
14
  "test": "jest",
15
15
  "test-nocache": "yarn jest --clearCache && yarn jest",
16
- "gen": "yarn compile_target && yarn gen_bultin_evm && yarn gen_bultin_others && yarn gen_test_abi",
17
- "gen_test_abi": "ts-node src/test-abi-code-gen.ts src/tests/abis src/tests/types",
16
+ "gen": "yarn compile_target && yarn gen_bultin_evm",
18
17
  "gen_bultin_evm": "typechain --target lib/target-ethers-sentio --out-dir src/builtin/internal 'src/abis/*.json'",
19
- "gen_bultin_others": "ts-node src/test-abi-code-gen.ts src/abis src/builtin",
20
18
  "docs": "typedoc --options typedoc.json"
21
19
  },
22
20
  "dependencies": {
23
21
  "@ethersproject/providers": "~5.7.0",
24
- "@project-serum/anchor": "^0.26.0",
25
- "@sentio/base": "^1.37.0-rc.1",
22
+ "@sentio/base": "^1.37.0-rc.3",
26
23
  "@sentio/cli": "^1.0.0",
27
- "@sentio/protos": "^1.37.0-rc.1",
28
- "@solana/web3.js": "^1.47.3",
24
+ "@sentio/protos": "^1.37.0-rc.3",
29
25
  "@typechain/ethers-v5": "^10.0.0",
30
- "@types/bn.js": "^5.1.0",
31
- "@types/bs58": "^4.0.1",
32
- "aptos-sdk": "npm:aptos@^1.3.17",
33
26
  "bignumber.js": "^9.1.0",
34
- "bn.js": "^5.2.1",
35
- "bs58": "^5.0.0",
36
27
  "command-line-args": "^5.2.1",
37
28
  "command-line-usage": "^6.1.3",
38
29
  "csv-parse": "^5.3.0",
@@ -51,7 +42,6 @@
51
42
  "@grpc/grpc-js": "1.7.3"
52
43
  },
53
44
  "devDependencies": {
54
- "@types/chai": "^4.3.1",
55
45
  "@types/command-line-args": "^5.2.0",
56
46
  "@types/command-line-usage": "^5.0.2",
57
47
  "@types/expect": "^24.3.0",
@@ -75,5 +65,5 @@
75
65
  "engines": {
76
66
  "node": ">=16"
77
67
  },
78
- "gitHead": "f5035604b83d4ef3b79d091a0c674b1e0546050b"
68
+ "gitHead": "3f8f1c5de90ac6876963024ee79f07cdd155c0c8"
79
69
  }
@@ -1,7 +1,4 @@
1
1
  export * as eacaggregatorproxy from './eacaggregatorproxy'
2
2
  export * as erc20 from './erc20'
3
3
  export * as erc20bytes from './erc20bytes'
4
- export * as weth9 from './weth9'
5
- export * as solana from './solana'
6
-
7
- export * as aptos from 'builtin/aptos'
4
+ export * as weth9 from './weth9'
@@ -9,7 +9,7 @@ import {
9
9
  ProcessConfigResponse,
10
10
  ProcessResult,
11
11
  } from '@sentio/protos'
12
- import { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'
12
+ import { errorString, mergeProcessResults, USER_PROCESSOR } from '@sentio/base'
13
13
 
14
14
  import { ServerError, Status } from 'nice-grpc'
15
15
  import { Block, Log } from '@ethersproject/abstract-provider'
@@ -43,7 +43,7 @@ export class EthPlugin implements Plugin {
43
43
  logConfigs: [],
44
44
  traceConfigs: [],
45
45
  startBlock: processor.config.startBlock,
46
- endBlock: DEFAULT_MAX_BLOCK,
46
+ endBlock: 0n,
47
47
  instructionConfig: undefined,
48
48
  aptosEventConfigs: [],
49
49
  aptosCallConfigs: [],
@@ -185,8 +185,7 @@ export class EthPlugin implements Plugin {
185
185
  if (request.data.ethLog) {
186
186
  log = request.data.ethLog.log as Log
187
187
  } else {
188
- const jsonString = Utf8ArrayToStr(request.data.raw)
189
- log = JSON.parse(jsonString)
188
+ throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
190
189
  }
191
190
 
192
191
  for (const handlerId of request.handlerIds) {
@@ -208,8 +207,7 @@ export class EthPlugin implements Plugin {
208
207
  if (binding.data.ethTrace?.trace) {
209
208
  trace = binding.data.ethTrace.trace as Trace
210
209
  } else {
211
- const jsonString = Utf8ArrayToStr(binding.data.raw)
212
- trace = JSON.parse(jsonString)
210
+ throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be null")
213
211
  }
214
212
 
215
213
  const promises: Promise<ProcessResult>[] = []
@@ -235,8 +233,7 @@ export class EthPlugin implements Plugin {
235
233
  if (binding.data.ethBlock?.block) {
236
234
  block = binding.data.ethBlock.block as Block
237
235
  } else {
238
- const jsonString = Utf8ArrayToStr(binding.data.raw)
239
- block = JSON.parse(jsonString)
236
+ throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
240
237
  }
241
238
 
242
239
  const promises: Promise<ProcessResult>[] = []
package/src/core/index.ts CHANGED
@@ -11,12 +11,7 @@ export { GenericProcessor } from './generic-processor'
11
11
  export { BaseProcessorTemplate } from './base-processor-template'
12
12
  export { SuiBaseProcessor, SuiBindOptions } from './sui-processor'
13
13
 
14
- export { SolanaContext } from './solana-context'
15
- export { SolanaBindOptions } from './solana-options'
16
- export { SolanaBaseProcessor } from './solana-processor'
17
-
18
14
  export type { TypedCallTrace, Trace } from './trace'
19
15
 
20
16
  export { EthPlugin } from './eth-plugin'
21
- export { SolanaPlugin } from './solana-plugin'
22
17
  export { SuiPlugin } from './sui-plugin'
@@ -1,10 +1,9 @@
1
1
  import { BigNumber } from 'ethers'
2
2
  import { BigInteger, MetricValue } from '@sentio/protos'
3
3
  import { BigDecimal } from '.'
4
- import { BN } from '@project-serum/anchor'
5
4
  import { BlockTag } from '@ethersproject/providers'
6
5
 
7
- export type Numberish = number | BigNumber | bigint | BigDecimal
6
+ export type Numberish = number | BigNumber | bigint | BigDecimal | string
8
7
 
9
8
  export function toBlockTag(a: number | bigint): BlockTag {
10
9
  if (typeof a === 'number') {
@@ -41,9 +40,9 @@ export function toMetricValue(value: Numberish): MetricValue {
41
40
  })
42
41
  }
43
42
  }
44
- if (BN.isBN(value)) {
43
+ if (typeof value === 'string') {
45
44
  return MetricValue.fromPartial({
46
- bigInteger: bnToBigInteger(value),
45
+ bigDecimal: value,
47
46
  })
48
47
  }
49
48
  if (typeof value === 'bigint' || Number.isInteger(value)) {
@@ -74,14 +73,6 @@ function bigDecimalToBigInteger(a: BigDecimal): BigInteger {
74
73
  return hexToBigInteger(a.toString(16), negative)
75
74
  }
76
75
 
77
- function bnToBigInteger(a: BN): BigInteger {
78
- const negative = a.isNeg()
79
- if (negative) {
80
- a = a.abs()
81
- }
82
- return hexToBigInteger(a.toString(16), negative)
83
- }
84
-
85
76
  function intToBigInteger(a: bigint | number): BigInteger {
86
77
  const negative = a < 0
87
78
  if (negative) {
@@ -94,12 +85,14 @@ export function toBigInteger(a: Numberish): BigInteger {
94
85
  if (a instanceof BigDecimal) {
95
86
  return bigDecimalToBigInteger(a)
96
87
  }
97
- if (a instanceof BN) {
98
- return bnToBigInteger(a)
99
- }
88
+
100
89
  if (a instanceof BigNumber) {
101
90
  return intToBigInteger(a.toBigInt())
102
91
  }
92
+ if (typeof a === 'string') {
93
+ return intToBigInteger(BigInt(a))
94
+ }
95
+
103
96
  return intToBigInteger(a)
104
97
 
105
98
  // Following code is actually very slow
@@ -1,7 +1,7 @@
1
1
  import { Plugin, PluginManager } from '@sentio/base'
2
2
  import { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos'
3
3
 
4
- import { DEFAULT_MAX_BLOCK, USER_PROCESSOR } from '../service'
4
+ import { USER_PROCESSOR } from '../service'
5
5
 
6
6
  import { ServerError, Status } from 'nice-grpc'
7
7
 
@@ -25,7 +25,7 @@ export class SuiPlugin implements Plugin {
25
25
  intervalConfigs: [],
26
26
  traceConfigs: [],
27
27
  startBlock: suiProcessor.config.startSeqNumber,
28
- endBlock: DEFAULT_MAX_BLOCK,
28
+ endBlock: 0n,
29
29
  instructionConfig: undefined,
30
30
  aptosEventConfigs: [],
31
31
  aptosCallConfigs: [],
package/src/index.ts CHANGED
@@ -8,4 +8,6 @@ export * from '@sentio/protos'
8
8
 
9
9
  export * from './core'
10
10
 
11
- export * as aptos from './aptos'
11
+ export * from './utils/chain'
12
+
13
+ // export * from './api'
package/src/service.ts CHANGED
@@ -22,13 +22,12 @@ import { ProcessorTemplateProcessorState, TemplateInstanceState } from './core/b
22
22
  // (Long.prototype as any).toBigInt = function() {
23
23
  // return BigInt(this.toString())
24
24
  // };
25
- import { PluginManager } from '@sentio/base'
25
+ import { errorString, mergeProcessResults, PluginManager } from '@sentio/base'
26
+ import * as console from 'console'
26
27
  ;(BigInt.prototype as any).toJSON = function () {
27
28
  return this.toString()
28
29
  }
29
30
 
30
- export const DEFAULT_MAX_BLOCK = 0n
31
-
32
31
  export const USER_PROCESSOR = 'user_processor'
33
32
 
34
33
  export class ProcessorServiceImpl implements ProcessorServiceImplementation {
@@ -93,16 +92,17 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
93
92
  }
94
93
 
95
94
  try {
96
- try {
97
- require('./core/eth-plugin')
98
- require('./core/sui-plugin')
99
- require('./aptos/aptos-plugin')
100
- require('./core/solana-plugin')
101
- } catch (e) {
102
- require('@sentio/sdk/lib/core/eth-plugin')
103
- require('@sentio/sdk/lib/core/sui-plugin')
104
- require('@sentio/sdk/lib/aptos/aptos-plugin')
105
- require('@sentio/sdk/lib/core/solana-plugin')
95
+ for (const plugin of [
96
+ '@sentio/sdk/lib/core/eth-plugin',
97
+ '@sentio/sdk/lib/core/sui-plugin',
98
+ '@sentio/sdk/lib/aptos/aptos-plugin',
99
+ '@sentio/sdk-solana/lib/solana-plugin',
100
+ ]) {
101
+ try {
102
+ require(plugin)
103
+ } catch (e) {
104
+ console.error('Failed to load plugin: ', plugin)
105
+ }
106
106
  }
107
107
 
108
108
  this.loader()
@@ -186,60 +186,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
186
186
  }
187
187
  }
188
188
 
189
- // https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript
190
- /* eslint-disable */
191
- export function Utf8ArrayToStr(array: Uint8Array) {
192
- let out, i, len, c
193
- let char2, char3
194
-
195
- out = ''
196
- len = array.length
197
- i = 0
198
- while (i < len) {
199
- c = array[i++]
200
- switch (c >> 4) {
201
- case 0:
202
- case 1:
203
- case 2:
204
- case 3:
205
- case 4:
206
- case 5:
207
- case 6:
208
- case 7:
209
- // 0xxxxxxx
210
- out += String.fromCharCode(c)
211
- break
212
- case 12:
213
- case 13:
214
- // 110x xxxx 10xx xxxx
215
- char2 = array[i++]
216
- out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f))
217
- break
218
- case 14:
219
- // 1110 xxxx 10xx xxxx 10xx xxxx
220
- char2 = array[i++]
221
- char3 = array[i++]
222
- out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0))
223
- break
224
- }
225
- }
226
-
227
- return out
228
- }
229
-
230
- export function mergeProcessResults(results: ProcessResult[]): ProcessResult {
231
- const res = ProcessResult.fromPartial({})
232
-
233
- for (const r of results) {
234
- res.counters = res.counters.concat(r.counters)
235
- res.gauges = res.gauges.concat(r.gauges)
236
- res.logs = res.logs.concat(r.logs)
237
- res.events = res.events.concat(r.events)
238
- res.exports = res.exports.concat(r.exports)
239
- }
240
- return res
241
- }
242
-
243
189
  function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {
244
190
  for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {
245
191
  list.forEach((e) => {
@@ -249,7 +195,3 @@ function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {
249
195
  })
250
196
  }
251
197
  }
252
-
253
- export function errorString(e: Error): string {
254
- return e.stack || e.message
255
- }
@@ -1,2 +0,0 @@
1
- import { AptosQueryClient } from '@sentio/protos/lib/chainquery/protos/chainquery';
2
- export declare function getChainQueryClient(address?: string): AptosQueryClient;
package/lib/aptos/api.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChainQueryClient = void 0;
4
- const chainquery_1 = require("@sentio/protos/lib/chainquery/protos/chainquery");
5
- const nice_grpc_1 = require("nice-grpc");
6
- function getChainQueryClient(address) {
7
- if (!address) {
8
- address = global.ENDPOINTS.chainQueryAPI;
9
- }
10
- const channel = (0, nice_grpc_1.createChannel)(address);
11
- return (0, nice_grpc_1.createClient)(chainquery_1.AptosQueryDefinition, channel);
12
- }
13
- exports.getChainQueryClient = getChainQueryClient;
14
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/aptos/api.ts"],"names":[],"mappings":";;;AAAA,gFAAwG;AACxG,yCAAuD;AAEvD,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,aAAa,CAAA;KACzC;IACD,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,OAAO,CAAC,CAAA;IAEtC,OAAO,IAAA,wBAAY,EAAC,iCAAoB,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC;AAPD,kDAOC","sourcesContent":["import { AptosQueryClient, AptosQueryDefinition } from '@sentio/protos/lib/chainquery/protos/chainquery'\nimport { createChannel, createClient } from 'nice-grpc'\n\nexport function getChainQueryClient(address?: string): AptosQueryClient {\n if (!address) {\n address = global.ENDPOINTS.chainQueryAPI\n }\n const channel = createChannel(address)\n\n return createClient(AptosQueryDefinition, channel)\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { Plugin } from '@sentio/base';
2
- import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos';
3
- export declare class AptosPlugin implements Plugin {
4
- name: string;
5
- private aptosEventHandlers;
6
- private aptosCallHandlers;
7
- private aptosResourceHandlers;
8
- configure(config: ProcessConfigResponse): void;
9
- supportedHandlers: HandlerType[];
10
- processBinding(request: DataBinding): Promise<ProcessResult>;
11
- processAptosEvent(binding: DataBinding): Promise<ProcessResult>;
12
- processAptosResource(binding: DataBinding): Promise<ProcessResult>;
13
- processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult>;
14
- }
@@ -1,185 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AptosPlugin = void 0;
4
- const base_1 = require("@sentio/base");
5
- const protos_1 = require("@sentio/protos");
6
- const service_1 = require("../service");
7
- const nice_grpc_1 = require("nice-grpc");
8
- const aptos_processor_1 = require("./aptos-processor");
9
- class AptosPlugin {
10
- name = 'AptosPlugin';
11
- aptosEventHandlers = [];
12
- aptosCallHandlers = [];
13
- aptosResourceHandlers = [];
14
- configure(config) {
15
- for (const aptosProcessor of aptos_processor_1.AptosProcessorState.INSTANCE.getValues()) {
16
- const contractConfig = {
17
- processorType: service_1.USER_PROCESSOR,
18
- contract: {
19
- name: aptosProcessor.moduleName,
20
- chainId: aptosProcessor.getChainId(),
21
- address: aptosProcessor.config.address,
22
- abi: '',
23
- },
24
- intervalConfigs: [],
25
- logConfigs: [],
26
- traceConfigs: [],
27
- startBlock: aptosProcessor.config.startVersion,
28
- endBlock: service_1.DEFAULT_MAX_BLOCK,
29
- instructionConfig: undefined,
30
- aptosEventConfigs: [],
31
- aptosCallConfigs: [],
32
- };
33
- // 1. Prepare event handlers
34
- for (const handler of aptosProcessor.eventHandlers) {
35
- const handlerId = this.aptosEventHandlers.push(handler.handler) - 1;
36
- const eventHandlerConfig = {
37
- filters: handler.filters.map((f) => {
38
- return {
39
- type: f.type,
40
- account: f.account || '',
41
- };
42
- }),
43
- handlerId,
44
- };
45
- contractConfig.aptosEventConfigs.push(eventHandlerConfig);
46
- }
47
- // 2. Prepare function handlers
48
- for (const handler of aptosProcessor.callHandlers) {
49
- const handlerId = this.aptosCallHandlers.push(handler.handler) - 1;
50
- const functionHandlerConfig = {
51
- filters: handler.filters.map((filter) => {
52
- return {
53
- function: filter.function,
54
- typeArguments: filter.typeArguments || [],
55
- withTypeArguments: filter.typeArguments ? true : false,
56
- includeFailed: filter.includeFailed || false,
57
- };
58
- }),
59
- handlerId,
60
- };
61
- contractConfig.aptosCallConfigs.push(functionHandlerConfig);
62
- }
63
- config.contractConfigs.push(contractConfig);
64
- }
65
- for (const aptosProcessor of aptos_processor_1.AptosAccountProcessorState.INSTANCE.getValues()) {
66
- const accountConfig = {
67
- address: aptosProcessor.config.address,
68
- chainId: aptosProcessor.getChainId(),
69
- startBlock: aptosProcessor.config.startVersion,
70
- aptosIntervalConfigs: [],
71
- intervalConfigs: [],
72
- logConfigs: [],
73
- };
74
- for (const handler of aptosProcessor.resourcesHandlers) {
75
- const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1;
76
- accountConfig.aptosIntervalConfigs.push({
77
- intervalConfig: {
78
- handlerId: handlerId,
79
- minutes: 0,
80
- minutesInterval: handler.timeIntervalInMinutes,
81
- slot: 0,
82
- slotInterval: handler.versionInterval,
83
- },
84
- type: handler.type || '',
85
- });
86
- }
87
- config.accountConfigs.push(accountConfig);
88
- }
89
- }
90
- supportedHandlers = [protos_1.HandlerType.APT_CALL, protos_1.HandlerType.APT_RESOURCE, protos_1.HandlerType.APT_EVENT];
91
- processBinding(request) {
92
- switch (request.handlerType) {
93
- case protos_1.HandlerType.APT_CALL:
94
- return this.processAptosFunctionCall(request);
95
- case protos_1.HandlerType.APT_EVENT:
96
- return this.processAptosEvent(request);
97
- case protos_1.HandlerType.APT_RESOURCE:
98
- return this.processAptosResource(request);
99
- // case HandlerType.INSTRUCTION:
100
- // return this.processInstruction(request)
101
- default:
102
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
103
- }
104
- }
105
- async processAptosEvent(binding) {
106
- if (!binding.data) {
107
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
108
- }
109
- const promises = [];
110
- let event;
111
- if (binding.data.aptEvent?.event) {
112
- event = binding.data.aptEvent?.event;
113
- }
114
- else {
115
- const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
116
- event = JSON.parse(jsonString);
117
- }
118
- for (const handlerId of binding.handlerIds) {
119
- // only support aptos event for now
120
- promises.push(this.aptosEventHandlers[handlerId](event).catch((e) => {
121
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing event: ' + JSON.stringify(event) + '\n' + (0, service_1.errorString)(e));
122
- }));
123
- }
124
- return (0, service_1.mergeProcessResults)(await Promise.all(promises));
125
- }
126
- async processAptosResource(binding) {
127
- if (!binding.data) {
128
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
129
- }
130
- const resource = {
131
- resources: [],
132
- version: 0n,
133
- timestamp: 0,
134
- };
135
- if (binding.data.aptResource?.resources) {
136
- if (binding.data.aptResource.timestampMicros > Number.MAX_SAFE_INTEGER) {
137
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'timestamp is too large');
138
- }
139
- resource.timestamp = Number(binding.data.aptResource.timestampMicros);
140
- resource.version = binding.data.aptResource.version;
141
- resource.resources = binding.data.aptResource.resources;
142
- }
143
- else {
144
- const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
145
- const json = JSON.parse(jsonString);
146
- if (BigInt(json.timestamp) > Number.MAX_SAFE_INTEGER) {
147
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'timestamp is too large');
148
- }
149
- resource.timestamp = parseInt(json.timestamp);
150
- resource.version = BigInt(json.version);
151
- }
152
- const promises = [];
153
- for (const handlerId of binding.handlerIds) {
154
- promises.push(this.aptosResourceHandlers[handlerId](resource).catch((e) => {
155
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing event: ' + JSON.stringify(resource) + '\n' + (0, service_1.errorString)(e));
156
- }));
157
- }
158
- return (0, service_1.mergeProcessResults)(await Promise.all(promises));
159
- }
160
- async processAptosFunctionCall(binding) {
161
- if (!binding.data) {
162
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
163
- }
164
- let call;
165
- if (binding.data.aptCall?.call) {
166
- call = binding.data.aptCall?.call;
167
- }
168
- else {
169
- const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
170
- call = JSON.parse(jsonString);
171
- }
172
- const promises = [];
173
- for (const handlerId of binding.handlerIds) {
174
- // only support aptos call for now
175
- const promise = this.aptosCallHandlers[handlerId](call).catch((e) => {
176
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\n' + (0, service_1.errorString)(e));
177
- });
178
- promises.push(promise);
179
- }
180
- return (0, service_1.mergeProcessResults)(await Promise.all(promises));
181
- }
182
- }
183
- exports.AptosPlugin = AptosPlugin;
184
- base_1.PluginManager.INSTANCE.register(new AptosPlugin());
185
- //# sourceMappingURL=aptos-plugin.js.map
@@ -1 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AAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAlMD,kCAkMC;AAED,oBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/base'\nimport {\n AccountConfig,\n AptosCallHandlerConfig,\n AptosEventHandlerConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n ProcessConfigResponse,\n ProcessResult,\n} from '@sentio/protos'\n\nimport { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { MoveResource, Transaction_UserTransaction } from 'aptos-sdk/src/generated'\nimport { AptosAccountProcessorState, AptosProcessorState, MoveResourcesWithVersionPayload } from './aptos-processor'\n\nexport class AptosPlugin implements Plugin {\n name: string = 'AptosPlugin'\n\n private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []\n private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []\n private aptosResourceHandlers: ((resourceWithVersion: MoveResourcesWithVersionPayload) => Promise<ProcessResult>)[] =\n []\n\n configure(config: ProcessConfigResponse): void {\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: aptosProcessor.config.startVersion,\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 config.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: aptosProcessor.config.startVersion,\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 config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.APT_CALL, HandlerType.APT_RESOURCE, HandlerType.APT_EVENT]\n\n 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 // 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 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 > Number.MAX_SAFE_INTEGER) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n resource.timestamp = Number(binding.data.aptResource.timestampMicros)\n resource.version = 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 (BigInt(json.timestamp) > 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 = BigInt(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\nPluginManager.INSTANCE.register(new AptosPlugin())\n"]}