@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
@@ -2,5 +2,3 @@ export * as eacaggregatorproxy from './eacaggregatorproxy';
2
2
  export * as erc20 from './erc20';
3
3
  export * as erc20bytes from './erc20bytes';
4
4
  export * as weth9 from './weth9';
5
- export * as solana from './solana';
6
- export * as aptos from 'builtin/aptos';
@@ -23,11 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.aptos = exports.solana = exports.weth9 = exports.erc20bytes = exports.erc20 = exports.eacaggregatorproxy = void 0;
26
+ exports.weth9 = exports.erc20bytes = exports.erc20 = exports.eacaggregatorproxy = void 0;
27
27
  exports.eacaggregatorproxy = __importStar(require("./eacaggregatorproxy"));
28
28
  exports.erc20 = __importStar(require("./erc20"));
29
29
  exports.erc20bytes = __importStar(require("./erc20bytes"));
30
30
  exports.weth9 = __importStar(require("./weth9"));
31
- exports.solana = __importStar(require("./solana"));
32
- exports.aptos = __importStar(require("builtin/aptos"));
33
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA0D;AAC1D,iDAAgC;AAChC,2DAA0C;AAC1C,iDAAgC;AAChC,mDAAkC;AAElC,uDAAsC","sourcesContent":["export * as eacaggregatorproxy from './eacaggregatorproxy'\nexport * as erc20 from './erc20'\nexport * as erc20bytes from './erc20bytes'\nexport * as weth9 from './weth9'\nexport * as solana from './solana'\n\nexport * as aptos from 'builtin/aptos'"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA0D;AAC1D,iDAAgC;AAChC,2DAA0C;AAC1C,iDAAgC","sourcesContent":["export * as eacaggregatorproxy from './eacaggregatorproxy'\nexport * as erc20 from './erc20'\nexport * as erc20bytes from './erc20bytes'\nexport * as weth9 from './weth9'"]}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EthPlugin = void 0;
4
4
  const base_1 = require("@sentio/base");
5
5
  const protos_1 = require("@sentio/protos");
6
- const service_1 = require("../service");
6
+ const base_2 = require("@sentio/base");
7
7
  const nice_grpc_1 = require("nice-grpc");
8
8
  const binds_1 = require("../binds");
9
9
  const account_processor_1 = require("./account-processor");
