@sentio/runtime 2.39.7-rc.8 → 2.40.0-rc.1

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.
Files changed (96) hide show
  1. package/lib/chunk-LMUCLUM5.js +78161 -0
  2. package/lib/index.d.ts +308 -9
  3. package/lib/index.js +92 -9
  4. package/lib/processor-runner.d.ts +0 -2
  5. package/lib/processor-runner.js +51457 -129
  6. package/package.json +5 -25
  7. package/src/db-context.ts +165 -7
  8. package/src/gen/processor/protos/processor.ts +361 -1
  9. package/src/plugin.ts +30 -4
  10. package/src/processor-runner.ts +26 -2
  11. package/src/provider.ts +166 -0
  12. package/src/service.ts +147 -28
  13. package/src/tsup.config.ts +14 -0
  14. package/lib/chain-config.d.ts +0 -6
  15. package/lib/chain-config.d.ts.map +0 -1
  16. package/lib/chain-config.js +0 -2
  17. package/lib/chain-config.js.map +0 -1
  18. package/lib/db-context.d.ts +0 -16
  19. package/lib/db-context.d.ts.map +0 -1
  20. package/lib/db-context.js +0 -56
  21. package/lib/db-context.js.map +0 -1
  22. package/lib/decode-benchmark.d.ts +0 -3
  23. package/lib/decode-benchmark.d.ts.map +0 -1
  24. package/lib/decode-benchmark.js +0 -20
  25. package/lib/decode-benchmark.js.map +0 -1
  26. package/lib/endpoints.d.ts +0 -9
  27. package/lib/endpoints.d.ts.map +0 -1
  28. package/lib/endpoints.js +0 -9
  29. package/lib/endpoints.js.map +0 -1
  30. package/lib/full-service.d.ts +0 -655
  31. package/lib/full-service.d.ts.map +0 -1
  32. package/lib/full-service.js +0 -137
  33. package/lib/full-service.js.map +0 -1
  34. package/lib/gen/google/protobuf/empty.d.ts +0 -17
  35. package/lib/gen/google/protobuf/empty.d.ts.map +0 -1
  36. package/lib/gen/google/protobuf/empty.js +0 -40
  37. package/lib/gen/google/protobuf/empty.js.map +0 -1
  38. package/lib/gen/google/protobuf/struct.d.ts +0 -77
  39. package/lib/gen/google/protobuf/struct.d.ts.map +0 -1
  40. package/lib/gen/google/protobuf/struct.js +0 -429
  41. package/lib/gen/google/protobuf/struct.js.map +0 -1
  42. package/lib/gen/google/protobuf/timestamp.d.ts +0 -19
  43. package/lib/gen/google/protobuf/timestamp.d.ts.map +0 -1
  44. package/lib/gen/google/protobuf/timestamp.js +0 -83
  45. package/lib/gen/google/protobuf/timestamp.js.map +0 -1
  46. package/lib/gen/processor/protos/processor.d.ts +0 -1470
  47. package/lib/gen/processor/protos/processor.d.ts.map +0 -1
  48. package/lib/gen/processor/protos/processor.js +0 -8512
  49. package/lib/gen/processor/protos/processor.js.map +0 -1
  50. package/lib/gen/service/common/protos/common.d.ts +0 -1698
  51. package/lib/gen/service/common/protos/common.d.ts.map +0 -1
  52. package/lib/gen/service/common/protos/common.js +0 -11383
  53. package/lib/gen/service/common/protos/common.js.map +0 -1
  54. package/lib/global-config.d.ts +0 -8
  55. package/lib/global-config.d.ts.map +0 -1
  56. package/lib/global-config.js +0 -23
  57. package/lib/global-config.js.map +0 -1
  58. package/lib/global-config.test.d.ts +0 -2
  59. package/lib/global-config.test.d.ts.map +0 -1
  60. package/lib/global-config.test.js.map +0 -1
  61. package/lib/index.d.ts.map +0 -1
  62. package/lib/index.js.map +0 -1
  63. package/lib/logger.d.ts +0 -2
  64. package/lib/logger.d.ts.map +0 -1
  65. package/lib/logger.js +0 -39
  66. package/lib/logger.js.map +0 -1
  67. package/lib/logger.test.d.ts +0 -2
  68. package/lib/logger.test.d.ts.map +0 -1
  69. package/lib/logger.test.js.map +0 -1
  70. package/lib/plugin.d.ts +0 -29
  71. package/lib/plugin.d.ts.map +0 -1
  72. package/lib/plugin.js +0 -58
  73. package/lib/plugin.js.map +0 -1
  74. package/lib/processor-runner.d.ts.map +0 -1
  75. package/lib/processor-runner.js.map +0 -1
  76. package/lib/seq-mode.test.d.ts +0 -3
  77. package/lib/seq-mode.test.d.ts.map +0 -1
  78. package/lib/seq-mode.test.js.map +0 -1
  79. package/lib/service.d.ts +0 -179
  80. package/lib/service.d.ts.map +0 -1
  81. package/lib/service.js +0 -179
  82. package/lib/service.js.map +0 -1
  83. package/lib/service.test.d.ts +0 -3
  84. package/lib/service.test.d.ts.map +0 -1
  85. package/lib/service.test.js.map +0 -1
  86. package/lib/state-storage.test.d.ts +0 -2
  87. package/lib/state-storage.test.d.ts.map +0 -1
  88. package/lib/state-storage.test.js.map +0 -1
  89. package/lib/state.d.ts +0 -23
  90. package/lib/state.d.ts.map +0 -1
  91. package/lib/state.js +0 -61
  92. package/lib/state.js.map +0 -1
  93. package/lib/utils.d.ts +0 -6
  94. package/lib/utils.d.ts.map +0 -1
  95. package/lib/utils.js +0 -23
  96. package/lib/utils.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "2.39.7-rc.8",
