@sentio/runtime 2.40.0-rc.9 → 2.40.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/chunk-N7A3MJFE.js +131 -0
- package/lib/chunk-N7A3MJFE.js.map +1 -0
- package/lib/index.d.ts +22 -9
- package/lib/index.js +2 -93
- 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 +2 -2
- package/src/db-context.ts +51 -44
- package/src/index.ts +1 -0
- package/src/metrics.ts +138 -0
- package/src/multicall.ts +1615 -0
- package/src/otlp.ts +50 -0
- package/src/plugin.ts +7 -3
- package/src/processor-runner.ts +64 -21
- package/src/provider.ts +3 -9
- package/src/service.ts +98 -37
- package/src/tsup.config.ts +2 -0
- package/src/utils.ts +1 -1
- package/lib/chunk-FFU5RYDX.js +0 -78856
package/lib/index.d.ts
CHANGED
@@ -5,16 +5,19 @@ 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 {
|
@@ -107,16 +115,18 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
107
115
|
unhandled: Error;
|
108
116
|
private readonly loader;
|
109
117
|
private readonly shutdownHandler?;
|
110
|
-
private
|
118
|
+
private preparedData;
|
111
119
|
constructor(loader: () => Promise<any>, shutdownHandler?: () => void);
|
112
120
|
getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse>;
|
113
121
|
start(request: StartRequest, context: CallContext): Promise<Empty>;
|
114
122
|
stop(request: Empty, context: CallContext): Promise<Empty>;
|
115
123
|
processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse>;
|
116
|
-
preprocessBindings(bindings: DataBinding[],
|
117
|
-
[
|
118
|
-
}>;
|
119
|
-
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>;
|
120
130
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, options?: CallContext): Promise<ProcessResult>;
|
121
131
|
processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext): AsyncGenerator<{
|
122
132
|
processId?: number | undefined;
|
@@ -368,4 +378,7 @@ interface GlobalConfig {
|
|
368
378
|
}
|
369
379
|
declare const GLOBAL_CONFIG: GlobalConfig;
|
370
380
|
|
371
|
-
|
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,94 +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
|
-
makeEthCallKey,
|
13
|
-
mergeProcessResults,
|
14
|
-
timeoutError
|
15
|
-
} from "./chunk-FFU5RYDX.js";
|
16
|
-
|
17
|
-
// src/state.ts
|
18
|
-
var _State = class {
|
19
|
-
stateMap = /* @__PURE__ */ new Map();
|
20
|
-
static reset() {
|
21
|
-
_State.INSTANCE = new _State();
|
22
|
-
}
|
23
|
-
};
|
24
|
-
var State = _State;
|
25
|
-
__publicField(State, "INSTANCE", new _State());
|
26
|
-
var StateStorage = class {
|
27
|
-
// TODO learn how to define single instance for all subclasses
|
28
|
-
constructor() {
|
29
|
-
}
|
30
|
-
key() {
|
31
|
-
return this.constructor.name;
|
32
|
-
}
|
33
|
-
getOrRegister() {
|
34
|
-
let metricState = State.INSTANCE.stateMap.get(this.key());
|
35
|
-
if (!metricState) {
|
36
|
-
metricState = this.initValue();
|
37
|
-
State.INSTANCE.stateMap.set(this.key(), metricState);
|
38
|
-
}
|
39
|
-
return metricState;
|
40
|
-
}
|
41
|
-
};
|
42
|
-
var MapStateStorage = class extends StateStorage {
|
43
|
-
initValue() {
|
44
|
-
return /* @__PURE__ */ new Map();
|
45
|
-
}
|
46
|
-
getValue(key) {
|
47
|
-
const m = this.getOrRegister();
|
48
|
-
return m.get(key);
|
49
|
-
}
|
50
|
-
getValues() {
|
51
|
-
const m = this.getOrRegister();
|
52
|
-
return Array.from(m.values());
|
53
|
-
}
|
54
|
-
getOrSetValue(key, value) {
|
55
|
-
const m = this.getOrRegister();
|
56
|
-
const oldValue = m.get(key);
|
57
|
-
if (oldValue) {
|
58
|
-
console.warn(key, "has been registered twice, use the previous one");
|
59
|
-
return oldValue;
|
60
|
-
}
|
61
|
-
m.set(key, value);
|
62
|
-
return value;
|
63
|
-
}
|
64
|
-
};
|
65
|
-
var ListStateStorage = class extends StateStorage {
|
66
|
-
initValue() {
|
67
|
-
return [];
|
68
|
-
}
|
69
|
-
getValues() {
|
70
|
-
return this.getOrRegister();
|
71
|
-
}
|
72
|
-
addValue(value) {
|
73
|
-
const m = this.getOrRegister();
|
74
|
-
m.push(value);
|
75
|
-
return value;
|
76
|
-
}
|
77
|
-
};
|
78
|
-
export {
|
79
|
-
Endpoints,
|
80
|
-
GLOBAL_CONFIG,
|
81
|
-
ListStateStorage,
|
82
|
-
MapStateStorage,
|
83
|
-
Plugin,
|
84
|
-
PluginManager,
|
85
|
-
ProcessorServiceImpl,
|
86
|
-
State,
|
87
|
-
StateStorage,
|
88
|
-
StoreContext,
|
89
|
-
USER_PROCESSOR,
|
90
|
-
errorString,
|
91
|
-
makeEthCallKey,
|
92
|
-
mergeProcessResults,
|
93
|
-
timeoutError
|
94
|
-
};
|
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-N7A3MJFE.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"]}
|