@sentio/sdk 1.36.4 → 1.37.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/api.d.ts +1 -1
- package/lib/aptos/api.js +1 -1
- package/lib/aptos/api.js.map +1 -1
- package/lib/aptos/aptos-plugin.d.ts +2 -2
- package/lib/aptos/aptos-plugin.js +14 -19
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +2 -2
- package/lib/aptos/aptos-processor.js +3 -3
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/context.d.ts +1 -1
- package/lib/aptos/context.js +2 -6
- package/lib/aptos/context.js.map +1 -1
- package/lib/binds.d.ts +1 -1
- package/lib/binds.js +2 -2
- package/lib/binds.js.map +1 -1
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +18 -18
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
- package/lib/builtin/internal/erc1155_processor.js +5 -5
- package/lib/builtin/internal/erc1155_processor.js.map +1 -1
- package/lib/builtin/internal/erc20_processor.js +8 -8
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.js +6 -6
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/erc721_processor.js +9 -9
- package/lib/builtin/internal/erc721_processor.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.js +6 -6
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/core/account-processor.d.ts +1 -1
- package/lib/core/account-processor.js +2 -2
- package/lib/core/account-processor.js.map +1 -1
- package/lib/core/base-context.d.ts +1 -1
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/base-processor-template.d.ts +2 -2
- package/lib/core/base-processor-template.js +7 -21
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/base-processor.d.ts +1 -1
- package/lib/core/base-processor.js +6 -20
- package/lib/core/base-processor.js.map +1 -1
- package/lib/core/bind-options.d.ts +5 -6
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +4 -5
- package/lib/core/context.js +6 -10
- package/lib/core/context.js.map +1 -1
- package/lib/core/eth-plugin.d.ts +2 -2
- package/lib/core/eth-plugin.js +8 -12
- package/lib/core/eth-plugin.js.map +1 -1
- package/lib/core/event-tracker.d.ts +1 -1
- package/lib/core/event-tracker.js +2 -2
- package/lib/core/event-tracker.js.map +1 -1
- package/lib/core/exporter.d.ts +1 -1
- package/lib/core/exporter.js +2 -2
- package/lib/core/exporter.js.map +1 -1
- package/lib/core/generic-processor.test.js.map +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.js +2 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/logger.d.ts +1 -1
- package/lib/core/logger.js +5 -5
- package/lib/core/logger.js.map +1 -1
- package/lib/core/meter.d.ts +2 -2
- package/lib/core/meter.js +10 -10
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.d.ts +3 -3
- package/lib/core/numberish.js +18 -12
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/numberish.test.js.map +1 -1
- package/lib/core/solana-context.d.ts +2 -3
- package/lib/core/solana-context.js.map +1 -1
- package/lib/core/solana-options.d.ts +2 -3
- package/lib/core/solana-options.js.map +1 -1
- package/lib/core/solana-plugin.d.ts +2 -2
- package/lib/core/solana-plugin.js +6 -6
- package/lib/core/solana-plugin.js.map +1 -1
- package/lib/core/solana-processor.d.ts +7 -8
- package/lib/core/solana-processor.js +5 -15
- package/lib/core/solana-processor.js.map +1 -1
- package/lib/core/sui-plugin.d.ts +2 -2
- package/lib/core/sui-plugin.js +5 -5
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/core/sui-processor.d.ts +8 -9
- package/lib/core/sui-processor.js +5 -15
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +3 -5
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +4 -4
- package/lib/processor-runner.js.map +1 -1
- package/lib/service.d.ts +3 -4
- package/lib/service.js +7 -11
- package/lib/service.js.map +1 -1
- package/lib/target-ethers-sentio/file.js +1 -0
- package/lib/target-ethers-sentio/file.js.map +1 -1
- package/lib/target-ethers-sentio/view-function.js +1 -1
- package/lib/testing/metric-utils.d.ts +1 -1
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +3 -3
- package/lib/testing/test-processor-server.js +10 -22
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/conversion.d.ts +1 -1
- package/lib/utils/conversion.js.map +1 -1
- package/lib/utils/dex-price.test.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/lib/utils/price.d.ts +10 -10
- package/lib/utils/price.js +1 -1
- package/lib/utils/price.js.map +1 -1
- package/package.json +4 -2
- package/src/aptos/api.ts +1 -1
- package/src/aptos/aptos-plugin.ts +10 -11
- package/src/aptos/aptos-processor.ts +2 -2
- package/src/aptos/context.ts +3 -4
- package/src/binds.ts +1 -1
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +19 -18
- package/src/builtin/internal/erc1155_processor.ts +6 -5
- package/src/builtin/internal/erc20_processor.ts +9 -8
- package/src/builtin/internal/erc20bytes_processor.ts +7 -6
- package/src/builtin/internal/erc721_processor.ts +10 -9
- package/src/builtin/internal/weth9_processor.ts +7 -6
- package/src/core/account-processor.ts +1 -1
- package/src/core/base-context.ts +1 -1
- package/src/core/base-processor-template.ts +6 -15
- package/src/core/base-processor.ts +4 -13
- package/src/core/bind-options.ts +5 -6
- package/src/core/context.ts +10 -11
- package/src/core/eth-plugin.ts +3 -4
- package/src/core/event-tracker.ts +2 -2
- package/src/core/exporter.ts +1 -1
- package/src/core/index.ts +1 -1
- package/src/core/logger.ts +1 -1
- package/src/core/meter.ts +2 -2
- package/src/core/numberish.ts +12 -6
- package/src/core/solana-context.ts +2 -3
- package/src/core/solana-options.ts +2 -4
- package/src/core/solana-plugin.ts +3 -3
- package/src/core/solana-processor.ts +10 -17
- package/src/core/sui-plugin.ts +3 -8
- package/src/core/sui-processor.ts +11 -18
- package/src/index.ts +3 -5
- package/src/processor-runner.ts +3 -3
- package/src/service.ts +5 -5
- package/src/target-ethers-sentio/file.ts +1 -0
- package/src/target-ethers-sentio/view-function.ts +1 -1
- package/src/testing/metric-utils.ts +1 -1
- package/src/testing/test-processor-server.ts +6 -16
- package/src/types/global.d.ts +2 -2
- package/src/utils/conversion.ts +1 -1
- package/src/utils/price.ts +1 -1
- package/lib/gen/builtin.d.ts +0 -6
- package/lib/gen/builtin.js +0 -3
- package/lib/gen/builtin.js.map +0 -1
- package/lib/gen/chainquery/protos/chainquery.d.ts +0 -400
- package/lib/gen/chainquery/protos/chainquery.js +0 -972
- package/lib/gen/chainquery/protos/chainquery.js.map +0 -1
- package/lib/gen/google/protobuf/empty.d.ts +0 -16
- package/lib/gen/google/protobuf/empty.js +0 -47
- package/lib/gen/google/protobuf/empty.js.map +0 -1
- package/lib/gen/google/protobuf/struct.d.ts +0 -73
- package/lib/gen/google/protobuf/struct.js +0 -371
- package/lib/gen/google/protobuf/struct.js.map +0 -1
- package/lib/gen/google/protobuf/timestamp.d.ts +0 -18
- package/lib/gen/google/protobuf/timestamp.js +0 -71
- package/lib/gen/google/protobuf/timestamp.js.map +0 -1
- package/lib/gen/index.d.ts +0 -2
- package/lib/gen/index.js +0 -19
- package/lib/gen/index.js.map +0 -1
- package/lib/gen/processor/protos/processor.d.ts +0 -826
- package/lib/gen/processor/protos/processor.js +0 -3988
- package/lib/gen/processor/protos/processor.js.map +0 -1
- package/lib/gen/service/price/protos/price.d.ts +0 -85
- package/lib/gen/service/price/protos/price.js +0 -269
- package/lib/gen/service/price/protos/price.js.map +0 -1
- package/lib/plugin.d.ts +0 -15
- package/lib/plugin.js +0 -32
- package/lib/plugin.js.map +0 -1
- package/lib/state/processor-state.d.ts +0 -3
- package/lib/state/processor-state.js +0 -8
- package/lib/state/processor-state.js.map +0 -1
- package/lib/state/state-storage.d.ts +0 -17
- package/lib/state/state-storage.js +0 -60
- package/lib/state/state-storage.js.map +0 -1
- package/lib/state/state-storage.test.d.ts +0 -1
- package/lib/state/state-storage.test.js.map +0 -1
- package/src/gen/builtin.ts +0 -22
- package/src/gen/chainquery/protos/chainquery.ts +0 -1212
- package/src/gen/google/protobuf/empty.ts +0 -58
- package/src/gen/google/protobuf/struct.ts +0 -422
- package/src/gen/google/protobuf/timestamp.ts +0 -85
- package/src/gen/index.ts +0 -3
- package/src/gen/processor/protos/processor.ts +0 -4619
- package/src/gen/service/price/protos/price.ts +0 -329
- package/src/plugin.ts +0 -41
- package/src/state/processor-state.ts +0 -3
- package/src/state/state-storage.ts +0 -65
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import Long from 'long';
|
|
2
1
|
export declare class SolanaBindOptions {
|
|
3
2
|
address: string;
|
|
4
3
|
network?: string;
|
|
5
4
|
name?: string;
|
|
6
|
-
startBlock?:
|
|
7
|
-
endBlock?:
|
|
5
|
+
startBlock?: bigint | number;
|
|
6
|
+
endBlock?: bigint | number;
|
|
8
7
|
processInnerInstruction?: boolean;
|
|
9
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana-options.js","sourceRoot":"","sources":["../../src/core/solana-options.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"solana-options.js","sourceRoot":"","sources":["../../src/core/solana-options.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;IAC5B,OAAO,CAAQ;IACf,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,UAAU,CAAkB;IAC5B,QAAQ,CAAkB;IAC1B,uBAAuB,CAAU;CAClC;AAPD,8CAOC","sourcesContent":["export class SolanaBindOptions {\n address: string\n network?: string\n name?: string\n startBlock?: bigint | number\n endBlock?: bigint | number\n processInnerInstruction?: boolean\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
2
|
-
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '
|
|
1
|
+
import { Plugin } from '@sentio/base';
|
|
2
|
+
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos';
|
|
3
3
|
export declare class SolanaPlugin implements Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
configure(config: ProcessConfigResponse): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SolanaPlugin = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const base_1 = require("@sentio/base");
|
|
5
|
+
const protos_1 = require("@sentio/protos");
|
|
6
6
|
const service_1 = require("../service");
|
|
7
7
|
const nice_grpc_1 = require("nice-grpc");
|
|
8
8
|
const solana_processor_1 = require("./solana-processor");
|
|
@@ -35,10 +35,10 @@ class SolanaPlugin {
|
|
|
35
35
|
config.contractConfigs.push(contractConfig);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
supportedHandlers = [
|
|
38
|
+
supportedHandlers = [protos_1.HandlerType.SOL_INSTRUCTION];
|
|
39
39
|
processBinding(request) {
|
|
40
40
|
switch (request.handlerType) {
|
|
41
|
-
case
|
|
41
|
+
case protos_1.HandlerType.SOL_INSTRUCTION:
|
|
42
42
|
return this.processSolInstruction(request);
|
|
43
43
|
default:
|
|
44
44
|
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
|
|
@@ -48,7 +48,7 @@ class SolanaPlugin {
|
|
|
48
48
|
if (!request.data) {
|
|
49
49
|
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'instruction data cannot be empty');
|
|
50
50
|
}
|
|
51
|
-
const instruction = request.data.solInstruction ||
|
|
51
|
+
const instruction = request.data.solInstruction || protos_1.Data_SolInstruction.decode(request.data.raw); // JSON.parse(jsonString)
|
|
52
52
|
const promises = [];
|
|
53
53
|
// Only have instruction handlers for solana processors
|
|
54
54
|
for (const processor of solana_processor_1.SolanaProcessorState.INSTANCE.getValues()) {
|
|
@@ -75,5 +75,5 @@ class SolanaPlugin {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
exports.SolanaPlugin = SolanaPlugin;
|
|
78
|
-
|
|
78
|
+
base_1.PluginManager.INSTANCE.register(new SolanaPlugin());
|
|
79
79
|
//# sourceMappingURL=solana-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana-plugin.js","sourceRoot":"","sources":["../../src/core/solana-plugin.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"solana-plugin.js","sourceRoot":"","sources":["../../src/core/solana-plugin.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AACpD,2CAOuB;AACvB,wCAAmF;AAEnF,yCAA+C;AAE/C,yDAAyD;AAGzD,MAAa,YAAY;IACvB,IAAI,GAAW,cAAc,CAAA;IAE7B,SAAS,CAAC,MAA6B;QACrC,sCAAsC;QACtC,KAAK,MAAM,eAAe,IAAI,uCAAoB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACvE,MAAM,cAAc,GAAmB;gBACrC,aAAa,EAAE,wBAAc;gBAC7B,QAAQ,EAAE;oBACR,IAAI,EAAE,eAAe,CAAC,YAAY;oBAClC,OAAO,EAAE,eAAe,CAAC,OAAO;oBAChC,OAAO,EAAE,eAAe,CAAC,OAAO;oBAChC,GAAG,EAAE,EAAE;iBACR;gBACD,UAAU,EAAE,EAAE;gBACd,YAAY,EAAE,EAAE;gBAChB,eAAe,EAAE,EAAE;gBACnB,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,SAAS;gBAC5C,QAAQ,EAAE,2BAAiB;gBAC3B,iBAAiB,EAAE;oBACjB,gBAAgB,EAAE,eAAe,CAAC,uBAAuB;oBACzD,iBAAiB,EAAE,eAAe,CAAC,qBAAqB,K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AI,WAAW,CAAC,eAAe,EAAE;oBACtC,iBAAiB,GAAG,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;iBAChF;gBACD,IAAI,iBAAiB,IAAI,IAAI,EAAE;oBAC7B,SAAQ;iBACT;gBACD,MAAM,UAAU,GAAG,SAAS,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;gBACrE,IAAI,UAAU,IAAI,IAAI,EAAE;oBACtB,SAAQ;iBACT;gBACD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAC3C,iBAAiB,EACjB,WAAW,CAAC,QAAQ,EACpB,UAAU,EACV,WAAW,CAAC,IAAI,CACjB,CAAA;gBAED,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;aACpC;SACF;QACD,OAAO,IAAA,6BAAmB,EAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AA9ED,oCA8EC;AAED,oBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '@sentio/base'\nimport {\n ContractConfig,\n Data_SolInstruction,\n DataBinding,\n HandlerType,\n ProcessConfigResponse,\n ProcessResult,\n} from '@sentio/protos'\nimport { DEFAULT_MAX_BLOCK, mergeProcessResults, USER_PROCESSOR } from '../service'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { SolanaProcessorState } from './solana-processor'\nimport { Instruction as SolInstruction } from '@project-serum/anchor/dist/cjs/coder/borsh/instruction'\n\nexport class SolanaPlugin implements Plugin {\n name: string = 'SolanaPlugin'\n\n configure(config: ProcessConfigResponse): void {\n // Part 2, prepare solana constractors\n for (const solanaProcessor of SolanaProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: solanaProcessor.contractName,\n chainId: solanaProcessor.network,\n address: solanaProcessor.address,\n abi: '',\n },\n logConfigs: [],\n traceConfigs: [],\n intervalConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n config.contractConfigs.push(contractConfig)\n }\n }\n\n supportedHandlers = [HandlerType.SOL_INSTRUCTION]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SOL_INSTRUCTION:\n return this.processSolInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processSolInstruction(request: DataBinding): Promise<ProcessResult> {\n if (!request.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')\n }\n\n const instruction = request.data.solInstruction || Data_SolInstruction.decode(request.data.raw) // JSON.parse(jsonString)\n const promises: Promise<ProcessResult>[] = []\n\n // Only have instruction handlers for solana processors\n for (const processor of SolanaProcessorState.INSTANCE.getValues()) {\n if (processor.address === instruction.programAccountId) {\n let parsedInstruction: SolInstruction | null = null\n if (instruction.parsed) {\n parsedInstruction = processor.getParsedInstruction(instruction.parsed as { type: string; info: any })\n } else if (instruction.instructionData) {\n parsedInstruction = processor.getParsedInstruction(instruction.instructionData)\n }\n if (parsedInstruction == null) {\n continue\n }\n const insHandler = processor.getInstructionHandler(parsedInstruction)\n if (insHandler == null) {\n continue\n }\n const res = await processor.handleInstruction(\n parsedInstruction,\n instruction.accounts,\n insHandler,\n instruction.slot\n )\n\n promises.push(Promise.resolve(res))\n }\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n}\n\nPluginManager.INSTANCE.register(new SolanaPlugin())\n"]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { ProcessResult } from '
|
|
1
|
+
import { ProcessResult } from '@sentio/protos';
|
|
2
2
|
import { SolanaContext } from './solana-context';
|
|
3
|
-
import Long from 'long';
|
|
4
3
|
import { Instruction } from '@project-serum/anchor';
|
|
5
4
|
import { SolanaBindOptions } from './solana-options';
|
|
6
|
-
import { ListStateStorage } from '
|
|
5
|
+
import { ListStateStorage } from '@sentio/base';
|
|
7
6
|
declare type IndexConfigure = {
|
|
8
|
-
startSlot:
|
|
9
|
-
endSlot?:
|
|
7
|
+
startSlot: bigint;
|
|
8
|
+
endSlot?: bigint;
|
|
10
9
|
};
|
|
11
10
|
export declare type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void;
|
|
12
11
|
export declare class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {
|
|
@@ -33,9 +32,9 @@ export declare class SolanaBaseProcessor {
|
|
|
33
32
|
info: any;
|
|
34
33
|
}): Instruction | null;
|
|
35
34
|
getInstructionHandler(parsedInstruction: Instruction): SolanaInstructionHandler | undefined;
|
|
36
|
-
handleInstruction(parsedInstruction: Instruction, accounts: string[], handler: SolanaInstructionHandler, slot:
|
|
35
|
+
handleInstruction(parsedInstruction: Instruction, accounts: string[], handler: SolanaInstructionHandler, slot: bigint): ProcessResult;
|
|
37
36
|
isBind(): boolean;
|
|
38
|
-
startSlot(startSlot:
|
|
39
|
-
endBlock(endBlock:
|
|
37
|
+
startSlot(startSlot: bigint | number): this;
|
|
38
|
+
endBlock(endBlock: bigint | number): this;
|
|
40
39
|
}
|
|
41
40
|
export {};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.SolanaBaseProcessor = exports.SolanaProcessorState = void 0;
|
|
7
4
|
const solana_context_1 = require("./solana-context");
|
|
8
|
-
const
|
|
9
|
-
const state_storage_1 = require("../state/state-storage");
|
|
5
|
+
const base_1 = require("@sentio/base");
|
|
10
6
|
const chain_1 = require("../utils/chain");
|
|
11
|
-
class SolanaProcessorState extends
|
|
7
|
+
class SolanaProcessorState extends base_1.ListStateStorage {
|
|
12
8
|
static INSTANCE = new SolanaProcessorState();
|
|
13
9
|
}
|
|
14
10
|
exports.SolanaProcessorState = SolanaProcessorState;
|
|
@@ -19,7 +15,7 @@ class SolanaBaseProcessor {
|
|
|
19
15
|
contractName;
|
|
20
16
|
network;
|
|
21
17
|
processInnerInstruction;
|
|
22
|
-
config = { startSlot:
|
|
18
|
+
config = { startSlot: 0n };
|
|
23
19
|
decodeInstruction;
|
|
24
20
|
fromParsedInstruction;
|
|
25
21
|
constructor(options) {
|
|
@@ -72,17 +68,11 @@ class SolanaBaseProcessor {
|
|
|
72
68
|
return this.address !== null;
|
|
73
69
|
}
|
|
74
70
|
startSlot(startSlot) {
|
|
75
|
-
|
|
76
|
-
startSlot = long_1.default.fromNumber(startSlot);
|
|
77
|
-
}
|
|
78
|
-
this.config.startSlot = startSlot;
|
|
71
|
+
this.config.startSlot = BigInt(startSlot);
|
|
79
72
|
return this;
|
|
80
73
|
}
|
|
81
74
|
endBlock(endBlock) {
|
|
82
|
-
|
|
83
|
-
endBlock = long_1.default.fromNumber(endBlock);
|
|
84
|
-
}
|
|
85
|
-
this.config.endSlot = endBlock;
|
|
75
|
+
this.config.endSlot = BigInt(endBlock);
|
|
86
76
|
return this;
|
|
87
77
|
}
|
|
88
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/core/solana-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/core/solana-processor.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAGhD,uCAA+C;AAC/C,0CAA0C;AA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AAC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;QACtC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAnFD,kDAmFC","sourcesContent":["import { ProcessResult } from '@sentio/protos'\nimport { SolanaContext } from './solana-context'\nimport { Instruction } from '@project-serum/anchor'\nimport { SolanaBindOptions } from './solana-options'\nimport { ListStateStorage } from '@sentio/base'\nimport { CHAIN_IDS } from '../utils/chain'\n\ntype IndexConfigure = {\n startSlot: bigint\n endSlot?: bigint\n}\n\nexport type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void\n\nexport class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {\n static INSTANCE: SolanaProcessorState = new SolanaProcessorState()\n}\n\nexport class SolanaBaseProcessor {\n public instructionHandlerMap: Map<string, SolanaInstructionHandler> = new Map()\n address: string\n endpoint: string\n contractName: string\n network: string\n processInnerInstruction: boolean\n config: IndexConfigure = { startSlot: 0n }\n decodeInstruction: (rawInstruction: string) => Instruction | null\n fromParsedInstruction: (instruction: { type: string; info: any }) => Instruction | null\n\n constructor(options: SolanaBindOptions) {\n if (options) {\n this.bind(options)\n }\n SolanaProcessorState.INSTANCE.addValue(this)\n }\n\n bind(options: SolanaBindOptions) {\n this.address = options.address\n this.contractName = options.name || ''\n this.processInnerInstruction = options.processInnerInstruction || false\n this.network = options.network || CHAIN_IDS.SOLANA_MAINNET\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n this.endpoint = options.network || 'https://api.mainnet-beta.solana.com'\n }\n\n public onInstruction(instructionName: string, handler: SolanaInstructionHandler) {\n if (!this.isBind()) {\n throw new Error(\"Processor doesn't bind to an address\")\n }\n\n this.instructionHandlerMap.set(instructionName, handler)\n\n return this\n }\n\n public getParsedInstruction(ins: string | { type: string; info: any }): Instruction | null {\n if (ins) {\n if ((ins as { type: string; info: any }).info) {\n return this.fromParsedInstruction ? this.fromParsedInstruction(ins as { type: string; info: any }) : null\n }\n if (this.decodeInstruction != null) {\n return this.decodeInstruction(ins as string)\n }\n }\n return null\n }\n\n public getInstructionHandler(parsedInstruction: Instruction): SolanaInstructionHandler | undefined {\n return this.instructionHandlerMap.get(parsedInstruction.name)\n }\n\n // TODO this should be a async function\n public handleInstruction(\n parsedInstruction: Instruction,\n accounts: string[],\n handler: SolanaInstructionHandler,\n slot: bigint\n ): ProcessResult {\n const ctx = new SolanaContext(this.contractName, this.network, this.address, slot)\n handler(parsedInstruction, ctx, accounts)\n return ctx.getProcessResult()\n }\n\n public isBind() {\n return this.address !== null\n }\n\n public startSlot(startSlot: bigint | number) {\n this.config.startSlot = BigInt(startSlot)\n return this\n }\n\n public endBlock(endBlock: bigint | number) {\n this.config.endSlot = BigInt(endBlock)\n return this\n }\n}\n"]}
|
package/lib/core/sui-plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
2
|
-
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '
|
|
1
|
+
import { Plugin } from '@sentio/base';
|
|
2
|
+
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos';
|
|
3
3
|
export declare class SuiPlugin implements Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
configure(config: ProcessConfigResponse): void;
|
package/lib/core/sui-plugin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuiPlugin = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const base_1 = require("@sentio/base");
|
|
5
|
+
const protos_1 = require("@sentio/protos");
|
|
6
6
|
const service_1 = require("../service");
|
|
7
7
|
const nice_grpc_1 = require("nice-grpc");
|
|
8
8
|
const chain_1 = require("../utils/chain");
|
|
@@ -31,10 +31,10 @@ class SuiPlugin {
|
|
|
31
31
|
config.contractConfigs.push(contractConfig);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
supportedHandlers = [
|
|
34
|
+
supportedHandlers = [protos_1.HandlerType.SUI_TRANSACTION];
|
|
35
35
|
processBinding(request) {
|
|
36
36
|
switch (request.handlerType) {
|
|
37
|
-
case
|
|
37
|
+
case protos_1.HandlerType.SUI_TRANSACTION:
|
|
38
38
|
// return this.processSolInstruction(request)
|
|
39
39
|
default:
|
|
40
40
|
throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
|
|
@@ -42,5 +42,5 @@ class SuiPlugin {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.SuiPlugin = SuiPlugin;
|
|
45
|
-
|
|
45
|
+
base_1.PluginManager.INSTANCE.register(new SuiPlugin());
|
|
46
46
|
//# sourceMappingURL=sui-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/core/sui-plugin.ts"],"names":[],"mappings":";;;AAAA,
|
|
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,14 +1,13 @@
|
|
|
1
1
|
import { SuiContext } from './context';
|
|
2
|
-
import { ProcessResult } from '
|
|
3
|
-
import
|
|
4
|
-
import { ListStateStorage } from '../state/state-storage';
|
|
2
|
+
import { ProcessResult } from '@sentio/protos';
|
|
3
|
+
import { ListStateStorage } from '@sentio/base';
|
|
5
4
|
declare type IndexConfigure = {
|
|
6
|
-
startSeqNumber:
|
|
7
|
-
endSeqNumber?:
|
|
5
|
+
startSeqNumber: bigint;
|
|
6
|
+
endSeqNumber?: bigint;
|
|
8
7
|
};
|
|
9
8
|
export declare class SuiBindOptions {
|
|
10
9
|
address: string;
|
|
11
|
-
startBlock?:
|
|
10
|
+
startBlock?: bigint | number;
|
|
12
11
|
}
|
|
13
12
|
export declare class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {
|
|
14
13
|
static INSTANCE: SuiProcessorState;
|
|
@@ -19,8 +18,8 @@ export declare class SuiBaseProcessor {
|
|
|
19
18
|
config: IndexConfigure;
|
|
20
19
|
constructor(name: string, options: SuiBindOptions);
|
|
21
20
|
onTransaction(handler: (transaction: any, ctx: SuiContext) => void): this;
|
|
22
|
-
handleTransaction(txn: any, slot:
|
|
23
|
-
startSlot(startSlot:
|
|
24
|
-
endBlock(endBlock:
|
|
21
|
+
handleTransaction(txn: any, slot: bigint): ProcessResult | null;
|
|
22
|
+
startSlot(startSlot: bigint | number): this;
|
|
23
|
+
endBlock(endBlock: bigint | number): this;
|
|
25
24
|
}
|
|
26
25
|
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.SuiBaseProcessor = exports.SuiProcessorState = exports.SuiBindOptions = void 0;
|
|
7
4
|
const context_1 = require("./context");
|
|
8
|
-
const
|
|
9
|
-
const state_storage_1 = require("../state/state-storage");
|
|
5
|
+
const base_1 = require("@sentio/base");
|
|
10
6
|
class SuiBindOptions {
|
|
11
7
|
address;
|
|
12
8
|
// network?: Networkish = 1
|
|
@@ -14,14 +10,14 @@ class SuiBindOptions {
|
|
|
14
10
|
startBlock;
|
|
15
11
|
}
|
|
16
12
|
exports.SuiBindOptions = SuiBindOptions;
|
|
17
|
-
class SuiProcessorState extends
|
|
13
|
+
class SuiProcessorState extends base_1.ListStateStorage {
|
|
18
14
|
static INSTANCE = new SuiProcessorState();
|
|
19
15
|
}
|
|
20
16
|
exports.SuiProcessorState = SuiProcessorState;
|
|
21
17
|
class SuiBaseProcessor {
|
|
22
18
|
transactionHanlder;
|
|
23
19
|
address;
|
|
24
|
-
config = { startSeqNumber:
|
|
20
|
+
config = { startSeqNumber: 0n };
|
|
25
21
|
constructor(name, options) {
|
|
26
22
|
this.address = options.address;
|
|
27
23
|
if (options.startBlock) {
|
|
@@ -41,17 +37,11 @@ class SuiBaseProcessor {
|
|
|
41
37
|
return ctx.getProcessResult();
|
|
42
38
|
}
|
|
43
39
|
startSlot(startSlot) {
|
|
44
|
-
|
|
45
|
-
startSlot = long_1.default.fromNumber(startSlot);
|
|
46
|
-
}
|
|
47
|
-
this.config.startSeqNumber = startSlot;
|
|
40
|
+
this.config.startSeqNumber = BigInt(startSlot);
|
|
48
41
|
return this;
|
|
49
42
|
}
|
|
50
43
|
endBlock(endBlock) {
|
|
51
|
-
|
|
52
|
-
endBlock = long_1.default.fromNumber(endBlock);
|
|
53
|
-
}
|
|
54
|
-
this.config.endSeqNumber = endBlock;
|
|
44
|
+
this.config.endSeqNumber = BigInt(endBlock);
|
|
55
45
|
return this;
|
|
56
46
|
}
|
|
57
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/core/sui-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/core/sui-processor.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAEtC,uCAA+C;AAO/C,MAAa,cAAc;IACzB,OAAO,CAAQ;IACf,2BAA2B;IAC3B,gBAAgB;IAChB,UAAU,CAAkB;CAE7B;AAND,wCAMC;AAED,MAAa,iBAAkB,SAAQ,uBAAkC;IACvE,MAAM,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAA;;AAD3C,8CAEC;AAED,MAAa,gBAAgB;IACpB,kBAAkB,CAA6C;IACtE,OAAO,CAAQ;IACf,MAAM,GAAmB,EAAE,cAAc,EAAE,EAAE,EAAE,CAAA;IAE/C,YAAY,IAAY,EAAE,OAAuB;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACnC;QACD,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;IAEM,aAAa,CAAC,OAAoD;QACvE,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,iBAAiB,CAAC,GAAQ,EAAE,IAAY;QAC7C,MAAM,GAAG,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAE9C,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAClC;QACD,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC/B,CAAC;IAEM,SAAS,CAAC,SAA0B;QACzC,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;QAC9C,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAyB;QACvC,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC3C,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AApCD,4CAoCC","sourcesContent":["import { SuiContext } from './context'\nimport { ProcessResult } from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/base'\n\ntype IndexConfigure = {\n startSeqNumber: bigint\n endSeqNumber?: bigint\n}\n\nexport class SuiBindOptions {\n address: string\n // network?: Networkish = 1\n // name?: string\n startBlock?: bigint | number\n // endBlock?: Long | number\n}\n\nexport class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {\n static INSTANCE = new SuiProcessorState()\n}\n\nexport class SuiBaseProcessor {\n public transactionHanlder: (transaction: any, ctx: SuiContext) => void\n address: string\n config: IndexConfigure = { startSeqNumber: 0n }\n\n constructor(name: string, options: SuiBindOptions) {\n this.address = options.address\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n SuiProcessorState.INSTANCE.addValue(this)\n }\n\n public onTransaction(handler: (transaction: any, ctx: SuiContext) => void) {\n this.transactionHanlder = handler\n return this\n }\n\n public handleTransaction(txn: any, slot: bigint): ProcessResult | null {\n const ctx = new SuiContext(this.address, slot)\n\n if (txn) {\n this.transactionHanlder(txn, ctx)\n }\n return ctx.getProcessResult()\n }\n\n public startSlot(startSlot: bigint | number) {\n this.config.startSeqNumber = BigInt(startSlot)\n return this\n }\n\n public endBlock(endBlock: bigint | number) {\n this.config.endSeqNumber = BigInt(endBlock)\n return this\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { getProvider, setProvider, DummyProvider } from './provider';
|
|
2
|
-
export { transformEtherError } from './error';
|
|
3
|
-
export { EthersError } from './error';
|
|
2
|
+
export { transformEtherError, EthersError } from './error';
|
|
4
3
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds';
|
|
5
|
-
export * from '
|
|
4
|
+
export * from '@sentio/protos';
|
|
6
5
|
export * from './core';
|
|
7
6
|
export * as aptos from './aptos';
|
package/lib/index.js
CHANGED
|
@@ -27,22 +27,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.aptos = exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.EthersError = exports.transformEtherError = exports.DummyProvider = exports.setProvider = exports.getProvider = void 0;
|
|
30
|
-
// export { ProcessorServiceImpl } from './service'
|
|
31
30
|
var provider_1 = require("./provider");
|
|
32
31
|
Object.defineProperty(exports, "getProvider", { enumerable: true, get: function () { return provider_1.getProvider; } });
|
|
33
32
|
Object.defineProperty(exports, "setProvider", { enumerable: true, get: function () { return provider_1.setProvider; } });
|
|
34
33
|
Object.defineProperty(exports, "DummyProvider", { enumerable: true, get: function () { return provider_1.DummyProvider; } });
|
|
35
34
|
var error_1 = require("./error");
|
|
36
35
|
Object.defineProperty(exports, "transformEtherError", { enumerable: true, get: function () { return error_1.transformEtherError; } });
|
|
37
|
-
|
|
38
|
-
var error_2 = require("./error");
|
|
39
|
-
Object.defineProperty(exports, "EthersError", { enumerable: true, get: function () { return error_2.EthersError; } });
|
|
36
|
+
Object.defineProperty(exports, "EthersError", { enumerable: true, get: function () { return error_1.EthersError; } });
|
|
40
37
|
var binds_1 = require("./binds");
|
|
41
38
|
Object.defineProperty(exports, "getProcessor", { enumerable: true, get: function () { return binds_1.getProcessor; } });
|
|
42
39
|
Object.defineProperty(exports, "addProcessor", { enumerable: true, get: function () { return binds_1.addProcessor; } });
|
|
43
40
|
Object.defineProperty(exports, "getContractByABI", { enumerable: true, get: function () { return binds_1.getContractByABI; } });
|
|
44
41
|
Object.defineProperty(exports, "addContractByABI", { enumerable: true, get: function () { return binds_1.addContractByABI; } });
|
|
45
|
-
|
|
42
|
+
// TODO maybe remove this
|
|
43
|
+
__exportStar(require("@sentio/protos"), exports);
|
|
46
44
|
__exportStar(require("./core"), exports);
|
|
47
45
|
exports.aptos = __importStar(require("./aptos"));
|
|
48
46
|
//# 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,
|
|
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"]}
|
package/lib/processor-runner.js
CHANGED
|
@@ -34,13 +34,13 @@ const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
|
34
34
|
const nice_grpc_1 = require("nice-grpc");
|
|
35
35
|
const winston_1 = require("winston");
|
|
36
36
|
const compression_algorithms_1 = require("@grpc/grpc-js/build/src/compression-algorithms");
|
|
37
|
-
const
|
|
37
|
+
const protos_1 = require("@sentio/protos");
|
|
38
38
|
const service_1 = require("./service");
|
|
39
39
|
const provider_1 = require("./provider");
|
|
40
|
-
const
|
|
40
|
+
const base_1 = require("@sentio/base");
|
|
41
41
|
const loader_1 = require("./loader");
|
|
42
42
|
const endpoints_1 = require("./endpoints");
|
|
43
|
-
|
|
43
|
+
base_1.State.reset();
|
|
44
44
|
global.ENDPOINTS = new endpoints_1.Endpoints();
|
|
45
45
|
const optionDefinitions = [
|
|
46
46
|
{ name: 'target', type: String, defaultOption: true },
|
|
@@ -96,7 +96,7 @@ const server = (0, nice_grpc_1.createServer)({
|
|
|
96
96
|
'grpc.default_compression_algorithm': compression_algorithms_1.CompressionAlgorithms.gzip,
|
|
97
97
|
});
|
|
98
98
|
const service = new service_1.ProcessorServiceImpl(() => (0, loader_1.load)(options.target), server.shutdown);
|
|
99
|
-
server.add(
|
|
99
|
+
server.add(protos_1.ProcessorDefinition, service);
|
|
100
100
|
server.listen('0.0.0.0:' + options.port);
|
|
101
101
|
console.log('Processor Server Started');
|
|
102
102
|
//# sourceMappingURL=processor-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gDAAuB;AACvB,wDAAyB;AACzB,2CAA4B;AAE5B,0EAA+C;AAC/C,yCAAwC;AACxC,qCAA0D;AAC1D,2FAAsF;AAEtF
|
|
1
|
+
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;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,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nimport { ProcessorDefinition } from '@sentio/protos'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\nimport { State } from '@sentio/base'\nimport { load } from './loader'\nimport { Endpoints } from './endpoints'\n\nState.reset()\nglobal.ENDPOINTS = new Endpoints()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\nglobalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server']\nglobalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server']\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started')\n"]}
|
package/lib/service.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CallContext } from 'nice-grpc';
|
|
2
|
-
import { DataBinding, ProcessBindingResponse, ProcessBindingsRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessorServiceImplementation, ProcessResult, StartRequest } from '
|
|
3
|
-
import { Empty } from '
|
|
4
|
-
|
|
5
|
-
export declare const DEFAULT_MAX_BLOCK: Long;
|
|
2
|
+
import { DataBinding, ProcessBindingResponse, ProcessBindingsRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessorServiceImplementation, ProcessResult, StartRequest } from '@sentio/protos';
|
|
3
|
+
import { Empty } from '@sentio/protos/lib/google/protobuf/empty';
|
|
4
|
+
export declare const DEFAULT_MAX_BLOCK = 0n;
|
|
6
5
|
export declare const USER_PROCESSOR = "user_processor";
|
|
7
6
|
export declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
8
7
|
private started;
|
package/lib/service.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.errorString = exports.mergeProcessResults = exports.Utf8ArrayToStr = exports.ProcessorServiceImpl = exports.USER_PROCESSOR = exports.DEFAULT_MAX_BLOCK = void 0;
|
|
7
4
|
const nice_grpc_1 = require("nice-grpc");
|
|
8
|
-
const
|
|
9
|
-
const long_1 = __importDefault(require("long"));
|
|
5
|
+
const protos_1 = require("@sentio/protos");
|
|
10
6
|
const meter_1 = require("./core/meter");
|
|
11
7
|
const exporter_1 = require("./core/exporter");
|
|
12
8
|
const event_tracker_1 = require("./core/event-tracker");
|
|
@@ -14,11 +10,11 @@ const base_processor_template_1 = require("./core/base-processor-template");
|
|
|
14
10
|
// (Long.prototype as any).toBigInt = function() {
|
|
15
11
|
// return BigInt(this.toString())
|
|
16
12
|
// };
|
|
17
|
-
const
|
|
13
|
+
const base_1 = require("@sentio/base");
|
|
18
14
|
BigInt.prototype.toJSON = function () {
|
|
19
15
|
return this.toString();
|
|
20
16
|
};
|
|
21
|
-
exports.DEFAULT_MAX_BLOCK =
|
|
17
|
+
exports.DEFAULT_MAX_BLOCK = 0n;
|
|
22
18
|
exports.USER_PROCESSOR = 'user_processor';
|
|
23
19
|
class ProcessorServiceImpl {
|
|
24
20
|
started = false;
|
|
@@ -39,7 +35,7 @@ class ProcessorServiceImpl {
|
|
|
39
35
|
return this.processorConfig;
|
|
40
36
|
}
|
|
41
37
|
async configure() {
|
|
42
|
-
this.processorConfig =
|
|
38
|
+
this.processorConfig = protos_1.ProcessConfigResponse.fromPartial({});
|
|
43
39
|
// This syntax is to copy values instead of using references
|
|
44
40
|
this.processorConfig.templateInstances = [...base_processor_template_1.TemplateInstanceState.INSTANCE.getValues()];
|
|
45
41
|
// part 0, prepare metrics and event tracking configs
|
|
@@ -64,7 +60,7 @@ class ProcessorServiceImpl {
|
|
|
64
60
|
channel: exporter.channel,
|
|
65
61
|
});
|
|
66
62
|
}
|
|
67
|
-
|
|
63
|
+
base_1.PluginManager.INSTANCE.configure(this.processorConfig);
|
|
68
64
|
}
|
|
69
65
|
async start(request, context) {
|
|
70
66
|
if (this.started) {
|
|
@@ -138,7 +134,7 @@ class ProcessorServiceImpl {
|
|
|
138
134
|
};
|
|
139
135
|
}
|
|
140
136
|
async processBinding(request, options) {
|
|
141
|
-
const result = await
|
|
137
|
+
const result = await base_1.PluginManager.INSTANCE.processBinding(request);
|
|
142
138
|
recordRuntimeInfo(result, request.handlerType);
|
|
143
139
|
return result;
|
|
144
140
|
}
|
|
@@ -198,7 +194,7 @@ function Utf8ArrayToStr(array) {
|
|
|
198
194
|
}
|
|
199
195
|
exports.Utf8ArrayToStr = Utf8ArrayToStr;
|
|
200
196
|
function mergeProcessResults(results) {
|
|
201
|
-
const res =
|
|
197
|
+
const res = protos_1.ProcessResult.fromPartial({});
|
|
202
198
|
for (const r of results) {
|
|
203
199
|
res.counters = res.counters.concat(r.counters);
|
|
204
200
|
res.gauges = res.gauges.concat(r.gauges);
|