3
+ "version": "2.40.0-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -14,46 +14,26 @@
14
14
  "!**/*.test.{js,ts}",
15
15
  "!{lib,src}/tests"
16
16
  ],
17
- "dependencies": {
18
- "@grpc/grpc-js": "^1.9.14",
19
- "command-line-args": "^5.2.1",
20
- "command-line-usage": "^7.0.1",
21
- "fs-extra": "^11.2.0",
22
- "google-protobuf": "^3.21.2",
23
- "ix": "^5.0.0",
24
- "long": "^5.2.3",
25
- "nice-grpc": "^2.1.7",
26
- "nice-grpc-client-middleware-retry": "^3.1.6",
27
- "nice-grpc-common": "^2.0.2",
28
- "nice-grpc-error-details": "^0.2.4",
29
- "nice-grpc-prometheus": "^0.2.2",
30
- "prom-client": "^14.2.0",
31
- "protobufjs": "^7.2.6",
32
- "rxjs": "^7.8.1",
33
- "utility-types": "^3.11.0",
34
- "winston": "^3.11.0",
35
- "@sentio/protos": "2.39.7-rc.8"
36
- },
17
+ "dependencies": {},
37
18
  "devDependencies": {
38
19
  "@types/command-line-args": "^5.2.3",
39
20
  "@types/command-line-usage": "^5.0.4",
40
21
  "@types/fs-extra": "^11.0.4",
41
22
  "@types/google-protobuf": "^3.15.12",
42
- "jest": "^29.7.0",
43
- "ts-node": "^10.9.2",
44
23
  "tslib": "^2.6.2"
45
24
  },
46
25
  "engines": {
47
26
  "node": ">=16"
48
27
  },
49
28
  "scripts": {
50
- "build": "pnpm compile",
29
+ "build": "pnpm bundle",
51
30
  "build:all": "pnpm --filter=$(node -p \"require('./package.json').name\")... build",
31
+ "bundle": "tsup --config src/tsup.config.ts",
52
32
  "compile": "tsc",
53
33
  "run": "tsx src/processor-runner.ts --log-format=json",
54
34
  "run-benchmark": "tsx src/decode-benchmark.ts",
55
35
  "start_js": "tsx ./lib/processor-runner.js $PWD/../../debug/dist/lib.js",
56
36
  "start_ts": "tsx ./lib/processor-runner.js --log-format=json $PWD/../../debug/src/processor.ts",
57
- "test": "NODE_OPTIONS=--experimental-vm-modules pnpm jest"
37
+ "test": "glob -c 'tsx --test' '**/*.test.ts'"
58
38
  }
