@sentio/runtime 2.31.0-rc.14 → 2.31.0-rc.15

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.
@@ -1,6 +1,4 @@
1
- export interface ExecutionConfig {
2
- sequential: boolean;
3
- }
1
+ import { ExecutionConfig } from './gen/processor/protos/processor.js';
4
2
  export interface GlobalConfig {
5
3
  execution: ExecutionConfig;
6
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../src/global-config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,OAAO,CAAA;CACpB;AACD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,CAAA;CAC3B;AAGD,eAAO,MAAM,aAAa,EAAE,YAI3B,CAAA;AAED,wBAAgB,kBAAkB,SAEjC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,OAcrC"}
1
+ {"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../src/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAErE,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,CAAA;CAC3B;AAGD,eAAO,MAAM,aAAa,EAAE,YAI3B,CAAA;AAED,wBAAgB,kBAAkB,SAEjC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,OAcrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"global-config.js","sourceRoot":"","sources":["../src/global-config.ts"],"names":[],"mappings":"AAQA,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,SAAS,EAAE;QACT,UAAU,EAAE,KAAK;KAClB;CACF,CAAA;AAED,MAAM,UAAU,kBAAkB;IAChC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAW;IACpC,gDAAgD;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEzC,yCAAyC;IACzC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAE1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACvE,UAAU,CAAC,KAAK,CAAC,CAAA;SAClB;KACF;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC9B,CAAC"}
1
+ {"version":3,"file":"global-config.js","sourceRoot":"","sources":["../src/global-config.ts"],"names":[],"mappings":"AAMA,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,SAAS,EAAE;QACT,UAAU,EAAE,KAAK;KAClB;CACF,CAAA;AAED,MAAM,UAAU,kBAAkB;IAChC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAW;IACpC,gDAAgD;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEzC,yCAAyC;IACzC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAE1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACvE,UAAU,CAAC,KAAK,CAAC,CAAA;SAClB;KACF;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC9B,CAAC"}
package/lib/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export * from './utils.js';
4
4
  export * from './endpoints.js';
5
5
  export * from './chain-config.js';
6
6
  export * from './service.js';
7
- export { GLOBAL_CONFIG, type ExecutionConfig, type GlobalConfig } from './global-config.js';
7
+ export { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAA2C,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.31.0-rc.14",
3
+ "version": "2.31.0-rc.15",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,10 +30,10 @@
30
30
  "protobufjs": "^7.2.5",
31
31
  "utility-types": "^3.10.0",
32
32
  "winston": "^3.10.0",
33
- "@sentio/protos": "2.31.0-rc.14"
33
+ "@sentio/protos": "2.31.0-rc.15"
34
34
  },
35
35
  "peerDependencies": {
36
- "@sentio/sdk": "^2.31.0-rc.14"
36
+ "@sentio/sdk": "^2.31.0-rc.15"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/command-line-args": "^5.2.0",
@@ -10,13 +10,14 @@ import {
10
10
  ProcessConfigRequest,
11
11
  ProcessorServiceImplementation,
12
12
  StartRequest,
13
- ProcessResult,
13
+ ProcessResult
14
14
  } from './gen/processor/protos/processor.js'
15
15
 
16
16
  import { Empty } from '@sentio/protos'
17
17
  import fs from 'fs-extra'
18
18
  import path from 'path'
19
19
  import os from 'os'
20
+ import { GLOBAL_CONFIG } from './global-config.js'
20
21
 
21
22
  function locatePackageJson(pkgId: string) {
22
23
  const m = require.resolve(pkgId)
@@ -46,6 +47,8 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
46
47
 
47
48
  async getConfig(request: ProcessConfigRequest, context: CallContext) {
48
49
  const config = await this.instance.getConfig(request, context)
50
+ config.executionConfig = GLOBAL_CONFIG.execution
51
+
49
52
  if (config.contractConfigs) {
50
53
  for (const contract of config.contractConfigs) {
51
54
  // @ts-ignore old fields
@@ -72,6 +75,8 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
72
75
  }
73
76
 
74
77
  async processBindings(request: ProcessBindingsRequest, options: CallContext) {
78
+ request.bindings = request.bindings.sort(dataCompare)
79
+
75
80
  for (const binding of request.bindings) {
76
81
  this.adjustDataBinding(binding)
77
82
  }
@@ -129,3 +134,32 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
129
134
  }
130
135
  }
131
136
  }
137
+
138
+ // TODO push the logic into sdk
139
+ function dataCompare(a: DataBinding, b: DataBinding): number {
140
+ const timeA = getTimestamp(a) || new Date(0)
141
+ const timeB = getTimestamp(b) || new Date(0)
142
+ const timeCmp = timeA.getTime() - timeB.getTime()
143
+ if (timeCmp !== 0) {
144
+ return timeCmp
145
+ }
146
+ return getSecondary(a) - getSecondary(b)
147
+ }
148
+
149
+ function getTimestamp(d: DataBinding): Date | undefined {
150
+ return (
151
+ d.data?.ethLog?.timestamp ||
152
+ d.data?.ethTransaction?.timestamp ||
153
+ d.data?.ethBlock?.block?.timestamp ||
154
+ d.data?.ethTrace?.timestamp
155
+ )
156
+ }
157
+
158
+ function getSecondary(d: DataBinding) {
159
+ return (
160
+ d.data?.ethLog?.log?.logIndex ||
161
+ d.data?.ethTransaction?.transaction?.transactionIndex ||
162
+ d.data?.ethBlock?.block?.number ||
163
+ d.data?.ethTrace?.trace?.transactionPosition
164
+ )
165
+ }
@@ -342,11 +342,16 @@ export interface ProjectConfig {
342
342
  version: string;
343
343
  }
344
344
 
345
+ export interface ExecutionConfig {
346
+ sequential: boolean;
347
+ }
348
+
345
349
  export interface ProcessConfigRequest {
346
350
  }
347
351
 
348
352
  export interface ProcessConfigResponse {
349
353
  config: ProjectConfig | undefined;
354
+ executionConfig: ExecutionConfig | undefined;
350
355
  contractConfigs: ContractConfig[];
351
356
  templateInstances: TemplateInstance[];
352
357
  accountConfigs: AccountConfig[];
@@ -925,6 +930,57 @@ export const ProjectConfig = {
925
930
  },
926
931
  };
927
932
 
933
+ function createBaseExecutionConfig(): ExecutionConfig {
934
+ return { sequential: false };
935
+ }
936
+
937
+ export const ExecutionConfig = {
938
+ encode(message: ExecutionConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
939
+ if (message.sequential === true) {
940
+ writer.uint32(8).bool(message.sequential);
941
+ }
942
+ return writer;
943
+ },
944
+
945
+ decode(input: _m0.Reader | Uint8Array, length?: number): ExecutionConfig {
946
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
947
+ let end = length === undefined ? reader.len : reader.pos + length;
948
+ const message = createBaseExecutionConfig();
949
+ while (reader.pos < end) {
950
+ const tag = reader.uint32();
951
+ switch (tag >>> 3) {
952
+ case 1:
953
+ message.sequential = reader.bool();
954
+ break;
955
+ default:
956
+ reader.skipType(tag & 7);
957
+ break;
958
+ }
959
+ }
960
+ return message;
961
+ },
962
+
963
+ fromJSON(object: any): ExecutionConfig {
964
+ return { sequential: isSet(object.sequential) ? Boolean(object.sequential) : false };
965
+ },
966
+
967
+ toJSON(message: ExecutionConfig): unknown {
968
+ const obj: any = {};
969
+ message.sequential !== undefined && (obj.sequential = message.sequential);
970
+ return obj;
971
+ },
972
+
973
+ create(base?: DeepPartial<ExecutionConfig>): ExecutionConfig {
974
+ return ExecutionConfig.fromPartial(base ?? {});
975
+ },
976
+
977
+ fromPartial(object: DeepPartial<ExecutionConfig>): ExecutionConfig {
978
+ const message = createBaseExecutionConfig();
979
+ message.sequential = object.sequential ?? false;
980
+ return message;
981
+ },
982
+ };
983
+
928
984
  function createBaseProcessConfigRequest(): ProcessConfigRequest {
929
985
  return {};
930
986
  }
@@ -971,6 +1027,7 @@ export const ProcessConfigRequest = {
971
1027
  function createBaseProcessConfigResponse(): ProcessConfigResponse {
972
1028
  return {
973
1029
  config: undefined,
1030
+ executionConfig: undefined,
974
1031
  contractConfigs: [],
975
1032
  templateInstances: [],
976
1033
  accountConfigs: [],
@@ -986,6 +1043,9 @@ export const ProcessConfigResponse = {
986
1043
  if (message.config !== undefined) {
987
1044
  ProjectConfig.encode(message.config, writer.uint32(10).fork()).ldelim();
988
1045
  }
1046
+ if (message.executionConfig !== undefined) {
1047
+ ExecutionConfig.encode(message.executionConfig, writer.uint32(74).fork()).ldelim();
1048
+ }
989
1049
  for (const v of message.contractConfigs) {
990
1050
  ContractConfig.encode(v!, writer.uint32(18).fork()).ldelim();
991
1051
  }
@@ -1020,6 +1080,9 @@ export const ProcessConfigResponse = {
1020
1080
  case 1:
1021
1081
  message.config = ProjectConfig.decode(reader, reader.uint32());
1022
1082
  break;
1083
+ case 9:
1084
+ message.executionConfig = ExecutionConfig.decode(reader, reader.uint32());
1085
+ break;
1023
1086
  case 2:
1024
1087
  message.contractConfigs.push(ContractConfig.decode(reader, reader.uint32()));
1025
1088
  break;
@@ -1052,6 +1115,7 @@ export const ProcessConfigResponse = {
1052
1115
  fromJSON(object: any): ProcessConfigResponse {
1053
1116
  return {
1054
1117
  config: isSet(object.config) ? ProjectConfig.fromJSON(object.config) : undefined,
1118
+ executionConfig: isSet(object.executionConfig) ? ExecutionConfig.fromJSON(object.executionConfig) : undefined,
1055
1119
  contractConfigs: Array.isArray(object?.contractConfigs)
1056
1120
  ? object.contractConfigs.map((e: any) => ContractConfig.fromJSON(e))
1057
1121
  : [],
@@ -1079,6 +1143,8 @@ export const ProcessConfigResponse = {
1079
1143
  toJSON(message: ProcessConfigResponse): unknown {
1080
1144
  const obj: any = {};
1081
1145
  message.config !== undefined && (obj.config = message.config ? ProjectConfig.toJSON(message.config) : undefined);
1146
+ message.executionConfig !== undefined &&
1147
+ (obj.executionConfig = message.executionConfig ? ExecutionConfig.toJSON(message.executionConfig) : undefined);
1082
1148
  if (message.contractConfigs) {
1083
1149
  obj.contractConfigs = message.contractConfigs.map((e) => e ? ContractConfig.toJSON(e) : undefined);
1084
1150
  } else {
@@ -1126,6 +1192,9 @@ export const ProcessConfigResponse = {
1126
1192
  message.config = (object.config !== undefined && object.config !== null)
1127
1193
  ? ProjectConfig.fromPartial(object.config)
1128
1194
  : undefined;
1195
+ message.executionConfig = (object.executionConfig !== undefined && object.executionConfig !== null)
1196
+ ? ExecutionConfig.fromPartial(object.executionConfig)
1197
+ : undefined;
1129
1198
  message.contractConfigs = object.contractConfigs?.map((e) => ContractConfig.fromPartial(e)) || [];
1130
1199
  message.templateInstances = object.templateInstances?.map((e) => TemplateInstance.fromPartial(e)) || [];
1131
1200
  message.accountConfigs = object.accountConfigs?.map((e) => AccountConfig.fromPartial(e)) || [];
@@ -1,7 +1,5 @@
1
- export interface ExecutionConfig {
2
- // Whether to execute transactions sequentially, by default it's false
3
- sequential: boolean
4
- }
1
+ import { ExecutionConfig } from './gen/processor/protos/processor.js'
2
+
5
3
  export interface GlobalConfig {
6
4
  execution: ExecutionConfig
7
5
  }
package/src/index.ts CHANGED
@@ -4,4 +4,4 @@ export * from './utils.js'
4
4
  export * from './endpoints.js'
5
5
  export * from './chain-config.js'
6
6
  export * from './service.js'
7
- export { GLOBAL_CONFIG, type ExecutionConfig, type GlobalConfig } from './global-config.js'
7
+ export { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'