@sentio/runtime 2.40.0-rc.4 → 2.40.0-rc.41
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-QYVWD4BX.js +131 -0
- package/lib/chunk-QYVWD4BX.js.map +1 -0
- package/lib/index.d.ts +24 -9
- package/lib/index.js +2 -91
- package/lib/index.js.map +1 -0
- package/lib/processor-runner.d.ts +3 -0
- package/lib/processor-runner.js +58 -51468
- package/lib/processor-runner.js.map +1 -0
- package/package.json +1 -1
- package/src/db-context.ts +51 -44
- package/src/gen/processor/protos/processor.ts +121 -76
- package/src/index.ts +1 -0
- package/src/metrics.ts +138 -0
- package/src/multicall.ts +1615 -0
- package/src/plugin.ts +7 -3
- package/src/processor-runner.ts +64 -21
- package/src/provider.ts +3 -9
- package/src/service.ts +105 -42
- package/src/tsup.config.ts +2 -0
- package/src/utils.ts +11 -3
- package/lib/chunk-FGIYODHE.js +0 -78810
package/lib/index.d.ts
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
import * as _sentio_protos from '@sentio/protos';
|
2
|
-
import { DeepPartial as DeepPartial$1, ProcessStreamResponse, DBResponse, DBRequest_DBUpsert, DBRequest, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, ProcessorServiceImplementation, ProcessConfigRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, ProcessStreamRequest, PreprocessStreamRequest, PreprocessStreamResponse } from '@sentio/protos';
|
2
|
+
import { DeepPartial as DeepPartial$1, ProcessStreamResponse, DBResponse, DBRequest_DBUpsert, DBRequest, HandlerType, ProcessConfigResponse, StartRequest, DataBinding, PreparedData, ProcessResult, PreprocessResult, EthCallParam, ProcessorServiceImplementation, ProcessConfigRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, ProcessStreamRequest, PreprocessStreamRequest, PreprocessStreamResponse } from '@sentio/protos';
|
3
3
|
import { Subject } from 'rxjs';
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
5
5
|
import { Required } from 'utility-types';
|
6
6
|
import { CallContext } from 'nice-grpc';
|
7
7
|
import _m0 from 'protobufjs/minimal.js';
|
8
|
+
import { JsonRpcProvider, Provider } from 'ethers';
|
9
|
+
import { EthChainId } from '@sentio/chain';
|
8
10
|
|
9
11
|
type Request = Omit<DBRequest, 'opId'>;
|
10
12
|
type RequestType = keyof Request;
|
11
|
-
declare const timeoutError:
|
13
|
+
declare const timeoutError: Error;
|
12
14
|
declare class StoreContext {
|
13
15
|
readonly subject: Subject<DeepPartial$1<ProcessStreamResponse>>;
|
14
16
|
readonly processId: number;
|
15
17
|
private static opCounter;
|
16
18
|
private defers;
|
17
19
|
private statsInterval;
|
20
|
+
private pendings;
|
18
21
|
constructor(subject: Subject<DeepPartial$1<ProcessStreamResponse>>, processId: number);
|
19
22
|
newPromise<T>(opId: bigint, requestType?: RequestType): Promise<T>;
|
20
23
|
sendRequest(request: DeepPartial$1<Request>, timeoutSecs?: number): Promise<DBResponse>;
|
@@ -29,6 +32,7 @@ declare class StoreContext {
|
|
29
32
|
} | undefined;
|
30
33
|
private sendUpsertInBatch;
|
31
34
|
private sendBatch;
|
35
|
+
awaitPendings(): Promise<void>;
|
32
36
|
}
|
33
37
|
|
34
38
|
declare abstract class Plugin {
|
@@ -41,7 +45,9 @@ declare abstract class Plugin {
|
|
41
45
|
*/
|
42
46
|
stateDiff(config: ProcessConfigResponse): boolean;
|
43
47
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult>;
|
44
|
-
preprocessBinding(request: DataBinding
|
48
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
49
|
+
[k: string]: any;
|
50
|
+
}): Promise<PreprocessResult>;
|
45
51
|
}
|
46
52
|
declare class PluginManager {
|
47
53
|
static INSTANCE: PluginManager;
|
@@ -56,7 +62,9 @@ declare class PluginManager {
|
|
56
62
|
*/
|
57
63
|
stateDiff(config: ProcessConfigResponse): boolean;
|
58
64
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: StoreContext): Promise<ProcessResult>;
|
59
|
-
preprocessBinding(request: DataBinding,
|
65
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
66
|
+
[k: string]: any;
|
67
|
+
}, dbContext?: StoreContext): Promise<PreprocessResult>;
|
60
68
|
}
|
61
69
|
|
62
70
|
declare class State {
|
@@ -85,6 +93,7 @@ declare abstract class ListStateStorage<T> extends StateStorage<T[]> {
|
|
85
93
|
declare function mergeProcessResults(results: ProcessResult[]): Required<ProcessResult, 'states'>;
|
86
94
|
declare function errorString(e: Error): string;
|
87
95
|
declare const USER_PROCESSOR = "user_processor";
|
96
|
+
declare function makeEthCallKey(param: EthCallParam): string;
|
88
97
|
|
89
98
|
declare class Endpoints {
|
90
99
|
static INSTANCE: Endpoints;
|
@@ -106,15 +115,18 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
106
115
|
unhandled: Error;
|
107
116
|
private readonly loader;
|
108
117
|
private readonly shutdownHandler?;
|
118
|
+
private preparedData;
|
109
119
|
constructor(loader: () => Promise<any>, shutdownHandler?: () => void);
|
110
120
|
getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse>;
|
111
121
|
start(request: StartRequest, context: CallContext): Promise<Empty>;
|
112
122
|
stop(request: Empty, context: CallContext): Promise<Empty>;
|
113
123
|
processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse>;
|
114
|
-
preprocessBindings(bindings: DataBinding[],
|
115
|
-
[
|
116
|
-
}>;
|
117
|
-
preprocessBinding(request: DataBinding,
|
124
|
+
preprocessBindings(bindings: DataBinding[], preprocessStore: {
|
125
|
+
[k: string]: any;
|
126
|
+
}, dbContext?: StoreContext, options?: CallContext): Promise<PreparedData>;
|
127
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
128
|
+
[k: string]: any;
|
129
|
+
}, dbContext?: StoreContext, options?: CallContext): Promise<PreprocessResult>;
|
118
130
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, options?: CallContext): Promise<ProcessResult>;
|
119
131
|
processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext): AsyncGenerator<{
|
120
132
|
processId?: number | undefined;
|
@@ -366,4 +378,7 @@ interface GlobalConfig {
|
|
366
378
|
}
|
367
379
|
declare const GLOBAL_CONFIG: GlobalConfig;
|
368
380
|
|
369
|
-
|
381
|
+
declare const DummyProvider: JsonRpcProvider;
|
382
|
+
declare function getProvider(chainId?: EthChainId): Provider;
|
383
|
+
|
384
|
+
export { ChainConfig, DummyProvider, Endpoints, GLOBAL_CONFIG, GlobalConfig, ListStateStorage, MapStateStorage, Plugin, PluginManager, ProcessorServiceImpl, State, StateStorage, StoreContext, USER_PROCESSOR, errorString, getProvider, makeEthCallKey, mergeProcessResults, timeoutError };
|
package/lib/index.js
CHANGED
@@ -1,92 +1,3 @@
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
2
|
-
import {
|
3
|
-
|
4
|
-
GLOBAL_CONFIG,
|
5
|
-
Plugin,
|
6
|
-
PluginManager,
|
7
|
-
ProcessorServiceImpl,
|
8
|
-
StoreContext,
|
9
|
-
USER_PROCESSOR,
|
10
|
-
__publicField,
|
11
|
-
errorString,
|
12
|
-
mergeProcessResults,
|
13
|
-
timeoutError
|
14
|
-
} from "./chunk-FGIYODHE.js";
|
15
|
-
|
16
|
-
// src/state.ts
|
17
|
-
var _State = class {
|
18
|
-
stateMap = /* @__PURE__ */ new Map();
|
19
|
-
static reset() {
|
20
|
-
_State.INSTANCE = new _State();
|
21
|
-
}
|
22
|
-
};
|
23
|
-
var State = _State;
|
24
|
-
__publicField(State, "INSTANCE", new _State());
|
25
|
-
var StateStorage = class {
|
26
|
-
// TODO learn how to define single instance for all subclasses
|
27
|
-
constructor() {
|
28
|
-
}
|
29
|
-
key() {
|
30
|
-
return this.constructor.name;
|
31
|
-
}
|
32
|
-
getOrRegister() {
|
33
|
-
let metricState = State.INSTANCE.stateMap.get(this.key());
|
34
|
-
if (!metricState) {
|
35
|
-
metricState = this.initValue();
|
36
|
-
State.INSTANCE.stateMap.set(this.key(), metricState);
|
37
|
-
}
|
38
|
-
return metricState;
|
39
|
-
}
|
40
|
-
};
|
41
|
-
var MapStateStorage = class extends StateStorage {
|
42
|
-
initValue() {
|
43
|
-
return /* @__PURE__ */ new Map();
|
44
|
-
}
|
45
|
-
getValue(key) {
|
46
|
-
const m = this.getOrRegister();
|
47
|
-
return m.get(key);
|
48
|
-
}
|
49
|
-
getValues() {
|
50
|
-
const m = this.getOrRegister();
|
51
|
-
return Array.from(m.values());
|
52
|
-
}
|
53
|
-
getOrSetValue(key, value) {
|
54
|
-
const m = this.getOrRegister();
|
55
|
-
const oldValue = m.get(key);
|
56
|
-
if (oldValue) {
|
57
|
-
console.warn(key, "has been registered twice, use the previous one");
|
58
|
-
return oldValue;
|
59
|
-
}
|
60
|
-
m.set(key, value);
|
61
|
-
return value;
|
62
|
-
}
|
63
|
-
};
|
64
|
-
var ListStateStorage = class extends StateStorage {
|
65
|
-
initValue() {
|
66
|
-
return [];
|
67
|
-
}
|
68
|
-
getValues() {
|
69
|
-
return this.getOrRegister();
|
70
|
-
}
|
71
|
-
addValue(value) {
|
72
|
-
const m = this.getOrRegister();
|
73
|
-
m.push(value);
|
74
|
-
return value;
|
75
|
-
}
|
76
|
-
};
|
77
|
-
export {
|
78
|
-
Endpoints,
|
79
|
-
GLOBAL_CONFIG,
|
80
|
-
ListStateStorage,
|
81
|
-
MapStateStorage,
|
82
|
-
Plugin,
|
83
|
-
PluginManager,
|
84
|
-
ProcessorServiceImpl,
|
85
|
-
State,
|
86
|
-
StateStorage,
|
87
|
-
StoreContext,
|
88
|
-
USER_PROCESSOR,
|
89
|
-
errorString,
|
90
|
-
mergeProcessResults,
|
91
|
-
timeoutError
|
92
|
-
};
|
2
|
+
import{U as d,V as N,W as O,X as b,Y as w,g as u,i as T,j as l,m,n as x,o as f,p as h,q as V,y as p}from"./chunk-QYVWD4BX.js";var r=class{stateMap=new Map;static reset(){r.INSTANCE=new r}},e=r;u(e,"INSTANCE",new r);var n=class{constructor(){}key(){return this.constructor.name}getOrRegister(){let t=e.INSTANCE.stateMap.get(this.key());return t||(t=this.initValue(),e.INSTANCE.stateMap.set(this.key(),t)),t}},g=class extends n{initValue(){return new Map}getValue(t){return this.getOrRegister().get(t)}getValues(){let t=this.getOrRegister();return Array.from(t.values())}getOrSetValue(t,s){let o=this.getOrRegister(),a=o.get(t);return a?(console.warn(t,"has been registered twice, use the previous one"),a):(o.set(t,s),s)}},c=class extends n{initValue(){return[]}getValues(){return this.getOrRegister()}addValue(t){return this.getOrRegister().push(t),t}};export{O as DummyProvider,V as Endpoints,p as GLOBAL_CONFIG,c as ListStateStorage,g as MapStateStorage,T as Plugin,l as PluginManager,w as ProcessorServiceImpl,e as State,n as StateStorage,N as StoreContext,f as USER_PROCESSOR,x as errorString,b as getProvider,h as makeEthCallKey,m as mergeProcessResults,d as timeoutError};
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/state.ts"],"sourcesContent":["export class State {\n stateMap = new Map<string, any>()\n\n static INSTANCE = new State()\n\n static reset() {\n State.INSTANCE = new State()\n }\n}\n\nexport abstract class StateStorage<T> {\n // TODO learn how to define single instance for all subclasses\n\n protected constructor() {\n //\n }\n\n abstract initValue(): T\n\n key(): string {\n return this.constructor.name\n }\n\n getOrRegister(): T {\n let metricState: T = State.INSTANCE.stateMap.get(this.key())\n if (!metricState) {\n metricState = this.initValue()\n State.INSTANCE.stateMap.set(this.key(), metricState)\n }\n return metricState\n }\n}\n\nexport abstract class MapStateStorage<T> extends StateStorage<Map<string, T>> {\n initValue() {\n return new Map<string, T>()\n }\n\n getValue(key: string): T | undefined {\n const m = this.getOrRegister()\n return m.get(key)\n }\n\n getValues(): T[] {\n const m = this.getOrRegister()\n return Array.from(m.values())\n }\n\n getOrSetValue(key: string, value: T): T {\n const m = this.getOrRegister()\n const oldValue = m.get(key)\n if (oldValue) {\n console.warn(key, 'has been registered twice, use the previous one')\n return oldValue\n }\n m.set(key, value)\n return value\n }\n}\n\nexport abstract class ListStateStorage<T> extends StateStorage<T[]> {\n initValue() {\n return []\n }\n\n getValues(): T[] {\n return this.getOrRegister()\n }\n\n addValue(value: T): T {\n const m = this.getOrRegister()\n m.push(value)\n return value\n }\n}\n"],"mappings":";8HAAO,IAAMA,EAAN,KAAY,CACjB,SAAW,IAAI,IAIf,OAAO,OAAQ,CACbA,EAAM,SAAW,IAAIA,CACvB,CACF,EARaC,EAAND,EAGLE,EAHWD,EAGJ,WAAW,IAAID,GAOjB,IAAeG,EAAf,KAA+B,CAG1B,aAAc,CAExB,CAIA,KAAc,CACZ,OAAO,KAAK,YAAY,IAC1B,CAEA,eAAmB,CACjB,IAAIC,EAAiBH,EAAM,SAAS,SAAS,IAAI,KAAK,IAAI,CAAC,EAC3D,OAAKG,IACHA,EAAc,KAAK,UAAU,EAC7BH,EAAM,SAAS,SAAS,IAAI,KAAK,IAAI,EAAGG,CAAW,GAE9CA,CACT,CACF,EAEsBC,EAAf,cAA0CF,CAA6B,CAC5E,WAAY,CACV,OAAO,IAAI,GACb,CAEA,SAASG,EAA4B,CAEnC,OADU,KAAK,cAAc,EACpB,IAAIA,CAAG,CAClB,CAEA,WAAiB,CACf,IAAMC,EAAI,KAAK,cAAc,EAC7B,OAAO,MAAM,KAAKA,EAAE,OAAO,CAAC,CAC9B,CAEA,cAAcD,EAAaE,EAAa,CACtC,IAAMD,EAAI,KAAK,cAAc,EACvBE,EAAWF,EAAE,IAAID,CAAG,EAC1B,OAAIG,GACF,QAAQ,KAAKH,EAAK,iDAAiD,EAC5DG,IAETF,EAAE,IAAID,EAAKE,CAAK,EACTA,EACT,CACF,EAEsBE,EAAf,cAA2CP,CAAkB,CAClE,WAAY,CACV,MAAO,CAAC,CACV,CAEA,WAAiB,CACf,OAAO,KAAK,cAAc,CAC5B,CAEA,SAASK,EAAa,CAEpB,OADU,KAAK,cAAc,EAC3B,KAAKA,CAAK,EACLA,CACT,CACF","names":["_State","State","__publicField","StateStorage","metricState","MapStateStorage","key","m","value","oldValue","ListStateStorage"]}
|