59
39
  }
package/src/db-context.ts CHANGED
@@ -1,28 +1,94 @@
1
1
  import { Subject } from 'rxjs'
2
- import { DBRequest, DBResponse, DeepPartial, ProcessResult, ProcessStreamResponse } from '@sentio/protos'
2
+ import {
3
+ DBRequest,
4
+ DBRequest_DBUpsert,
5
+ DBResponse,
6
+ DeepPartial,
7
+ ProcessResult,
8
+ ProcessStreamResponse
9
+ } from '@sentio/protos'
10
+ import * as process from 'node:process'
11
+ import { Attributes, Counter, metrics } from '@opentelemetry/api'
12
+
13
+ const STORE_BATCH_IDLE = process.env['STORE_BATCH_MAX_IDLE'] ? parseInt(process.env['STORE_BATCH_MAX_IDLE']) : 1
14
+ const STORE_BATCH_SIZE = process.env['STORE_BATCH_SIZE'] ? parseInt(process.env['STORE_BATCH_SIZE']) : 10
3
15
 
4
16
  type Request = Omit<DBRequest, 'opId'>
17
+ type RequestType = keyof Request
18
+
19
+ const meter = metrics.getMeter('processor_store')
20
+ const send_counts: Record<RequestType, Counter<Attributes>> = {
21
+ get: meter.createCounter('store_get_count'),
22
+ upsert: meter.createCounter('store_upsert_count'),
23
+ list: meter.createCounter('store_list_count'),
24
+ delete: meter.createCounter('store_delete_count')
25
+ }
26
+ const recv_counts: Record<RequestType, Counter<Attributes>> = {
27
+ get: meter.createCounter('store_get_count'),
28
+ upsert: meter.createCounter('store_upsert_count'),
29
+ list: meter.createCounter('store_list_count'),
30
+ delete: meter.createCounter('store_delete_count')
31
+ }
32
+ const request_times: Record<RequestType, Counter<Attributes>> = {
33
+ get: meter.createCounter('store_get_time'),
34
+ upsert: meter.createCounter('store_upsert_time'),
35
+ list: meter.createCounter('store_list_time'),
36
+ delete: meter.createCounter('store_delete_time')
37
+ }
38
+ const request_errors: Record<RequestType, Counter<Attributes>> = {
39
+ get: meter.createCounter('store_get_error'),
40
+ upsert: meter.createCounter('store_upsert_error'),
41
+ list: meter.createCounter('store_list_error'),
42
+ delete: meter.createCounter('store_delete_error')
43
+ }
44
+
45
+ const batched_total_count = meter.createCounter('batched_total_count')
46
+ const batched_request_count = meter.createCounter('batched_request_count')
47
+
48
+ const unsolved_requests = meter.createGauge('store_unsolved_requests')
49
+
50
+ export const timeoutError = Symbol()
5
51
 
