@sentio/sdk 1.37.0-rc.6 → 1.37.0-rc.7
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/binds.d.ts +1 -1
- package/lib/binds.js +2 -2
- package/lib/binds.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-processor-template.d.ts +1 -1
- package/lib/core/base-processor-template.js +3 -3
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/core-plugin.d.ts +6 -0
- package/lib/core/core-plugin.js +37 -0
- package/lib/core/core-plugin.js.map +1 -0
- package/lib/core/eth-plugin.d.ts +5 -3
- package/lib/core/eth-plugin.js +34 -11
- 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.js +2 -2
- package/lib/core/generic-processor.js.map +1 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +3 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/meter.d.ts +1 -1
- package/lib/core/meter.js +2 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/sui-plugin.d.ts +4 -4
- package/lib/core/sui-plugin.js +6 -7
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/core/sui-processor.d.ts +1 -1
- package/lib/core/sui-processor.js +2 -2
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +1 -1
- package/lib/testing/test-processor-server.js +5 -10
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +2 -2
- package/lib/testing/test-provider.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.js +2 -1
- package/lib/utils/price.js.map +1 -1
- package/package.json +9 -18
- package/src/binds.ts +1 -1
- package/src/core/account-processor.ts +1 -1
- package/src/core/base-processor-template.ts +1 -1
- package/src/core/core-plugin.ts +39 -0
- package/src/core/eth-plugin.ts +30 -3
- package/src/core/event-tracker.ts +1 -1
- package/src/core/exporter.ts +1 -1
- package/src/core/generic-processor.ts +1 -1
- package/src/core/index.ts +1 -0
- package/src/core/meter.ts +1 -1
- package/src/core/sui-plugin.ts +4 -6
- package/src/core/sui-processor.ts +1 -1
- package/src/index.ts +1 -1
- package/src/testing/test-processor-server.ts +2 -8
- package/src/testing/test-provider.ts +1 -2
- package/src/utils/price.ts +2 -1
- package/lib/chain-config.d.ts +0 -6
- package/lib/chain-config.js +0 -3
- package/lib/chain-config.js.map +0 -1
- package/lib/endpoints.d.ts +0 -6
- package/lib/endpoints.js +0 -11
- package/lib/endpoints.js.map +0 -1
- package/lib/loader.d.ts +0 -5
- package/lib/loader.js +0 -30
- package/lib/loader.js.map +0 -1
- package/lib/processor-runner.d.ts +0 -2
- package/lib/processor-runner.js +0 -102
- package/lib/processor-runner.js.map +0 -1
- package/lib/provider.d.ts +0 -6
- package/lib/provider.js +0 -66
- package/lib/provider.js.map +0 -1
- package/lib/service.d.ts +0 -21
- package/lib/service.js +0 -190
- package/lib/service.js.map +0 -1
- package/src/chain-config.ts +0 -6
- package/src/endpoints.ts +0 -9
- package/src/loader.ts +0 -24
- package/src/processor-runner.ts +0 -93
- package/src/provider.ts +0 -74
- package/src/service.ts +0 -197
- package/src/types/global.d.ts +0 -15
package/lib/core/meter.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Meter = exports.GaugeBinding = exports.Gauge = exports.CounterBinding =
|
|
|
4
4
|
const numberish_1 = require("./numberish");
|
|
5
5
|
const metadata_1 = require("./metadata");
|
|
6
6
|
const protos_1 = require("@sentio/protos");
|
|
7
|
-
const
|
|
7
|
+
const runtime_1 = require("@sentio/runtime");
|
|
8
8
|
function normalizeName(name) {
|
|
9
9
|
const regex = new RegExp('![_.a-zA-Z0-9]');
|
|
10
10
|
return name.slice(0, 100).replace(regex, '_');
|
|
@@ -63,7 +63,7 @@ class Metric extends metadata_1.NamedResultDescriptor {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
exports.Metric = Metric;
|
|
66
|
-
class MetricState extends
|
|
66
|
+
class MetricState extends runtime_1.MapStateStorage {
|
|
67
67
|
static INSTANCE = new MetricState();
|
|
68
68
|
getOrRegisterMetric(type, name, option) {
|
|
69
69
|
const metricMap = this.getOrRegister();
|
package/lib/core/meter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.js","sourceRoot":"","sources":["../../src/core/meter.ts"],"names":[],"mappings":";;;AACA,2CAAsD;AACtD,yCAA0D;AAC1D,2CAA6F;AAC7F,
|
|
1
|
+
{"version":3,"file":"meter.js","sourceRoot":"","sources":["../../src/core/meter.ts"],"names":[],"mappings":";;;AACA,2CAAsD;AACtD,yCAA0D;AAC1D,2CAA6F;AAC7F,6CAAiD;AAEjD,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAHD,sCAGC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,OAAO,SAAS,CAAA;KACjB;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AALD,oCAKC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;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AI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CACF;AAdD,sBAcC","sourcesContent":["import { BaseContext } from './base-context'\nimport { Numberish, toMetricValue } from './numberish'\nimport { Labels, NamedResultDescriptor } from './metadata'\nimport { AggregationConfig, AggregationType, MetricConfig, MetricType } from '@sentio/protos'\nimport { MapStateStorage } from '@sentio/runtime'\n\nexport function normalizeName(name: string): string {\n const regex = new RegExp('![_.a-zA-Z0-9]')\n return name.slice(0, 100).replace(regex, '_')\n}\n\nexport function normalizeKey(name: string): string {\n if (name === 'labels') {\n return 'labels_'\n }\n return normalizeName(name)\n}\n\nexport function normalizeValue(name: string): string {\n return name.slice(0, 100)\n}\n\nexport function normalizeLabels(labels: Labels): Labels {\n const normLabels: Labels = {}\n for (const key in labels) {\n normLabels[normalizeKey(key)] = normalizeValue(labels[key])\n }\n return normLabels\n}\n\nexport class MetricOptions {\n unit?: string\n description?: string\n sparse?: boolean\n aggregationConfig?: Partial<AggregationConfig>\n}\n\nexport class CounterOptions {\n unit?: string\n description?: string\n sparse?: boolean\n}\n\n// enum MetricType {\n// Counter = 0,\n// Gauge = 1,\n// }\n\nexport class Metric extends NamedResultDescriptor {\n config: MetricConfig\n constructor(type: MetricType, name: string, option?: MetricOptions) {\n super(name)\n this.config = MetricConfig.fromPartial({ name: this.name, type: type, ...option })\n const aggregationConfig = this.config.aggregationConfig\n if (aggregationConfig && aggregationConfig.intervalInMinutes.length) {\n if (aggregationConfig.intervalInMinutes.length > 1) {\n console.error('current only support one intervalInMinutes, only first interval will be used for', name)\n }\n if (aggregationConfig.intervalInMinutes[0] > 0 && aggregationConfig.types.length === 0) {\n aggregationConfig.types = [AggregationType.SUM, AggregationType.COUNT]\n }\n }\n }\n}\n\nexport class MetricState extends MapStateStorage<Metric> {\n static INSTANCE = new MetricState()\n\n getOrRegisterMetric(type: MetricType, name: string, option?: CounterOptions | MetricOptions): Metric {\n const metricMap = this.getOrRegister()\n let metric = metricMap.get(name)\n if (metric && metric.config.type !== type) {\n throw Error(`redefine ${name} of metric type ${type} that is previously ${metric.config.type}`)\n }\n\n if (!metric) {\n if (type === MetricType.COUNTER) {\n metric = new Counter(name, option)\n } else {\n metric = new Gauge(name, option)\n }\n }\n metricMap.set(name, metric)\n return metric\n }\n}\n\nexport class Counter extends Metric {\n static register(name: string, option?: CounterOptions): Counter {\n return MetricState.INSTANCE.getOrRegisterMetric(MetricType.COUNTER, name, option) as Counter\n }\n\n constructor(name: string, option?: MetricOptions) {\n super(MetricType.COUNTER, name, option)\n }\n\n add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, true)\n }\n\n sub(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, false)\n }\n\n private record(ctx: BaseContext, value: Numberish, labels: Labels, add: boolean) {\n ctx.res.counters.push({\n metadata: ctx.getMetaData(this.name, labels),\n metricValue: toMetricValue(value),\n add: add,\n runtimeInfo: undefined,\n })\n }\n}\n\nexport class CounterBinding {\n private readonly ctx: BaseContext\n private readonly counter: Counter\n\n constructor(name: string, ctx: BaseContext) {\n this.counter = new Counter(name)\n this.ctx = ctx\n }\n\n add(value: Numberish, labels: Labels = {}) {\n this.counter.add(this.ctx, value, labels)\n }\n\n sub(value: Numberish, labels: Labels = {}) {\n this.counter.sub(this.ctx, value, labels)\n }\n}\n\nexport class Gauge extends Metric {\n static register(name: string, option?: MetricOptions): Gauge {\n return MetricState.INSTANCE.getOrRegisterMetric(MetricType.GAUGE, name, option) as Gauge\n }\n\n constructor(name: string, option?: MetricOptions) {\n super(MetricType.GAUGE, name, option)\n }\n\n record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n ctx.res.gauges.push({\n metadata: ctx.getMetaData(this.config.name, labels),\n metricValue: toMetricValue(value),\n runtimeInfo: undefined,\n })\n }\n}\n\nexport class GaugeBinding {\n private readonly gauge: Gauge\n private readonly ctx: BaseContext\n\n constructor(name: string, ctx: BaseContext) {\n this.gauge = new Gauge(name)\n this.ctx = ctx\n }\n\n record(value: Numberish, labels: Labels = {}) {\n this.gauge.record(this.ctx, value, labels)\n }\n}\n\nexport class Meter {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext) {\n this.ctx = ctx\n }\n\n Counter(name: string): CounterBinding {\n return new CounterBinding(name, this.ctx)\n }\n\n Gauge(name: string): GaugeBinding {\n return new GaugeBinding(name, this.ctx)\n }\n}\n"]}
|
package/lib/core/sui-plugin.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin } from '@sentio/
|
|
2
|
-
import { DataBinding,
|
|
3
|
-
export declare class SuiPlugin
|
|
1
|
+
import { Plugin } from '@sentio/runtime';
|
|
2
|
+
import { DataBinding, ProcessConfigResponse, ProcessResult } from '@sentio/protos';
|
|
3
|
+
export declare class SuiPlugin extends Plugin {
|
|
4
4
|
name: string;
|
|
5
5
|
configure(config: ProcessConfigResponse): void;
|
|
6
|
-
supportedHandlers:
|
|
6
|
+
supportedHandlers: never[];
|
|
7
7
|
processBinding(request: DataBinding): Promise<ProcessResult>;
|
|
8
8
|
}
|
package/lib/core/sui-plugin.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuiPlugin = void 0;
|
|
4
|
-
const
|
|
4
|
+
const runtime_1 = require("@sentio/runtime");
|
|
5
5
|
const protos_1 = require("@sentio/protos");
|
|
6
|
-
const service_1 = require("../service");
|
|
7
6
|
const nice_grpc_1 = require("nice-grpc");
|
|
8
7
|
const chain_1 = require("../utils/chain");
|
|
9
8
|
const sui_processor_1 = require("./sui-processor");
|
|
10
|
-
class SuiPlugin {
|
|
11
|
-
name = '
|
|
9
|
+
class SuiPlugin extends runtime_1.Plugin {
|
|
10
|
+
name = 'SuiPlugin';
|
|
12
11
|
configure(config) {
|
|
13
12
|
for (const suiProcessor of sui_processor_1.SuiProcessorState.INSTANCE.getValues()) {
|
|
14
13
|
const contractConfig = {
|
|
15
|
-
processorType:
|
|
14
|
+
processorType: runtime_1.USER_PROCESSOR,
|
|
16
15
|
contract: {
|
|
17
16
|
name: 'sui contract',
|
|
18
17
|
chainId: chain_1.CHAIN_IDS.SUI_DEVNET,
|
|
@@ -31,7 +30,7 @@ class SuiPlugin {
|
|
|
31
30
|
config.contractConfigs.push(contractConfig);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
supportedHandlers = [
|
|
33
|
+
supportedHandlers = [];
|
|
35
34
|
processBinding(request) {
|
|
36
35
|
switch (request.handlerType) {
|
|
37
36
|
case protos_1.HandlerType.SUI_TRANSACTION:
|
|
@@ -42,5 +41,5 @@ class SuiPlugin {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
exports.SuiPlugin = SuiPlugin;
|
|
45
|
-
|
|
44
|
+
runtime_1.PluginManager.INSTANCE.register(new SuiPlugin());
|
|
46
45
|
//# 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,6CAAuE;AACvE,2CAA+G;AAE/G,yCAA+C;AAE/C,0CAA0C;AAC1C,mDAAmD;AAEnD,MAAa,SAAU,SAAQ,gBAAM;IACnC,IAAI,GAAW,WAAW,CAAA;IAE1B,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,EAAE,CAAA;IAEtB,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,uBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { CHAIN_IDS } from '../utils/chain'\nimport { SuiProcessorState } from './sui-processor'\n\nexport class SuiPlugin extends Plugin {\n name: string = 'SuiPlugin'\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 = []\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,6 +1,6 @@
|
|
|
1
1
|
import { SuiContext } from './context';
|
|
2
2
|
import { ProcessResult } from '@sentio/protos';
|
|
3
|
-
import { ListStateStorage } from '@sentio/
|
|
3
|
+
import { ListStateStorage } from '@sentio/runtime';
|
|
4
4
|
declare type IndexConfigure = {
|
|
5
5
|
startSeqNumber: bigint;
|
|
6
6
|
endSeqNumber?: bigint;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuiBaseProcessor = exports.SuiProcessorState = exports.SuiBindOptions = void 0;
|
|
4
4
|
const context_1 = require("./context");
|
|
5
|
-
const
|
|
5
|
+
const runtime_1 = require("@sentio/runtime");
|
|
6
6
|
class SuiBindOptions {
|
|
7
7
|
address;
|
|
8
8
|
// network?: Networkish = 1
|
|
@@ -10,7 +10,7 @@ class SuiBindOptions {
|
|
|
10
10
|
startBlock;
|
|
11
11
|
}
|
|
12
12
|
exports.SuiBindOptions = SuiBindOptions;
|
|
13
|
-
class SuiProcessorState extends
|
|
13
|
+
class SuiProcessorState extends runtime_1.ListStateStorage {
|
|
14
14
|
static INSTANCE = new SuiProcessorState();
|
|
15
15
|
}
|
|
16
16
|
exports.SuiProcessorState = SuiProcessorState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/core/sui-processor.ts"],"names":[],"mapp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AAI,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/runtime'\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,4 +1,4 @@
|
|
|
1
|
-
export { getProvider, setProvider, DummyProvider } from '
|
|
1
|
+
export { getProvider, setProvider, DummyProvider } from '@sentio/runtime';
|
|
2
2
|
export { transformEtherError, EthersError } from './error';
|
|
3
3
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds';
|
|
4
4
|
export * from '@sentio/protos';
|
package/lib/index.js
CHANGED
|
@@ -15,10 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.addContractByABI = exports.getContractByABI = exports.addProcessor = exports.getProcessor = exports.EthersError = exports.transformEtherError = exports.DummyProvider = exports.setProvider = exports.getProvider = void 0;
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "getProvider", { enumerable: true, get: function () { return
|
|
20
|
-
Object.defineProperty(exports, "setProvider", { enumerable: true, get: function () { return
|
|
21
|
-
Object.defineProperty(exports, "DummyProvider", { enumerable: true, get: function () { return
|
|
18
|
+
var runtime_1 = require("@sentio/runtime");
|
|
19
|
+
Object.defineProperty(exports, "getProvider", { enumerable: true, get: function () { return runtime_1.getProvider; } });
|
|
20
|
+
Object.defineProperty(exports, "setProvider", { enumerable: true, get: function () { return runtime_1.setProvider; } });
|
|
21
|
+
Object.defineProperty(exports, "DummyProvider", { enumerable: true, get: function () { return runtime_1.DummyProvider; } });
|
|
22
22
|
var error_1 = require("./error");
|
|
23
23
|
Object.defineProperty(exports, "transformEtherError", { enumerable: true, get: function () { return error_1.transformEtherError; } });
|
|
24
24
|
Object.defineProperty(exports, "EthersError", { enumerable: true, get: function () { return error_1.EthersError; } });
|
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,2CAAyE;AAAhE,sGAAA,WAAW,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,wGAAA,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 '@sentio/runtime'\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"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AccountConfig, ContractConfig, DataBinding, Data_SolInstruction, ProcessBindingResponse, ProcessBindingsRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessorServiceImplementation, StartRequest } from '@sentio/protos';
|
|
2
2
|
import { CallContext } from 'nice-grpc-common';
|
|
3
3
|
import { Empty } from '@sentio/protos/lib/google/protobuf/empty';
|
|
4
|
+
import { ProcessorServiceImpl } from '@sentio/runtime';
|
|
4
5
|
import { Block, Log } from '@ethersproject/abstract-provider';
|
|
5
6
|
import { Networkish } from '@ethersproject/providers';
|
|
6
|
-
import { ProcessorServiceImpl } from '../service';
|
|
7
7
|
import { Trace } from '../core/trace';
|
|
8
8
|
export declare const TEST_CONTEXT: CallContext;
|
|
9
9
|
export declare function cleanTest(): void;
|
|
@@ -2,18 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TestProcessorServer = exports.cleanTest = exports.TEST_CONTEXT = void 0;
|
|
4
4
|
const protos_1 = require("@sentio/protos");
|
|
5
|
+
const runtime_1 = require("@sentio/runtime");
|
|
5
6
|
const chain_1 = require("../utils/chain");
|
|
6
7
|
const providers_1 = require("@ethersproject/providers");
|
|
7
|
-
const endpoints_1 = require("../endpoints");
|
|
8
|
-
const base_1 = require("@sentio/base");
|
|
9
|
-
const service_1 = require("../service");
|
|
10
|
-
const provider_1 = require("../provider");
|
|
11
8
|
exports.TEST_CONTEXT = {};
|
|
12
9
|
function cleanTest() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
global.ENDPOINTS = new endpoints_1.Endpoints();
|
|
16
|
-
}
|
|
10
|
+
runtime_1.State.reset();
|
|
11
|
+
runtime_1.Endpoints.reset();
|
|
17
12
|
}
|
|
18
13
|
exports.cleanTest = cleanTest;
|
|
19
14
|
class TestProcessorServer {
|
|
@@ -22,7 +17,7 @@ class TestProcessorServer {
|
|
|
22
17
|
accountConfigs;
|
|
23
18
|
constructor(loader, httpEndpoints = {}) {
|
|
24
19
|
cleanTest();
|
|
25
|
-
this.service = new
|
|
20
|
+
this.service = new runtime_1.ProcessorServiceImpl(loader);
|
|
26
21
|
const dummyConfig = {};
|
|
27
22
|
for (const k in chain_1.CHAIN_MAP) {
|
|
28
23
|
const http = httpEndpoints[k] || '';
|
|
@@ -31,7 +26,7 @@ class TestProcessorServer {
|
|
|
31
26
|
Https: [http],
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
|
-
(0,
|
|
29
|
+
(0, runtime_1.setProvider)(dummyConfig);
|
|
35
30
|
}
|
|
36
31
|
async start(request = { templateInstances: [] }, context = exports.TEST_CONTEXT) {
|
|
37
32
|
const res = await this.service.start(request, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-processor-server.js","sourceRoot":"","sources":["../../src/testing/test-processor-server.ts"],"names":[],"mappings":";;;AAAA,2CAYuB;AAIvB,0CAA0C;AAE1C,wDAAiE;AACjE,4CAAwC;AACxC,uCAAoC;AACpC,wCAAiD;AAEjD,0CAAyC;AAE5B,QAAA,YAAY,GAA6B,EAAE,CAAA;AAExD,SAAgB,SAAS;IACvB,YAAK,CAAC,KAAK,EAAE,CAAA;IACb,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,MAAM,CAAC,SAAS,GAAG,IAAI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E,WAAW;qBAC5B;oBACD,UAAU,EAAE,EAAE;oBACd,WAAW,EAAE,oBAAW,CAAC,eAAe;iBACzC,CAAA;YACH,CAAC,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CACb,OAA+B,EAC/B,UAAuB,oBAAY;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;IAED,qBAAqB,CAAC,OAAmC,EAAE,OAAoB;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7D,CAAC;CACF;AAjSD,kDAiSC","sourcesContent":["import {\n AccountConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n Data_SolInstruction,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n StartRequest,\n} from '@sentio/protos'\nimport { CallContext } from 'nice-grpc-common'\nimport { Empty } from '@sentio/protos/lib/google/protobuf/empty'\nimport { ChainConfig } from '../chain-config'\nimport { CHAIN_MAP } from '../utils/chain'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { getNetwork, Networkish } from '@ethersproject/providers'\nimport { Endpoints } from '../endpoints'\nimport { State } from '@sentio/base'\nimport { ProcessorServiceImpl } from '../service'\nimport { Trace } from '../core/trace'\nimport { setProvider } from '../provider'\n\nexport const TEST_CONTEXT: CallContext = <CallContext>{}\n\nexport function cleanTest() {\n State.reset()\n if (!global.ENDPOINTS) {\n global.ENDPOINTS = new Endpoints()\n }\n}\n\nexport class TestProcessorServer implements ProcessorServiceImplementation {\n service: ProcessorServiceImpl\n contractConfigs: ContractConfig[]\n accountConfigs: AccountConfig[]\n\n constructor(loader: () => void, httpEndpoints: Record<string, string> = {}) {\n cleanTest()\n\n this.service = new ProcessorServiceImpl(loader)\n const dummyConfig: Record<string, ChainConfig> = {}\n\n for (const k in CHAIN_MAP) {\n const http = httpEndpoints[k] || ''\n dummyConfig[k] = {\n ChainID: k,\n Https: [http],\n }\n }\n\n setProvider(dummyConfig)\n }\n\n async start(request: StartRequest = { templateInstances: [] }, context = TEST_CONTEXT): Promise<Empty> {\n const res = await this.service.start(request, context)\n const config = await this.getConfig({})\n this.contractConfigs = config.contractConfigs\n this.accountConfigs = config.accountConfigs\n return res\n }\n\n stop(request: Empty, context = TEST_CONTEXT): Promise<Empty> {\n return this.service.stop(request, context)\n }\n\n getConfig(request: ProcessConfigRequest, context = TEST_CONTEXT): Promise<ProcessConfigResponse> {\n return this.service.getConfig(request, context)\n }\n\n // processLogs(request: ProcessBindingsRequest, context = TEST_CONTEXT): Promise<ProcessBindingResponse> {\n // return this.service.processLogs(request, context)\n // }\n //\n // processTraces(request: ProcessBindingsRequest, context: CallContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {\n // return this.service.processTraces(request, context)\n // }\n\n testTrace(trace: Trace, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testTraces([trace], network)\n }\n\n testTraces(traces: Trace[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const trace of traces) {\n const binding = this.buildTraceBinding(trace, network)\n if (!binding) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildTraceBinding(trace: Trace, network: Networkish = 1): DataBinding | undefined {\n if (trace.type !== 'call' || !trace.action.input) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n const signature = trace.action.input.slice(0, 10)\n\n for (const contract of this.contractConfigs) {\n if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.traceConfigs) {\n if (config.signature == signature) {\n return {\n data: {\n raw: new Uint8Array(),\n ethTrace: { trace },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_TRACE,\n }\n }\n }\n }\n return undefined\n }\n\n testLog(log: Log, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testLogs([log], network)\n }\n\n testLogs(logs: Log[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildLogBinding(log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildLogBinding(log: Log, network: Networkish = 1): DataBinding | undefined {\n for (const contract of this.contractConfigs) {\n if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n raw: new Uint8Array(),\n ethLog: { log },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n testAccountLog(address: string, log: Log, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testAccountLogs(address, [log], network)\n }\n\n testAccountLogs(address: string, logs: Log[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildAccountLogBinding(address, log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildAccountLogBinding(address: string, log: Log, network: Networkish = 1): DataBinding | undefined {\n for (const account of this.accountConfigs) {\n if (account.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n if (address.toLowerCase() !== account.address.toLowerCase()) {\n continue\n }\n for (const config of account.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n raw: new Uint8Array(),\n ethLog: { log },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n\n testBlock(block: Partial<Block> & { number: number }, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testBlocks([block], network)\n }\n\n testBlocks(blocks: Partial<Block> & { number: number }[], network: Networkish = 1) {\n const bindings = []\n for (const block of blocks) {\n const binding = this.buildBlockBinding(block, network)\n if (!binding) {\n throw Error('Invalid test block: ' + JSON.stringify(block))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildBlockBinding(block: Partial<Block> & { number: number }, network: Networkish = 1): DataBinding {\n const binding: DataBinding = {\n data: {\n raw: new Uint8Array(),\n ethBlock: { block },\n },\n handlerType: HandlerType.ETH_BLOCK,\n handlerIds: [],\n }\n for (const contract of this.contractConfigs) {\n if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n const longBlockNumber = block.number\n if (longBlockNumber < contract.startBlock) {\n continue\n }\n if (contract.endBlock !== 0n && longBlockNumber >= contract.endBlock) {\n continue\n }\n\n for (const config of contract.intervalConfigs) {\n binding.handlerIds.push(config.handlerId)\n }\n }\n return binding\n }\n\n testInstructions(instructions: Data_SolInstruction[]): Promise<ProcessBindingResponse> {\n return this.processBindings({\n bindings: instructions.map((instruction) => {\n return {\n data: {\n raw: new Uint8Array(),\n solInstruction: instruction,\n },\n handlerIds: [],\n handlerType: HandlerType.SOL_INSTRUCTION,\n }\n }),\n })\n }\n\n processBindings(\n request: ProcessBindingsRequest,\n context: CallContext = TEST_CONTEXT\n ): Promise<ProcessBindingResponse> {\n return this.service.processBindings(request, context)\n }\n\n processBindingsStream(request: AsyncIterable<DataBinding>, context: CallContext) {\n return this.service.processBindingsStream(request, context)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"test-processor-server.js","sourceRoot":"","sources":["../../src/testing/test-processor-server.ts"],"names":[],"mappings":";;;AAAA,2CAYuB;AAGvB,6CAAkG;AAClG,0CAA0C;AAE1C,wDAAiE;AAGpD,QAAA,YAAY,GAA6B,EAAE,CAAA;AAExD,SAAgB,SAAS;IACvB,eAAK,CAAC,KAAK,EAAE,CAAA;IACb,mBAAS,CAAC,KAAK,EAAE,CAAA;AACnB,CAAC;AAHD,8BAGC;AAED,MAAa,mBAAmB;IAC9B,OAAO,CAAsB;IAC7B,eAAe,CAAkB;IACjC,cAAc,CAAiB;IAE/B,YAAY,MAAkB,EAAE,gBAAwC,EAAE;QACxE,SAAS,EAAE,CAAA;QAEX,IAAI,CAAC,OAAO,GAAG,IAAI,8BAAoB,CAAC,MAAM,CAAC,CAAA;QAC/C,MAAM,WAAW,GAAgC,EAAE,CAAA;QAEnD,KAAK,MAAM,CAAC,IAAI,iBAAS,EAAE;YACzB,MAAM,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;YACnC,WAAW,CAAC,CAAC,CAAC,GAAG;gBACf,OAAO,EAAE,CAAC;gBACV,KAAK,EAAE,CAAC,IAAI,CAAC;aACd,CAAA;SACF;QAED,IAAA,qBAAW,EAAC,WAAW,CAAC,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,UAAwB,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAAE,OAAO,GAAG,oBAAY;QACnF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC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gBACzC,SAAQ;aACT;YACD,IAAI,QAAQ,CAAC,QAAQ,KAAK,EAAE,IAAI,eAAe,IAAI,QAAQ,CAAC,QAAQ,EAAE;gBACpE,SAAQ;aACT;YAED,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,eAAe,EAAE;gBAC7C,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;aAC1C;SACF;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,gBAAgB,CAAC,YAAmC;QAClD,OAAO,IAAI,CAAC,eAAe,CAAC;YAC1B,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;gBACzC,OAAO;oBACL,IAAI,EAAE;wBACJ,GAAG,EAAE,IAAI,UAAU,EAAE;wBACrB,cAAc,EAAE,WAAW;qBAC5B;oBACD,UAAU,EAAE,EAAE;oBACd,WAAW,EAAE,oBAAW,CAAC,eAAe;iBACzC,CAAA;YACH,CAAC,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CACb,OAA+B,EAC/B,UAAuB,oBAAY;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;IAED,qBAAqB,CAAC,OAAmC,EAAE,OAAoB;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC7D,CAAC;CACF;AAjSD,kDAiSC","sourcesContent":["import {\n AccountConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n Data_SolInstruction,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n StartRequest,\n} from '@sentio/protos'\nimport { CallContext } from 'nice-grpc-common'\nimport { Empty } from '@sentio/protos/lib/google/protobuf/empty'\nimport { ChainConfig, ProcessorServiceImpl, setProvider, Endpoints, State } from '@sentio/runtime'\nimport { CHAIN_MAP } from '../utils/chain'\nimport { Block, Log } from '@ethersproject/abstract-provider'\nimport { getNetwork, Networkish } from '@ethersproject/providers'\nimport { Trace } from '../core/trace'\n\nexport const TEST_CONTEXT: CallContext = <CallContext>{}\n\nexport function cleanTest() {\n State.reset()\n Endpoints.reset()\n}\n\nexport class TestProcessorServer implements ProcessorServiceImplementation {\n service: ProcessorServiceImpl\n contractConfigs: ContractConfig[]\n accountConfigs: AccountConfig[]\n\n constructor(loader: () => void, httpEndpoints: Record<string, string> = {}) {\n cleanTest()\n\n this.service = new ProcessorServiceImpl(loader)\n const dummyConfig: Record<string, ChainConfig> = {}\n\n for (const k in CHAIN_MAP) {\n const http = httpEndpoints[k] || ''\n dummyConfig[k] = {\n ChainID: k,\n Https: [http],\n }\n }\n\n setProvider(dummyConfig)\n }\n\n async start(request: StartRequest = { templateInstances: [] }, context = TEST_CONTEXT): Promise<Empty> {\n const res = await this.service.start(request, context)\n const config = await this.getConfig({})\n this.contractConfigs = config.contractConfigs\n this.accountConfigs = config.accountConfigs\n return res\n }\n\n stop(request: Empty, context = TEST_CONTEXT): Promise<Empty> {\n return this.service.stop(request, context)\n }\n\n getConfig(request: ProcessConfigRequest, context = TEST_CONTEXT): Promise<ProcessConfigResponse> {\n return this.service.getConfig(request, context)\n }\n\n // processLogs(request: ProcessBindingsRequest, context = TEST_CONTEXT): Promise<ProcessBindingResponse> {\n // return this.service.processLogs(request, context)\n // }\n //\n // processTraces(request: ProcessBindingsRequest, context: CallContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {\n // return this.service.processTraces(request, context)\n // }\n\n testTrace(trace: Trace, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testTraces([trace], network)\n }\n\n testTraces(traces: Trace[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const trace of traces) {\n const binding = this.buildTraceBinding(trace, network)\n if (!binding) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildTraceBinding(trace: Trace, network: Networkish = 1): DataBinding | undefined {\n if (trace.type !== 'call' || !trace.action.input) {\n throw Error('Invalid test trace: ' + JSON.stringify(trace))\n }\n const signature = trace.action.input.slice(0, 10)\n\n for (const contract of this.contractConfigs) {\n if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n if (trace.action.to?.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.traceConfigs) {\n if (config.signature == signature) {\n return {\n data: {\n raw: new Uint8Array(),\n ethTrace: { trace },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_TRACE,\n }\n }\n }\n }\n return undefined\n }\n\n testLog(log: Log, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testLogs([log], network)\n }\n\n testLogs(logs: Log[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildLogBinding(log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildLogBinding(log: Log, network: Networkish = 1): DataBinding | undefined {\n for (const contract of this.contractConfigs) {\n if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n if (log.address.toLowerCase() !== contract.contract?.address.toLowerCase()) {\n continue\n }\n for (const config of contract.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n raw: new Uint8Array(),\n ethLog: { log },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n testAccountLog(address: string, log: Log, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testAccountLogs(address, [log], network)\n }\n\n testAccountLogs(address: string, logs: Log[], network: Networkish = 1): Promise<ProcessBindingResponse> {\n const bindings = []\n for (const log of logs) {\n const binding = this.buildAccountLogBinding(address, log, network)\n if (!binding) {\n throw Error('Invalid test log: ' + JSON.stringify(log))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildAccountLogBinding(address: string, log: Log, network: Networkish = 1): DataBinding | undefined {\n for (const account of this.accountConfigs) {\n if (account.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n if (address.toLowerCase() !== account.address.toLowerCase()) {\n continue\n }\n for (const config of account.logConfigs) {\n for (const filter of config.filters) {\n // if (filter.topics.length != log.topics.length) {\n // continue\n // }\n\n let match = true\n for (const topicIdx in filter.topics) {\n const logTopic = log.topics[topicIdx]\n const possibleTopic = filter.topics[topicIdx].hashes\n if (possibleTopic.length === 0) {\n // match all\n continue\n }\n if (possibleTopic.find((e) => e.toLowerCase() === logTopic.toLowerCase())) {\n // find one\n continue\n }\n match = false\n break\n }\n if (match) {\n return {\n data: {\n raw: new Uint8Array(),\n ethLog: { log },\n },\n handlerIds: [config.handlerId],\n handlerType: HandlerType.ETH_LOG,\n }\n }\n }\n }\n }\n return undefined\n }\n\n testBlock(block: Partial<Block> & { number: number }, network: Networkish = 1): Promise<ProcessBindingResponse> {\n return this.testBlocks([block], network)\n }\n\n testBlocks(blocks: Partial<Block> & { number: number }[], network: Networkish = 1) {\n const bindings = []\n for (const block of blocks) {\n const binding = this.buildBlockBinding(block, network)\n if (!binding) {\n throw Error('Invalid test block: ' + JSON.stringify(block))\n }\n bindings.push(binding)\n }\n return this.processBindings({\n bindings: bindings,\n })\n }\n\n buildBlockBinding(block: Partial<Block> & { number: number }, network: Networkish = 1): DataBinding {\n const binding: DataBinding = {\n data: {\n raw: new Uint8Array(),\n ethBlock: { block },\n },\n handlerType: HandlerType.ETH_BLOCK,\n handlerIds: [],\n }\n for (const contract of this.contractConfigs) {\n if (contract.contract?.chainId !== getNetwork(network).chainId.toString()) {\n continue\n }\n const longBlockNumber = block.number\n if (longBlockNumber < contract.startBlock) {\n continue\n }\n if (contract.endBlock !== 0n && longBlockNumber >= contract.endBlock) {\n continue\n }\n\n for (const config of contract.intervalConfigs) {\n binding.handlerIds.push(config.handlerId)\n }\n }\n return binding\n }\n\n testInstructions(instructions: Data_SolInstruction[]): Promise<ProcessBindingResponse> {\n return this.processBindings({\n bindings: instructions.map((instruction) => {\n return {\n data: {\n raw: new Uint8Array(),\n solInstruction: instruction,\n },\n handlerIds: [],\n handlerType: HandlerType.SOL_INSTRUCTION,\n }\n }),\n })\n }\n\n processBindings(\n request: ProcessBindingsRequest,\n context: CallContext = TEST_CONTEXT\n ): Promise<ProcessBindingResponse> {\n return this.service.processBindings(request, context)\n }\n\n processBindingsStream(request: AsyncIterable<DataBinding>, context: CallContext) {\n return this.service.processBindingsStream(request, context)\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadTestProvidersFromEnv = void 0;
|
|
4
|
+
const runtime_1 = require("@sentio/runtime");
|
|
4
5
|
const chain_1 = require("../utils/chain");
|
|
5
|
-
const provider_1 = require("../provider");
|
|
6
6
|
function loadTestProvidersFromEnv(requiredChainIds) {
|
|
7
7
|
const dummyConfig = {};
|
|
8
8
|
const found = [];
|
|
@@ -21,7 +21,7 @@ function loadTestProvidersFromEnv(requiredChainIds) {
|
|
|
21
21
|
Https: [http],
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
(0,
|
|
24
|
+
(0, runtime_1.setProvider)(dummyConfig);
|
|
25
25
|
for (const id of requiredChainIds) {
|
|
26
26
|
if (!found.includes(id)) {
|
|
27
27
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-provider.js","sourceRoot":"","sources":["../../src/testing/test-provider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test-provider.js","sourceRoot":"","sources":["../../src/testing/test-provider.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAC1D,0CAA0C;AAE1C,SAAgB,wBAAwB,CAAC,gBAAmC;IAC1E,MAAM,WAAW,GAAgC,EAAE,CAAA;IACnD,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;QACpC,gBAAgB,GAAG,CAAC,gBAAgB,CAAC,CAAA;KACtC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAS,CAAC,EAAE;QACtC,MAAM,MAAM,GAAG,gBAAgB,GAAG,CAAC,CAAA;QACnC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI,EAAE;YACT,SAAQ;SACT;QACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACb,WAAW,CAAC,CAAC,CAAC,GAAG;YACf,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,CAAC,IAAI,CAAC;SACd,CAAA;KACF;IAED,IAAA,qBAAW,EAAC,WAAW,CAAC,CAAA;IACxB,KAAK,MAAM,EAAE,IAAI,gBAAgB,EAAE;QACjC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;YACvB,OAAO,KAAK,CAAA;SACb;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AA5BD,4DA4BC","sourcesContent":["import { ChainConfig, setProvider } from '@sentio/runtime'\nimport { CHAIN_MAP } from '../utils/chain'\n\nexport function loadTestProvidersFromEnv(requiredChainIds: string[] | string): boolean {\n const dummyConfig: Record<string, ChainConfig> = {}\n const found: string[] = []\n\n if (!Array.isArray(requiredChainIds)) {\n requiredChainIds = [requiredChainIds]\n }\n\n for (const k of Object.keys(CHAIN_MAP)) {\n const envKey = 'TEST_ENDPOINT_' + k\n const http = process.env[envKey]\n if (!http) {\n continue\n }\n found.push(k)\n dummyConfig[k] = {\n ChainID: k,\n Https: [http],\n }\n }\n\n setProvider(dummyConfig)\n for (const id of requiredChainIds) {\n if (!found.includes(id)) {\n return false\n }\n }\n return true\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dex-price.test.js","sourceRoot":"","sources":["../../src/utils/dex-price.test.ts"],"names":[],"mappings":";;AAAA,2CAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"dex-price.test.js","sourceRoot":"","sources":["../../src/utils/dex-price.test.ts"],"names":[],"mappings":";;AAAA,2CAA8D;AAC9D,6CAAuC;AACvC,4DAAmE;AAEnE,+BAA6B;AAC7B,6CAA2C;AAE3C,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,eAAK,CAAC,KAAK,EAAE,CAAA;IACb,mBAAS,CAAC,KAAK,EAAE,CAAA;IAEjB,MAAM,aAAa,GAAG,IAAA,wCAAwB,EAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IAE1D,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAE/C,MAAM,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,IAAI,GAAG,MAAM,4BAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAC9D,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAA;QAEjC,MAAM,QAAQ,GAAG,MAAM,4BAAgB,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAClE,IAAA,aAAM,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,GAAG,GAAG,MAAM,0BAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACzD,IAAA,aAAM,EAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { EthereumDexPrice, GoerliDexPrice } from './dex-price'\nimport { State } from '@sentio/runtime'\nimport { loadTestProvidersFromEnv } from '../testing/test-provider'\n\nimport { expect } from 'chai'\nimport { Endpoints } from '@sentio/runtime'\n\ndescribe('dex price tests', () => {\n State.reset()\n Endpoints.reset()\n\n const haveProviders = loadTestProvidersFromEnv(['1', '5'])\n\n const testIf = haveProviders ? test : test.skip\n\n testIf('get price at mainnet', async () => {\n const usdc = await EthereumDexPrice.getPrice('usdc', 15677823)\n expect(usdc.price).eq(0.99991649)\n\n const compound = await EthereumDexPrice.getPrice('COMP', 15677823)\n expect(compound.price).eq(60.27)\n })\n\n testIf('get price at goerli', async () => {\n const dai = await GoerliDexPrice.getPrice('DAI', 7712734)\n expect(dai.price).eq(0.99971281)\n })\n})\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20.test.js","sourceRoot":"","sources":["../../src/utils/erc20.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"erc20.test.js","sourceRoot":"","sources":["../../src/utils/erc20.test.ts"],"names":[],"mappings":";;AAAA,6CAAkD;AAClD,mCAA2C;AAC3C,4DAAmE;AAEnE,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,eAAK,CAAC,KAAK,EAAE,CAAA;IACb,mBAAS,CAAC,KAAK,EAAE,CAAA;IAEjB,MAAM,aAAa,GAAG,IAAA,wCAAwB,EAAC,GAAG,CAAC,CAAA;IAEnD,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAE/C,MAAM,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAiB,EAAC,4CAA4C,CAAC,CAAA;QAElF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAiB,EAAC,4CAA4C,CAAC,CAAA;QAElF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACnC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { State, Endpoints } from '@sentio/runtime'\nimport { getERC20TokenInfo } from './token'\nimport { loadTestProvidersFromEnv } from '../testing/test-provider'\n\ndescribe('erc20 tests', () => {\n State.reset()\n Endpoints.reset()\n\n const haveProviders = loadTestProvidersFromEnv('1')\n\n const testIf = haveProviders ? test : test.skip\n\n testIf('test bytes32', async () => {\n const info = await getERC20TokenInfo('0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2')\n\n expect(info.decimal).toEqual(18)\n expect(info.symbol).toEqual('MKR')\n expect(info.name).toEqual('Maker')\n })\n\n testIf('test normal', async () => {\n const info = await getERC20TokenInfo('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')\n\n expect(info.decimal).toEqual(6)\n expect(info.symbol).toEqual('USDC')\n expect(info.name).toEqual('USD Coin')\n })\n})\n"]}
|
package/lib/utils/price.js
CHANGED
|
@@ -4,9 +4,10 @@ exports.getPriceBySymbol = exports.getPriceByType = exports.getPriceClient = voi
|
|
|
4
4
|
const price_1 = require("@sentio/protos/lib/service/price/protos/price");
|
|
5
5
|
const nice_grpc_1 = require("nice-grpc");
|
|
6
6
|
const nice_grpc_client_middleware_retry_1 = require("nice-grpc-client-middleware-retry");
|
|
7
|
+
const runtime_1 = require("@sentio/runtime");
|
|
7
8
|
function getPriceClient(address) {
|
|
8
9
|
if (!address) {
|
|
9
|
-
address =
|
|
10
|
+
address = runtime_1.Endpoints.INSTANCE.priceFeedAPI;
|
|
10
11
|
}
|
|
11
12
|
const channel = (0, nice_grpc_1.createChannel)(address);
|
|
12
13
|
return (0, nice_grpc_1.createClientFactory)().use(nice_grpc_client_middleware_retry_1.retryMiddleware).create(price_1.PriceServiceDefinition, channel);
|
package/lib/utils/price.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":";;;AAAA,yEAA0G;AAC1G,yCAA8D;AAC9D,yFAAiF;
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":";;;AAAA,yEAA0G;AAC1G,yCAA8D;AAC9D,yFAAiF;AACjF,6CAA2C;AAE3C,SAAgB,cAAc,CAAC,OAAgB;IAC7C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,mBAAS,CAAC,QAAQ,CAAC,YAAY,CAAA;KAC1C;IACD,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,OAAO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c,EAAE,CAAA;KAC/B;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;IAChC,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,OAAO,EAAE,CAAA;IAClC,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,KAAK,EAAE;QACT,OAAO,KAAK,CAAA;KACb;IAED,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,QAAQ,CACzC;QACE,SAAS,EAAE,IAAI;QACf,MAAM,EAAE;YACN,MAAM;SACP;KACF,EACD;QACE,KAAK,EAAE,IAAI;QACX,gBAAgB,EAAE,CAAC;KACpB,CACF,CAAA;IACD,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAA;IACtB,IAAI,QAAQ,CAAC,SAAS,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,OAAO,EAAE;QACpE,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;KACzB;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AA7BD,4CA6BC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACrF,CAAC","sourcesContent":["import { PriceServiceClient, PriceServiceDefinition } from '@sentio/protos/lib/service/price/protos/price'\nimport { createChannel, createClientFactory } from 'nice-grpc'\nimport { retryMiddleware, RetryOptions } from 'nice-grpc-client-middleware-retry'\nimport { Endpoints } from '@sentio/runtime'\n\nexport function getPriceClient(address?: string) {\n if (!address) {\n address = Endpoints.INSTANCE.priceFeedAPI\n }\n const channel = createChannel(address)\n\n return createClientFactory().use(retryMiddleware).create(PriceServiceDefinition, channel)\n}\n\nconst priceMap = new Map<string, number>()\nlet priceClient: PriceServiceClient<RetryOptions>\n\n/**\n *\n * @param chainId chain id refers to CHAIN_MAP\n * @param coinType\n * @param date\n */\nexport async function getPriceByType(chainId: string, coinType: string, date: Date): Promise<number> {\n if (!priceClient) {\n priceClient = getPriceClient()\n }\n\n const dateStr = dateString(date)\n const key = `${coinType}-${dateStr}`\n let price = priceMap.get(key)\n if (price) {\n return price\n }\n\n const response = await priceClient.getPrice(\n {\n timestamp: date,\n coinId: {\n address: {\n chain: chainId,\n address: coinType,\n },\n },\n },\n {\n retry: true,\n retryMaxAttempts: 8,\n }\n )\n price = response.price\n if (response.timestamp && dateString(response.timestamp) === dateStr) {\n priceMap.set(key, price)\n }\n return price\n}\n\n/**\n *\n * @param symbol token symbol like BTC, etc\n * @param date\n */\nexport async function getPriceBySymbol(symbol: string, date: Date): Promise<number> {\n if (!priceClient) {\n priceClient = getPriceClient()\n }\n\n const dateStr = dateString(date)\n const key = `${symbol}-${dateStr}`\n let price = priceMap.get(key)\n if (price) {\n return price\n }\n\n const response = await priceClient.getPrice(\n {\n timestamp: date,\n coinId: {\n symbol,\n },\n },\n {\n retry: true,\n retryMaxAttempts: 8,\n }\n )\n price = response.price\n if (response.timestamp && dateString(response.timestamp) === dateStr) {\n priceMap.set(key, price)\n }\n return price\n}\n\nfunction dateString(date: Date) {\n return [date.getUTCDate(), date.getUTCMonth() + 1, date.getUTCFullYear()].join('-')\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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.7",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/utils/*.csv lib/utils",
|
|
8
8
|
"build": "yarn gen && yarn compile",
|
|
9
9
|
"build_all": "yarn lerna run --scope=@sentio/sdk build --include-dependencies",
|
|
10
|
-
"start_ts": "ts-node --files src/processor-runner.ts --log-format=json
|
|
11
|
-
"start": "ts-node --files src/processor-runner.ts
|
|
10
|
+
"start_ts": "ts-node --files ../runtime/src/processor-runner.ts --log-format=json ../../examples/x2y2/src/processor.ts",
|
|
11
|
+
"start": "ts-node --files ../runtime/src/processor-runner.ts ../../examples/aptos/dist/lib.js",
|
|
12
12
|
"start_js": "node lib/processor-runner.js ../examples/aptos/dist/lib.js",
|
|
13
|
-
"ts-start": "ts-node --files src/processor-runner.ts ./src/anyswap/src/processor.ts",
|
|
13
|
+
"ts-start": "ts-node --files ../runtime/src/processor-runner.ts ./src/anyswap/src/processor.ts",
|
|
14
14
|
"test": "jest",
|
|
15
15
|
"test-nocache": "yarn jest --clearCache && yarn jest",
|
|
16
16
|
"gen": "yarn compile_target && yarn gen_bultin_evm",
|
|
@@ -18,22 +18,17 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@ethersproject/providers": "~5.7.0",
|
|
21
|
-
"@sentio/
|
|
22
|
-
"@sentio/
|
|
23
|
-
"@sentio/
|
|
21
|
+
"@sentio/cli": "^1.37.0-rc.7",
|
|
22
|
+
"@sentio/protos": "^1.37.0-rc.7",
|
|
23
|
+
"@sentio/runtime": "^1.37.0-rc.7",
|
|
24
24
|
"@typechain/ethers-v5": "^10.0.0",
|
|
25
25
|
"bignumber.js": "^9.1.0",
|
|
26
26
|
"command-line-args": "^5.2.1",
|
|
27
27
|
"command-line-usage": "^6.1.3",
|
|
28
28
|
"csv-parse": "^5.3.0",
|
|
29
29
|
"ethers": "~5.7.1",
|
|
30
|
-
"fs-extra": "^11.0.0",
|
|
31
30
|
"google-protobuf": "^3.15.8",
|
|
32
|
-
"js-yaml": "^4.1.0",
|
|
33
31
|
"nice-grpc": "^2.0.0",
|
|
34
|
-
"nice-grpc-client-middleware-retry": "^2.0.1",
|
|
35
|
-
"nice-grpc-error-details": "^0.1.4",
|
|
36
|
-
"p-queue": "^6.6.2",
|
|
37
32
|
"typechain": "^8.0.0",
|
|
38
33
|
"winston": "^3.8.2"
|
|
39
34
|
},
|
|
@@ -46,17 +41,13 @@
|
|
|
46
41
|
"@types/expect": "^24.3.0",
|
|
47
42
|
"@types/fs-extra": "^9.0.13",
|
|
48
43
|
"@types/google-protobuf": "^3.15.6",
|
|
49
|
-
"@types/js-yaml": "^4.0.5",
|
|
50
44
|
"@types/node": "^18.0.4"
|
|
51
45
|
},
|
|
52
|
-
"bin": {
|
|
53
|
-
"processor-runner": "./lib/processor-runner.js"
|
|
54
|
-
},
|
|
55
46
|
"main": "./lib/index.js",
|
|
56
47
|
"types": "./lib/index.d.ts",
|
|
57
48
|
"module": "./lib/index.js",
|
|
58
49
|
"files": [
|
|
59
|
-
"{lib,src
|
|
50
|
+
"{lib,src}",
|
|
60
51
|
"!{lib,src}/tests",
|
|
61
52
|
"!**/*.test.{js,ts}"
|
|
62
53
|
],
|
|
@@ -66,5 +57,5 @@
|
|
|
66
57
|
"typedoc": {
|
|
67
58
|
"entryPoint": "./src/index.ts"
|
|
68
59
|
},
|
|
69
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "123d4665245fbe433935dd4405ded58c13b2a994"
|
|
70
61
|
}
|
package/src/binds.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BaseProcessor, ContractView } from './core'
|
|
|
3
3
|
import { Networkish } from '@ethersproject/networks'
|
|
4
4
|
import { getNetwork } from '@ethersproject/providers'
|
|
5
5
|
import { BaseContract } from 'ethers'
|
|
6
|
-
import { MapStateStorage } from '@sentio/
|
|
6
|
+
import { MapStateStorage } from '@sentio/runtime'
|
|
7
7
|
|
|
8
8
|
export class ProcessorState extends MapStateStorage<BaseProcessor<any, any>> {
|
|
9
9
|
static INSTANCE = new ProcessorState()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ListStateStorage } from '@sentio/
|
|
1
|
+
import { ListStateStorage } from '@sentio/runtime'
|
|
2
2
|
import { ERC20__factory, ERC721__factory } from '../builtin/internal'
|
|
3
3
|
import { AddressType, DummyProvider, ProcessResult } from '@sentio/sdk'
|
|
4
4
|
import { AccountBindOptions } from './bind-options'
|
|
@@ -8,7 +8,7 @@ import { HandleInterval, TemplateInstance } from '@sentio/protos'
|
|
|
8
8
|
import { getNetwork } from '@ethersproject/providers'
|
|
9
9
|
import { PromiseOrVoid } from '../promise-or-void'
|
|
10
10
|
import { Trace } from './trace'
|
|
11
|
-
import { ListStateStorage } from '@sentio/
|
|
11
|
+
import { ListStateStorage } from '@sentio/runtime'
|
|
12
12
|
|
|
13
13
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
|
14
14
|
BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Plugin, PluginManager } from '@sentio/runtime'
|
|
2
|
+
import { ProcessConfigResponse } from '@sentio/protos'
|
|
3
|
+
|
|
4
|
+
import { MetricState } from './meter'
|
|
5
|
+
import { EventTrackerState } from './event-tracker'
|
|
6
|
+
import { ExporterState } from './exporter'
|
|
7
|
+
|
|
8
|
+
export class CorePlugin extends Plugin {
|
|
9
|
+
name: string = 'CorePlugin'
|
|
10
|
+
|
|
11
|
+
configure(config: ProcessConfigResponse): void {
|
|
12
|
+
// part 0, prepare metrics and event tracking configs
|
|
13
|
+
for (const metric of MetricState.INSTANCE.getValues()) {
|
|
14
|
+
config.metricConfigs.push({
|
|
15
|
+
...metric.config,
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
for (const eventTracker of EventTrackerState.INSTANCE.getValues()) {
|
|
20
|
+
config.eventTrackingConfigs.push({
|
|
21
|
+
distinctAggregationByDays: eventTracker.options.distinctByDays || [],
|
|
22
|
+
eventName: eventTracker.name,
|
|
23
|
+
retentionConfig: undefined,
|
|
24
|
+
totalByDay: eventTracker.options.totalByDay || false,
|
|
25
|
+
totalPerEntity: undefined,
|
|
26
|
+
unique: eventTracker.options.unique || false,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
for (const exporter of ExporterState.INSTANCE.getValues()) {
|
|
31
|
+
config.exportConfigs.push({
|
|
32
|
+
name: exporter.name,
|
|
33
|
+
channel: exporter.channel,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
PluginManager.INSTANCE.register(new CorePlugin())
|