@sentio/runtime 2.62.7 → 2.63.0-rc2.2
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/chunk-36V5YZUD.js +25925 -0
- package/lib/chunk-36V5YZUD.js.map +1 -0
- package/lib/chunk-6XHWJ2VS.js +92 -0
- package/lib/{chunk-WHWNPZZ3.js.map → chunk-6XHWJ2VS.js.map} +1 -1
- package/lib/chunk-CPJKSHSV.js +10976 -0
- package/lib/{chunk-XI22N6AJ.js.map → chunk-CPJKSHSV.js.map} +1 -1
- package/lib/chunk-FLUYK6N3.js +60177 -0
- package/lib/{chunk-BMMTCRYG.js.map → chunk-FLUYK6N3.js.map} +1 -1
- package/lib/chunk-KVSDPGUI.js +50 -0
- package/lib/chunk-L2A6JPIQ.js +21 -0
- package/lib/{chunk-CJDESLYQ.js.map → chunk-L2A6JPIQ.js.map} +1 -1
- package/lib/chunk-MV6JXS2P.js +1703 -0
- package/lib/{chunk-G6HW3DCN.js.map → chunk-MV6JXS2P.js.map} +1 -1
- package/lib/getMachineId-bsd-ZJR2OQTA.js +41 -0
- package/lib/{getMachineId-bsd-I6PJXCQT.js.map → getMachineId-bsd-ZJR2OQTA.js.map} +1 -1
- package/lib/getMachineId-darwin-OW6SYINH.js +41 -0
- package/lib/{getMachineId-darwin-HKHV3WMW.js.map → getMachineId-darwin-OW6SYINH.js.map} +1 -1
- package/lib/getMachineId-linux-L5XPRJBN.js +33 -0
- package/lib/{getMachineId-linux-I76A7IOE.js.map → getMachineId-linux-L5XPRJBN.js.map} +1 -1
- package/lib/getMachineId-unsupported-B3NMIOO3.js +24 -0
- package/lib/{getMachineId-unsupported-VPOZWIZS.js.map → getMachineId-unsupported-B3NMIOO3.js.map} +1 -1
- package/lib/getMachineId-win-TT64F63B.js +43 -0
- package/lib/{getMachineId-win-W5S4EK74.js.map → getMachineId-win-TT64F63B.js.map} +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +76 -1
- package/lib/index.js.map +1 -1
- package/lib/{processor-CIR4erWa.d.ts → processor-C-5LJT6m.d.ts} +5 -0
- package/lib/processor-runner.js +32977 -47
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +132 -2
- package/lib/service-worker.js.map +1 -1
- package/lib/test-processor.test.d.ts +1 -1
- package/lib/test-processor.test.js.map +1 -1
- package/package.json +6 -1
- package/src/full-service.ts +22 -0
- package/src/gen/processor/protos/processor.ts +90 -2
- package/lib/chunk-3A7UBKPA.js +0 -26
- package/lib/chunk-3A7UBKPA.js.map +0 -1
- package/lib/chunk-AUPVVLD3.js +0 -3
- package/lib/chunk-BMMTCRYG.js +0 -117
- package/lib/chunk-CJDESLYQ.js +0 -3
- package/lib/chunk-G6HW3DCN.js +0 -3
- package/lib/chunk-WHWNPZZ3.js +0 -3
- package/lib/chunk-XI22N6AJ.js +0 -38
- package/lib/getMachineId-bsd-I6PJXCQT.js +0 -3
- package/lib/getMachineId-darwin-HKHV3WMW.js +0 -4
- package/lib/getMachineId-linux-I76A7IOE.js +0 -3
- package/lib/getMachineId-unsupported-VPOZWIZS.js +0 -3
- package/lib/getMachineId-win-W5S4EK74.js +0 -3
- /package/lib/{chunk-AUPVVLD3.js.map → chunk-KVSDPGUI.js.map} +0 -0
package/lib/service-worker.js
CHANGED
|
@@ -1,4 +1,134 @@
|
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
setupLogger
|
|
4
|
+
} from "./chunk-CPJKSHSV.js";
|
|
5
|
+
import {
|
|
6
|
+
ProcessorServiceImpl,
|
|
7
|
+
configureEndpoints,
|
|
8
|
+
errorString,
|
|
9
|
+
freezeGlobalConfig,
|
|
10
|
+
require_cjs,
|
|
11
|
+
require_lib3 as require_lib,
|
|
12
|
+
require_lib4 as require_lib2
|
|
13
|
+
} from "./chunk-FLUYK6N3.js";
|
|
14
|
+
import "./chunk-36V5YZUD.js";
|
|
15
|
+
import "./chunk-MV6JXS2P.js";
|
|
16
|
+
import {
|
|
17
|
+
__toESM
|
|
18
|
+
} from "./chunk-KVSDPGUI.js";
|
|
19
|
+
|
|
20
|
+
// src/service-worker.ts
|
|
21
|
+
var import_nice_grpc = __toESM(require_lib(), 1);
|
|
22
|
+
var import_nice_grpc_error_details = __toESM(require_lib2(), 1);
|
|
23
|
+
import { threadId } from "worker_threads";
|
|
24
|
+
import { Piscina } from "piscina";
|
|
25
|
+
var import_rxjs = __toESM(require_cjs(), 1);
|
|
26
|
+
var started = false;
|
|
27
|
+
var unhandled;
|
|
28
|
+
process.on("uncaughtException", (err) => {
|
|
29
|
+
console.error("Uncaught Exception, please checking if await is properly used", err);
|
|
30
|
+
unhandled = err;
|
|
31
|
+
}).on("unhandledRejection", (reason, p) => {
|
|
32
|
+
if (reason?.message.startsWith('invalid ENS name (disallowed character: "*"')) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.error("Unhandled Rejection, please checking if await is properly", reason);
|
|
36
|
+
unhandled = reason;
|
|
37
|
+
}).on("exit", () => {
|
|
38
|
+
console.info("Worker thread exiting, threadId:", threadId);
|
|
39
|
+
});
|
|
40
|
+
var service;
|
|
41
|
+
var loader = async (options) => {
|
|
42
|
+
if (options.target) {
|
|
43
|
+
const m = await import(options.target);
|
|
44
|
+
console.debug("Module loaded, path:", options.target, "module:", m);
|
|
45
|
+
return m;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var emptyCallContext = {};
|
|
49
|
+
async function start(request, options) {
|
|
50
|
+
if (started) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
freezeGlobalConfig();
|
|
54
|
+
try {
|
|
55
|
+
service = new ProcessorServiceImpl(() => loader(options), options);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Failed to load processor: " + errorString(e));
|
|
58
|
+
}
|
|
59
|
+
await service.start(request, emptyCallContext);
|
|
60
|
+
started = true;
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
async function service_worker_default({
|
|
64
|
+
processId,
|
|
65
|
+
request: firstRequest,
|
|
66
|
+
workerPort
|
|
67
|
+
}) {
|
|
68
|
+
const { startRequest, configRequest, options } = Piscina.workerData;
|
|
69
|
+
if (!started) {
|
|
70
|
+
const logLevel = process.env["LOG_LEVEL"]?.toUpperCase();
|
|
71
|
+
setupLogger(options.logFormat === "json", logLevel === "debug" ? true : options.debug, threadId);
|
|
72
|
+
configureEndpoints(options);
|
|
73
|
+
if (startRequest) {
|
|
74
|
+
await start(startRequest, options);
|
|
75
|
+
console.debug("worker", threadId, " started, template instance:", startRequest.templateInstances?.length);
|
|
76
|
+
}
|
|
77
|
+
if (configRequest) {
|
|
78
|
+
await service?.getConfig(configRequest, emptyCallContext);
|
|
79
|
+
console.debug("worker", threadId, " configured");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (unhandled) {
|
|
83
|
+
const err = unhandled;
|
|
84
|
+
unhandled = void 0;
|
|
85
|
+
console.error("Unhandled exception/rejection in previous request:", err);
|
|
86
|
+
throw new import_nice_grpc_error_details.RichServerError(
|
|
87
|
+
import_nice_grpc.Status.UNAVAILABLE,
|
|
88
|
+
"Unhandled exception/rejection in previous request: " + errorString(err),
|
|
89
|
+
[
|
|
90
|
+
import_nice_grpc_error_details.DebugInfo.fromPartial({
|
|
91
|
+
detail: err.message,
|
|
92
|
+
stackEntries: err.stack?.split("\n")
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const timeout = (options.workerTimeout || 0) * 1e3;
|
|
98
|
+
const enablePartition = options.enablePartition || false;
|
|
99
|
+
await new Promise((resolve, reject) => {
|
|
100
|
+
const subject = new import_rxjs.Subject();
|
|
101
|
+
let timeoutId = void 0;
|
|
102
|
+
subject.subscribe((resp) => {
|
|
103
|
+
console.debug("Worker", threadId, "send response:", resp.result ? "result" : "dbResult");
|
|
104
|
+
workerPort.postMessage(resp);
|
|
105
|
+
if (resp.result) {
|
|
106
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
107
|
+
resolve();
|
|
108
|
+
workerPort.close();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
workerPort.on("message", (msg) => {
|
|
112
|
+
const request = msg;
|
|
113
|
+
console.debug("Worker", threadId, "received request:", request.start ? "start" : "dbResult");
|
|
114
|
+
service?.handleRequest(request, firstRequest.binding, subject);
|
|
115
|
+
if (enablePartition && request.start && timeout > 0) {
|
|
116
|
+
timeoutId = setTimeout(async () => {
|
|
117
|
+
reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
|
|
118
|
+
}, timeout);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
console.debug("Worker", threadId, "handle request: binding");
|
|
122
|
+
service?.handleRequest(firstRequest, firstRequest.binding, subject);
|
|
123
|
+
if (!enablePartition && timeout > 0) {
|
|
124
|
+
timeoutId = setTimeout(() => {
|
|
125
|
+
reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
|
|
126
|
+
}, timeout);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
import("node:process").then((p) => p.stdout.write(""));
|
|
131
|
+
export {
|
|
132
|
+
service_worker_default as default
|
|
133
|
+
};
|
|
4
134
|
//# sourceMappingURL=service-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import { DeepPartial, Empty, ProcessStreamRequest, ProcessStreamResponse, StartRequest } from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { errorString } from './utils.js'\nimport { freezeGlobalConfig } from './global-config.js'\nimport { DebugInfo, RichServerError } from 'nice-grpc-error-details'\nimport { ProcessorServiceImpl } from './service.js'\nimport { MessagePort, threadId } from 'worker_threads'\nimport { Piscina } from 'piscina'\nimport { configureEndpoints } from './endpoints.js'\nimport { setupLogger } from './logger.js'\nimport { Subject } from 'rxjs'\nimport { ProcessorRuntimeOptions } from 'processor-runner-program.js'\n\nlet started = false\n\nlet unhandled: Error | undefined\n\nprocess\n .on('uncaughtException', (err) => {\n console.error('Uncaught Exception, please checking if await is properly used', err)\n unhandled = err\n })\n .on('unhandledRejection', (reason, p) => {\n // @ts-ignore ignore invalid ens error\n if (reason?.message.startsWith('invalid ENS name (disallowed character: \"*\"')) {\n return\n }\n console.error('Unhandled Rejection, please checking if await is properly', reason)\n unhandled = reason as Error\n // shutdownServers(1)\n })\n .on('exit', () => {\n console.info('Worker thread exiting, threadId:', threadId)\n })\n\nlet service: ProcessorServiceImpl | undefined\n\nconst loader = async (options: ProcessorRuntimeOptions) => {\n if (options.target) {\n const m = await import(options.target)\n console.debug('Module loaded, path:', options.target, 'module:', m)\n return m\n }\n}\n\nconst emptyCallContext = <CallContext>{}\n\nasync function start(request: StartRequest, options: ProcessorRuntimeOptions): Promise<Empty> {\n if (started) {\n return {}\n }\n freezeGlobalConfig()\n\n try {\n service = new ProcessorServiceImpl(() => loader(options), options)\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await service.start(request, emptyCallContext)\n started = true\n return {}\n}\n\nexport default async function ({\n processId,\n request: firstRequest,\n workerPort\n}: {\n processId: number\n request: ProcessStreamRequest\n workerPort: MessagePort\n}) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (!started) {\n const logLevel = process.env['LOG_LEVEL']?.toUpperCase()\n setupLogger(options.logFormat === 'json', logLevel === 'debug' ? true : options.debug, threadId)\n\n configureEndpoints(options)\n\n if (startRequest) {\n await start(startRequest, options)\n console.debug('worker', threadId, ' started, template instance:', startRequest.templateInstances?.length)\n }\n\n if (configRequest) {\n await service?.getConfig(configRequest, emptyCallContext)\n console.debug('worker', threadId, ' configured')\n }\n }\n\n if (unhandled) {\n const err = unhandled\n unhandled = undefined\n console.error('Unhandled exception/rejection in previous request:', err)\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(err),\n [\n DebugInfo.fromPartial({\n detail: err.message,\n stackEntries: err.stack?.split('\\n')\n })\n ]\n )\n }\n const timeout = (options.workerTimeout || 0) * 1000 // convert to milliseconds\n const enablePartition = options.enablePartition || false\n await new Promise<void>((resolve, reject) => {\n const subject = new Subject<DeepPartial<ProcessStreamResponse>>()\n let timeoutId: NodeJS.Timeout | undefined = undefined\n subject.subscribe((resp: ProcessStreamResponse) => {\n console.debug('Worker', threadId, 'send response:', resp.result ? 'result' : 'dbResult')\n workerPort.postMessage(resp)\n // receive the response from the processor , close and resolve the promise\n if (resp.result) {\n if (timeoutId) clearTimeout(timeoutId)\n resolve()\n workerPort.close()\n }\n })\n workerPort.on('message', (msg: ProcessStreamRequest) => {\n const request = msg as ProcessStreamRequest\n console.debug('Worker', threadId, 'received request:', request.start ? 'start' : 'dbResult')\n service?.handleRequest(request, firstRequest.binding, subject)\n if (enablePartition && request.start && timeout > 0) {\n timeoutId = setTimeout(async () => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n console.debug('Worker', threadId, 'handle request: binding')\n service?.handleRequest(firstRequest, firstRequest.binding, subject)\n if (!enablePartition && timeout > 0) {\n timeoutId = setTimeout(() => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/service-worker.ts"],"sourcesContent":["import { DeepPartial, Empty, ProcessStreamRequest, ProcessStreamResponse, StartRequest } from '@sentio/protos'\nimport { CallContext, ServerError, Status } from 'nice-grpc'\nimport { errorString } from './utils.js'\nimport { freezeGlobalConfig } from './global-config.js'\nimport { DebugInfo, RichServerError } from 'nice-grpc-error-details'\nimport { ProcessorServiceImpl } from './service.js'\nimport { MessagePort, threadId } from 'worker_threads'\nimport { Piscina } from 'piscina'\nimport { configureEndpoints } from './endpoints.js'\nimport { setupLogger } from './logger.js'\nimport { Subject } from 'rxjs'\nimport { ProcessorRuntimeOptions } from 'processor-runner-program.js'\n\nlet started = false\n\nlet unhandled: Error | undefined\n\nprocess\n .on('uncaughtException', (err) => {\n console.error('Uncaught Exception, please checking if await is properly used', err)\n unhandled = err\n })\n .on('unhandledRejection', (reason, p) => {\n // @ts-ignore ignore invalid ens error\n if (reason?.message.startsWith('invalid ENS name (disallowed character: \"*\"')) {\n return\n }\n console.error('Unhandled Rejection, please checking if await is properly', reason)\n unhandled = reason as Error\n // shutdownServers(1)\n })\n .on('exit', () => {\n console.info('Worker thread exiting, threadId:', threadId)\n })\n\nlet service: ProcessorServiceImpl | undefined\n\nconst loader = async (options: ProcessorRuntimeOptions) => {\n if (options.target) {\n const m = await import(options.target)\n console.debug('Module loaded, path:', options.target, 'module:', m)\n return m\n }\n}\n\nconst emptyCallContext = <CallContext>{}\n\nasync function start(request: StartRequest, options: ProcessorRuntimeOptions): Promise<Empty> {\n if (started) {\n return {}\n }\n freezeGlobalConfig()\n\n try {\n service = new ProcessorServiceImpl(() => loader(options), options)\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await service.start(request, emptyCallContext)\n started = true\n return {}\n}\n\nexport default async function ({\n processId,\n request: firstRequest,\n workerPort\n}: {\n processId: number\n request: ProcessStreamRequest\n workerPort: MessagePort\n}) {\n const { startRequest, configRequest, options } = Piscina.workerData\n if (!started) {\n const logLevel = process.env['LOG_LEVEL']?.toUpperCase()\n setupLogger(options.logFormat === 'json', logLevel === 'debug' ? true : options.debug, threadId)\n\n configureEndpoints(options)\n\n if (startRequest) {\n await start(startRequest, options)\n console.debug('worker', threadId, ' started, template instance:', startRequest.templateInstances?.length)\n }\n\n if (configRequest) {\n await service?.getConfig(configRequest, emptyCallContext)\n console.debug('worker', threadId, ' configured')\n }\n }\n\n if (unhandled) {\n const err = unhandled\n unhandled = undefined\n console.error('Unhandled exception/rejection in previous request:', err)\n throw new RichServerError(\n Status.UNAVAILABLE,\n 'Unhandled exception/rejection in previous request: ' + errorString(err),\n [\n DebugInfo.fromPartial({\n detail: err.message,\n stackEntries: err.stack?.split('\\n')\n })\n ]\n )\n }\n const timeout = (options.workerTimeout || 0) * 1000 // convert to milliseconds\n const enablePartition = options.enablePartition || false\n await new Promise<void>((resolve, reject) => {\n const subject = new Subject<DeepPartial<ProcessStreamResponse>>()\n let timeoutId: NodeJS.Timeout | undefined = undefined\n subject.subscribe((resp: ProcessStreamResponse) => {\n console.debug('Worker', threadId, 'send response:', resp.result ? 'result' : 'dbResult')\n workerPort.postMessage(resp)\n // receive the response from the processor , close and resolve the promise\n if (resp.result) {\n if (timeoutId) clearTimeout(timeoutId)\n resolve()\n workerPort.close()\n }\n })\n workerPort.on('message', (msg: ProcessStreamRequest) => {\n const request = msg as ProcessStreamRequest\n console.debug('Worker', threadId, 'received request:', request.start ? 'start' : 'dbResult')\n service?.handleRequest(request, firstRequest.binding, subject)\n if (enablePartition && request.start && timeout > 0) {\n timeoutId = setTimeout(async () => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n console.debug('Worker', threadId, 'handle request: binding')\n service?.handleRequest(firstRequest, firstRequest.binding, subject)\n if (!enablePartition && timeout > 0) {\n timeoutId = setTimeout(() => {\n reject(new RichServerError(Status.DEADLINE_EXCEEDED, 'Worker timeout exceeded'))\n }, timeout)\n }\n })\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,uBAAiD;AAGjD,qCAA2C;AAE3C,SAAsB,gBAAgB;AACtC,SAAS,eAAe;AA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AC;AAAA,QACjF,GAAG,OAAO;AAAA,MACZ;AAAA,IACF,CAAC;AACD,YAAQ,MAAM,UAAU,UAAU,yBAAyB;AAC3D,aAAS,cAAc,cAAc,aAAa,SAAS,OAAO;AAClE,QAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,kBAAY,WAAW,MAAM;AAC3B,eAAO,IAAI,+CAAgB,wBAAO,mBAAmB,yBAAyB,CAAC;AAAA,MACjF,GAAG,OAAO;AAAA,IACZ;AAAA,EACF,CAAC;AACH;AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin, D as DataBinding, a as ProcessResult, H as HandlerType } from './processor-
|
|
1
|
+
import { P as Plugin, D as DataBinding, a as ProcessResult, H as HandlerType } from './processor-C-5LJT6m.js';
|
|
2
2
|
import { ProcessStreamResponse_Partitions, InitResponse, ProcessConfigResponse } from '@sentio/protos';
|
|
3
3
|
import 'rxjs';
|
|
4
4
|
import 'node:async_hooks';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\nimport { AccountConfig, InitResponse, ProcessConfigResponse, ProcessStreamResponse_Partitions } from '@sentio/protos'\n\nexport class TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n\n async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {\n return {\n partitions: request.handlerIds.reduce(\n (acc, id) => ({\n ...acc,\n [id]: {\n userValue: 'test'\n }\n }),\n {}\n )\n }\n }\n\n async init(config: InitResponse): Promise<void> {\n config.chainIds = ['1']\n }\n\n async configure(config: ProcessConfigResponse, forChainId?: string): Promise<void> {\n config.accountConfigs = [\n AccountConfig.fromPartial({\n address: '0x',\n chainId: '1'\n })\n ]\n }\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/test-processor.test.ts"],"sourcesContent":["import { Plugin, PluginManager } from './plugin.js'\nimport { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'\nimport { AccountConfig, InitResponse, ProcessConfigResponse, ProcessStreamResponse_Partitions } from '@sentio/protos'\n\nexport class TestPlugin extends Plugin {\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n const dbContext = PluginManager.INSTANCE.dbContextLocalStorage.getStore()\n if (dbContext) {\n await dbContext.sendRequest({\n get: {\n entity: 'Test',\n id: '1'\n }\n })\n }\n\n return ProcessResult.fromPartial({\n states: {\n configUpdated: true\n }\n })\n }\n supportedHandlers = [HandlerType.UNKNOWN, HandlerType.ETH_LOG]\n\n async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {\n return {\n partitions: request.handlerIds.reduce(\n (acc, id) => ({\n ...acc,\n [id]: {\n userValue: 'test'\n }\n }),\n {}\n )\n }\n }\n\n async init(config: InitResponse): Promise<void> {\n config.chainIds = ['1']\n }\n\n async configure(config: ProcessConfigResponse, forChainId?: string): Promise<void> {\n config.accountConfigs = [\n AccountConfig.fromPartial({\n address: '0x',\n chainId: '1'\n })\n ]\n }\n}\n\nPluginManager.INSTANCE.plugins = []\nPluginManager.INSTANCE.register(new TestPlugin())\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;AAIO,IAAM,aAAN,cAAyB,OAAO;AAAA,EACrC,MAAM,eAAe,SAA8C;AACjE,UAAM,YAAY,cAAc,SAAS,sBAAsB,SAAS;AACxE,QAAI,WAAW;AACb,YAAM,UAAU,YAAY;AAAA,QAC1B,KAAK;AAAA,UACH,QAAQ;AAAA,UACR,IAAI;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,cAAc,YAAY;AAAA,MAC/B,QAAQ;AAAA,QACN,eAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,oBAAoB,iCAAyC;AAAA,EAE7D,MAAM,UAAU,SAAiE;AAC/E,WAAO;AAAA,MACL,YAAY,QAAQ,WAAW;AAAA,QAC7B,CAAC,KAAK,QAAQ;AAAA,UACZ,GAAG;AAAA,UACH,CAAC,EAAE,GAAG;AAAA,YACJ,WAAW;AAAA,UACb;AAAA,QACF;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,KAAK,QAAqC;AAC9C,WAAO,WAAW,CAAC,GAAG;AAAA,EACxB;AAAA,EAEA,MAAM,UAAU,QAA+B,YAAoC;AACjF,WAAO,iBAAiB;AAAA,MACtB,cAAc,YAAY;AAAA,QACxB,SAAS;AAAA,QACT,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,cAAc,SAAS,UAAU,CAAC;AAClC,cAAc,SAAS,SAAS,IAAI,WAAW,CAAC;AAC/C,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.63.0-rc2.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/sentioxyz/sentio-sdk.git",
|
|
8
|
+
"directory": "packages/runtime"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"exports": {
|
|
7
12
|
".": "./lib/index.js"
|
package/src/full-service.ts
CHANGED
|
@@ -136,6 +136,28 @@ export class RuntimeServicePatcher {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
break
|
|
139
|
+
case HandlerType.ETH_BLOCK:
|
|
140
|
+
const ethBlock = dataBinding.data?.ethBlock
|
|
141
|
+
if (ethBlock?.block == null && ethBlock?.rawBlock) {
|
|
142
|
+
ethBlock.block = getParsedData(ethBlock.rawBlock)
|
|
143
|
+
}
|
|
144
|
+
break
|
|
145
|
+
case HandlerType.ETH_TRACE:
|
|
146
|
+
const ethTrace = dataBinding.data?.ethTrace
|
|
147
|
+
if (ethTrace?.trace == null && ethTrace?.rawTrace) {
|
|
148
|
+
ethTrace.trace = getParsedData(ethTrace.rawTrace)
|
|
149
|
+
|
|
150
|
+
if (ethTrace.rawTransaction) {
|
|
151
|
+
ethTrace.transaction = getParsedData(ethTrace.rawTransaction)
|
|
152
|
+
}
|
|
153
|
+
if (ethTrace.rawBlock) {
|
|
154
|
+
ethTrace.block = getParsedData(ethTrace.rawBlock)
|
|
155
|
+
}
|
|
156
|
+
if (ethTrace.rawTransactionReceipt) {
|
|
157
|
+
ethTrace.transactionReceipt = getParsedData(ethTrace.rawTransactionReceipt)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
break
|
|
139
161
|
case HandlerType.FUEL_TRANSACTION:
|
|
140
162
|
if (compareSemver(this.sdkVersion, FUEL_PROTO_UPDATE_VERSION) < 0) {
|
|
141
163
|
dataBinding.handlerType = HandlerType.FUEL_CALL
|
|
@@ -1244,6 +1244,7 @@ export interface Data_EthLog {
|
|
|
1244
1244
|
|
|
1245
1245
|
export interface Data_EthBlock {
|
|
1246
1246
|
block: { [key: string]: any } | undefined;
|
|
1247
|
+
rawBlock: string;
|
|
1247
1248
|
}
|
|
1248
1249
|
|
|
1249
1250
|
export interface Data_EthTransaction {
|
|
@@ -1264,6 +1265,10 @@ export interface Data_EthTrace {
|
|
|
1264
1265
|
transaction?: { [key: string]: any } | undefined;
|
|
1265
1266
|
transactionReceipt?: { [key: string]: any } | undefined;
|
|
1266
1267
|
block?: { [key: string]: any } | undefined;
|
|
1268
|
+
rawTrace: string;
|
|
1269
|
+
rawTransaction?: string | undefined;
|
|
1270
|
+
rawTransactionReceipt?: string | undefined;
|
|
1271
|
+
rawBlock?: string | undefined;
|
|
1267
1272
|
}
|
|
1268
1273
|
|
|
1269
1274
|
export interface Data_SolInstruction {
|
|
@@ -10129,7 +10134,7 @@ export const Data_EthLog = {
|
|
|
10129
10134
|
};
|
|
10130
10135
|
|
|
10131
10136
|
function createBaseData_EthBlock(): Data_EthBlock {
|
|
10132
|
-
return { block: undefined };
|
|
10137
|
+
return { block: undefined, rawBlock: "" };
|
|
10133
10138
|
}
|
|
10134
10139
|
|
|
10135
10140
|
export const Data_EthBlock = {
|
|
@@ -10137,6 +10142,9 @@ export const Data_EthBlock = {
|
|
|
10137
10142
|
if (message.block !== undefined) {
|
|
10138
10143
|
Struct.encode(Struct.wrap(message.block), writer.uint32(18).fork()).ldelim();
|
|
10139
10144
|
}
|
|
10145
|
+
if (message.rawBlock !== "") {
|
|
10146
|
+
writer.uint32(10).string(message.rawBlock);
|
|
10147
|
+
}
|
|
10140
10148
|
return writer;
|
|
10141
10149
|
},
|
|
10142
10150
|
|
|
@@ -10154,6 +10162,13 @@ export const Data_EthBlock = {
|
|
|
10154
10162
|
|
|
10155
10163
|
message.block = Struct.unwrap(Struct.decode(reader, reader.uint32()));
|
|
10156
10164
|
continue;
|
|
10165
|
+
case 1:
|
|
10166
|
+
if (tag !== 10) {
|
|
10167
|
+
break;
|
|
10168
|
+
}
|
|
10169
|
+
|
|
10170
|
+
message.rawBlock = reader.string();
|
|
10171
|
+
continue;
|
|
10157
10172
|
}
|
|
10158
10173
|
if ((tag & 7) === 4 || tag === 0) {
|
|
10159
10174
|
break;
|
|
@@ -10164,7 +10179,10 @@ export const Data_EthBlock = {
|
|
|
10164
10179
|
},
|
|
10165
10180
|
|
|
10166
10181
|
fromJSON(object: any): Data_EthBlock {
|
|
10167
|
-
return {
|
|
10182
|
+
return {
|
|
10183
|
+
block: isObject(object.block) ? object.block : undefined,
|
|
10184
|
+
rawBlock: isSet(object.rawBlock) ? globalThis.String(object.rawBlock) : "",
|
|
10185
|
+
};
|
|
10168
10186
|
},
|
|
10169
10187
|
|
|
10170
10188
|
toJSON(message: Data_EthBlock): unknown {
|
|
@@ -10172,6 +10190,9 @@ export const Data_EthBlock = {
|
|
|
10172
10190
|
if (message.block !== undefined) {
|
|
10173
10191
|
obj.block = message.block;
|
|
10174
10192
|
}
|
|
10193
|
+
if (message.rawBlock !== "") {
|
|
10194
|
+
obj.rawBlock = message.rawBlock;
|
|
10195
|
+
}
|
|
10175
10196
|
return obj;
|
|
10176
10197
|
},
|
|
10177
10198
|
|
|
@@ -10181,6 +10202,7 @@ export const Data_EthBlock = {
|
|
|
10181
10202
|
fromPartial(object: DeepPartial<Data_EthBlock>): Data_EthBlock {
|
|
10182
10203
|
const message = createBaseData_EthBlock();
|
|
10183
10204
|
message.block = object.block ?? undefined;
|
|
10205
|
+
message.rawBlock = object.rawBlock ?? "";
|
|
10184
10206
|
return message;
|
|
10185
10207
|
},
|
|
10186
10208
|
};
|
|
@@ -10383,6 +10405,10 @@ function createBaseData_EthTrace(): Data_EthTrace {
|
|
|
10383
10405
|
transaction: undefined,
|
|
10384
10406
|
transactionReceipt: undefined,
|
|
10385
10407
|
block: undefined,
|
|
10408
|
+
rawTrace: "",
|
|
10409
|
+
rawTransaction: undefined,
|
|
10410
|
+
rawTransactionReceipt: undefined,
|
|
10411
|
+
rawBlock: undefined,
|
|
10386
10412
|
};
|
|
10387
10413
|
}
|
|
10388
10414
|
|
|
@@ -10403,6 +10429,18 @@ export const Data_EthTrace = {
|
|
|
10403
10429
|
if (message.block !== undefined) {
|
|
10404
10430
|
Struct.encode(Struct.wrap(message.block), writer.uint32(50).fork()).ldelim();
|
|
10405
10431
|
}
|
|
10432
|
+
if (message.rawTrace !== "") {
|
|
10433
|
+
writer.uint32(58).string(message.rawTrace);
|
|
10434
|
+
}
|
|
10435
|
+
if (message.rawTransaction !== undefined) {
|
|
10436
|
+
writer.uint32(66).string(message.rawTransaction);
|
|
10437
|
+
}
|
|
10438
|
+
if (message.rawTransactionReceipt !== undefined) {
|
|
10439
|
+
writer.uint32(74).string(message.rawTransactionReceipt);
|
|
10440
|
+
}
|
|
10441
|
+
if (message.rawBlock !== undefined) {
|
|
10442
|
+
writer.uint32(82).string(message.rawBlock);
|
|
10443
|
+
}
|
|
10406
10444
|
return writer;
|
|
10407
10445
|
},
|
|
10408
10446
|
|
|
@@ -10448,6 +10486,34 @@ export const Data_EthTrace = {
|
|
|
10448
10486
|
|
|
10449
10487
|
message.block = Struct.unwrap(Struct.decode(reader, reader.uint32()));
|
|
10450
10488
|
continue;
|
|
10489
|
+
case 7:
|
|
10490
|
+
if (tag !== 58) {
|
|
10491
|
+
break;
|
|
10492
|
+
}
|
|
10493
|
+
|
|
10494
|
+
message.rawTrace = reader.string();
|
|
10495
|
+
continue;
|
|
10496
|
+
case 8:
|
|
10497
|
+
if (tag !== 66) {
|
|
10498
|
+
break;
|
|
10499
|
+
}
|
|
10500
|
+
|
|
10501
|
+
message.rawTransaction = reader.string();
|
|
10502
|
+
continue;
|
|
10503
|
+
case 9:
|
|
10504
|
+
if (tag !== 74) {
|
|
10505
|
+
break;
|
|
10506
|
+
}
|
|
10507
|
+
|
|
10508
|
+
message.rawTransactionReceipt = reader.string();
|
|
10509
|
+
continue;
|
|
10510
|
+
case 10:
|
|
10511
|
+
if (tag !== 82) {
|
|
10512
|
+
break;
|
|
10513
|
+
}
|
|
10514
|
+
|
|
10515
|
+
message.rawBlock = reader.string();
|
|
10516
|
+
continue;
|
|
10451
10517
|
}
|
|
10452
10518
|
if ((tag & 7) === 4 || tag === 0) {
|
|
10453
10519
|
break;
|
|
@@ -10464,6 +10530,12 @@ export const Data_EthTrace = {
|
|
|
10464
10530
|
transaction: isObject(object.transaction) ? object.transaction : undefined,
|
|
10465
10531
|
transactionReceipt: isObject(object.transactionReceipt) ? object.transactionReceipt : undefined,
|
|
10466
10532
|
block: isObject(object.block) ? object.block : undefined,
|
|
10533
|
+
rawTrace: isSet(object.rawTrace) ? globalThis.String(object.rawTrace) : "",
|
|
10534
|
+
rawTransaction: isSet(object.rawTransaction) ? globalThis.String(object.rawTransaction) : undefined,
|
|
10535
|
+
rawTransactionReceipt: isSet(object.rawTransactionReceipt)
|
|
10536
|
+
? globalThis.String(object.rawTransactionReceipt)
|
|
10537
|
+
: undefined,
|
|
10538
|
+
rawBlock: isSet(object.rawBlock) ? globalThis.String(object.rawBlock) : undefined,
|
|
10467
10539
|
};
|
|
10468
10540
|
},
|
|
10469
10541
|
|
|
@@ -10484,6 +10556,18 @@ export const Data_EthTrace = {
|
|
|
10484
10556
|
if (message.block !== undefined) {
|
|
10485
10557
|
obj.block = message.block;
|
|
10486
10558
|
}
|
|
10559
|
+
if (message.rawTrace !== "") {
|
|
10560
|
+
obj.rawTrace = message.rawTrace;
|
|
10561
|
+
}
|
|
10562
|
+
if (message.rawTransaction !== undefined) {
|
|
10563
|
+
obj.rawTransaction = message.rawTransaction;
|
|
10564
|
+
}
|
|
10565
|
+
if (message.rawTransactionReceipt !== undefined) {
|
|
10566
|
+
obj.rawTransactionReceipt = message.rawTransactionReceipt;
|
|
10567
|
+
}
|
|
10568
|
+
if (message.rawBlock !== undefined) {
|
|
10569
|
+
obj.rawBlock = message.rawBlock;
|
|
10570
|
+
}
|
|
10487
10571
|
return obj;
|
|
10488
10572
|
},
|
|
10489
10573
|
|
|
@@ -10497,6 +10581,10 @@ export const Data_EthTrace = {
|
|
|
10497
10581
|
message.transaction = object.transaction ?? undefined;
|
|
10498
10582
|
message.transactionReceipt = object.transactionReceipt ?? undefined;
|
|
10499
10583
|
message.block = object.block ?? undefined;
|
|
10584
|
+
message.rawTrace = object.rawTrace ?? "";
|
|
10585
|
+
message.rawTransaction = object.rawTransaction ?? undefined;
|
|
10586
|
+
message.rawTransactionReceipt = object.rawTransactionReceipt ?? undefined;
|
|
10587
|
+
message.rawBlock = object.rawBlock ?? undefined;
|
|
10500
10588
|
return message;
|
|
10501
10589
|
},
|
|
10502
10590
|
};
|