6
52
  export class StoreContext {
7
53
  private static opCounter = 0n
8
54
 
9
- private defers = new Map<bigint, { resolve: (value: any) => void; reject: (reason?: any) => void }>()
55
+ private defers = new Map<
56
+ bigint,
57
+ { resolve: (value: any) => void; reject: (reason?: any) => void; requestType?: RequestType }
58
+ >()
59
+ private statsInterval: NodeJS.Timeout | undefined
10
60
 
11
61
  constructor(
12
62
  readonly subject: Subject<DeepPartial<ProcessStreamResponse>>,
13
63
  readonly processId: number
14
64
  ) {}
15
65
 
16
- newPromise<T>(opId: bigint) {
66
+ newPromise<T>(opId: bigint, requestType?: RequestType) {
17
67
  return new Promise<T>((resolve, reject) => {
18
- this.defers.set(opId, { resolve, reject })
68
+ this.defers.set(opId, { resolve, reject, requestType })
69
+ unsolved_requests.record(this.defers.size, { processId: this.processId })
19
70
  })
20
71
  }
21
72
 
22
- sendRequest(request: DeepPartial<Request>) {
73
+ sendRequest(request: DeepPartial<Request>, timeoutSecs?: number): Promise<DBResponse> {
74
+ if (STORE_BATCH_IDLE > 0 && STORE_BATCH_SIZE > 1 && request.upsert) {
75
+ // batch upsert if possible
76
+ return this.sendUpsertInBatch(request.upsert as DBRequest_DBUpsert)
77
+ }
78
+
79
+ const requestType = Object.keys(request)[0] as RequestType
23
80
  const opId = StoreContext.opCounter++
24
- const promise = this.newPromise(opId)
81
+ const promise = this.newPromise(opId, requestType)
82
+
83
+ const start = Date.now()
84
+ const promises = [promise]
25
85
  console.debug('sending db request ', opId, request)
86
+ let timer: NodeJS.Timeout | undefined
87
+ if (timeoutSecs) {
88
+ const timeoutPromise = new Promise((_r, rej) => (timer = setTimeout(rej, timeoutSecs * 1000, timeoutError)))
89
+ promises.push(timeoutPromise)
90
+ }
91
+
26
92
  this.subject.next({
27
93
  dbRequest: {
28
94
  ...request,
@@ -30,7 +96,27 @@ export class StoreContext {
30
96
  },
31
97
  processId: this.processId
32
98
  })
33
- return promise
99
+
100
+ send_counts[requestType]?.add(1)
101
+
102
+ return Promise.race(promises)
103
+ .then((result: DBResponse) => {
104
+ console.debug('db request', requestType, 'op', opId, ' took', Date.now() - start, 'ms')
105
+ request_times[requestType]?.add(Date.now() - start)
106
+ return result
107
+ })
108
+ .catch((e) => {
109
+ if (e === timeoutError) {
110
+ console.error('db request', requestType, 'op:', opId, ' timeout')
111
+ }
112
+ request_errors[requestType]?.add(1)
113
+ throw e
114
+ })
115
+ .finally(() => {
116
+ if (timer) {
117
+ clearTimeout(timer)
118
+ }
119
+ })
34
120
  }
35
121
 
36
122
  result(dbResult: DBResponse) {
@@ -38,6 +124,9 @@ export class StoreContext {
38
124
  const defer = this.defers.get(opId)
39
125
  console.debug('received db result ', opId, dbResult)
40
126
  if (defer) {
127
+ if (defer.requestType) {
128
+ recv_counts[defer.requestType]?.add(1)
129
+ }
41
130
  if (dbResult.error) {
42
131
  defer.reject(new Error(dbResult.error))
43
132
  } else {
@@ -45,6 +134,7 @@ export class StoreContext {
45
134
  }
46
135
  this.defers.delete(opId)
47
136
  }
137
+ unsolved_requests.record(this.defers.size, { processId: this.processId })
48
138
  }
49
139
 
50
140
  error(processId: number, e: any) {
@@ -59,4 +149,72 @@ export class StoreContext {
59
149
  processId
60
150
  })
61
151
  }
152
+
153
+ close() {
154
+ for (const [opId, defer] of this.defers) {
155
+ console.warn('context closed before db response', opId)
156
+ defer.reject(new Error('context closed'))
157
+ }
158
+ this.defers.clear()
159
+ if (this.statsInterval) {
160
+ clearInterval(this.statsInterval)
161
+ }
162
+ }
163
+
164
+ upsertBatch:
165
+ | {
166
+ opId: bigint
167
+ request: DBRequest_DBUpsert
168
+ promise: Promise<DBResponse>
169
+ timer: NodeJS.Timeout
170
+ }
171
+ | undefined = undefined
172
+
173
+ private async sendUpsertInBatch(req: DBRequest_DBUpsert): Promise<DBResponse> {
174
+ if (this.upsertBatch) {
175
+ // merge the upserts
176
+ const { request, promise } = this.upsertBatch
177
+ request.entity = this.upsertBatch.request.entity.concat(req.entity)
178
+ request.entityData = this.upsertBatch.request.entityData.concat(req.entityData)
179
+ request.id = this.upsertBatch.request.id.concat(req.id)
180
+ if (request.entity.length >= STORE_BATCH_SIZE) {
181
+ this.sendBatch()
182
+ }
183
+ return promise
184
+ } else {
185
+ const opId = StoreContext.opCounter++
186
+ const promise = this.newPromise<DBResponse>(opId, 'upsert')
187
+ const timeout = setTimeout(() => {
188
+ this.sendBatch()
189
+ }, STORE_BATCH_IDLE)
190
+
191
+ this.upsertBatch = {
192
+ opId,
193
+ request: req,
194
+ promise,
195
+ timer: timeout
196
+ }
197
+
198
+ return promise
199
+ }
200
+ }
201
+
202
+ private sendBatch() {
203
+ if (this.upsertBatch) {
204
+ const { request, opId, timer } = this.upsertBatch
205
+ console.debug('sending batch upsert', opId, 'batch size', request?.entity.length)
206
+ clearTimeout(timer)
207
+ this.upsertBatch = undefined
208
+ this.subject.next({
209
+ dbRequest: {
210
+ upsert: request,
211
+ opId
212
+ },
213
+ processId: this.processId
214
+ })
215
+ send_counts['upsert']?.add(1)
216
+ batched_request_count.add(1)
217
+ batched_total_count.add(request.entity.length)
218
+ }
219
+ }
62
220
  }
@@ -3,7 +3,7 @@ import Long from "long";
3
3
  import type { CallContext, CallOptions } from "nice-grpc-common";
4
4
  import _m0 from "protobufjs/minimal.js";
5
5
  import { Empty } from "../../google/protobuf/empty.js";
6
- import { ListValue, Struct } from "../../google/protobuf/struct.js";
6
+ import { ListValue, Struct, Value } from "../../google/protobuf/struct.js";
7
7
  import { Timestamp } from "../../google/protobuf/timestamp.js";
8
8
  import { BigInteger, CoinID, RichStruct, RichStructList, RichValueList } from "../../service/common/protos/common.js";
9
9
 
@@ -1030,6 +1030,27 @@ export interface ProcessResult {
1030
1030
  states: StateResult | undefined;
1031
1031
  }
1032
1032
 
1033
+ export interface EthCallParam {
1034
+ chainId: string;
1035
+ address: string;
1036
+ function: string;
1037
+ signature: string;
1038
+ args: any[];
1039
+ }
1040
+
1041
+ export interface PreprocessResult {
1042
+ ethCallParams: EthCallParam[];
1043
+ }
1044
+
1045
+ export interface PreparedData {
1046
+ ethCallResults: { [key: string]: Array<any> | undefined };
1047
+ }
1048
+
1049
+ export interface PreparedData_EthCallResultsEntry {
1050
+ key: string;
1051
+ value: Array<any> | undefined;
1052
+ }
1053
+
1033
1054
  export interface RecordMetaData {
1034
1055
  address: string;
1035
1056
  contractName: string;
@@ -8786,6 +8807,345 @@ export const ProcessResult = {
8786
8807
  },
8787
8808
  };
8788
8809
 
8810
+ function createBaseEthCallParam(): EthCallParam {
8811
+ return { chainId: "", address: "", function: "", signature: "", args: [] };
8812
+ }
8813
+
8814
+ export const EthCallParam = {
8815
+ encode(message: EthCallParam, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
8816
+ if (message.chainId !== "") {
8817
+ writer.uint32(10).string(message.chainId);
8818
+ }
8819
+ if (message.address !== "") {
8820
+ writer.uint32(18).string(message.address);
8821
+ }
8822
+ if (message.function !== "") {
8823
+ writer.uint32(26).string(message.function);
8824
+ }
8825
+ if (message.signature !== "") {
8826
+ writer.uint32(34).string(message.signature);
8827
+ }
8828
+ for (const v of message.args) {
8829
+ Value.encode(Value.wrap(v!), writer.uint32(42).fork()).ldelim();
8830
+ }
8831
+ return writer;
8832
+ },
8833
+
8834
+ decode(input: _m0.Reader | Uint8Array, length?: number): EthCallParam {
8835
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
8836
+ let end = length === undefined ? reader.len : reader.pos + length;
8837
+ const message = createBaseEthCallParam();
8838
+ while (reader.pos < end) {
8839
+ const tag = reader.uint32();
8840
+ switch (tag >>> 3) {
8841
+ case 1:
8842
+ if (tag !== 10) {
8843
+ break;
8844
+ }
8845
+
8846
+ message.chainId = reader.string();
8847
+ continue;
8848
+ case 2:
8849
+ if (tag !== 18) {
8850
+ break;
8851
+ }
8852
+
8853
+ message.address = reader.string();
8854
+ continue;
8855
+ case 3:
8856
+ if (tag !== 26) {
8857
+ break;
8858
+ }
8859
+
8860
+ message.function = reader.string();
8861
+ continue;
8862
+ case 4:
8863
+ if (tag !== 34) {
8864
+ break;
8865
+ }
8866
+
8867
+ message.signature = reader.string();
8868
+ continue;
8869
+ case 5:
8870
+ if (tag !== 42) {
8871
+ break;
8872
+ }
8873
+
8874
+ message.args.push(Value.unwrap(Value.decode(reader, reader.uint32())));
8875
+ continue;
8876
+ }
8877
+ if ((tag & 7) === 4 || tag === 0) {
8878
+ break;
8879
+ }
8880
+ reader.skipType(tag & 7);
8881
+ }
8882
+ return message;
8883
+ },
8884
+
8885
+ fromJSON(object: any): EthCallParam {
8886
+ return {
8887
+ chainId: isSet(object.chainId) ? globalThis.String(object.chainId) : "",
8888
+ address: isSet(object.address) ? globalThis.String(object.address) : "",
8889
+ function: isSet(object.function) ? globalThis.String(object.function) : "",
8890
+ signature: isSet(object.signature) ? globalThis.String(object.signature) : "",
8891
+ args: globalThis.Array.isArray(object?.args) ? [...object.args] : [],
8892
+ };
8893
+ },
8894
+
8895
+ toJSON(message: EthCallParam): unknown {
8896
+ const obj: any = {};
8897
+ if (message.chainId !== "") {
8898
+ obj.chainId = message.chainId;
8899
+ }
8900
+ if (message.address !== "") {
8901
+ obj.address = message.address;
8902
+ }
8903
+ if (message.function !== "") {
8904
+ obj.function = message.function;
8905
+ }
8906
+ if (message.signature !== "") {
8907
+ obj.signature = message.signature;
8908
+ }
8909
+ if (message.args?.length) {
8910
+ obj.args = message.args;
8911
+ }
8912
+ return obj;
8913
+ },
8914
+
8915
+ create(base?: DeepPartial<EthCallParam>): EthCallParam {
8916
+ return EthCallParam.fromPartial(base ?? {});
8917
+ },
8918
+ fromPartial(object: DeepPartial<EthCallParam>): EthCallParam {
8919
+ const message = createBaseEthCallParam();
8920
+ message.chainId = object.chainId ?? "";
8921
+ message.address = object.address ?? "";
8922
+ message.function = object.function ?? "";
8923
+ message.signature = object.signature ?? "";
8924
+ message.args = object.args?.map((e) => e) || [];
8925
+ return message;
8926
+ },
8927
+ };
8928
+
8929
+ function createBasePreprocessResult(): PreprocessResult {
8930
+ return { ethCallParams: [] };
8931
+ }
8932
+
8933
+ export const PreprocessResult = {
8934
+ encode(message: PreprocessResult, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
8935
+ for (const v of message.ethCallParams) {
8936
+ EthCallParam.encode(v!, writer.uint32(10).fork()).ldelim();
8937
+ }
8938
+ return writer;
8939
+ },
8940
+
8941
+ decode(input: _m0.Reader | Uint8Array, length?: number): PreprocessResult {
8942
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
8943
+ let end = length === undefined ? reader.len : reader.pos + length;
8944
+ const message = createBasePreprocessResult();
8945
+ while (reader.pos < end) {
8946
+ const tag = reader.uint32();
8947
+ switch (tag >>> 3) {
8948
+ case 1:
8949
+ if (tag !== 10) {
8950
+ break;
8951
+ }
8952
+
8953
+ message.ethCallParams.push(EthCallParam.decode(reader, reader.uint32()));
8954
+ continue;
8955
+ }
8956
+ if ((tag & 7) === 4 || tag === 0) {
8957
+ break;
8958
+ }
8959
+ reader.skipType(tag & 7);
8960
+ }
8961
+ return message;
8962
+ },
8963
+
8964
+ fromJSON(object: any): PreprocessResult {
8965
+ return {
8966
+ ethCallParams: globalThis.Array.isArray(object?.ethCallParams)
8967
+ ? object.ethCallParams.map((e: any) => EthCallParam.fromJSON(e))
8968
+ : [],
8969
+ };
8970
+ },
8971
+
8972
+ toJSON(message: PreprocessResult): unknown {
8973
+ const obj: any = {};
8974
+ if (message.ethCallParams?.length) {
8975
+ obj.ethCallParams = message.ethCallParams.map((e) => EthCallParam.toJSON(e));
8976
+ }
8977
+ return obj;
8978
+ },
8979
+
8980
+ create(base?: DeepPartial<PreprocessResult>): PreprocessResult {
8981
+ return PreprocessResult.fromPartial(base ?? {});
8982
+ },
8983
+ fromPartial(object: DeepPartial<PreprocessResult>): PreprocessResult {
8984
+ const message = createBasePreprocessResult();
8985
+ message.ethCallParams = object.ethCallParams?.map((e) => EthCallParam.fromPartial(e)) || [];
8986
+ return message;
8987
+ },
8988
+ };
8989
+
8990
+ function createBasePreparedData(): PreparedData {
8991
+ return { ethCallResults: {} };
8992
+ }
8993
+
8994
+ export const PreparedData = {
8995
+ encode(message: PreparedData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
8996
+ Object.entries(message.ethCallResults).forEach(([key, value]) => {
8997
+ if (value !== undefined) {
8998
+ PreparedData_EthCallResultsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).ldelim();
8999
+ }
9000
+ });
9001
+ return writer;
9002
+ },
9003
+
9004
+ decode(input: _m0.Reader | Uint8Array, length?: number): PreparedData {
9005
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
9006
+ let end = length === undefined ? reader.len : reader.pos + length;
9007
+ const message = createBasePreparedData();
9008
+ while (reader.pos < end) {
9009
+ const tag = reader.uint32();
9010
+ switch (tag >>> 3) {
9011
+ case 1:
9012
+ if (tag !== 10) {
9013
+ break;
9014
+ }
9015
+
9016
+ const entry1 = PreparedData_EthCallResultsEntry.decode(reader, reader.uint32());
9017
+ if (entry1.value !== undefined) {
9018
+ message.ethCallResults[entry1.key] = entry1.value;
9019
+ }
9020
+ continue;
9021
+ }
9022
+ if ((tag & 7) === 4 || tag === 0) {
9023
+ break;
9024
+ }
9025
+ reader.skipType(tag & 7);
9026
+ }
9027
+ return message;
9028
+ },
9029
+
9030
+ fromJSON(object: any): PreparedData {
9031
+ return {
9032
+ ethCallResults: isObject(object.ethCallResults)
9033
+ ? Object.entries(object.ethCallResults).reduce<{ [key: string]: Array<any> | undefined }>(
9034
+ (acc, [key, value]) => {
9035
+ acc[key] = value as Array<any> | undefined;
9036
+ return acc;
9037
+ },
9038
+ {},
9039
+ )
9040
+ : {},
9041
+ };
9042
+ },
9043
+
9044
+ toJSON(message: PreparedData): unknown {
9045
+ const obj: any = {};
9046
+ if (message.ethCallResults) {
9047
+ const entries = Object.entries(message.ethCallResults);
9048
+ if (entries.length > 0) {
9049
+ obj.ethCallResults = {};
9050
+ entries.forEach(([k, v]) => {
9051
+ obj.ethCallResults[k] = v;
9052
+ });
9053
+ }
9054
+ }
9055
+ return obj;
9056
+ },
9057
+
9058
+ create(base?: DeepPartial<PreparedData>): PreparedData {
9059
+ return PreparedData.fromPartial(base ?? {});
9060
+ },
9061
+ fromPartial(object: DeepPartial<PreparedData>): PreparedData {
9062
+ const message = createBasePreparedData();
9063
+ message.ethCallResults = Object.entries(object.ethCallResults ?? {}).reduce<
9064
+ { [key: string]: Array<any> | undefined }
9065
+ >((acc, [key, value]) => {
9066
+ if (value !== undefined) {
9067
+ acc[key] = value;
9068
+ }
9069
+ return acc;
9070
+ }, {});
9071
+ return message;
9072
+ },
9073
+ };
9074
+
9075
+ function createBasePreparedData_EthCallResultsEntry(): PreparedData_EthCallResultsEntry {
9076
+ return { key: "", value: undefined };
9077
+ }
9078
+
9079
+ export const PreparedData_EthCallResultsEntry = {
9080
+ encode(message: PreparedData_EthCallResultsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
9081
+ if (message.key !== "") {
9082
+ writer.uint32(10).string(message.key);
9083
+ }
9084
+ if (message.value !== undefined) {
9085
+ ListValue.encode(ListValue.wrap(message.value), writer.uint32(18).fork()).ldelim();
9086
+ }
9087
+ return writer;
9088
+ },
9089
+
9090
+ decode(input: _m0.Reader | Uint8Array, length?: number): PreparedData_EthCallResultsEntry {
9091
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
9092
+ let end = length === undefined ? reader.len : reader.pos + length;
9093
+ const message = createBasePreparedData_EthCallResultsEntry();
9094
+ while (reader.pos < end) {
9095
+ const tag = reader.uint32();
9096
+ switch (tag >>> 3) {
9097
+ case 1:
9098
+ if (tag !== 10) {
9099
+ break;
9100
+ }
9101
+
9102
+ message.key = reader.string();
9103
+ continue;
9104
+ case 2:
9105
+ if (tag !== 18) {
9106
+ break;
9107
+ }
9108
+
9109
+ message.value = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
9110
+ continue;
9111
+ }
9112
+ if ((tag & 7) === 4 || tag === 0) {
9113
+ break;
9114
+ }
9115
+ reader.skipType(tag & 7);
9116
+ }
9117
+ return message;
9118
+ },
9119
+
9120
+ fromJSON(object: any): PreparedData_EthCallResultsEntry {
9121
+ return {
9122
+ key: isSet(object.key) ? globalThis.String(object.key) : "",
9123
+ value: globalThis.Array.isArray(object.value) ? [...object.value] : undefined,
9124
+ };
9125
+ },
9126
+
9127
+ toJSON(message: PreparedData_EthCallResultsEntry): unknown {
9128
+ const obj: any = {};
9129
+ if (message.key !== "") {
9130
+ obj.key = message.key;
9131
+ }
9132
+ if (message.value !== undefined) {
9133
+ obj.value = message.value;
9134
+ }
9135
+ return obj;
9136
+ },
9137
+
9138
+ create(base?: DeepPartial<PreparedData_EthCallResultsEntry>): PreparedData_EthCallResultsEntry {
9139
+ return PreparedData_EthCallResultsEntry.fromPartial(base ?? {});
9140
+ },
9141
+ fromPartial(object: DeepPartial<PreparedData_EthCallResultsEntry>): PreparedData_EthCallResultsEntry {
9142
+ const message = createBasePreparedData_EthCallResultsEntry();
9143
+ message.key = object.key ?? "";
9144
+ message.value = object.value ?? undefined;
9145
+ return message;
9146
+ },
9147
+ };
9148
+
8789
9149
  function createBaseRecordMetaData(): RecordMetaData {
8790
9150
  return {
8791
9151
  address: "",