@sentio/runtime 2.40.0-rc.17 → 2.40.0-rc.18

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.
@@ -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) {
@@ -78548,7 +78544,7 @@ var ProcessorServiceImpl = class {
78548
78544
  ethCallResults: results
78549
78545
  };
78550
78546
  }
78551
- async preprocessBinding(request, dbContext, options) {
78547
+ async preprocessBinding(request, preprocessStore, dbContext, options) {
78552
78548
  if (!this.started) {
78553
78549
  throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
78554
78550
  }
@@ -78564,7 +78560,7 @@ var ProcessorServiceImpl = class {
78564
78560
  ]
78565
78561
  );
78566
78562
  }
78567
- return await PluginManager.INSTANCE.preprocessBinding(request, dbContext);
78563
+ return await PluginManager.INSTANCE.preprocessBinding(request, preprocessStore, dbContext);
78568
78564
  }
78569
78565
  async processBinding(request, preparedData, options) {
78570
78566
  if (!this.started) {
@@ -78603,15 +78599,14 @@ var ProcessorServiceImpl = class {
78603
78599
  }
78604
78600
  async handlePreprocessRequests(requests, subject) {
78605
78601
  const contexts = new Contexts();
78602
+ const preprocessStore = {};
78606
78603
  for await (const request of requests) {
78607
78604
  try {
78608
- console.debug("received request:", request);
78609
78605
  if (request.bindings) {
78610
78606
  const bindings = request.bindings.bindings;
78611
78607
  const dbContext = contexts.new(request.processId, subject);
78612
78608
  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));
78609
+ this.preprocessBindings(bindings, preprocessStore, dbContext, void 0).then((preparedData) => {
78615
78610
  this.preparedData = {
78616
78611
  ethCallResults: {
78617
78612
  ...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): Promise<PreprocessResult>;
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, dbContext?: StoreContext): Promise<PreprocessResult>;
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[], dbContext?: StoreContext, options?: CallContext): Promise<PreparedData>;
117
- preprocessBinding(request: DataBinding, dbContext?: StoreContext, options?: CallContext): Promise<PreprocessResult>;
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
@@ -12,7 +12,7 @@ import {
12
12
  makeEthCallKey,
13
13
  mergeProcessResults,
14
14
  timeoutError
15
- } from "./chunk-ADIQF3IB.js";
15
+ } from "./chunk-FYV7R6QO.js";
16
16
 
17
17
  // src/state.ts
18
18
  var _State = class {
@@ -40,7 +40,7 @@ import {
40
40
  require_minimal,
41
41
  require_src,
42
42
  trace
43
- } from "./chunk-ADIQF3IB.js";
43
+ } from "./chunk-FYV7R6QO.js";
44
44
 
45
45
  // ../../node_modules/.pnpm/universalify@2.0.1/node_modules/universalify/index.js
46
46
  var require_universalify = __commonJS({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.40.0-rc.17",
3
+ "version": "2.40.0-rc.18",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
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(request: DataBinding, dbContext?: StoreContext): Promise<PreprocessResult> {
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) {
@@ -229,6 +226,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
229
226
 
230
227
  async preprocessBinding(
231
228
  request: DataBinding,
229
+ preprocessStore: { [k: string]: any },
232
230
  dbContext?: StoreContext,
233
231
  options?: CallContext
234
232
  ): Promise<PreprocessResult> {
@@ -247,7 +245,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
247
245
  ]
248
246
  )
249
247
  }
250
- return await PluginManager.INSTANCE.preprocessBinding(request, dbContext)
248
+ return await PluginManager.INSTANCE.preprocessBinding(request, preprocessStore, dbContext)
251
249
  }
252
250
 
253
251
  async processBinding(
@@ -299,18 +297,17 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
299
297
  subject: Subject<DeepPartial<PreprocessStreamResponse>>
300
298
  ) {
301
299
  const contexts = new Contexts()
300
+ const preprocessStore: { [k: string]: any } = {}
302
301
 
303
302
  for await (const request of requests) {
304
303
  try {
305
- console.debug('received request:', request)
306
304
  if (request.bindings) {
307
305
  const bindings = request.bindings.bindings
308
306
  const dbContext = contexts.new(request.processId, subject)
309
307
  const start = Date.now()
310
- this.preprocessBindings(bindings, dbContext)
308
+ this.preprocessBindings(bindings, preprocessStore, dbContext, undefined)
311
309
  .then((preparedData) => {
312
310
  // 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
311
  this.preparedData = {
315
312
  ethCallResults: {
316
313
  ...this.preparedData?.ethCallResults,