@@ -19,7 +19,7 @@ class EthPlugin {
19
19
  const chainId = processor.getChainId();
20
20
  // this.processorsByChainId.set(chainId, processor)
21
21
  const contractConfig = {
22
- processorType: service_1.USER_PROCESSOR,
22
+ processorType: base_2.USER_PROCESSOR,
23
23
  contract: {
24
24
  name: processor.config.name,
25
25
  chainId: chainId.toString(),
@@ -30,7 +30,7 @@ class EthPlugin {
30
30
  logConfigs: [],
31
31
  traceConfigs: [],
32
32
  startBlock: processor.config.startBlock,
33
- endBlock: service_1.DEFAULT_MAX_BLOCK,
33
+ endBlock: 0n,
34
34
  instructionConfig: undefined,
35
35
  aptosEventConfigs: [],
36
36
  aptosCallConfigs: [],
@@ -160,16 +160,15 @@ class EthPlugin {
160
160
  log = request.data.ethLog.log;
161
161
  }
162
162
  else {
163
- const jsonString = (0, service_1.Utf8ArrayToStr)(request.data.raw);
164
- log = JSON.parse(jsonString);
163
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Log can't be null");
165
164
  }
166
165
  for (const handlerId of request.handlerIds) {
167
166
  const handler = this.eventHandlers[handlerId];
168
167
  promises.push(handler(log).catch((e) => {
169
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\n' + (0, service_1.errorString)(e));
168
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing log: ' + JSON.stringify(log) + '\n' + (0, base_2.errorString)(e));
170
169
  }));
171
170
  }
172
- return (0, service_1.mergeProcessResults)(await Promise.all(promises));
171
+ return (0, base_2.mergeProcessResults)(await Promise.all(promises));
173
172
  }
174
173
  async processTrace(binding) {
175
174
  if (!binding.data) {
@@ -180,16 +179,15 @@ class EthPlugin {
180
179
  trace = binding.data.ethTrace.trace;
181
180
  }
182
181
  else {
183
- const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
184
- trace = JSON.parse(jsonString);
182
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Trace can't be null");
185
183
  }
186
184
  const promises = [];
187
185
  for (const handlerId of binding.handlerIds) {
188
186
  promises.push(this.traceHandlers[handlerId](trace).catch((e) => {
189
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing trace: ' + JSON.stringify(trace) + '\n' + (0, service_1.errorString)(e));
187
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing trace: ' + JSON.stringify(trace) + '\n' + (0, base_2.errorString)(e));
190
188
  }));
191
189
  }
192
- return (0, service_1.mergeProcessResults)(await Promise.all(promises));
190
+ return (0, base_2.mergeProcessResults)(await Promise.all(promises));
193
191
  }
194
192
  async processBlock(binding) {
195
193
  if (!binding.data) {
@@ -200,16 +198,15 @@ class EthPlugin {
200
198
  block = binding.data.ethBlock.block;
201
199
  }
202
200
  else {
203
- const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
204
- block = JSON.parse(jsonString);
201
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Block can't be empty");
205
202
  }
206
203
  const promises = [];
207
204
  for (const handlerId of binding.handlerIds) {
208
205
  promises.push(this.blockHandlers[handlerId](block).catch((e) => {
209
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing block: ' + block.number + '\n' + (0, service_1.errorString)(e));
206
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing block: ' + block.number + '\n' + (0, base_2.errorString)(e));
210
207
  }));
211
208
  }
212
- return (0, service_1.mergeProcessResults)(await Promise.all(promises));
209
+ return (0, base_2.mergeProcessResults)(await Promise.all(promises));
213
210
  }
214
211
  }
215
212
  exports.EthPlugin = EthPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"eth-plugin.js","sourceRoot":"","sources":["../../src/core/eth-plugin.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,2CASuB;AACvB,wCAAgH;AAEhH,yCAA+C;AAG/C,oCAAyC;AACzC,2DAA2D;AAE3D,MAAa,SAAS;IACpB,IAAI,GAAW,WAAW,CAAA;IAElB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAExE,SAAS,CAAC,MAA6B;QACrC,KAAK,MAAM,SAAS,IAAI,sBAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YAC3D,yDAAyD;YACzD,kCAAkC;YAClC,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,CAAA;YACtC,mDAAmD;YAEnD,MAAM,cAAc,GAAmB;gBACrC,aAAa,EAAE,wBAAc;gBAC7B,QAAQ,EAAE;oBACR,IAAI,EAAE,SAAS,CAAC,MAA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,EAAE;gBAC/C,MAAM,IAAI,uBAAW,CAAC,kBAAM,CAAC,QAAQ,EAAE,0BAA0B,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,IAAA,qBAAW,EAAC,CAAC,CAAC,CAAC,CAAA;YAC3G,CAAC,CAAC,CACH,CAAA;SACF;QACD,OAAO,IAAA,6BAAmB,EAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAxOD,8BAwOC;AAED,oBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/base'\nimport {\n AccountConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessConfigResponse,\n ProcessResult,\n} from '@sentio/protos'\nimport { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'\n\nimport { ServerError, Status } from 'nice-grpc'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { Trace } from '@sentio/sdk'\nimport { ProcessorState } from '../binds'\nimport { AccountProcessorState } from './account-processor'\n\nexport class EthPlugin implements Plugin {\n name: string = 'EthPlugin'\n\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n configure(config: ProcessConfigResponse): void {\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 config.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 ? BigInt(processor.config.startBlock) : 0n,\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 config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.ETH_LOG, HandlerType.ETH_BLOCK, HandlerType.ETH_TRACE]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n // return Promise.resolve(undefined);\n switch (request.handlerType) {\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 default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\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 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 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\nPluginManager.INSTANCE.register(new EthPlugin())\n"]}
1
+ {"version":3,"file":"eth-plugin.js","sourceRoot":"","sources":["../../src/core/eth-plugin.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,2CASuB;AACvB,uCAA+E;AAE/E,yCAA+C;AAG/C,oCAAyC;AACzC,2DAA2D;AAE3D,MAAa,SAAS;IACpB,IAAI,GAAW,WAAW,CAAA;IAElB,aAAa,GAA+C,EAAE,CAAA;IAC9D,aAAa,GAAiD,EAAE,CAAA;IAChE,aAAa,GAAiD,EAAE,CAAA;IAExE,SAAS,CAAC,MAA6B;QACrC,KAAK,MAAM,SAAS,IAAI,sBAAc,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AC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC/C,MAAM,IAAI,uBAAW,CAAC,kBAAM,CAAC,QAAQ,EAAE,0BAA0B,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,IAAA,kBAAW,EAAC,CAAC,CAAC,CAAC,CAAA;YAC3G,CAAC,CAAC,CACH,CAAA;SACF;QACD,OAAO,IAAA,0BAAmB,EAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AArOD,8BAqOC;AAED,oBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/base'\nimport {\n AccountConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n LogFilter,\n LogHandlerConfig,\n ProcessConfigResponse,\n ProcessResult,\n} from '@sentio/protos'\nimport { errorString, mergeProcessResults, USER_PROCESSOR } from '@sentio/base'\n\nimport { ServerError, Status } from 'nice-grpc'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { Trace } from '@sentio/sdk'\nimport { ProcessorState } from '../binds'\nimport { AccountProcessorState } from './account-processor'\n\nexport class EthPlugin implements Plugin {\n name: string = 'EthPlugin'\n\n private eventHandlers: ((event: Log) => Promise<ProcessResult>)[] = []\n private traceHandlers: ((trace: Trace) => Promise<ProcessResult>)[] = []\n private blockHandlers: ((block: Block) => Promise<ProcessResult>)[] = []\n\n configure(config: ProcessConfigResponse): void {\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: 0n,\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 config.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 ? BigInt(processor.config.startBlock) : 0n,\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 config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.ETH_LOG, HandlerType.ETH_BLOCK, HandlerType.ETH_TRACE]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n // return Promise.resolve(undefined);\n switch (request.handlerType) {\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 default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\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 throw new ServerError(Status.INVALID_ARGUMENT, \"Log can't be null\")\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 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 throw new ServerError(Status.INVALID_ARGUMENT, \"Trace can't be null\")\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 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 throw new ServerError(Status.INVALID_ARGUMENT, \"Block can't be empty\")\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\nPluginManager.INSTANCE.register(new EthPlugin())\n"]}
@@ -8,10 +8,6 @@ export { BaseProcessor } from './base-processor';
8
8
  export { GenericProcessor } from './generic-processor';
9
9
  export { BaseProcessorTemplate } from './base-processor-template';
10
10
  export { SuiBaseProcessor, SuiBindOptions } from './sui-processor';
11
- export { SolanaContext } from './solana-context';
12
- export { SolanaBindOptions } from './solana-options';
13
- export { SolanaBaseProcessor } from './solana-processor';
14
11
  export type { TypedCallTrace, Trace } from './trace';
15
12
  export { EthPlugin } from './eth-plugin';
16
- export { SolanaPlugin } from './solana-plugin';
17
13
  export { SuiPlugin } from './sui-plugin';
package/lib/core/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SuiPlugin = exports.SolanaPlugin = exports.EthPlugin = exports.SolanaBaseProcessor = exports.SolanaBindOptions = exports.SolanaContext = exports.SuiBindOptions = exports.SuiBaseProcessor = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = exports.BindOptions = exports.toBlockTag = exports.toMetricValue = exports.toBigInteger = exports.AccountEventTracker = exports.EventTracker = exports.MetricOptions = exports.Gauge = exports.Counter = exports.GaugeBinding = exports.Meter = exports.CounterBinding = exports.BoundContractView = exports.ContractView = exports.ContractContext = exports.BigDecimal = void 0;
3
+ exports.SuiPlugin = exports.EthPlugin = exports.SuiBindOptions = exports.SuiBaseProcessor = exports.BaseProcessorTemplate = exports.GenericProcessor = exports.BaseProcessor = exports.BindOptions = exports.toBlockTag = exports.toMetricValue = exports.toBigInteger = exports.AccountEventTracker = exports.EventTracker = exports.MetricOptions = exports.Gauge = exports.Counter = exports.GaugeBinding = exports.Meter = exports.CounterBinding = exports.BoundContractView = exports.ContractView = exports.ContractContext = exports.BigDecimal = void 0;
4
4
  var big_decimal_1 = require("./big-decimal");
5
5
  Object.defineProperty(exports, "BigDecimal", { enumerable: true, get: function () { return big_decimal_1.BigDecimal; } });
6
6
  var context_1 = require("./context");
@@ -32,16 +32,8 @@ Object.defineProperty(exports, "BaseProcessorTemplate", { enumerable: true, get:
32
32
  var sui_processor_1 = require("./sui-processor");
33
33
  Object.defineProperty(exports, "SuiBaseProcessor", { enumerable: true, get: function () { return sui_processor_1.SuiBaseProcessor; } });
34
34
  Object.defineProperty(exports, "SuiBindOptions", { enumerable: true, get: function () { return sui_processor_1.SuiBindOptions; } });
35
- var solana_context_1 = require("./solana-context");
36
- Object.defineProperty(exports, "SolanaContext", { enumerable: true, get: function () { return solana_context_1.SolanaContext; } });
37
- var solana_options_1 = require("./solana-options");
38
- Object.defineProperty(exports, "SolanaBindOptions", { enumerable: true, get: function () { return solana_options_1.SolanaBindOptions; } });
39
- var solana_processor_1 = require("./solana-processor");
40
- Object.defineProperty(exports, "SolanaBaseProcessor", { enumerable: true, get: function () { return solana_processor_1.SolanaBaseProcessor; } });
41
35
  var eth_plugin_1 = require("./eth-plugin");
42
36
  Object.defineProperty(exports, "EthPlugin", { enumerable: true, get: function () { return eth_plugin_1.EthPlugin; } });
43
- var solana_plugin_1 = require("./solana-plugin");
44
- Object.defineProperty(exports, "SolanaPlugin", { enumerable: true, get: function () { return solana_plugin_1.SolanaPlugin; } });
45
37
  var sui_plugin_1 = require("./sui-plugin");
46
38
  Object.defineProperty(exports, "SuiPlugin", { enumerable: true, get: function () { return sui_plugin_1.SuiPlugin; } });
47
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,qCAA4E;AAAnE,0GAAA,eAAe,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AACzD,iCAA4F;AAAnF,uGAAA,cAAc,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC3E,iDAAmE;AAA1D,6GAAA,YAAY,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAC1C,yCAAqF;AAA5D,yGAAA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAEhE,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AAEpB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA;AACzB,qEAAiE;AAAxD,gIAAA,qBAAqB,OAAA;AAC9B,iDAAkE;AAAzD,iHAAA,gBAAgB,OAAA;AAAE,+GAAA,cAAc,OAAA;AAEzC,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,mDAAoD;AAA3C,mHAAA,iBAAiB,OAAA;AAC1B,uDAAwD;AAA/C,uHAAA,mBAAmB,OAAA;AAI5B,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,iDAA8C;AAArC,6GAAA,YAAY,OAAA;AACrB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA","sourcesContent":["export { BigDecimal } from './big-decimal'\nexport { ContractContext, ContractView, BoundContractView } from './context'\nexport { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'\nexport { EventTracker, AccountEventTracker } from './event-tracker'\nexport { type Numberish, toBigInteger, toMetricValue, toBlockTag } from './numberish'\n\nexport { BindOptions } from './bind-options'\n\nexport { BaseProcessor } from './base-processor'\nexport { GenericProcessor } from './generic-processor'\nexport { BaseProcessorTemplate } from './base-processor-template'\nexport { SuiBaseProcessor, SuiBindOptions } from './sui-processor'\n\nexport { SolanaContext } from './solana-context'\nexport { SolanaBindOptions } from './solana-options'\nexport { SolanaBaseProcessor } from './solana-processor'\n\nexport type { TypedCallTrace, Trace } from './trace'\n\nexport { EthPlugin } from './eth-plugin'\nexport { SolanaPlugin } from './solana-plugin'\nexport { SuiPlugin } from './sui-plugin'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,qCAA4E;AAAnE,0GAAA,eAAe,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AACzD,iCAA4F;AAAnF,uGAAA,cAAc,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC3E,iDAAmE;AAA1D,6GAAA,YAAY,OAAA;AAAE,oHAAA,mBAAmB,OAAA;AAC1C,yCAAqF;AAA5D,yGAAA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAEhE,+CAA4C;AAAnC,2GAAA,WAAW,OAAA;AAEpB,mDAAgD;AAAvC,+GAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,qHAAA,gBAAgB,OAAA;AACzB,qEAAiE;AAAxD,gIAAA,qBAAqB,OAAA;AAC9B,iDAAkE;AAAzD,iHAAA,gBAAgB,OAAA;AAAE,+GAAA,cAAc,OAAA;AAIzC,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAClB,2CAAwC;AAA/B,uGAAA,SAAS,OAAA","sourcesContent":["export { BigDecimal } from './big-decimal'\nexport { ContractContext, ContractView, BoundContractView } from './context'\nexport { CounterBinding, Meter, GaugeBinding, Counter, Gauge, MetricOptions } from './meter'\nexport { EventTracker, AccountEventTracker } from './event-tracker'\nexport { type Numberish, toBigInteger, toMetricValue, toBlockTag } from './numberish'\n\nexport { BindOptions } from './bind-options'\n\nexport { BaseProcessor } from './base-processor'\nexport { GenericProcessor } from './generic-processor'\nexport { BaseProcessorTemplate } from './base-processor-template'\nexport { SuiBaseProcessor, SuiBindOptions } from './sui-processor'\n\nexport type { TypedCallTrace, Trace } from './trace'\n\nexport { EthPlugin } from './eth-plugin'\nexport { SuiPlugin } from './sui-plugin'\n"]}
@@ -2,7 +2,7 @@ import { BigNumber } from 'ethers';
2
2
  import { BigInteger, MetricValue } from '@sentio/protos';
3
3
  import { BigDecimal } from '.';
4
4
  import { BlockTag } from '@ethersproject/providers';
5
- export declare type Numberish = number | BigNumber | bigint | BigDecimal;
5
+ export declare type Numberish = number | BigNumber | bigint | BigDecimal | string;
6
6
  export declare function toBlockTag(a: number | bigint): BlockTag;
7
7
  export declare function toMetricValue(value: Numberish): MetricValue;
8
8
  export declare function toBigInteger(a: Numberish): BigInteger;
@@ -4,7 +4,6 @@ exports.toBigInteger = exports.toMetricValue = exports.toBlockTag = void 0;
4
4
  const ethers_1 = require("ethers");
5
5
  const protos_1 = require("@sentio/protos");
6
6
  const _1 = require(".");
7
- const anchor_1 = require("@project-serum/anchor");
8
7
  function toBlockTag(a) {
9
8
  if (typeof a === 'number') {
10
9
  return a;
@@ -41,9 +40,9 @@ function toMetricValue(value) {
41
40
  });
42
41
  }
43
42
  }
44
- if (anchor_1.BN.isBN(value)) {
43
+ if (typeof value === 'string') {
45
44
  return protos_1.MetricValue.fromPartial({
46
- bigInteger: bnToBigInteger(value),
45
+ bigDecimal: value,
47
46
  });
48
47
  }
49
48
  if (typeof value === 'bigint' || Number.isInteger(value)) {
@@ -71,13 +70,6 @@ function bigDecimalToBigInteger(a) {
71
70
  }
72
71
  return hexToBigInteger(a.toString(16), negative);
73
72
  }
74
- function bnToBigInteger(a) {
75
- const negative = a.isNeg();
76
- if (negative) {
77
- a = a.abs();
78
- }
79
- return hexToBigInteger(a.toString(16), negative);
80
- }
81
73
  function intToBigInteger(a) {
82
74
  const negative = a < 0;
83
75
  if (negative) {
@@ -89,12 +81,12 @@ function toBigInteger(a) {
89
81
  if (a instanceof _1.BigDecimal) {
90
82
  return bigDecimalToBigInteger(a);
91
83
  }
92
- if (a instanceof anchor_1.BN) {
93
- return bnToBigInteger(a);
94
- }
95
84
  if (a instanceof ethers_1.BigNumber) {
96
85
  return intToBigInteger(a.toBigInt());
97
86
  }
87
+ if (typeof a === 'string') {
88
+ return intToBigInteger(BigInt(a));
89
+ }
98
90
  return intToBigInteger(a);
99
91
  // Following code is actually very slow
100
92
  // while (a > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"numberish.js","sourceRoot":"","sources":["../../src/core/numberish.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC,2CAAwD;AACxD,wBAA8B;AAC9B,kDAA0C;AAK1C,SAAgB,UAAU,CAAC,CAAkB;IAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACzB,OAAO,CAAC,CAAA;KACT;IACD,IAAI,CAAC,GAAG,MAAM,C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IAAI,CAAC,YAAY,aAAU,EAAE;QAC3B,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAA;KACjC;IACD,IAAI,CAAC,YAAY,WAAE,EAAE;QACnB,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;KACzB;IACD,IAAI,CAAC,YAAY,kBAAS,EAAE;QAC1B,OAAO,eAAe,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;KACrC;IACD,OAAO,eAAe,CAAC,CAAC,CAAC,CAAA;IAEzB,uCAAuC;IACvC,kBAAkB;IAClB,wBAAwB;IACxB,aAAa;IACb,0BAA0B;IAC1B,IAAI;IACJ,EAAE;IACF,WAAW;IACX,sDAAsD;IACtD,IAAI;AACN,CAAC;AAtBD,oCAsBC;AAED,SAAS,eAAe,CAAC,GAAW,EAAE,QAAiB;IACrD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;QACxB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;KAChB;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAEtC,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC;KAC7B,CAAA;AACH,CAAC","sourcesContent":["import { BigNumber } from 'ethers'\nimport { BigInteger, MetricValue } from '@sentio/protos'\nimport { BigDecimal } from '.'\nimport { BN } from '@project-serum/anchor'\nimport { BlockTag } from '@ethersproject/providers'\n\nexport type Numberish = number | BigNumber | bigint | BigDecimal\n\nexport function toBlockTag(a: number | bigint): BlockTag {\n if (typeof a === 'number') {\n return a\n }\n if (a > Number.MAX_SAFE_INTEGER) {\n return '0x' + a.toString(16)\n }\n return Number(a)\n}\n\nexport function toMetricValue(value: Numberish): MetricValue {\n if (value instanceof BigNumber) {\n return MetricValue.fromPartial({\n bigInteger: toBigInteger(value.toBigInt()),\n })\n }\n if (value instanceof BigDecimal) {\n // Carefully consider the use case here\n if (value.isInteger()) {\n return MetricValue.fromPartial({\n bigInteger: bigDecimalToBigInteger(value),\n })\n } else {\n if (value.isNaN()) {\n throw new Error('Cannot record NaN value')\n }\n if (!value.isFinite()) {\n // NaN also not finite\n throw new Error('Cannot record infinite value')\n }\n return MetricValue.fromPartial({\n bigDecimal: value.toString(), // e.g. -7.350918e-428\n })\n }\n }\n if (BN.isBN(value)) {\n return MetricValue.fromPartial({\n bigInteger: bnToBigInteger(value),\n })\n }\n if (typeof value === 'bigint' || Number.isInteger(value)) {\n return MetricValue.fromPartial({\n bigInteger: toBigInteger(value),\n })\n }\n\n if (typeof value === 'number') {\n if (Number.isNaN(value)) {\n throw new Error('Cannot record NaN value')\n }\n if (!Number.isFinite(value)) {\n throw new Error('Cannot record infinite value')\n }\n }\n\n return MetricValue.fromPartial({\n doubleValue: Number(value),\n })\n}\n\nfunction bigDecimalToBigInteger(a: BigDecimal): BigInteger {\n const negative = a.isNegative()\n if (negative) {\n a = a.abs()\n }\n return hexToBigInteger(a.toString(16), negative)\n}\n\nfunction bnToBigInteger(a: BN): BigInteger {\n const negative = a.isNeg()\n if (negative) {\n a = a.abs()\n }\n return hexToBigInteger(a.toString(16), negative)\n}\n\nfunction intToBigInteger(a: bigint | number): BigInteger {\n const negative = a < 0\n if (negative) {\n a = -a\n }\n return hexToBigInteger(a.toString(16), negative)\n}\n\nexport function toBigInteger(a: Numberish): BigInteger {\n if (a instanceof BigDecimal) {\n return bigDecimalToBigInteger(a)\n }\n if (a instanceof BN) {\n return bnToBigInteger(a)\n }\n if (a instanceof BigNumber) {\n return intToBigInteger(a.toBigInt())\n }\n return intToBigInteger(a)\n\n // Following code is actually very slow\n // while (a > 0) {\n // const d = a & 0xffn\n // a >>= 8n\n // value.push(Number(d))\n // }\n //\n // return {\n // negative, value: new Uint8Array(value.reverse()),\n // }\n}\n\nfunction hexToBigInteger(hex: string, negative: boolean): BigInteger {\n if (hex.length % 2 === 1) {\n hex = '0' + hex\n }\n const buffer = Buffer.from(hex, 'hex')\n\n return {\n negative: negative,\n data: new Uint8Array(buffer),\n }\n}\n"]}
1
+ {"version":3,"file":"numberish.js","sourceRoot":"","sources":["../../src/core/numberish.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC,2CAAwD;AACxD,wBAA8B;AAK9B,SAAgB,UAAU,CAAC,CAAkB;IAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACzB,OAAO,CAAC,CAAA;KACT;IACD,IAAI,CAAC,GAAG,MAAM,CAAC,gBAAgB,EAAE;QAC/B,OAAO,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;KAC7B;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;AAClB,CAAC;AARD,gCAQC;AAED,SAAgB,aAAa,CAAC,KAAgB;IAC5C,IAAI,KAAK,YAAY,kBAAS,EAAE;QAC9B,OAAO,oBAAW,CAAC,WAAW,CAAC;YAC7B,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SAC3C,CAAC,CAAA;KACH;IACD,IAAI,KAAK,YAAY,aAAU,EAAE;QAC/B,uCAAuC;QACvC,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO,oBAAW,CAAC,WAAW,CAAC;gBAC7B,UAAU,EAAE,sBAAsB,CAAC,KAAK,CAAC;aAC1C,CAAC,CAAA;SACH;aAAM;YACL,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE;gBACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;aAC3C;YACD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE;gBACrB,sBAAsB;gBACtB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;aAChD;YACD,OAAO,oBAAW,CAAC,WAAW,CAAC;gBAC7B,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,sBAAsB;aACrD,CAAC,CAAA;SACH;KACF;I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,SAAgB,YAAY,CAAC,CAAY;IACvC,IAAI,CAAC,YAAY,aAAU,EAAE;QAC3B,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAA;KACjC;IAED,IAAI,CAAC,YAAY,kBAAS,EAAE;QAC1B,OAAO,eAAe,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;KACrC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACzB,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;KAClC;IAED,OAAO,eAAe,CAAC,CAAC,CAAC,CAAA;IAEzB,uCAAuC;IACvC,kBAAkB;IAClB,wBAAwB;IACxB,aAAa;IACb,0BAA0B;IAC1B,IAAI;IACJ,EAAE;IACF,WAAW;IACX,sDAAsD;IACtD,IAAI;AACN,CAAC;AAxBD,oCAwBC;AAED,SAAS,eAAe,CAAC,GAAW,EAAE,QAAiB;IACrD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;QACxB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;KAChB;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAEtC,OAAO;QACL,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC;KAC7B,CAAA;AACH,CAAC","sourcesContent":["import { BigNumber } from 'ethers'\nimport { BigInteger, MetricValue } from '@sentio/protos'\nimport { BigDecimal } from '.'\nimport { BlockTag } from '@ethersproject/providers'\n\nexport type Numberish = number | BigNumber | bigint | BigDecimal | string\n\nexport function toBlockTag(a: number | bigint): BlockTag {\n if (typeof a === 'number') {\n return a\n }\n if (a > Number.MAX_SAFE_INTEGER) {\n return '0x' + a.toString(16)\n }\n return Number(a)\n}\n\nexport function toMetricValue(value: Numberish): MetricValue {\n if (value instanceof BigNumber) {\n return MetricValue.fromPartial({\n bigInteger: toBigInteger(value.toBigInt()),\n })\n }\n if (value instanceof BigDecimal) {\n // Carefully consider the use case here\n if (value.isInteger()) {\n return MetricValue.fromPartial({\n bigInteger: bigDecimalToBigInteger(value),\n })\n } else {\n if (value.isNaN()) {\n throw new Error('Cannot record NaN value')\n }\n if (!value.isFinite()) {\n // NaN also not finite\n throw new Error('Cannot record infinite value')\n }\n return MetricValue.fromPartial({\n bigDecimal: value.toString(), // e.g. -7.350918e-428\n })\n }\n }\n if (typeof value === 'string') {\n return MetricValue.fromPartial({\n bigDecimal: value,\n })\n }\n if (typeof value === 'bigint' || Number.isInteger(value)) {\n return MetricValue.fromPartial({\n bigInteger: toBigInteger(value),\n })\n }\n\n if (typeof value === 'number') {\n if (Number.isNaN(value)) {\n throw new Error('Cannot record NaN value')\n }\n if (!Number.isFinite(value)) {\n throw new Error('Cannot record infinite value')\n }\n }\n\n return MetricValue.fromPartial({\n doubleValue: Number(value),\n })\n}\n\nfunction bigDecimalToBigInteger(a: BigDecimal): BigInteger {\n const negative = a.isNegative()\n if (negative) {\n a = a.abs()\n }\n return hexToBigInteger(a.toString(16), negative)\n}\n\nfunction intToBigInteger(a: bigint | number): BigInteger {\n const negative = a < 0\n if (negative) {\n a = -a\n }\n return hexToBigInteger(a.toString(16), negative)\n}\n\nexport function toBigInteger(a: Numberish): BigInteger {\n if (a instanceof BigDecimal) {\n return bigDecimalToBigInteger(a)\n }\n\n if (a instanceof BigNumber) {\n return intToBigInteger(a.toBigInt())\n }\n if (typeof a === 'string') {\n return intToBigInteger(BigInt(a))\n }\n\n return intToBigInteger(a)\n\n // Following code is actually very slow\n // while (a > 0) {\n // const d = a & 0xffn\n // a >>= 8n\n // value.push(Number(d))\n // }\n //\n // return {\n // negative, value: new Uint8Array(value.reverse()),\n // }\n}\n\nfunction hexToBigInteger(hex: string, negative: boolean): BigInteger {\n if (hex.length % 2 === 1) {\n hex = '0' + hex\n }\n const buffer = Buffer.from(hex, 'hex')\n\n return {\n negative: negative,\n data: new Uint8Array(buffer),\n }\n}\n"]}
@@ -23,7 +23,7 @@ class SuiPlugin {
23
23
  intervalConfigs: [],
24
24
  traceConfigs: [],
25
25
  startBlock: suiProcessor.config.startSeqNumber,
26
- endBlock: service_1.DEFAULT_MAX_BLOCK,
26
+ endBlock: 0n,
27
27
  instructionConfig: undefined,
28
28
  aptosEventConfigs: [],
29
29
  aptosCallConfigs: [],
@@ -1 +1 @@
1
- {"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/core/sui-plugin.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,2CAA+G;AAE/G,wCAA8D;AAE9D,yCAA+C;AAE/C,0CAA0C;AAC1C,mDAAmD;AAEnD,MAAa,SAAS;IACpB,IAAI,GAAW,cAAc,CAAA;IAE7B,SAAS,CAAC,MAA6B;QACrC,KAAK,MAAM,YAAY,IAAI,iCAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACjE,MAAM,cAAc,GAAmB;gBACrC,aAAa,EAAE,wBAAc;gBAC7B,QAAQ,EAAE;oBACR,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,iBAAS,CAAC,UAAU;oBAC7B,OAAO,EAAE,YAAY,CAAC,OAAO;oBAC7B,GAAG,EAAE,EAAE;iBACR;gBACD,UAAU,EAAE,EAAE;gBACd,eAAe,EAAE,EAAE;gBACnB,YAAY,EAAE,EAAE;gBAChB,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,cAAc;gBAC9C,QAAQ,EAAE,2BAAiB;gBAC3B,iBAAiB,EAAE,SAAS;gBAC5B,iBAAiB,EAAE,EAAE;gBACrB,gBAAgB,EAAE,EAAE;aACrB,CAAA;YACD,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;SAC5C;IACH,CAAC;IAED,iBAAiB,GAAG,CAAC,oBAAW,CAAC,eAAe,CAAC,CAAA;IAEjD,cAAc,CAAC,OAAoB;QACjC,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,oBAAW,CAAC,eAAe,CAAC;YACjC,6CAA6C;YAC7C;gBACE,MAAM,IAAI,uBAAW,CAAC,kBAAM,CAAC,gBAAgB,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;SACrG;IACH,CAAC;CACF;AApCD,8BAoCC;AAED,oBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/base'\nimport { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos'\n\nimport { DEFAULT_MAX_BLOCK, USER_PROCESSOR } from '../service'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { CHAIN_IDS } from '../utils/chain'\nimport { SuiProcessorState } from './sui-processor'\n\nexport class SuiPlugin implements Plugin {\n name: string = 'SolanaPlugin'\n\n configure(config: ProcessConfigResponse): void {\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 config.contractConfigs.push(contractConfig)\n }\n }\n\n supportedHandlers = [HandlerType.SUI_TRANSACTION]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SUI_TRANSACTION:\n // return this.processSolInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n}\n\nPluginManager.INSTANCE.register(new SuiPlugin())\n"]}
1
+ {"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/core/sui-plugin.ts"],"names":[],"mappings":";;;AAAA,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ConfigResponse, ProcessResult } from '@sentio/protos'\n\nimport { USER_PROCESSOR } from '../service'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { CHAIN_IDS } from '../utils/chain'\nimport { SuiProcessorState } from './sui-processor'\n\nexport class SuiPlugin implements Plugin {\n name: string = 'SolanaPlugin'\n\n configure(config: ProcessConfigResponse): void {\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: 0n,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n config.contractConfigs.push(contractConfig)\n }\n }\n\n supportedHandlers = [HandlerType.SUI_TRANSACTION]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SUI_TRANSACTION:\n // return this.processSolInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n}\n\nPluginManager.INSTANCE.register(new SuiPlugin())\n"]}
package/lib/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { transformEtherError, EthersError } from './error';
3
3
  export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds';
4
4
  export * from '@sentio/protos';
5
5
  export * from './core';
6
- export * as aptos from './aptos';
6
+ export * from './utils/chain';
package/lib/index.js CHANGED
@@ -10,23 +10,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
15
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.aptos = exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.EthersError = exports.transformEtherError = exports.DummyProvider = exports.setProvider = exports.getProvider = void 0;
17
+ exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.EthersError = exports.transformEtherError = exports.DummyProvider = exports.setProvider = exports.getProvider = void 0;
30
18
  var provider_1 = require("./provider");
31
19
  Object.defineProperty(exports, "getProvider", { enumerable: true, get: function () { return provider_1.getProvider; } });
32
20
  Object.defineProperty(exports, "setProvider", { enumerable: true, get: function () { return provider_1.setProvider; } });
@@ -42,5 +30,6 @@ Object.defineProperty(exports, "addContractByABI", { enumerable: true, get: func
42
30
  // TODO maybe remove this
43
31
  __exportStar(require("@sentio/protos"), exports);
44
32
  __exportStar(require("./core"), exports);
45
- exports.aptos = __importStar(require("./aptos"));
33
+ __exportStar(require("./utils/chain"), exports);
34
+ // export * from './api'
46
35
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoE;AAA3D,uGAAA,WAAW,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,yGAAA,aAAa,OAAA;AAChD,iCAA0D;AAAjD,4GAAA,mBAAmB,OAAA;AAAE,oGAAA,WAAW,OAAA;AAEzC,iCAAwF;AAA/E,qGAAA,YAAY,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAEvE,yBAAyB;AACzB,iDAA8B;AAE9B,yCAAsB;AAEtB,iDAAgC","sourcesContent":["export { getProvider, setProvider, DummyProvider } from './provider'\nexport { transformEtherError, EthersError } from './error'\n\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds'\n\n// TODO maybe remove this\nexport * from '@sentio/protos'\n\nexport * from './core'\n\nexport * as aptos from './aptos'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAoE;AAA3D,uGAAA,WAAW,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,yGAAA,aAAa,OAAA;AAChD,iCAA0D;AAAjD,4GAAA,mBAAmB,OAAA;AAAE,oGAAA,WAAW,OAAA;AAEzC,iCAAwF;AAA/E,qGAAA,YAAY,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAEvE,yBAAyB;AACzB,iDAA8B;AAE9B,yCAAsB;AAEtB,gDAA6B;AAE7B,yBAAyB","sourcesContent":["export { getProvider, setProvider, DummyProvider } from './provider'\nexport { transformEtherError, EthersError } from './error'\n\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds'\n\n// TODO maybe remove this\nexport * from '@sentio/protos'\n\nexport * from './core'\n\nexport * from './utils/chain'\n\n// export * from './api'\n"]}
package/lib/service.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { CallContext } from 'nice-grpc';
2
2
  import { DataBinding, ProcessBindingResponse, ProcessBindingsRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessorServiceImplementation, ProcessResult, StartRequest } from '@sentio/protos';
3
3
  import { Empty } from '@sentio/protos/lib/google/protobuf/empty';
4
- export declare const DEFAULT_MAX_BLOCK = 0n;
5
4
  export declare const USER_PROCESSOR = "user_processor";
6
5
  export declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
7
6
  private started;
@@ -20,6 +19,3 @@ export declare class ProcessorServiceImpl implements ProcessorServiceImplementat
20
19
  configUpdated: boolean;
21
20
  }, void, unknown>;
22
21
  }
23
- export declare function Utf8ArrayToStr(array: Uint8Array): string;
24
- export declare function mergeProcessResults(results: ProcessResult[]): ProcessResult;
25
- export declare function errorString(e: Error): string;
package/lib/service.js CHANGED
@@ -1,6 +1,29 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.errorString = exports.mergeProcessResults = exports.Utf8ArrayToStr = exports.ProcessorServiceImpl = exports.USER_PROCESSOR = exports.DEFAULT_MAX_BLOCK = void 0;
26
+ exports.ProcessorServiceImpl = exports.USER_PROCESSOR = void 0;
4
27
  const nice_grpc_1 = require("nice-grpc");
5
28
  const protos_1 = require("@sentio/protos");
6
29
  const meter_1 = require("./core/meter");
@@ -11,10 +34,10 @@ const base_processor_template_1 = require("./core/base-processor-template");
11
34
  // return BigInt(this.toString())
12
35
  // };
13
36
  const base_1 = require("@sentio/base");
37
+ const console = __importStar(require("console"));
14
38
  BigInt.prototype.toJSON = function () {
15
39
  return this.toString();
16
40
  };
17
- exports.DEFAULT_MAX_BLOCK = 0n;
18
41
  exports.USER_PROCESSOR = 'user_processor';
19
42
  class ProcessorServiceImpl {
20
43
  started = false;
@@ -67,22 +90,23 @@ class ProcessorServiceImpl {
67
90
  return {};
68
91
  }
69
92
  try {
70
- try {
71
- require('./core/eth-plugin');
72
- require('./core/sui-plugin');
73
- require('./aptos/aptos-plugin');
74
- require('./core/solana-plugin');
75
- }
76
- catch (e) {
77
- require('@sentio/sdk/lib/core/eth-plugin');
78
- require('@sentio/sdk/lib/core/sui-plugin');
79
- require('@sentio/sdk/lib/aptos/aptos-plugin');
80
- require('@sentio/sdk/lib/core/solana-plugin');
93
+ for (const plugin of [
94
+ '@sentio/sdk/lib/core/eth-plugin',
95
+ '@sentio/sdk/lib/core/sui-plugin',
96
+ '@sentio/sdk/lib/aptos/aptos-plugin',
97
+ '@sentio/sdk-solana/lib/solana-plugin',
98
+ ]) {
99
+ try {
100
+ require(plugin);
101
+ }
102
+ catch (e) {
103
+ console.error('Failed to load plugin: ', plugin);
104
+ }
81
105
  }
82
106
  this.loader();
83
107
  }
84
108
  catch (e) {
85
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e));
109
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'Failed to load processor: ' + (0, base_1.errorString)(e));
86
110
  }
87
111
  for (const instance of request.templateInstances) {
88
112
  const template = base_processor_template_1.ProcessorTemplateProcessorState.INSTANCE.getValues()[instance.templateId];
@@ -104,7 +128,7 @@ class ProcessorServiceImpl {
104
128
  await this.configure();
105
129
  }
106
130
  catch (e) {
107
- throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'Failed to start processor : ' + errorString(e));
131
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'Failed to start processor : ' + (0, base_1.errorString)(e));
108
132
  }
109
133
  this.started = true;
110
134
  return {};
@@ -121,7 +145,7 @@ class ProcessorServiceImpl {
121
145
  throw new nice_grpc_1.ServerError(nice_grpc_1.Status.UNAVAILABLE, 'Service Not started.');
122
146
  }
123
147
  const promises = request.bindings.map((binding) => this.processBinding(binding));
124
- const result = mergeProcessResults(await Promise.all(promises));
148
+ const result = (0, base_1.mergeProcessResults)(await Promise.all(promises));
125
149
  let updated = false;
126
150
  const t = base_processor_template_1.TemplateInstanceState.INSTANCE.getValues();
127
151
  if (base_processor_template_1.TemplateInstanceState.INSTANCE.getValues().length !== this.processorConfig.templateInstances.length) {
@@ -154,57 +178,6 @@ class ProcessorServiceImpl {
154
178
  }
155
179
  }
156
180
  exports.ProcessorServiceImpl = ProcessorServiceImpl;
157
- // https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript
158
- /* eslint-disable */
159
- function Utf8ArrayToStr(array) {
160
- let out, i, len, c;
161
- let char2, char3;
162
- out = '';
163
- len = array.length;
164
- i = 0;
165
- while (i < len) {
166
- c = array[i++];
167
- switch (c >> 4) {
168
- case 0:
169
- case 1:
170
- case 2:
171
- case 3:
172
- case 4:
173
- case 5:
174
- case 6:
175
- case 7:
176
- // 0xxxxxxx
177
- out += String.fromCharCode(c);
178
- break;
179
- case 12:
180
- case 13:
181
- // 110x xxxx 10xx xxxx
182
- char2 = array[i++];
183
- out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
184
- break;
185
- case 14:
186
- // 1110 xxxx 10xx xxxx 10xx xxxx
187
- char2 = array[i++];
188
- char3 = array[i++];
189
- out += String.fromCharCode(((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0));
190
- break;
191
- }
192
- }
193
- return out;
194
- }
195
- exports.Utf8ArrayToStr = Utf8ArrayToStr;
196
- function mergeProcessResults(results) {
197
- const res = protos_1.ProcessResult.fromPartial({});
198
- for (const r of results) {
199
- res.counters = res.counters.concat(r.counters);
200
- res.gauges = res.gauges.concat(r.gauges);
201
- res.logs = res.logs.concat(r.logs);
202
- res.events = res.events.concat(r.events);
203
- res.exports = res.exports.concat(r.exports);
204
- }
205
- return res;
206
- }
207
- exports.mergeProcessResults = mergeProcessResults;
208
181
  function recordRuntimeInfo(results, handlerType) {
209
182
  for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {
210
183
  list.forEach((e) => {
@@ -214,8 +187,4 @@ function recordRuntimeInfo(results, handlerType) {
214
187
  });
215
188
  }
216
189
  }
217
- function errorString(e) {
218
- return e.stack || e.message;
219
- }
220
- exports.errorString = errorString;
221
190
  //# sourceMappingURL=service.js.map