@sentio/runtime 2.60.2 → 2.60.3-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chunk-2LXJZQSF.js +10975 -0
- package/lib/{chunk-NWI5IEZU.js.map → chunk-2LXJZQSF.js.map} +1 -1
- package/lib/chunk-6XHWJ2VS.js +92 -0
- package/lib/{chunk-WHWNPZZ3.js.map → chunk-6XHWJ2VS.js.map} +1 -1
- package/lib/chunk-J4QKUO6L.js +28408 -0
- package/lib/chunk-J4QKUO6L.js.map +1 -0
- package/lib/chunk-XIU7XZT7.js +59981 -0
- package/lib/{chunk-MW44ATDW.js.map → chunk-XIU7XZT7.js.map} +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +74 -1
- package/lib/index.js.map +1 -1
- package/lib/{processor-BDXlufg5.d.ts → processor-Cbun9NKJ.d.ts} +1 -0
- package/lib/processor-runner.js +26835 -21
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +130 -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 +1 -1
- package/src/gen/google/type/money.ts +122 -0
- package/src/gen/processor/protos/processor.ts +17 -1
- package/src/gen/service/common/protos/common.ts +339 -0
- package/lib/chunk-MW44ATDW.js +0 -117
- package/lib/chunk-NWI5IEZU.js +0 -38
- package/lib/chunk-WHWNPZZ3.js +0 -3
- package/lib/chunk-YYEA4PFJ.js +0 -26
- package/lib/chunk-YYEA4PFJ.js.map +0 -1
package/lib/service-worker.js
CHANGED
@@ -1,4 +1,132 @@
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
2
|
-
import
|
3
|
-
|
2
|
+
import {
|
3
|
+
setupLogger
|
4
|
+
} from "./chunk-2LXJZQSF.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-XIU7XZT7.js";
|
14
|
+
import {
|
15
|
+
__toESM
|
16
|
+
} from "./chunk-J4QKUO6L.js";
|
17
|
+
|
18
|
+
// src/service-worker.ts
|
19
|
+
var import_nice_grpc = __toESM(require_lib(), 1);
|
20
|
+
var import_nice_grpc_error_details = __toESM(require_lib2(), 1);
|
21
|
+
import { threadId } from "worker_threads";
|
22
|
+
import { Piscina } from "piscina";
|
23
|
+
var import_rxjs = __toESM(require_cjs(), 1);
|
24
|
+
var started = false;
|
25
|
+
var unhandled;
|
26
|
+
process.on("uncaughtException", (err) => {
|
27
|
+
console.error("Uncaught Exception, please checking if await is properly used", err);
|
28
|
+
unhandled = err;
|
29
|
+
}).on("unhandledRejection", (reason, p) => {
|
30
|
+
if (reason?.message.startsWith('invalid ENS name (disallowed character: "*"')) {
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
console.error("Unhandled Rejection, please checking if await is properly", reason);
|
34
|
+
unhandled = reason;
|
35
|
+
}).on("exit", () => {
|
36
|
+
console.info("Worker thread exiting, threadId:", threadId);
|
37
|
+
});
|
38
|
+
var service;
|
39
|
+
var loader = async (options) => {
|
40
|
+
if (options.target) {
|
41
|
+
const m = await import(options.target);
|
42
|
+
console.debug("Module loaded, path:", options.target, "module:", m);
|
43
|
+
return m;
|
44
|
+
}
|
45
|
+
};
|
46
|
+
var emptyCallContext = {};
|
47
|
+
async function start(request, options) {
|
48
|
+
if (started) {
|
49
|
+
return {};
|
50
|
+
}
|
51
|
+
freezeGlobalConfig();
|
52
|
+
try {
|
53
|
+
service = new ProcessorServiceImpl(() => loader(options), options);
|
54
|
+
} catch (e) {
|
55
|
+
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "Failed to load processor: " + errorString(e));
|
56
|
+
}
|
57
|
+
await service.start(request, emptyCallContext);
|
58
|
+
started = true;
|
59
|
+
return {};
|
60
|
+
}
|
61
|
+
async function service_worker_default({
|
62
|
+
processId,
|
63
|
+
request: firstRequest,
|
64
|
+
workerPort
|
65
|
+
}) {
|
66
|
+
const { startRequest, configRequest, options } = Piscina.workerData;
|
67
|
+
if (!started) {
|
68
|
+
const logLevel = process.env["LOG_LEVEL"]?.toUpperCase();
|
69
|
+
setupLogger(options["log-format"] === "json", logLevel === "debug" ? true : options.debug, threadId);
|
70
|
+
configureEndpoints(options);
|
71
|
+
if (startRequest) {
|
72
|
+
await start(startRequest, options);
|
73
|
+
console.debug("worker", threadId, " started, template instance:", startRequest.templateInstances?.length);
|
74
|
+
}
|
75
|
+
if (configRequest) {
|
76
|
+
await service?.getConfig(configRequest, emptyCallContext);
|
77
|
+
console.debug("worker", threadId, " configured");
|
78
|
+
}
|
79
|
+
}
|
80
|
+
if (unhandled) {
|
81
|
+
const err = unhandled;
|
82
|
+
unhandled = void 0;
|
83
|
+
console.error("Unhandled exception/rejection in previous request:", err);
|
84
|
+
throw new import_nice_grpc_error_details.RichServerError(
|
85
|
+
import_nice_grpc.Status.UNAVAILABLE,
|
86
|
+
"Unhandled exception/rejection in previous request: " + errorString(err),
|
87
|
+
[
|
88
|
+
import_nice_grpc_error_details.DebugInfo.fromPartial({
|
89
|
+
detail: err.message,
|
90
|
+
stackEntries: err.stack?.split("\n")
|
91
|
+
})
|
92
|
+
]
|
93
|
+
);
|
94
|
+
}
|
95
|
+
const timeout = (options["worker-timeout"] || 0) * 1e3;
|
96
|
+
const enablePartition = options["enable-partition"] || false;
|
97
|
+
await new Promise((resolve, reject) => {
|
98
|
+
const subject = new import_rxjs.Subject();
|
99
|
+
let timeoutId = void 0;
|
100
|
+
subject.subscribe((resp) => {
|
101
|
+
console.debug("Worker", threadId, "send response:", resp.result ? "result" : "dbResult");
|
102
|
+
workerPort.postMessage(resp);
|
103
|
+
if (resp.result) {
|
104
|
+
if (timeoutId) clearTimeout(timeoutId);
|
105
|
+
resolve();
|
106
|
+
workerPort.close();
|
107
|
+
}
|
108
|
+
});
|
109
|
+
workerPort.on("message", (msg) => {
|
110
|
+
const request = msg;
|
111
|
+
console.debug("Worker", threadId, "received request:", request.start ? "start" : "dbResult");
|
112
|
+
service?.handleRequest(request, firstRequest.binding, subject);
|
113
|
+
if (enablePartition && request.start && timeout > 0) {
|
114
|
+
timeoutId = setTimeout(async () => {
|
115
|
+
reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
|
116
|
+
}, timeout);
|
117
|
+
}
|
118
|
+
});
|
119
|
+
console.debug("Worker", threadId, "handle request: binding");
|
120
|
+
service?.handleRequest(firstRequest, firstRequest.binding, subject);
|
121
|
+
if (!enablePartition && timeout > 0) {
|
122
|
+
timeoutId = setTimeout(() => {
|
123
|
+
reject(new import_nice_grpc_error_details.RichServerError(import_nice_grpc.Status.DEADLINE_EXCEEDED, "Worker timeout exceeded"));
|
124
|
+
}, timeout);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
}
|
128
|
+
import("node:process").then((p) => p.stdout.write(""));
|
129
|
+
export {
|
130
|
+
service_worker_default as default
|
131
|
+
};
|
4
132
|
//# 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'\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: any) => {\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: any): 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['log-format'] === '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['worker-timeout'] || 0) * 1000 // convert to milliseconds\n const enablePartition = options['enable-partition'] || 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'\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: any) => {\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: any): 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['log-format'] === '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['worker-timeout'] || 0) * 1000 // convert to milliseconds\n const enablePartition = options['enable-partition'] || 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;AAGxB,kBAAwB;AAExB,IAAI,UAAU;AAEd,IAAI;AAEJ,QACG,GAAG,qBAAqB,CAAC,QAAQ;AAChC,UAAQ,MAAM,iEAAiE,GAAG;AAClF,cAAY;AACd,CAAC,EACA,GAAG,sBAAsB,CAAC,QAAQ,MAAM;AAEvC,MAAI,QAAQ,QAAQ,WAAW,6CAA6C,GAAG;AAC7E;AAAA,EACF;AACA,UAAQ,MAAM,6DAA6D,MAAM;AACjF,cAAY;AAEd,CAAC,EACA,GAAG,QAAQ,MAAM;AAChB,U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AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { P as Plugin, c as DataBinding, d as ProcessResult, H as HandlerType } from './processor-
|
1
|
+
import { P as Plugin, c as DataBinding, d as ProcessResult, H as HandlerType } from './processor-Cbun9NKJ.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
@@ -0,0 +1,122 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import Long from "long";
|
3
|
+
import _m0 from "protobufjs/minimal.js";
|
4
|
+
|
5
|
+
export interface Money {
|
6
|
+
currencyCode: string;
|
7
|
+
units: bigint;
|
8
|
+
nanos: number;
|
9
|
+
}
|
10
|
+
|
11
|
+
function createBaseMoney(): Money {
|
12
|
+
return { currencyCode: "", units: BigInt("0"), nanos: 0 };
|
13
|
+
}
|
14
|
+
|
15
|
+
export const Money = {
|
16
|
+
encode(message: Money, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
17
|
+
if (message.currencyCode !== "") {
|
18
|
+
writer.uint32(10).string(message.currencyCode);
|
19
|
+
}
|
20
|
+
if (message.units !== BigInt("0")) {
|
21
|
+
if (BigInt.asIntN(64, message.units) !== message.units) {
|
22
|
+
throw new globalThis.Error("value provided for field message.units of type int64 too large");
|
23
|
+
}
|
24
|
+
writer.uint32(16).int64(message.units.toString());
|
25
|
+
}
|
26
|
+
if (message.nanos !== 0) {
|
27
|
+
writer.uint32(24).int32(message.nanos);
|
28
|
+
}
|
29
|
+
return writer;
|
30
|
+
},
|
31
|
+
|
32
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Money {
|
33
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
34
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
35
|
+
const message = createBaseMoney();
|
36
|
+
while (reader.pos < end) {
|
37
|
+
const tag = reader.uint32();
|
38
|
+
switch (tag >>> 3) {
|
39
|
+
case 1:
|
40
|
+
if (tag !== 10) {
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
|
44
|
+
message.currencyCode = reader.string();
|
45
|
+
continue;
|
46
|
+
case 2:
|
47
|
+
if (tag !== 16) {
|
48
|
+
break;
|
49
|
+
}
|
50
|
+
|
51
|
+
message.units = longToBigint(reader.int64() as Long);
|
52
|
+
continue;
|
53
|
+
case 3:
|
54
|
+
if (tag !== 24) {
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
|
58
|
+
message.nanos = reader.int32();
|
59
|
+
continue;
|
60
|
+
}
|
61
|
+
if ((tag & 7) === 4 || tag === 0) {
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
reader.skipType(tag & 7);
|
65
|
+
}
|
66
|
+
return message;
|
67
|
+
},
|
68
|
+
|
69
|
+
fromJSON(object: any): Money {
|
70
|
+
return {
|
71
|
+
currencyCode: isSet(object.currencyCode) ? globalThis.String(object.currencyCode) : "",
|
72
|
+
units: isSet(object.units) ? BigInt(object.units) : BigInt("0"),
|
73
|
+
nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0,
|
74
|
+
};
|
75
|
+
},
|
76
|
+
|
77
|
+
toJSON(message: Money): unknown {
|
78
|
+
const obj: any = {};
|
79
|
+
if (message.currencyCode !== "") {
|
80
|
+
obj.currencyCode = message.currencyCode;
|
81
|
+
}
|
82
|
+
if (message.units !== BigInt("0")) {
|
83
|
+
obj.units = message.units.toString();
|
84
|
+
}
|
85
|
+
if (message.nanos !== 0) {
|
86
|
+
obj.nanos = Math.round(message.nanos);
|
87
|
+
}
|
88
|
+
return obj;
|
89
|
+
},
|
90
|
+
|
91
|
+
create(base?: DeepPartial<Money>): Money {
|
92
|
+
return Money.fromPartial(base ?? {});
|
93
|
+
},
|
94
|
+
fromPartial(object: DeepPartial<Money>): Money {
|
95
|
+
const message = createBaseMoney();
|
96
|
+
message.currencyCode = object.currencyCode ?? "";
|
97
|
+
message.units = object.units ?? BigInt("0");
|
98
|
+
message.nanos = object.nanos ?? 0;
|
99
|
+
return message;
|
100
|
+
},
|
101
|
+
};
|
102
|
+
|
103
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
104
|
+
|
105
|
+
type DeepPartial<T> = T extends Builtin ? T
|
106
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
107
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
108
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
109
|
+
: Partial<T>;
|
110
|
+
|
111
|
+
function longToBigint(long: Long) {
|
112
|
+
return BigInt(long.toString());
|
113
|
+
}
|
114
|
+
|
115
|
+
if (_m0.util.Long !== Long) {
|
116
|
+
_m0.util.Long = Long as any;
|
117
|
+
_m0.configure();
|
118
|
+
}
|
119
|
+
|
120
|
+
function isSet(value: any): boolean {
|
121
|
+
return value !== null && value !== undefined;
|
122
|
+
}
|
@@ -1422,6 +1422,7 @@ export interface DataBinding {
|
|
1422
1422
|
data: Data | undefined;
|
1423
1423
|
handlerType: HandlerType;
|
1424
1424
|
handlerIds: number[];
|
1425
|
+
chainId: string;
|
1425
1426
|
}
|
1426
1427
|
|
1427
1428
|
export interface StateResult {
|
@@ -13203,7 +13204,7 @@ export const Data_BTCBlock = {
|
|
13203
13204
|
};
|
13204
13205
|
|
13205
13206
|
function createBaseDataBinding(): DataBinding {
|
13206
|
-
return { data: undefined, handlerType: 0, handlerIds: [] };
|
13207
|
+
return { data: undefined, handlerType: 0, handlerIds: [], chainId: "" };
|
13207
13208
|
}
|
13208
13209
|
|
13209
13210
|
export const DataBinding = {
|
@@ -13219,6 +13220,9 @@ export const DataBinding = {
|
|
13219
13220
|
writer.int32(v);
|
13220
13221
|
}
|
13221
13222
|
writer.ldelim();
|
13223
|
+
if (message.chainId !== "") {
|
13224
|
+
writer.uint32(42).string(message.chainId);
|
13225
|
+
}
|
13222
13226
|
return writer;
|
13223
13227
|
},
|
13224
13228
|
|
@@ -13260,6 +13264,13 @@ export const DataBinding = {
|
|
13260
13264
|
}
|
13261
13265
|
|
13262
13266
|
break;
|
13267
|
+
case 5:
|
13268
|
+
if (tag !== 42) {
|
13269
|
+
break;
|
13270
|
+
}
|
13271
|
+
|
13272
|
+
message.chainId = reader.string();
|
13273
|
+
continue;
|
13263
13274
|
}
|
13264
13275
|
if ((tag & 7) === 4 || tag === 0) {
|
13265
13276
|
break;
|
@@ -13276,6 +13287,7 @@ export const DataBinding = {
|
|
13276
13287
|
handlerIds: globalThis.Array.isArray(object?.handlerIds)
|
13277
13288
|
? object.handlerIds.map((e: any) => globalThis.Number(e))
|
13278
13289
|
: [],
|
13290
|
+
chainId: isSet(object.chainId) ? globalThis.String(object.chainId) : "",
|
13279
13291
|
};
|
13280
13292
|
},
|
13281
13293
|
|
@@ -13290,6 +13302,9 @@ export const DataBinding = {
|
|
13290
13302
|
if (message.handlerIds?.length) {
|
13291
13303
|
obj.handlerIds = message.handlerIds.map((e) => Math.round(e));
|
13292
13304
|
}
|
13305
|
+
if (message.chainId !== "") {
|
13306
|
+
obj.chainId = message.chainId;
|
13307
|
+
}
|
13293
13308
|
return obj;
|
13294
13309
|
},
|
13295
13310
|
|
@@ -13301,6 +13316,7 @@ export const DataBinding = {
|
|
13301
13316
|
message.data = (object.data !== undefined && object.data !== null) ? Data.fromPartial(object.data) : undefined;
|
13302
13317
|
message.handlerType = object.handlerType ?? 0;
|
13303
13318
|
message.handlerIds = object.handlerIds?.map((e) => e) || [];
|
13319
|
+
message.chainId = object.chainId ?? "";
|
13304
13320
|
return message;
|
13305
13321
|
},
|
13306
13322
|
};
|