@sentio/sdk 1.37.0-rc.2 → 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.
- package/lib/builtin/index.d.ts +0 -2
- package/lib/builtin/index.js +1 -3
- package/lib/builtin/index.js.map +1 -1
- package/lib/core/eth-plugin.js +12 -15
- package/lib/core/eth-plugin.js.map +1 -1
- package/lib/core/index.d.ts +0 -4
- package/lib/core/index.js +1 -9
- package/lib/core/index.js.map +1 -1
- package/lib/core/sui-plugin.js +1 -1
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -14
- package/lib/index.js.map +1 -1
- package/lib/service.d.ts +0 -4
- package/lib/service.js +40 -71
- package/lib/service.js.map +1 -1
- package/package.json +5 -16
- package/src/builtin/index.ts +1 -4
- package/src/core/eth-plugin.ts +5 -8
- package/src/core/index.ts +0 -5
- package/src/core/sui-plugin.ts +2 -2
- package/src/index.ts +3 -1
- package/src/service.ts +13 -71
- package/lib/aptos/api.d.ts +0 -2
- package/lib/aptos/api.js +0 -14
- package/lib/aptos/api.js.map +0 -1
- package/lib/aptos/aptos-plugin.d.ts +0 -14
- package/lib/aptos/aptos-plugin.js +0 -185
- package/lib/aptos/aptos-plugin.js.map +0 -1
- package/lib/aptos/aptos-processor.d.ts +0 -75
- package/lib/aptos/aptos-processor.js +0 -193
- package/lib/aptos/aptos-processor.js.map +0 -1
- package/lib/aptos/context.d.ts +0 -22
- package/lib/aptos/context.js +0 -65
- package/lib/aptos/context.js.map +0 -1
- package/lib/aptos/index.d.ts +0 -9
- package/lib/aptos/index.js +0 -34
- package/lib/aptos/index.js.map +0 -1
- package/lib/aptos/models.d.ts +0 -23
- package/lib/aptos/models.js +0 -3
- package/lib/aptos/models.js.map +0 -1
- package/lib/aptos/network.d.ts +0 -14
- package/lib/aptos/network.js +0 -46
- package/lib/aptos/network.js.map +0 -1
- package/lib/aptos/runtime.d.ts +0 -2
- package/lib/aptos/runtime.js +0 -16
- package/lib/aptos/runtime.js.map +0 -1
- package/lib/aptos/type-registry.d.ts +0 -21
- package/lib/aptos/type-registry.js +0 -156
- package/lib/aptos/type-registry.js.map +0 -1
- package/lib/aptos/types.d.ts +0 -9
- package/lib/aptos/types.js +0 -135
- package/lib/aptos/types.js.map +0 -1
- package/lib/aptos/types.test.d.ts +0 -1
- package/lib/aptos/types.test.js.map +0 -1
- package/lib/aptos/utils.d.ts +0 -7
- package/lib/aptos/utils.js +0 -27
- package/lib/aptos/utils.js.map +0 -1
- package/lib/aptos-codegen/codegen.d.ts +0 -23
- package/lib/aptos-codegen/codegen.js +0 -364
- package/lib/aptos-codegen/codegen.js.map +0 -1
- package/lib/aptos-codegen/typegen.d.ts +0 -17
- package/lib/aptos-codegen/typegen.js +0 -142
- package/lib/aptos-codegen/typegen.js.map +0 -1
- package/lib/builtin/aptos/0x1.d.ts +0 -1913
- package/lib/builtin/aptos/0x1.js +0 -2748
- package/lib/builtin/aptos/0x1.js.map +0 -1
- package/lib/builtin/aptos/0x3.d.ts +0 -482
- package/lib/builtin/aptos/0x3.js +0 -526
- package/lib/builtin/aptos/0x3.js.map +0 -1
- package/lib/builtin/aptos/index.d.ts +0 -2
- package/lib/builtin/aptos/index.js +0 -29
- package/lib/builtin/aptos/index.js.map +0 -1
- package/lib/builtin/solana/index.d.ts +0 -2
- package/lib/builtin/solana/index.js +0 -19
- package/lib/builtin/solana/index.js.map +0 -1
- package/lib/builtin/solana/spl-token-processor.d.ts +0 -39
- package/lib/builtin/solana/spl-token-processor.js +0 -258
- package/lib/builtin/solana/spl-token-processor.js.map +0 -1
- package/lib/builtin/solana/types.d.ts +0 -427
- package/lib/builtin/solana/types.js +0 -203
- package/lib/builtin/solana/types.js.map +0 -1
- package/lib/builtin/solana/wormhole-processor.d.ts +0 -12
- package/lib/builtin/solana/wormhole-processor.js +0 -268
- package/lib/builtin/solana/wormhole-processor.js.map +0 -1
- package/lib/core/solana-context.d.ts +0 -11
- package/lib/core/solana-context.js +0 -34
- package/lib/core/solana-context.js.map +0 -1
- package/lib/core/solana-options.d.ts +0 -8
- package/lib/core/solana-options.js +0 -13
- package/lib/core/solana-options.js.map +0 -1
- package/lib/core/solana-plugin.d.ts +0 -9
- package/lib/core/solana-plugin.js +0 -79
- package/lib/core/solana-plugin.js.map +0 -1
- package/lib/core/solana-processor.d.ts +0 -40
- package/lib/core/solana-processor.js +0 -80
- package/lib/core/solana-processor.js.map +0 -1
- package/lib/solana-codegen/codegen.d.ts +0 -1
- package/lib/solana-codegen/codegen.js +0 -124
- package/lib/solana-codegen/codegen.js.map +0 -1
- package/lib/test-abi-code-gen.d.ts +0 -2
- package/lib/test-abi-code-gen.js +0 -20
- package/lib/test-abi-code-gen.js.map +0 -1
- package/src/abis/aptos/0x1.json +0 -9205
- package/src/abis/aptos/0x3.json +0 -1515
- package/src/aptos/api.ts +0 -11
- package/src/aptos/aptos-plugin.ts +0 -216
- package/src/aptos/aptos-processor.ts +0 -305
- package/src/aptos/context.ts +0 -74
- package/src/aptos/index.ts +0 -10
- package/src/aptos/models.ts +0 -34
- package/src/aptos/network.ts +0 -42
- package/src/aptos/runtime.ts +0 -13
- package/src/aptos/type-registry.ts +0 -187
- package/src/aptos/types.ts +0 -149
- package/src/aptos/utils.ts +0 -26
- package/src/aptos-codegen/codegen.ts +0 -428
- package/src/aptos-codegen/tsconfig.json +0 -9
- package/src/aptos-codegen/typegen.ts +0 -153
- package/src/builtin/aptos/0x1.ts +0 -4210
- package/src/builtin/aptos/0x3.ts +0 -888
- package/src/builtin/aptos/index.ts +0 -2
- package/src/builtin/solana/index.ts +0 -2
- package/src/builtin/solana/spl-token-processor.ts +0 -298
- package/src/builtin/solana/types.ts +0 -279
- package/src/builtin/solana/wormhole-processor.ts +0 -269
- package/src/core/solana-context.ts +0 -34
- package/src/core/solana-options.ts +0 -8
- package/src/core/solana-plugin.ts +0 -97
- package/src/core/solana-processor.ts +0 -102
- package/src/solana-codegen/codegen.ts +0 -129
- package/src/test-abi-code-gen.ts +0 -16
package/lib/builtin/index.d.ts
CHANGED
package/lib/builtin/index.js
CHANGED
|
@@ -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.
|
|
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
|
package/lib/builtin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA0D;AAC1D,iDAAgC;AAChC,2DAA0C;AAC1C,iDAAgC
|
|
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'"]}
|
package/lib/core/eth-plugin.js
CHANGED
|
@@ -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
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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,MAAM,CAAC,IAAI;oBAC3B,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;oBAC3B,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO;oBACjC,GAAG,EAAE,EAAE;iBACR;gBACD,eAAe,EAAE,EAAE;gBACnB,UAAU,EAAE,EAAE;gBACd,YAAY,EAAE,EAAE;gBAChB,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU;gBACvC,QAAQ,EAAE,2BAAiB;gBAC3B,iBAAiB,EAAE,SAAS;gBAC5B,iBAAiB,EAAE,EAAE;g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,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,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,qBAAc;gBAC7B,QAAQ,EAAE;oBACR,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI;oBAC3B,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;oBAC3B,OAAO,EAAE,SAAS,CAAC,MAAM,CA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BAqOC;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"]}
|
package/lib/core/index.d.ts
CHANGED
|
@@ -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.
|
|
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
|
package/lib/core/index.js.map
CHANGED
|
@@ -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;
|
|
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"]}
|
package/lib/core/sui-plugin.js
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/core/sui-plugin.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,2CAA+G;AAE/G,wCAA2C;AAE3C,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,EAAE;gBACZ,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 { 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 *
|
|
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.
|
|
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
|
-
|
|
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":"
|
|
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.
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"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G,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QACxC,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;KAC5C;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAXD,kDAWC;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACpG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC;AAED,SAAgB,WAAW,CAAC,CAAQ;IAClC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC;AAFD,kCAEC","sourcesContent":["import { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n} from '@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,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AAC,SAAS,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,MAAM,EAAE;gBACvG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;gBACtB,OAAO,GAAG,IAAI,CAAA;aACf;YACD,MAAM;gBACJ,MAAM;gBACN,aAAa,EAAE,OAAO;aACvB,CAAA;SACF;IACH,CAAC;CACF;AA1JD,oDA0JC;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACpG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC","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 { 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.
|
|
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,27 +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
|
|
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
|
-
"@dao-xyz/borsh": "^4.0.7",
|
|
24
21
|
"@ethersproject/providers": "~5.7.0",
|
|
25
|
-
"@
|
|
26
|
-
"@sentio/base": "^1.37.0-rc.2",
|
|
22
|
+
"@sentio/base": "^1.37.0-rc.3",
|
|
27
23
|
"@sentio/cli": "^1.0.0",
|
|
28
|
-
"@sentio/protos": "^1.37.0-rc.
|
|
29
|
-
"@solana/web3.js": "^1.47.3",
|
|
24
|
+
"@sentio/protos": "^1.37.0-rc.3",
|
|
30
25
|
"@typechain/ethers-v5": "^10.0.0",
|
|
31
|
-
"@types/bn.js": "^5.1.0",
|
|
32
|
-
"@types/bs58": "^4.0.1",
|
|
33
|
-
"aptos-sdk": "npm:aptos@^1.3.17",
|
|
34
26
|
"bignumber.js": "^9.1.0",
|
|
35
|
-
"bn.js": "^5.2.1",
|
|
36
|
-
"bs58": "^5.0.0",
|
|
37
27
|
"command-line-args": "^5.2.1",
|
|
38
28
|
"command-line-usage": "^6.1.3",
|
|
39
29
|
"csv-parse": "^5.3.0",
|
|
@@ -52,7 +42,6 @@
|
|
|
52
42
|
"@grpc/grpc-js": "1.7.3"
|
|
53
43
|
},
|
|
54
44
|
"devDependencies": {
|
|
55
|
-
"@types/chai": "^4.3.1",
|
|
56
45
|
"@types/command-line-args": "^5.2.0",
|
|
57
46
|
"@types/command-line-usage": "^5.0.2",
|
|
58
47
|
"@types/expect": "^24.3.0",
|
|
@@ -76,5 +65,5 @@
|
|
|
76
65
|
"engines": {
|
|
77
66
|
"node": ">=16"
|
|
78
67
|
},
|
|
79
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "3f8f1c5de90ac6876963024ee79f07cdd155c0c8"
|
|
80
69
|
}
|