@sentio/runtime 2.60.0-rc.9 → 2.60.0

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.
@@ -434,6 +434,11 @@ export interface ProcessConfigResponse {
434
434
  dbSchema: DataBaseSchema | undefined;
435
435
  }
436
436
 
437
+ export interface ConfigureHandlersResponse {
438
+ contractConfigs: ContractConfig[];
439
+ accountConfigs: AccountConfig[];
440
+ }
441
+
437
442
  export interface ContractConfig {
438
443
  contract: ContractInfo | undefined;
439
444
  intervalConfigs: OnIntervalConfig[];
@@ -668,6 +673,11 @@ export interface TemplateInstance {
668
673
  export interface InitResponse {
669
674
  chainIds: string[];
670
675
  dbSchema: DataBaseSchema | undefined;
676
+ config: ProjectConfig | undefined;
677
+ executionConfig: ExecutionConfig | undefined;
678
+ metricConfigs: MetricConfig[];
679
+ exportConfigs: ExportConfig[];
680
+ eventLogConfigs: EventLogConfig[];
671
681
  }
672
682
 
673
683
  export interface ConfigureHandlersRequest {
@@ -2148,6 +2158,84 @@ export const ProcessConfigResponse = {
2148
2158
  },
2149
2159
  };
2150
2160
 
2161
+ function createBaseConfigureHandlersResponse(): ConfigureHandlersResponse {
2162
+ return { contractConfigs: [], accountConfigs: [] };
2163
+ }
2164
+
2165
+ export const ConfigureHandlersResponse = {
2166
+ encode(message: ConfigureHandlersResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
2167
+ for (const v of message.contractConfigs) {
2168
+ ContractConfig.encode(v!, writer.uint32(18).fork()).ldelim();
2169
+ }
2170
+ for (const v of message.accountConfigs) {
2171
+ AccountConfig.encode(v!, writer.uint32(34).fork()).ldelim();
2172
+ }
2173
+ return writer;
2174
+ },
2175
+
2176
+ decode(input: _m0.Reader | Uint8Array, length?: number): ConfigureHandlersResponse {
2177
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
2178
+ let end = length === undefined ? reader.len : reader.pos + length;
2179
+ const message = createBaseConfigureHandlersResponse();
2180
+ while (reader.pos < end) {
2181
+ const tag = reader.uint32();
2182
+ switch (tag >>> 3) {
2183
+ case 2:
2184
+ if (tag !== 18) {
2185
+ break;
2186
+ }
2187
+
2188
+ message.contractConfigs.push(ContractConfig.decode(reader, reader.uint32()));
2189
+ continue;
2190
+ case 4:
2191
+ if (tag !== 34) {
2192
+ break;
2193
+ }
2194
+
2195
+ message.accountConfigs.push(AccountConfig.decode(reader, reader.uint32()));
2196
+ continue;
2197
+ }
2198
+ if ((tag & 7) === 4 || tag === 0) {
2199
+ break;
2200
+ }
2201
+ reader.skipType(tag & 7);
2202
+ }
2203
+ return message;
2204
+ },
2205
+
2206
+ fromJSON(object: any): ConfigureHandlersResponse {
2207
+ return {
2208
+ contractConfigs: globalThis.Array.isArray(object?.contractConfigs)
2209
+ ? object.contractConfigs.map((e: any) => ContractConfig.fromJSON(e))
2210
+ : [],
2211
+ accountConfigs: globalThis.Array.isArray(object?.accountConfigs)
2212
+ ? object.accountConfigs.map((e: any) => AccountConfig.fromJSON(e))
2213
+ : [],
2214
+ };
2215
+ },
2216
+
2217
+ toJSON(message: ConfigureHandlersResponse): unknown {
2218
+ const obj: any = {};
2219
+ if (message.contractConfigs?.length) {
2220
+ obj.contractConfigs = message.contractConfigs.map((e) => ContractConfig.toJSON(e));
2221
+ }
2222
+ if (message.accountConfigs?.length) {
2223
+ obj.accountConfigs = message.accountConfigs.map((e) => AccountConfig.toJSON(e));
2224
+ }
2225
+ return obj;
2226
+ },
2227
+
2228
+ create(base?: DeepPartial<ConfigureHandlersResponse>): ConfigureHandlersResponse {
2229
+ return ConfigureHandlersResponse.fromPartial(base ?? {});
2230
+ },
2231
+ fromPartial(object: DeepPartial<ConfigureHandlersResponse>): ConfigureHandlersResponse {
2232
+ const message = createBaseConfigureHandlersResponse();
2233
+ message.contractConfigs = object.contractConfigs?.map((e) => ContractConfig.fromPartial(e)) || [];
2234
+ message.accountConfigs = object.accountConfigs?.map((e) => AccountConfig.fromPartial(e)) || [];
2235
+ return message;
2236
+ },
2237
+ };
2238
+
2151
2239
  function createBaseContractConfig(): ContractConfig {
2152
2240
  return {
2153
2241
  contract: undefined,
@@ -4405,7 +4493,15 @@ export const TemplateInstance = {
4405
4493
  };
4406
4494
 
4407
4495
  function createBaseInitResponse(): InitResponse {
4408
- return { chainIds: [], dbSchema: undefined };
4496
+ return {
4497
+ chainIds: [],
4498
+ dbSchema: undefined,
4499
+ config: undefined,
4500
+ executionConfig: undefined,
4501
+ metricConfigs: [],
4502
+ exportConfigs: [],
4503
+ eventLogConfigs: [],
4504
+ };
4409
4505
  }
4410
4506
 
4411
4507
  export const InitResponse = {
@@ -4416,6 +4512,21 @@ export const InitResponse = {
4416
4512
  if (message.dbSchema !== undefined) {
4417
4513
  DataBaseSchema.encode(message.dbSchema, writer.uint32(18).fork()).ldelim();
4418
4514
  }
4515
+ if (message.config !== undefined) {
4516
+ ProjectConfig.encode(message.config, writer.uint32(26).fork()).ldelim();
4517
+ }
4518
+ if (message.executionConfig !== undefined) {
4519
+ ExecutionConfig.encode(message.executionConfig, writer.uint32(34).fork()).ldelim();
4520
+ }
4521
+ for (const v of message.metricConfigs) {
4522
+ MetricConfig.encode(v!, writer.uint32(42).fork()).ldelim();
4523
+ }
4524
+ for (const v of message.exportConfigs) {
4525
+ ExportConfig.encode(v!, writer.uint32(50).fork()).ldelim();
4526
+ }
4527
+ for (const v of message.eventLogConfigs) {
4528
+ EventLogConfig.encode(v!, writer.uint32(58).fork()).ldelim();
4529
+ }
4419
4530
  return writer;
4420
4531
  },
4421
4532
 
@@ -4440,6 +4551,41 @@ export const InitResponse = {
4440
4551
 
4441
4552
  message.dbSchema = DataBaseSchema.decode(reader, reader.uint32());
4442
4553
  continue;
4554
+ case 3:
4555
+ if (tag !== 26) {
4556
+ break;
4557
+ }
4558
+
4559
+ message.config = ProjectConfig.decode(reader, reader.uint32());
4560
+ continue;
4561
+ case 4:
4562
+ if (tag !== 34) {
4563
+ break;
4564
+ }
4565
+
4566
+ message.executionConfig = ExecutionConfig.decode(reader, reader.uint32());
4567
+ continue;
4568
+ case 5:
4569
+ if (tag !== 42) {
4570
+ break;
4571
+ }
4572
+
4573
+ message.metricConfigs.push(MetricConfig.decode(reader, reader.uint32()));
4574
+ continue;
4575
+ case 6:
4576
+ if (tag !== 50) {
4577
+ break;
4578
+ }
4579
+
4580
+ message.exportConfigs.push(ExportConfig.decode(reader, reader.uint32()));
4581
+ continue;
4582
+ case 7:
4583
+ if (tag !== 58) {
4584
+ break;
4585
+ }
4586
+
4587
+ message.eventLogConfigs.push(EventLogConfig.decode(reader, reader.uint32()));
4588
+ continue;
4443
4589
  }
4444
4590
  if ((tag & 7) === 4 || tag === 0) {
4445
4591
  break;
@@ -4453,6 +4599,17 @@ export const InitResponse = {
4453
4599
  return {
4454
4600
  chainIds: globalThis.Array.isArray(object?.chainIds) ? object.chainIds.map((e: any) => globalThis.String(e)) : [],
4455
4601
  dbSchema: isSet(object.dbSchema) ? DataBaseSchema.fromJSON(object.dbSchema) : undefined,
4602
+ config: isSet(object.config) ? ProjectConfig.fromJSON(object.config) : undefined,
4603
+ executionConfig: isSet(object.executionConfig) ? ExecutionConfig.fromJSON(object.executionConfig) : undefined,
4604
+ metricConfigs: globalThis.Array.isArray(object?.metricConfigs)
4605
+ ? object.metricConfigs.map((e: any) => MetricConfig.fromJSON(e))
4606
+ : [],
4607
+ exportConfigs: globalThis.Array.isArray(object?.exportConfigs)
4608
+ ? object.exportConfigs.map((e: any) => ExportConfig.fromJSON(e))
4609
+ : [],
4610
+ eventLogConfigs: globalThis.Array.isArray(object?.eventLogConfigs)
4611
+ ? object.eventLogConfigs.map((e: any) => EventLogConfig.fromJSON(e))
4612
+ : [],
4456
4613
  };
4457
4614
  },
4458
4615
 
@@ -4464,6 +4621,21 @@ export const InitResponse = {
4464
4621
  if (message.dbSchema !== undefined) {
4465
4622
  obj.dbSchema = DataBaseSchema.toJSON(message.dbSchema);
4466
4623
  }
4624
+ if (message.config !== undefined) {
4625
+ obj.config = ProjectConfig.toJSON(message.config);
4626
+ }
4627
+ if (message.executionConfig !== undefined) {
4628
+ obj.executionConfig = ExecutionConfig.toJSON(message.executionConfig);
4629
+ }
4630
+ if (message.metricConfigs?.length) {
4631
+ obj.metricConfigs = message.metricConfigs.map((e) => MetricConfig.toJSON(e));
4632
+ }
4633
+ if (message.exportConfigs?.length) {
4634
+ obj.exportConfigs = message.exportConfigs.map((e) => ExportConfig.toJSON(e));
4635
+ }
4636
+ if (message.eventLogConfigs?.length) {
4637
+ obj.eventLogConfigs = message.eventLogConfigs.map((e) => EventLogConfig.toJSON(e));
4638
+ }
4467
4639
  return obj;
4468
4640
  },
4469
4641
 
@@ -4476,6 +4648,15 @@ export const InitResponse = {
4476
4648
  message.dbSchema = (object.dbSchema !== undefined && object.dbSchema !== null)
4477
4649
  ? DataBaseSchema.fromPartial(object.dbSchema)
4478
4650
  : undefined;
4651
+ message.config = (object.config !== undefined && object.config !== null)
4652
+ ? ProjectConfig.fromPartial(object.config)
4653
+ : undefined;
4654
+ message.executionConfig = (object.executionConfig !== undefined && object.executionConfig !== null)
4655
+ ? ExecutionConfig.fromPartial(object.executionConfig)
4656
+ : undefined;
4657
+ message.metricConfigs = object.metricConfigs?.map((e) => MetricConfig.fromPartial(e)) || [];
4658
+ message.exportConfigs = object.exportConfigs?.map((e) => ExportConfig.fromPartial(e)) || [];
4659
+ message.eventLogConfigs = object.eventLogConfigs?.map((e) => EventLogConfig.fromPartial(e)) || [];
4479
4660
  return message;
4480
4661
  },
4481
4662
  };
@@ -14994,10 +15175,10 @@ export interface ProcessorClient<CallOptionsExt = {}> {
14994
15175
  ): AsyncIterable<PreprocessStreamResponse>;
14995
15176
  }
14996
15177
 
14997
- export type ProcessorV2Definition = typeof ProcessorV2Definition;
14998
- export const ProcessorV2Definition = {
14999
- name: "ProcessorV2",
15000
- fullName: "processor.ProcessorV2",
15178
+ export type ProcessorV3Definition = typeof ProcessorV3Definition;
15179
+ export const ProcessorV3Definition = {
15180
+ name: "ProcessorV3",
15181
+ fullName: "processor.ProcessorV3",
15001
15182
  methods: {
15002
15183
  init: {
15003
15184
  name: "Init",
@@ -15011,7 +15192,7 @@ export const ProcessorV2Definition = {
15011
15192
  name: "ConfigureHandlers",
15012
15193
  requestType: ConfigureHandlersRequest,
15013
15194
  requestStream: false,
15014
- responseType: ProcessConfigResponse,
15195
+ responseType: ConfigureHandlersResponse,
15015
15196
  responseStream: false,
15016
15197
  options: {},
15017
15198
  },
@@ -15026,24 +15207,24 @@ export const ProcessorV2Definition = {
15026
15207
  },
15027
15208
  } as const;
15028
15209
 
15029
- export interface ProcessorV2ServiceImplementation<CallContextExt = {}> {
15210
+ export interface ProcessorV3ServiceImplementation<CallContextExt = {}> {
15030
15211
  init(request: Empty, context: CallContext & CallContextExt): Promise<DeepPartial<InitResponse>>;
15031
15212
  configureHandlers(
15032
15213
  request: ConfigureHandlersRequest,
15033
15214
  context: CallContext & CallContextExt,
15034
- ): Promise<DeepPartial<ProcessConfigResponse>>;
15215
+ ): Promise<DeepPartial<ConfigureHandlersResponse>>;
15035
15216
  processBindingsStream(
15036
15217
  request: AsyncIterable<ProcessStreamRequest>,
15037
15218
  context: CallContext & CallContextExt,
15038
15219
  ): ServerStreamingMethodResult<DeepPartial<ProcessStreamResponseV2>>;
15039
15220
  }
15040
15221
 
15041
- export interface ProcessorV2Client<CallOptionsExt = {}> {
15222
+ export interface ProcessorV3Client<CallOptionsExt = {}> {
15042
15223
  init(request: DeepPartial<Empty>, options?: CallOptions & CallOptionsExt): Promise<InitResponse>;
15043
15224
  configureHandlers(
15044
15225
  request: DeepPartial<ConfigureHandlersRequest>,
15045
15226
  options?: CallOptions & CallOptionsExt,
15046
- ): Promise<ProcessConfigResponse>;
15227
+ ): Promise<ConfigureHandlersResponse>;
15047
15228
  processBindingsStream(
15048
15229
  request: AsyncIterable<DeepPartial<ProcessStreamRequest>>,
15049
15230
  options?: CallOptions & CallOptionsExt,
@@ -348,6 +348,7 @@ export interface User {
348
348
  username: string;
349
349
  accountStatus: User_AccountStatus;
350
350
  tier: Tier;
351
+ isOrganization: boolean;
351
352
  }
352
353
 
353
354
  export enum User_AccountStatus {
@@ -517,6 +518,12 @@ export interface Project_ProjectMember {
517
518
  export interface CommunityProject {
518
519
  dashAlias: string;
519
520
  curated?: boolean | undefined;
521
+ chain: { [key: string]: StringList };
522
+ }
523
+
524
+ export interface CommunityProject_ChainEntry {
525
+ key: string;
526
+ value: StringList | undefined;
520
527
  }
521
528
 
522
529
  export interface ProjectInfo {
@@ -2535,6 +2542,7 @@ function createBaseUser(): User {
2535
2542
  username: "",
2536
2543
  accountStatus: 0,
2537
2544
  tier: 0,
2545
+ isOrganization: false,
2538
2546
  };
2539
2547
  }
2540
2548
 
@@ -2588,6 +2596,9 @@ export const User = {
2588
2596
  if (message.tier !== 0) {
2589
2597
  writer.uint32(120).int32(message.tier);
2590
2598
  }
2599
+ if (message.isOrganization !== false) {
2600
+ writer.uint32(128).bool(message.isOrganization);
2601
+ }
2591
2602
  return writer;
2592
2603
  },
2593
2604
 
@@ -2696,6 +2707,13 @@ export const User = {
2696
2707
 
2697
2708
  message.tier = reader.int32() as any;
2698
2709
  continue;
2710
+ case 16:
2711
+ if (tag !== 128) {
2712
+ break;
2713
+ }
2714
+
2715
+ message.isOrganization = reader.bool();
2716
+ continue;
2699
2717
  }
2700
2718
  if ((tag & 7) === 4 || tag === 0) {
2701
2719
  break;
@@ -2721,6 +2739,7 @@ export const User = {
2721
2739
  username: isSet(object.username) ? globalThis.String(object.username) : "",
2722
2740
  accountStatus: isSet(object.accountStatus) ? user_AccountStatusFromJSON(object.accountStatus) : 0,
2723
2741
  tier: isSet(object.tier) ? tierFromJSON(object.tier) : 0,
2742
+ isOrganization: isSet(object.isOrganization) ? globalThis.Boolean(object.isOrganization) : false,
2724
2743
  };
2725
2744
  },
2726
2745
 
@@ -2768,6 +2787,9 @@ export const User = {
2768
2787
  if (message.tier !== 0) {
2769
2788
  obj.tier = tierToJSON(message.tier);
2770
2789
  }
2790
+ if (message.isOrganization !== false) {
2791
+ obj.isOrganization = message.isOrganization;
2792
+ }
2771
2793
  return obj;
2772
2794
  },
2773
2795
 
@@ -2790,6 +2812,7 @@ export const User = {
2790
2812
  message.username = object.username ?? "";
2791
2813
  message.accountStatus = object.accountStatus ?? 0;
2792
2814
  message.tier = object.tier ?? 0;
2815
+ message.isOrganization = object.isOrganization ?? false;
2793
2816
  return message;
2794
2817
  },
2795
2818
  };
@@ -3493,7 +3516,7 @@ export const Project_ProjectMember = {
3493
3516
  };
3494
3517
 
3495
3518
  function createBaseCommunityProject(): CommunityProject {
3496
- return { dashAlias: "", curated: undefined };
3519
+ return { dashAlias: "", curated: undefined, chain: {} };
3497
3520
  }
3498
3521
 
3499
3522
  export const CommunityProject = {
@@ -3504,6 +3527,9 @@ export const CommunityProject = {
3504
3527
  if (message.curated !== undefined) {
3505
3528
  writer.uint32(16).bool(message.curated);
3506
3529
  }
3530
+ Object.entries(message.chain).forEach(([key, value]) => {
3531
+ CommunityProject_ChainEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).ldelim();
3532
+ });
3507
3533
  return writer;
3508
3534
  },
3509
3535
 
@@ -3528,6 +3554,16 @@ export const CommunityProject = {
3528
3554
 
3529
3555
  message.curated = reader.bool();
3530
3556
  continue;
3557
+ case 3:
3558
+ if (tag !== 26) {
3559
+ break;
3560
+ }
3561
+
3562
+ const entry3 = CommunityProject_ChainEntry.decode(reader, reader.uint32());
3563
+ if (entry3.value !== undefined) {
3564
+ message.chain[entry3.key] = entry3.value;
3565
+ }
3566
+ continue;
3531
3567
  }
3532
3568
  if ((tag & 7) === 4 || tag === 0) {
3533
3569
  break;
@@ -3541,6 +3577,12 @@ export const CommunityProject = {
3541
3577
  return {
3542
3578
  dashAlias: isSet(object.dashAlias) ? globalThis.String(object.dashAlias) : "",
3543
3579
  curated: isSet(object.curated) ? globalThis.Boolean(object.curated) : undefined,
3580
+ chain: isObject(object.chain)
3581
+ ? Object.entries(object.chain).reduce<{ [key: string]: StringList }>((acc, [key, value]) => {
3582
+ acc[key] = StringList.fromJSON(value);
3583
+ return acc;
3584
+ }, {})
3585
+ : {},
3544
3586
  };
3545
3587
  },
3546
3588
 
@@ -3552,6 +3594,15 @@ export const CommunityProject = {
3552
3594
  if (message.curated !== undefined) {
3553
3595
  obj.curated = message.curated;
3554
3596
  }
3597
+ if (message.chain) {
3598
+ const entries = Object.entries(message.chain);
3599
+ if (entries.length > 0) {
3600
+ obj.chain = {};
3601
+ entries.forEach(([k, v]) => {
3602
+ obj.chain[k] = StringList.toJSON(v);
3603
+ });
3604
+ }
3605
+ }
3555
3606
  return obj;
3556
3607
  },
3557
3608
 
@@ -3562,6 +3613,88 @@ export const CommunityProject = {
3562
3613
  const message = createBaseCommunityProject();
3563
3614
  message.dashAlias = object.dashAlias ?? "";
3564
3615
  message.curated = object.curated ?? undefined;
3616
+ message.chain = Object.entries(object.chain ?? {}).reduce<{ [key: string]: StringList }>((acc, [key, value]) => {
3617
+ if (value !== undefined) {
3618
+ acc[key] = StringList.fromPartial(value);
3619
+ }
3620
+ return acc;
3621
+ }, {});
3622
+ return message;
3623
+ },
3624
+ };
3625
+
3626
+ function createBaseCommunityProject_ChainEntry(): CommunityProject_ChainEntry {
3627
+ return { key: "", value: undefined };
3628
+ }
3629
+
3630
+ export const CommunityProject_ChainEntry = {
3631
+ encode(message: CommunityProject_ChainEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
3632
+ if (message.key !== "") {
3633
+ writer.uint32(10).string(message.key);
3634
+ }
3635
+ if (message.value !== undefined) {
3636
+ StringList.encode(message.value, writer.uint32(18).fork()).ldelim();
3637
+ }
3638
+ return writer;
3639
+ },
3640
+
3641
+ decode(input: _m0.Reader | Uint8Array, length?: number): CommunityProject_ChainEntry {
3642
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
3643
+ let end = length === undefined ? reader.len : reader.pos + length;
3644
+ const message = createBaseCommunityProject_ChainEntry();
3645
+ while (reader.pos < end) {
3646
+ const tag = reader.uint32();
3647
+ switch (tag >>> 3) {
3648
+ case 1:
3649
+ if (tag !== 10) {
3650
+ break;
3651
+ }
3652
+
3653
+ message.key = reader.string();
3654
+ continue;
3655
+ case 2:
3656
+ if (tag !== 18) {
3657
+ break;
3658
+ }
3659
+
3660
+ message.value = StringList.decode(reader, reader.uint32());
3661
+ continue;
3662
+ }
3663
+ if ((tag & 7) === 4 || tag === 0) {
3664
+ break;
3665
+ }
3666
+ reader.skipType(tag & 7);
3667
+ }
3668
+ return message;
3669
+ },
3670
+
3671
+ fromJSON(object: any): CommunityProject_ChainEntry {
3672
+ return {
3673
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
3674
+ value: isSet(object.value) ? StringList.fromJSON(object.value) : undefined,
3675
+ };
3676
+ },
3677
+
3678
+ toJSON(message: CommunityProject_ChainEntry): unknown {
3679
+ const obj: any = {};
3680
+ if (message.key !== "") {
3681
+ obj.key = message.key;
3682
+ }
3683
+ if (message.value !== undefined) {
3684
+ obj.value = StringList.toJSON(message.value);
3685
+ }
3686
+ return obj;
3687
+ },
3688
+
3689
+ create(base?: DeepPartial<CommunityProject_ChainEntry>): CommunityProject_ChainEntry {
3690
+ return CommunityProject_ChainEntry.fromPartial(base ?? {});
3691
+ },
3692
+ fromPartial(object: DeepPartial<CommunityProject_ChainEntry>): CommunityProject_ChainEntry {
3693
+ const message = createBaseCommunityProject_ChainEntry();
3694
+ message.key = object.key ?? "";
3695
+ message.value = (object.value !== undefined && object.value !== null)
3696
+ ? StringList.fromPartial(object.value)
3697
+ : undefined;
3565
3698
  return message;
3566
3699
  },
3567
3700
  };
package/src/plugin.ts CHANGED
@@ -62,7 +62,7 @@ export abstract class Plugin {
62
62
  shutdownServer() {}
63
63
 
64
64
  /**
65
- * Initialize the plugin, for service v2.
65
+ * Initialize the plugin, for service v3.
66
66
  * @param config
67
67
  */
68
68
  async init(config: InitResponse): Promise<void> {}
@@ -15,13 +15,15 @@ import { Session } from 'node:inspector/promises'
15
15
  import { ProcessorDefinition } from './gen/processor/protos/processor.js'
16
16
  import { ProcessorServiceImpl } from './service.js'
17
17
  import { configureEndpoints } from './endpoints.js'
18
- import { FullProcessorServiceImpl } from './full-service.js'
18
+ import { FullProcessorServiceImpl, FullProcessorServiceV3Impl } from './full-service.js'
19
19
  import { setupLogger } from './logger.js'
20
20
 
21
21
  import { setupOTLP } from './otlp.js'
22
22
  import { ActionServer } from './action-server.js'
23
23
  import { ServiceManager } from './service-manager.js'
24
24
  import path from 'path'
25
+ import { ProcessorV3Definition } from '@sentio/protos'
26
+ import { ProcessorServiceImplV3 } from './service-v3.js'
25
27
 
26
28
  // const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])
27
29
 
@@ -103,7 +105,10 @@ if (options['start-action-server']) {
103
105
  const service = new FullProcessorServiceImpl(baseService)
104
106
 
105
107
  server.add(ProcessorDefinition, service)
106
-
108
+ server.add(
109
+ ProcessorV3Definition,
110
+ new FullProcessorServiceV3Impl(new ProcessorServiceImplV3(loader, options, server.shutdown))
111
+ )
107
112
  server.listen('0.0.0.0:' + options.port)
108
113
 
109
114
  console.log('Processor Server Started at:', options.port)
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  ConfigureHandlersRequest,
3
+ ConfigureHandlersResponse,
3
4
  DataBinding,
4
5
  DeepPartial,
5
6
  Empty,
6
7
  HandlerType,
7
8
  InitResponse,
8
9
  ProcessConfigResponse,
9
- ProcessorV2ServiceImplementation,
10
+ ProcessorV3ServiceImplementation,
10
11
  ProcessResult,
11
12
  ProcessStreamRequest,
13
+ ProcessStreamResponse,
12
14
  ProcessStreamResponseV2,
13
15
  StartRequest
14
16
  } from '@sentio/protos'
@@ -27,7 +29,7 @@ import { TemplateInstanceState } from './state.js'
27
29
 
28
30
  const { process_binding_count, process_binding_time, process_binding_error } = processMetrics
29
31
 
30
- export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation {
32
+ export class ProcessorServiceImplV3 implements ProcessorV3ServiceImplementation {
31
33
  readonly enablePartition: boolean
32
34
  private readonly loader: () => Promise<any>
33
35
  private readonly shutdownHandler?: () => void
@@ -40,6 +42,7 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
40
42
  }
41
43
 
42
44
  async init(request: Empty, context: CallContext): Promise<DeepPartial<InitResponse>> {
45
+ await this.loader()
43
46
  const resp = InitResponse.fromPartial({
44
47
  chainIds: []
45
48
  })
@@ -50,6 +53,21 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
50
53
 
51
54
  async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
52
55
  const subject = new Subject<DeepPartial<ProcessStreamResponseV2>>()
56
+ this.handleRequests(requests, subject)
57
+ .then(() => {
58
+ subject.complete()
59
+ })
60
+ .catch((e) => {
61
+ console.error(e)
62
+ subject.error(e)
63
+ })
64
+ yield* from(subject).pipe(withAbort(context.signal))
65
+ }
66
+
67
+ protected async handleRequests(
68
+ requests: AsyncIterable<ProcessStreamRequest>,
69
+ subject: Subject<DeepPartial<ProcessStreamResponse>>
70
+ ) {
53
71
  let lastBinding: DataBinding | undefined = undefined
54
72
  for await (const request of requests) {
55
73
  try {
@@ -63,8 +81,8 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
63
81
  console.error('unexpect error during handle loop', e)
64
82
  }
65
83
  }
66
- yield* from(subject).pipe(withAbort(context.signal))
67
84
  }
85
+
68
86
  private contexts = new Contexts()
69
87
 
70
88
  async handleRequest(
@@ -85,6 +103,7 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
85
103
 
86
104
  if (this.enablePartition) {
87
105
  try {
106
+ console.debug('sending partition request', request.binding)
88
107
  const partitions = await PluginManager.INSTANCE.partition(request.binding)
89
108
  subject.next({
90
109
  processId: request.processId,
@@ -126,11 +145,13 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
126
145
  ) {
127
146
  const context = this.contexts.new(processId, subject)
128
147
  const start = Date.now()
148
+ console.debug('process binding', processId)
129
149
  PluginManager.INSTANCE.processBinding(binding, undefined, context)
130
150
  .then(async (result) => {
131
- // await all pending db requests
151
+ console.debug(`process binding ${processId} done`)
132
152
  await context.awaitPendings()
133
153
 
154
+ console.debug('sending ts data length:', result.timeseriesResult.length)
134
155
  for (const ts of result.timeseriesResult) {
135
156
  subject.next({
136
157
  processId,
@@ -141,6 +162,7 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
141
162
  }
142
163
 
143
164
  if (result.states?.configUpdated) {
165
+ console.debug('sending tpl updates:')
144
166
  subject.next({
145
167
  processId,
146
168
  tplRequest: {
@@ -149,6 +171,7 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
149
171
  })
150
172
  }
151
173
 
174
+ console.debug('sending binding result', processId)
152
175
  subject.next({
153
176
  result: {
154
177
  states: result.states,
@@ -167,13 +190,14 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
167
190
  const cost = Date.now() - start
168
191
  process_binding_time.add(cost)
169
192
  this.contexts.delete(processId)
193
+ console.debug('process binding done', processId)
170
194
  })
171
195
  }
172
196
 
173
197
  async configureHandlers(
174
198
  request: ConfigureHandlersRequest,
175
199
  context: CallContext
176
- ): Promise<DeepPartial<ProcessConfigResponse>> {
200
+ ): Promise<DeepPartial<ConfigureHandlersResponse>> {
177
201
  await PluginManager.INSTANCE.start(
178
202
  StartRequest.fromPartial({
179
203
  templateInstances: request.templateInstances
@@ -182,7 +206,10 @@ export class ProcessorServiceImplV2 implements ProcessorV2ServiceImplementation
182
206
 
183
207
  const newConfig = ProcessConfigResponse.fromPartial({})
184
208
  await PluginManager.INSTANCE.configure(newConfig, request.chainId)
185
- return newConfig
209
+ return {
210
+ accountConfigs: newConfig.accountConfigs,
211
+ contractConfigs: newConfig.contractConfigs
212
+ }
186
213
  }
187
214
  }
188
215