@sentio/runtime 2.40.0-rc.17 → 2.40.0-rc.19
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-ADIQF3IB.js → chunk-WN27EZMT.js} +11 -21
- package/lib/index.d.ts +12 -4
- package/lib/index.js +1 -1
- package/lib/processor-runner.js +1 -1
- package/package.json +1 -1
- package/src/plugin.ts +7 -3
- package/src/service.ts +8 -16
@@ -49600,7 +49600,7 @@ var Plugin = class {
|
|
49600
49600
|
async processBinding(request, preparedData) {
|
49601
49601
|
return ProcessResult.create();
|
49602
49602
|
}
|
49603
|
-
async preprocessBinding(request) {
|
49603
|
+
async preprocessBinding(request, preprocessStore) {
|
49604
49604
|
return PreprocessResult.create();
|
49605
49605
|
}
|
49606
49606
|
};
|
@@ -49642,13 +49642,13 @@ var _PluginManager = class {
|
|
49642
49642
|
return plugin.processBinding(request, preparedData);
|
49643
49643
|
});
|
49644
49644
|
}
|
49645
|
-
preprocessBinding(request, dbContext) {
|
49645
|
+
preprocessBinding(request, preprocessStore, dbContext) {
|
49646
49646
|
const plugin = this.typesToPlugin.get(request.handlerType);
|
49647
49647
|
if (!plugin) {
|
49648
49648
|
throw new Error(`No plugin for ${request.handlerType}`);
|
49649
49649
|
}
|
49650
49650
|
return this.dbContextLocalStorage.run(dbContext, () => {
|
49651
|
-
return plugin.preprocessBinding(request);
|
49651
|
+
return plugin.preprocessBinding(request, preprocessStore);
|
49652
49652
|
});
|
49653
49653
|
}
|
49654
49654
|
};
|
@@ -78468,7 +78468,7 @@ var ProcessorServiceImpl = class {
|
|
78468
78468
|
return {};
|
78469
78469
|
}
|
78470
78470
|
async processBindings(request, options) {
|
78471
|
-
const preparedData = await this.preprocessBindings(request.bindings, void 0, options);
|
78471
|
+
const preparedData = await this.preprocessBindings(request.bindings, {}, void 0, options);
|
78472
78472
|
const promises = [];
|
78473
78473
|
for (const binding of request.bindings) {
|
78474
78474
|
const promise2 = this.processBinding(binding, preparedData);
|
@@ -78488,11 +78488,11 @@ var ProcessorServiceImpl = class {
|
|
78488
78488
|
result
|
78489
78489
|
};
|
78490
78490
|
}
|
78491
|
-
async preprocessBindings(bindings, dbContext, options) {
|
78491
|
+
async preprocessBindings(bindings, preprocessStore, dbContext, options) {
|
78492
78492
|
console.debug(`preprocessBindings start, bindings: ${bindings.length}`);
|
78493
78493
|
const promises = [];
|
78494
78494
|
for (const binding of bindings) {
|
78495
|
-
promises.push(this.preprocessBinding(binding, dbContext, options));
|
78495
|
+
promises.push(this.preprocessBinding(binding, preprocessStore, dbContext, options));
|
78496
78496
|
}
|
78497
78497
|
let preprocessResults;
|
78498
78498
|
try {
|
@@ -78500,10 +78500,6 @@ var ProcessorServiceImpl = class {
|
|
78500
78500
|
} catch (e) {
|
78501
78501
|
throw e;
|
78502
78502
|
}
|
78503
|
-
console.debug(
|
78504
|
-
"ethCallParams: ",
|
78505
|
-
preprocessResults.map((r) => r.ethCallParams)
|
78506
|
-
);
|
78507
78503
|
const groupedRequests = /* @__PURE__ */ new Map();
|
78508
78504
|
const providers2 = /* @__PURE__ */ new Map();
|
78509
78505
|
for (const result of preprocessResults) {
|
@@ -78529,11 +78525,7 @@ var ProcessorServiceImpl = class {
|
|
78529
78525
|
to: address,
|
78530
78526
|
data: param.calldata,
|
78531
78527
|
blockTag
|
78532
|
-
}).then((result) =>
|
78533
|
-
const ret = [makeEthCallKey(param), result];
|
78534
|
-
console.log(`got eth call result, key: ${ret[0]}, result: ${result}`);
|
78535
|
-
return ret;
|
78536
|
-
})
|
78528
|
+
}).then((result) => [makeEthCallKey(param), result])
|
78537
78529
|
);
|
78538
78530
|
}
|
78539
78531
|
}
|
@@ -78548,7 +78540,7 @@ var ProcessorServiceImpl = class {
|
|
78548
78540
|
ethCallResults: results
|
78549
78541
|
};
|
78550
78542
|
}
|
78551
|
-
async preprocessBinding(request, dbContext, options) {
|
78543
|
+
async preprocessBinding(request, preprocessStore, dbContext, options) {
|
78552
78544
|
if (!this.started) {
|
78553
78545
|
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
|
78554
78546
|
}
|
@@ -78564,7 +78556,7 @@ var ProcessorServiceImpl = class {
|
|
78564
78556
|
]
|
78565
78557
|
);
|
78566
78558
|
}
|
78567
|
-
return await PluginManager.INSTANCE.preprocessBinding(request, dbContext);
|
78559
|
+
return await PluginManager.INSTANCE.preprocessBinding(request, preprocessStore, dbContext);
|
78568
78560
|
}
|
78569
78561
|
async processBinding(request, preparedData, options) {
|
78570
78562
|
if (!this.started) {
|
@@ -78592,7 +78584,6 @@ var ProcessorServiceImpl = class {
|
|
78592
78584
|
}
|
78593
78585
|
const subject = new import_rxjs.Subject();
|
78594
78586
|
this.handleRequests(requests, subject).then(() => {
|
78595
|
-
console.log("clearing prepared data");
|
78596
78587
|
this.preparedData = { ethCallResults: {} };
|
78597
78588
|
subject.complete();
|
78598
78589
|
}).catch((e) => {
|
@@ -78603,15 +78594,14 @@ var ProcessorServiceImpl = class {
|
|
78603
78594
|
}
|
78604
78595
|
async handlePreprocessRequests(requests, subject) {
|
78605
78596
|
const contexts = new Contexts();
|
78597
|
+
const preprocessStore = {};
|
78606
78598
|
for await (const request of requests) {
|
78607
78599
|
try {
|
78608
|
-
console.debug("received request:", request);
|
78609
78600
|
if (request.bindings) {
|
78610
78601
|
const bindings = request.bindings.bindings;
|
78611
78602
|
const dbContext = contexts.new(request.processId, subject);
|
78612
78603
|
const start = Date.now();
|
78613
|
-
this.preprocessBindings(bindings, dbContext).then((preparedData) => {
|
78614
|
-
Object.keys(preparedData.ethCallResults).forEach((key) => console.log("got prepared data, key:", key));
|
78604
|
+
this.preprocessBindings(bindings, preprocessStore, dbContext, void 0).then((preparedData) => {
|
78615
78605
|
this.preparedData = {
|
78616
78606
|
ethCallResults: {
|
78617
78607
|
...this.preparedData?.ethCallResults,
|
package/lib/index.d.ts
CHANGED
@@ -41,7 +41,9 @@ declare abstract class Plugin {
|
|
41
41
|
*/
|
42
42
|
stateDiff(config: ProcessConfigResponse): boolean;
|
43
43
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult>;
|
44
|
-
preprocessBinding(request: DataBinding
|
44
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
45
|
+
[k: string]: any;
|
46
|
+
}): Promise<PreprocessResult>;
|
45
47
|
}
|
46
48
|
declare class PluginManager {
|
47
49
|
static INSTANCE: PluginManager;
|
@@ -56,7 +58,9 @@ declare class PluginManager {
|
|
56
58
|
*/
|
57
59
|
stateDiff(config: ProcessConfigResponse): boolean;
|
58
60
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: StoreContext): Promise<ProcessResult>;
|
59
|
-
preprocessBinding(request: DataBinding,
|
61
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
62
|
+
[k: string]: any;
|
63
|
+
}, dbContext?: StoreContext): Promise<PreprocessResult>;
|
60
64
|
}
|
61
65
|
|
62
66
|
declare class State {
|
@@ -113,8 +117,12 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
113
117
|
start(request: StartRequest, context: CallContext): Promise<Empty>;
|
114
118
|
stop(request: Empty, context: CallContext): Promise<Empty>;
|
115
119
|
processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse>;
|
116
|
-
preprocessBindings(bindings: DataBinding[],
|
117
|
-
|
120
|
+
preprocessBindings(bindings: DataBinding[], preprocessStore: {
|
121
|
+
[k: string]: any;
|
122
|
+
}, dbContext?: StoreContext, options?: CallContext): Promise<PreparedData>;
|
123
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
124
|
+
[k: string]: any;
|
125
|
+
}, dbContext?: StoreContext, options?: CallContext): Promise<PreprocessResult>;
|
118
126
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, options?: CallContext): Promise<ProcessResult>;
|
119
127
|
processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext): AsyncGenerator<{
|
120
128
|
processId?: number | undefined;
|
package/lib/index.js
CHANGED
package/lib/processor-runner.js
CHANGED
package/package.json
CHANGED
package/src/plugin.ts
CHANGED
@@ -28,7 +28,7 @@ export abstract class Plugin {
|
|
28
28
|
return ProcessResult.create()
|
29
29
|
}
|
30
30
|
|
31
|
-
async preprocessBinding(request: DataBinding): Promise<PreprocessResult> {
|
31
|
+
async preprocessBinding(request: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
32
32
|
return PreprocessResult.create()
|
33
33
|
}
|
34
34
|
}
|
@@ -84,13 +84,17 @@ export class PluginManager {
|
|
84
84
|
})
|
85
85
|
}
|
86
86
|
|
87
|
-
preprocessBinding(
|
87
|
+
preprocessBinding(
|
88
|
+
request: DataBinding,
|
89
|
+
preprocessStore: { [k: string]: any },
|
90
|
+
dbContext?: StoreContext
|
91
|
+
): Promise<PreprocessResult> {
|
88
92
|
const plugin = this.typesToPlugin.get(request.handlerType)
|
89
93
|
if (!plugin) {
|
90
94
|
throw new Error(`No plugin for ${request.handlerType}`)
|
91
95
|
}
|
92
96
|
return this.dbContextLocalStorage.run(dbContext, () => {
|
93
|
-
return plugin.preprocessBinding(request)
|
97
|
+
return plugin.preprocessBinding(request, preprocessStore)
|
94
98
|
})
|
95
99
|
}
|
96
100
|
}
|
package/src/service.ts
CHANGED
@@ -128,7 +128,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
128
128
|
}
|
129
129
|
|
130
130
|
async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {
|
131
|
-
const preparedData = await this.preprocessBindings(request.bindings, undefined, options)
|
131
|
+
const preparedData = await this.preprocessBindings(request.bindings, {}, undefined, options)
|
132
132
|
|
133
133
|
const promises = []
|
134
134
|
for (const binding of request.bindings) {
|
@@ -159,13 +159,14 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
159
159
|
|
160
160
|
async preprocessBindings(
|
161
161
|
bindings: DataBinding[],
|
162
|
+
preprocessStore: { [k: string]: any },
|
162
163
|
dbContext?: StoreContext,
|
163
164
|
options?: CallContext
|
164
165
|
): Promise<PreparedData> {
|
165
166
|
console.debug(`preprocessBindings start, bindings: ${bindings.length}`)
|
166
167
|
const promises = []
|
167
168
|
for (const binding of bindings) {
|
168
|
-
promises.push(this.preprocessBinding(binding, dbContext, options))
|
169
|
+
promises.push(this.preprocessBinding(binding, preprocessStore, dbContext, options))
|
169
170
|
}
|
170
171
|
let preprocessResults: PreprocessResult[]
|
171
172
|
try {
|
@@ -173,10 +174,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
173
174
|
} catch (e) {
|
174
175
|
throw e
|
175
176
|
}
|
176
|
-
console.debug(
|
177
|
-
'ethCallParams: ',
|
178
|
-
preprocessResults.map((r) => r.ethCallParams)
|
179
|
-
)
|
180
177
|
const groupedRequests = new Map<string, EthCallParam[]>()
|
181
178
|
const providers = new Map<string, Provider>()
|
182
179
|
for (const result of preprocessResults) {
|
@@ -207,11 +204,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
207
204
|
data: param.calldata,
|
208
205
|
blockTag
|
209
206
|
})
|
210
|
-
.then((result) =>
|
211
|
-
const ret = [makeEthCallKey(param), result]
|
212
|
-
console.log(`got eth call result, key: ${ret[0]}, result: ${result}`)
|
213
|
-
return ret
|
214
|
-
})
|
207
|
+
.then((result) => [makeEthCallKey(param), result])
|
215
208
|
)
|
216
209
|
}
|
217
210
|
}
|
@@ -229,6 +222,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
229
222
|
|
230
223
|
async preprocessBinding(
|
231
224
|
request: DataBinding,
|
225
|
+
preprocessStore: { [k: string]: any },
|
232
226
|
dbContext?: StoreContext,
|
233
227
|
options?: CallContext
|
234
228
|
): Promise<PreprocessResult> {
|
@@ -247,7 +241,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
247
241
|
]
|
248
242
|
)
|
249
243
|
}
|
250
|
-
return await PluginManager.INSTANCE.preprocessBinding(request, dbContext)
|
244
|
+
return await PluginManager.INSTANCE.preprocessBinding(request, preprocessStore, dbContext)
|
251
245
|
}
|
252
246
|
|
253
247
|
async processBinding(
|
@@ -283,7 +277,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
283
277
|
const subject = new Subject<DeepPartial<ProcessStreamResponse>>()
|
284
278
|
this.handleRequests(requests, subject)
|
285
279
|
.then(() => {
|
286
|
-
console.log('clearing prepared data')
|
287
280
|
this.preparedData = { ethCallResults: {} }
|
288
281
|
subject.complete()
|
289
282
|
})
|
@@ -299,18 +292,17 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
299
292
|
subject: Subject<DeepPartial<PreprocessStreamResponse>>
|
300
293
|
) {
|
301
294
|
const contexts = new Contexts()
|
295
|
+
const preprocessStore: { [k: string]: any } = {}
|
302
296
|
|
303
297
|
for await (const request of requests) {
|
304
298
|
try {
|
305
|
-
console.debug('received request:', request)
|
306
299
|
if (request.bindings) {
|
307
300
|
const bindings = request.bindings.bindings
|
308
301
|
const dbContext = contexts.new(request.processId, subject)
|
309
302
|
const start = Date.now()
|
310
|
-
this.preprocessBindings(bindings, dbContext)
|
303
|
+
this.preprocessBindings(bindings, preprocessStore, dbContext, undefined)
|
311
304
|
.then((preparedData) => {
|
312
305
|
// TODO maybe not proper to pass data in this way
|
313
|
-
Object.keys(preparedData.ethCallResults).forEach((key) => console.log('got prepared data, key:', key))
|
314
306
|
this.preparedData = {
|
315
307
|
ethCallResults: {
|
316
308
|
...this.preparedData?.ethCallResults,
|