@sentio/sdk 1.33.2 → 1.34.1-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.
- package/lib/aptos/context.js +0 -3
- package/lib/aptos/context.js.map +1 -1
- package/lib/core/context.js +0 -6
- package/lib/core/context.js.map +1 -1
- package/lib/core/logger.js.map +1 -1
- package/lib/gen/chainquery/protos/chainquery.d.ts +1 -1
- package/lib/gen/chainquery/protos/chainquery.js +108 -211
- package/lib/gen/chainquery/protos/chainquery.js.map +1 -1
- package/lib/gen/google/protobuf/empty.js.map +1 -1
- package/lib/gen/google/protobuf/timestamp.js +5 -9
- package/lib/gen/google/protobuf/timestamp.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +119 -189
- package/lib/gen/processor/protos/processor.js +783 -1118
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/gen/service/price/protos/price.d.ts +4 -4
- package/lib/gen/service/price/protos/price.js +15 -27
- package/lib/gen/service/price/protos/price.js.map +1 -1
- package/lib/release.config.js +2 -2
- package/lib/service.d.ts +8 -8
- package/lib/service.js +47 -160
- package/lib/service.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +7 -5
- package/lib/testing/test-processor-server.js +42 -19
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/token.d.ts +1 -1
- package/lib/utils/token.js.map +1 -1
- package/package.json +1 -1
- package/src/aptos/context.ts +1 -3
- package/src/core/context.ts +1 -6
- package/src/core/logger.ts +1 -1
- package/src/gen/chainquery/protos/chainquery.ts +171 -379
- package/src/gen/google/protobuf/empty.ts +7 -19
- package/src/gen/google/protobuf/timestamp.ts +11 -31
- package/src/gen/processor/protos/processor.ts +1058 -1847
- package/src/gen/service/price/protos/price.ts +38 -103
- package/src/service.ts +59 -210
- package/src/testing/test-processor-server.ts +47 -28
- package/src/utils/token.ts +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import { CallContext, CallOptions } from "nice-grpc-common";
|
|
3
|
-
import { Timestamp } from "../../../google/protobuf/timestamp";
|
|
4
2
|
import Long from "long";
|
|
3
|
+
import type { CallContext, CallOptions } from "nice-grpc-common";
|
|
5
4
|
import _m0 from "protobufjs/minimal";
|
|
5
|
+
import { Timestamp } from "../../../google/protobuf/timestamp";
|
|
6
6
|
|
|
7
7
|
export interface CoinID {
|
|
8
|
-
symbol
|
|
9
|
-
address
|
|
8
|
+
symbol?: string | undefined;
|
|
9
|
+
address?: CoinID_AddressIdentifier | undefined;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface CoinID_AddressIdentifier {
|
|
@@ -29,18 +29,12 @@ function createBaseCoinID(): CoinID {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const CoinID = {
|
|
32
|
-
encode(
|
|
33
|
-
message: CoinID,
|
|
34
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
35
|
-
): _m0.Writer {
|
|
32
|
+
encode(message: CoinID, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
36
33
|
if (message.symbol !== undefined) {
|
|
37
34
|
writer.uint32(18).string(message.symbol);
|
|
38
35
|
}
|
|
39
36
|
if (message.address !== undefined) {
|
|
40
|
-
CoinID_AddressIdentifier.encode(
|
|
41
|
-
message.address,
|
|
42
|
-
writer.uint32(26).fork()
|
|
43
|
-
).ldelim();
|
|
37
|
+
CoinID_AddressIdentifier.encode(message.address, writer.uint32(26).fork()).ldelim();
|
|
44
38
|
}
|
|
45
39
|
return writer;
|
|
46
40
|
},
|
|
@@ -56,10 +50,7 @@ export const CoinID = {
|
|
|
56
50
|
message.symbol = reader.string();
|
|
57
51
|
break;
|
|
58
52
|
case 3:
|
|
59
|
-
message.address = CoinID_AddressIdentifier.decode(
|
|
60
|
-
reader,
|
|
61
|
-
reader.uint32()
|
|
62
|
-
);
|
|
53
|
+
message.address = CoinID_AddressIdentifier.decode(reader, reader.uint32());
|
|
63
54
|
break;
|
|
64
55
|
default:
|
|
65
56
|
reader.skipType(tag & 7);
|
|
@@ -72,9 +63,7 @@ export const CoinID = {
|
|
|
72
63
|
fromJSON(object: any): CoinID {
|
|
73
64
|
return {
|
|
74
65
|
symbol: isSet(object.symbol) ? String(object.symbol) : undefined,
|
|
75
|
-
address: isSet(object.address)
|
|
76
|
-
? CoinID_AddressIdentifier.fromJSON(object.address)
|
|
77
|
-
: undefined,
|
|
66
|
+
address: isSet(object.address) ? CoinID_AddressIdentifier.fromJSON(object.address) : undefined,
|
|
78
67
|
};
|
|
79
68
|
},
|
|
80
69
|
|
|
@@ -82,19 +71,16 @@ export const CoinID = {
|
|
|
82
71
|
const obj: any = {};
|
|
83
72
|
message.symbol !== undefined && (obj.symbol = message.symbol);
|
|
84
73
|
message.address !== undefined &&
|
|
85
|
-
(obj.address = message.address
|
|
86
|
-
? CoinID_AddressIdentifier.toJSON(message.address)
|
|
87
|
-
: undefined);
|
|
74
|
+
(obj.address = message.address ? CoinID_AddressIdentifier.toJSON(message.address) : undefined);
|
|
88
75
|
return obj;
|
|
89
76
|
},
|
|
90
77
|
|
|
91
78
|
fromPartial(object: DeepPartial<CoinID>): CoinID {
|
|
92
79
|
const message = createBaseCoinID();
|
|
93
80
|
message.symbol = object.symbol ?? undefined;
|
|
94
|
-
message.address =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: undefined;
|
|
81
|
+
message.address = (object.address !== undefined && object.address !== null)
|
|
82
|
+
? CoinID_AddressIdentifier.fromPartial(object.address)
|
|
83
|
+
: undefined;
|
|
98
84
|
return message;
|
|
99
85
|
},
|
|
100
86
|
};
|
|
@@ -104,10 +90,7 @@ function createBaseCoinID_AddressIdentifier(): CoinID_AddressIdentifier {
|
|
|
104
90
|
}
|
|
105
91
|
|
|
106
92
|
export const CoinID_AddressIdentifier = {
|
|
107
|
-
encode(
|
|
108
|
-
message: CoinID_AddressIdentifier,
|
|
109
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
110
|
-
): _m0.Writer {
|
|
93
|
+
encode(message: CoinID_AddressIdentifier, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
111
94
|
if (message.address !== "") {
|
|
112
95
|
writer.uint32(10).string(message.address);
|
|
113
96
|
}
|
|
@@ -117,10 +100,7 @@ export const CoinID_AddressIdentifier = {
|
|
|
117
100
|
return writer;
|
|
118
101
|
},
|
|
119
102
|
|
|
120
|
-
decode(
|
|
121
|
-
input: _m0.Reader | Uint8Array,
|
|
122
|
-
length?: number
|
|
123
|
-
): CoinID_AddressIdentifier {
|
|
103
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): CoinID_AddressIdentifier {
|
|
124
104
|
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
125
105
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
126
106
|
const message = createBaseCoinID_AddressIdentifier();
|
|
@@ -155,9 +135,7 @@ export const CoinID_AddressIdentifier = {
|
|
|
155
135
|
return obj;
|
|
156
136
|
},
|
|
157
137
|
|
|
158
|
-
fromPartial(
|
|
159
|
-
object: DeepPartial<CoinID_AddressIdentifier>
|
|
160
|
-
): CoinID_AddressIdentifier {
|
|
138
|
+
fromPartial(object: DeepPartial<CoinID_AddressIdentifier>): CoinID_AddressIdentifier {
|
|
161
139
|
const message = createBaseCoinID_AddressIdentifier();
|
|
162
140
|
message.address = object.address ?? "";
|
|
163
141
|
message.chain = object.chain ?? "";
|
|
@@ -170,15 +148,9 @@ function createBaseGetPriceRequest(): GetPriceRequest {
|
|
|
170
148
|
}
|
|
171
149
|
|
|
172
150
|
export const GetPriceRequest = {
|
|
173
|
-
encode(
|
|
174
|
-
message: GetPriceRequest,
|
|
175
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
176
|
-
): _m0.Writer {
|
|
151
|
+
encode(message: GetPriceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
177
152
|
if (message.timestamp !== undefined) {
|
|
178
|
-
Timestamp.encode(
|
|
179
|
-
toTimestamp(message.timestamp),
|
|
180
|
-
writer.uint32(10).fork()
|
|
181
|
-
).ldelim();
|
|
153
|
+
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim();
|
|
182
154
|
}
|
|
183
155
|
if (message.coinId !== undefined) {
|
|
184
156
|
CoinID.encode(message.coinId, writer.uint32(18).fork()).ldelim();
|
|
@@ -194,9 +166,7 @@ export const GetPriceRequest = {
|
|
|
194
166
|
const tag = reader.uint32();
|
|
195
167
|
switch (tag >>> 3) {
|
|
196
168
|
case 1:
|
|
197
|
-
message.timestamp = fromTimestamp(
|
|
198
|
-
Timestamp.decode(reader, reader.uint32())
|
|
199
|
-
);
|
|
169
|
+
message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
200
170
|
break;
|
|
201
171
|
case 2:
|
|
202
172
|
message.coinId = CoinID.decode(reader, reader.uint32());
|
|
@@ -211,29 +181,24 @@ export const GetPriceRequest = {
|
|
|
211
181
|
|
|
212
182
|
fromJSON(object: any): GetPriceRequest {
|
|
213
183
|
return {
|
|
214
|
-
timestamp: isSet(object.timestamp)
|
|
215
|
-
? fromJsonTimestamp(object.timestamp)
|
|
216
|
-
: undefined,
|
|
184
|
+
timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
|
|
217
185
|
coinId: isSet(object.coinId) ? CoinID.fromJSON(object.coinId) : undefined,
|
|
218
186
|
};
|
|
219
187
|
},
|
|
220
188
|
|
|
221
189
|
toJSON(message: GetPriceRequest): unknown {
|
|
222
190
|
const obj: any = {};
|
|
223
|
-
message.timestamp !== undefined &&
|
|
224
|
-
|
|
225
|
-
message.coinId !== undefined &&
|
|
226
|
-
(obj.coinId = message.coinId ? CoinID.toJSON(message.coinId) : undefined);
|
|
191
|
+
message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
|
|
192
|
+
message.coinId !== undefined && (obj.coinId = message.coinId ? CoinID.toJSON(message.coinId) : undefined);
|
|
227
193
|
return obj;
|
|
228
194
|
},
|
|
229
195
|
|
|
230
196
|
fromPartial(object: DeepPartial<GetPriceRequest>): GetPriceRequest {
|
|
231
197
|
const message = createBaseGetPriceRequest();
|
|
232
198
|
message.timestamp = object.timestamp ?? undefined;
|
|
233
|
-
message.coinId =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
: undefined;
|
|
199
|
+
message.coinId = (object.coinId !== undefined && object.coinId !== null)
|
|
200
|
+
? CoinID.fromPartial(object.coinId)
|
|
201
|
+
: undefined;
|
|
237
202
|
return message;
|
|
238
203
|
},
|
|
239
204
|
};
|
|
@@ -243,18 +208,12 @@ function createBaseGetPriceResponse(): GetPriceResponse {
|
|
|
243
208
|
}
|
|
244
209
|
|
|
245
210
|
export const GetPriceResponse = {
|
|
246
|
-
encode(
|
|
247
|
-
message: GetPriceResponse,
|
|
248
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
249
|
-
): _m0.Writer {
|
|
211
|
+
encode(message: GetPriceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
250
212
|
if (message.price !== 0) {
|
|
251
213
|
writer.uint32(9).double(message.price);
|
|
252
214
|
}
|
|
253
215
|
if (message.timestamp !== undefined) {
|
|
254
|
-
Timestamp.encode(
|
|
255
|
-
toTimestamp(message.timestamp),
|
|
256
|
-
writer.uint32(18).fork()
|
|
257
|
-
).ldelim();
|
|
216
|
+
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(18).fork()).ldelim();
|
|
258
217
|
}
|
|
259
218
|
return writer;
|
|
260
219
|
},
|
|
@@ -270,9 +229,7 @@ export const GetPriceResponse = {
|
|
|
270
229
|
message.price = reader.double();
|
|
271
230
|
break;
|
|
272
231
|
case 2:
|
|
273
|
-
message.timestamp = fromTimestamp(
|
|
274
|
-
Timestamp.decode(reader, reader.uint32())
|
|
275
|
-
);
|
|
232
|
+
message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
276
233
|
break;
|
|
277
234
|
default:
|
|
278
235
|
reader.skipType(tag & 7);
|
|
@@ -285,17 +242,14 @@ export const GetPriceResponse = {
|
|
|
285
242
|
fromJSON(object: any): GetPriceResponse {
|
|
286
243
|
return {
|
|
287
244
|
price: isSet(object.price) ? Number(object.price) : 0,
|
|
288
|
-
timestamp: isSet(object.timestamp)
|
|
289
|
-
? fromJsonTimestamp(object.timestamp)
|
|
290
|
-
: undefined,
|
|
245
|
+
timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
|
|
291
246
|
};
|
|
292
247
|
},
|
|
293
248
|
|
|
294
249
|
toJSON(message: GetPriceResponse): unknown {
|
|
295
250
|
const obj: any = {};
|
|
296
251
|
message.price !== undefined && (obj.price = message.price);
|
|
297
|
-
message.timestamp !== undefined &&
|
|
298
|
-
(obj.timestamp = message.timestamp.toISOString());
|
|
252
|
+
message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
|
|
299
253
|
return obj;
|
|
300
254
|
},
|
|
301
255
|
|
|
@@ -323,39 +277,20 @@ export const PriceServiceDefinition = {
|
|
|
323
277
|
},
|
|
324
278
|
} as const;
|
|
325
279
|
|
|
326
|
-
export interface
|
|
327
|
-
getPrice(
|
|
328
|
-
request: GetPriceRequest,
|
|
329
|
-
context: CallContext & CallContextExt
|
|
330
|
-
): Promise<DeepPartial<GetPriceResponse>>;
|
|
280
|
+
export interface PriceServiceImplementation<CallContextExt = {}> {
|
|
281
|
+
getPrice(request: GetPriceRequest, context: CallContext & CallContextExt): Promise<DeepPartial<GetPriceResponse>>;
|
|
331
282
|
}
|
|
332
283
|
|
|
333
284
|
export interface PriceServiceClient<CallOptionsExt = {}> {
|
|
334
|
-
getPrice(
|
|
335
|
-
request: DeepPartial<GetPriceRequest>,
|
|
336
|
-
options?: CallOptions & CallOptionsExt
|
|
337
|
-
): Promise<GetPriceResponse>;
|
|
285
|
+
getPrice(request: DeepPartial<GetPriceRequest>, options?: CallOptions & CallOptionsExt): Promise<GetPriceResponse>;
|
|
338
286
|
}
|
|
339
287
|
|
|
340
|
-
type Builtin =
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
| boolean
|
|
347
|
-
| undefined;
|
|
348
|
-
|
|
349
|
-
type DeepPartial<T> = T extends Builtin
|
|
350
|
-
? T
|
|
351
|
-
: T extends Long
|
|
352
|
-
? string | number | Long
|
|
353
|
-
: T extends Array<infer U>
|
|
354
|
-
? Array<DeepPartial<U>>
|
|
355
|
-
: T extends ReadonlyArray<infer U>
|
|
356
|
-
? ReadonlyArray<DeepPartial<U>>
|
|
357
|
-
: T extends {}
|
|
358
|
-
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
288
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
289
|
+
|
|
290
|
+
type DeepPartial<T> = T extends Builtin ? T
|
|
291
|
+
: T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>>
|
|
292
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
293
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
359
294
|
: Partial<T>;
|
|
360
295
|
|
|
361
296
|
function toTimestamp(date: Date): Timestamp {
|
package/src/service.ts
CHANGED
|
@@ -6,25 +6,23 @@ import {
|
|
|
6
6
|
AccountConfig,
|
|
7
7
|
AptosCallHandlerConfig,
|
|
8
8
|
AptosEventHandlerConfig,
|
|
9
|
-
BlockBinding,
|
|
10
9
|
ContractConfig,
|
|
10
|
+
Data,
|
|
11
|
+
Data_SolInstruction,
|
|
11
12
|
DataBinding,
|
|
12
13
|
EventTrackingConfig,
|
|
13
14
|
ExportConfig,
|
|
14
15
|
HandlerType,
|
|
15
|
-
Instruction,
|
|
16
16
|
LogFilter,
|
|
17
17
|
LogHandlerConfig,
|
|
18
18
|
MetricConfig,
|
|
19
19
|
ProcessBindingResponse,
|
|
20
20
|
ProcessBindingsRequest,
|
|
21
|
-
ProcessBlocksRequest,
|
|
22
21
|
ProcessConfigRequest,
|
|
23
22
|
ProcessConfigResponse,
|
|
24
|
-
ProcessInstructionsRequest,
|
|
25
23
|
ProcessorServiceImplementation,
|
|
26
24
|
ProcessResult,
|
|
27
|
-
|
|
25
|
+
ServerStreamingMethodResult,
|
|
28
26
|
StartRequest,
|
|
29
27
|
TemplateInstance,
|
|
30
28
|
} from './gen'
|
|
@@ -154,7 +152,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
154
152
|
address: processor.config.address,
|
|
155
153
|
abi: '',
|
|
156
154
|
},
|
|
157
|
-
blockConfigs: [],
|
|
158
155
|
intervalConfigs: [],
|
|
159
156
|
logConfigs: [],
|
|
160
157
|
traceConfigs: [],
|
|
@@ -284,7 +281,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
284
281
|
address: solanaProcessor.address,
|
|
285
282
|
abi: '',
|
|
286
283
|
},
|
|
287
|
-
blockConfigs: [],
|
|
288
284
|
logConfigs: [],
|
|
289
285
|
traceConfigs: [],
|
|
290
286
|
intervalConfigs: [],
|
|
@@ -311,7 +307,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
311
307
|
address: suiProcessor.address,
|
|
312
308
|
abi: '',
|
|
313
309
|
},
|
|
314
|
-
blockConfigs: [],
|
|
315
310
|
logConfigs: [],
|
|
316
311
|
intervalConfigs: [],
|
|
317
312
|
traceConfigs: [],
|
|
@@ -334,7 +329,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
334
329
|
address: aptosProcessor.config.address,
|
|
335
330
|
abi: '',
|
|
336
331
|
},
|
|
337
|
-
blockConfigs: [],
|
|
338
332
|
intervalConfigs: [],
|
|
339
333
|
logConfigs: [],
|
|
340
334
|
traceConfigs: [],
|
|
@@ -472,10 +466,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
472
466
|
}
|
|
473
467
|
|
|
474
468
|
async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {
|
|
475
|
-
if (request.handlerIds.length == 0) {
|
|
476
|
-
request.handlerIds = [request.handlerId]
|
|
477
|
-
}
|
|
478
|
-
|
|
479
469
|
const processBindingInternal = (request: DataBinding) => {
|
|
480
470
|
switch (request.handlerType) {
|
|
481
471
|
case HandlerType.APT_CALL:
|
|
@@ -489,10 +479,10 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
489
479
|
case HandlerType.ETH_TRACE:
|
|
490
480
|
return this.processTrace(request)
|
|
491
481
|
case HandlerType.ETH_BLOCK:
|
|
492
|
-
return this.
|
|
493
|
-
case HandlerType.
|
|
494
|
-
return this.
|
|
495
|
-
// TODO migrate
|
|
482
|
+
return this.processBlock(request)
|
|
483
|
+
case HandlerType.SOL_INSTRUCTION:
|
|
484
|
+
return this.procecessSolInstructions(request)
|
|
485
|
+
// TODO migrate SUI cases
|
|
496
486
|
// case HandlerType.INSTRUCTION:
|
|
497
487
|
// return this.processInstruction(request)
|
|
498
488
|
default:
|
|
@@ -505,6 +495,24 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
505
495
|
return result
|
|
506
496
|
}
|
|
507
497
|
|
|
498
|
+
async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {
|
|
499
|
+
for await (const request of requests) {
|
|
500
|
+
const result = await this.processBinding(request)
|
|
501
|
+
let updated = false
|
|
502
|
+
if (
|
|
503
|
+
global.PROCESSOR_STATE.templatesInstances &&
|
|
504
|
+
this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length
|
|
505
|
+
) {
|
|
506
|
+
await this.configure()
|
|
507
|
+
updated = true
|
|
508
|
+
}
|
|
509
|
+
yield {
|
|
510
|
+
result,
|
|
511
|
+
configUpdated: updated,
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
508
516
|
async processLogs(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse> {
|
|
509
517
|
if (!this.started) {
|
|
510
518
|
throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')
|
|
@@ -533,19 +541,16 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
533
541
|
}
|
|
534
542
|
}
|
|
535
543
|
|
|
536
|
-
async processLog(
|
|
537
|
-
if (!
|
|
544
|
+
async processLog(request: DataBinding): Promise<ProcessResult> {
|
|
545
|
+
if (!request.data) {
|
|
538
546
|
throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
|
|
539
547
|
}
|
|
540
|
-
if (l.handlerIds.length == 0) {
|
|
541
|
-
l.handlerIds = [l.handlerId]
|
|
542
|
-
}
|
|
543
548
|
|
|
544
549
|
const promises: Promise<ProcessResult>[] = []
|
|
545
|
-
const jsonString = Utf8ArrayToStr(
|
|
550
|
+
const jsonString = Utf8ArrayToStr(request.data.ethLog?.data || request.data.raw)
|
|
546
551
|
const log: Log = JSON.parse(jsonString)
|
|
547
552
|
|
|
548
|
-
for (const handlerId of
|
|
553
|
+
for (const handlerId of request.handlerIds) {
|
|
549
554
|
const handler = this.eventHandlers[handlerId]
|
|
550
555
|
promises.push(
|
|
551
556
|
handler(log).catch((e) => {
|
|
@@ -556,203 +561,50 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
556
561
|
return mergeProcessResults(await Promise.all(promises))
|
|
557
562
|
}
|
|
558
563
|
|
|
559
|
-
async
|
|
560
|
-
request: ProcessTransactionsRequest,
|
|
561
|
-
context: CallContext
|
|
562
|
-
): Promise<ProcessBindingResponse> {
|
|
563
|
-
if (!this.started) {
|
|
564
|
-
throw new ServerError(Status.UNAVAILABLE, 'Service not started.')
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const result = ProcessResult.fromPartial({})
|
|
568
|
-
|
|
569
|
-
if (request.chainId.toLowerCase().startsWith('sui') && SuiProcessorState.INSTANCE.getValues()) {
|
|
570
|
-
const processorPromises: Promise<void>[] = []
|
|
571
|
-
for (const txn of request.transactions) {
|
|
572
|
-
processorPromises.push(
|
|
573
|
-
new Promise((resolve, _) => {
|
|
574
|
-
for (const processor of SuiProcessorState.INSTANCE.getValues()) {
|
|
575
|
-
const res = processor.handleTransaction(
|
|
576
|
-
JSON.parse(new TextDecoder().decode(txn.raw)),
|
|
577
|
-
txn.slot ?? Long.fromNumber(0)
|
|
578
|
-
)
|
|
579
|
-
if (res) {
|
|
580
|
-
res.gauges.forEach((g) => result.gauges.push(g))
|
|
581
|
-
res.counters.forEach((c) => result.counters.push(c))
|
|
582
|
-
res.logs.forEach((l) => result.logs.push(l))
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
resolve()
|
|
586
|
-
})
|
|
587
|
-
)
|
|
588
|
-
}
|
|
589
|
-
await Promise.all(processorPromises)
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
recordRuntimeInfo(result, HandlerType.SUI_TRANSACTION)
|
|
593
|
-
return {
|
|
594
|
-
result,
|
|
595
|
-
configUpdated: false,
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
async processInstructions(
|
|
600
|
-
request: ProcessInstructionsRequest,
|
|
601
|
-
context: CallContext
|
|
602
|
-
): Promise<ProcessBindingResponse> {
|
|
603
|
-
if (!this.started) {
|
|
604
|
-
throw new ServerError(Status.UNAVAILABLE, 'Service not started.')
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const result = ProcessResult.fromPartial({})
|
|
608
|
-
|
|
609
|
-
// Only have instruction handlers for solana processors
|
|
610
|
-
if (SolanaProcessorState.INSTANCE.getValues()) {
|
|
611
|
-
const processorPromises: Promise<void>[] = []
|
|
612
|
-
for (const instruction of request.instructions) {
|
|
613
|
-
if (!instruction) {
|
|
614
|
-
throw new ServerError(Status.INVALID_ARGUMENT, 'instruction cannot be null')
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
processorPromises.push(
|
|
618
|
-
new Promise((resolve, _) => {
|
|
619
|
-
for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
|
|
620
|
-
if (processor.address === instruction.programAccountId) {
|
|
621
|
-
let parsedInstruction: SolInstruction | null = null
|
|
622
|
-
if (instruction.parsed) {
|
|
623
|
-
parsedInstruction = processor.getParsedInstruction(
|
|
624
|
-
JSON.parse(new TextDecoder().decode(instruction.parsed))
|
|
625
|
-
)
|
|
626
|
-
} else if (instruction.instructionData) {
|
|
627
|
-
parsedInstruction = processor.getParsedInstruction(instruction.instructionData)
|
|
628
|
-
}
|
|
629
|
-
if (parsedInstruction == null) {
|
|
630
|
-
continue
|
|
631
|
-
}
|
|
632
|
-
const insHandler = processor.getInstructionHandler(parsedInstruction)
|
|
633
|
-
if (insHandler == null) {
|
|
634
|
-
continue
|
|
635
|
-
}
|
|
636
|
-
const res = processor.handleInstruction(
|
|
637
|
-
parsedInstruction,
|
|
638
|
-
instruction.accounts,
|
|
639
|
-
insHandler,
|
|
640
|
-
instruction.slot
|
|
641
|
-
)
|
|
642
|
-
res.gauges.forEach((g) => result.gauges.push(g))
|
|
643
|
-
res.counters.forEach((c) => result.counters.push(c))
|
|
644
|
-
res.logs.forEach((l) => result.logs.push(l))
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
resolve()
|
|
648
|
-
})
|
|
649
|
-
)
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
await Promise.all(processorPromises)
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
recordRuntimeInfo(result, HandlerType.SOL_INSTRUCTIONS)
|
|
656
|
-
return {
|
|
657
|
-
result,
|
|
658
|
-
configUpdated: false,
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
async processInstructionsNew(request: DataBinding): Promise<ProcessResult> {
|
|
663
|
-
if (!this.started) {
|
|
664
|
-
throw new ServerError(Status.UNAVAILABLE, 'Service not started.')
|
|
665
|
-
}
|
|
564
|
+
async procecessSolInstructions(request: DataBinding): Promise<ProcessResult> {
|
|
666
565
|
if (!request.data) {
|
|
667
566
|
throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')
|
|
668
567
|
}
|
|
669
568
|
|
|
670
|
-
const
|
|
671
|
-
const instructions: Instruction[] = JSON.parse(jsonString)
|
|
569
|
+
const instruction = request.data.solInstruction || Data_SolInstruction.decode(request.data.raw) // JSON.parse(jsonString)
|
|
672
570
|
const promises: Promise<ProcessResult>[] = []
|
|
673
571
|
|
|
674
572
|
// Only have instruction handlers for solana processors
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
573
|
+
for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
|
|
574
|
+
if (processor.address === instruction.programAccountId) {
|
|
575
|
+
let parsedInstruction: SolInstruction | null = null
|
|
576
|
+
if (instruction.parsed) {
|
|
577
|
+
const a1 = JSON.parse(new TextDecoder().decode(instruction.parsed))
|
|
578
|
+
parsedInstruction = processor.getParsedInstruction(a1)
|
|
579
|
+
} else if (instruction.instructionData) {
|
|
580
|
+
parsedInstruction = processor.getParsedInstruction(instruction.instructionData)
|
|
679
581
|
}
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (processor.address === instruction.programAccountId) {
|
|
683
|
-
let parsedInstruction: SolInstruction | null = null
|
|
684
|
-
if (instruction.parsed) {
|
|
685
|
-
parsedInstruction = processor.getParsedInstruction(
|
|
686
|
-
JSON.parse(new TextDecoder().decode(instruction.parsed))
|
|
687
|
-
)
|
|
688
|
-
} else if (instruction.instructionData) {
|
|
689
|
-
parsedInstruction = processor.getParsedInstruction(instruction.instructionData)
|
|
690
|
-
}
|
|
691
|
-
if (parsedInstruction == null) {
|
|
692
|
-
continue
|
|
693
|
-
}
|
|
694
|
-
const insHandler = processor.getInstructionHandler(parsedInstruction)
|
|
695
|
-
if (insHandler == null) {
|
|
696
|
-
continue
|
|
697
|
-
}
|
|
698
|
-
const res = await processor.handleInstruction(
|
|
699
|
-
parsedInstruction,
|
|
700
|
-
instruction.accounts,
|
|
701
|
-
insHandler,
|
|
702
|
-
instruction.slot
|
|
703
|
-
)
|
|
704
|
-
|
|
705
|
-
promises.push(Promise.resolve(res))
|
|
706
|
-
}
|
|
582
|
+
if (parsedInstruction == null) {
|
|
583
|
+
continue
|
|
707
584
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
const promises = request.blockBindings.map((binding) => this.processBlock(binding))
|
|
719
|
-
const result = mergeProcessResults(await Promise.all(promises))
|
|
720
|
-
|
|
721
|
-
recordRuntimeInfo(result, HandlerType.ETH_BLOCK)
|
|
722
|
-
return {
|
|
723
|
-
result,
|
|
724
|
-
configUpdated: false,
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
async processBlock(binding: BlockBinding): Promise<ProcessResult> {
|
|
729
|
-
if (!binding.block) {
|
|
730
|
-
throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
|
|
731
|
-
}
|
|
732
|
-
const jsonString = Utf8ArrayToStr(binding.block.raw)
|
|
733
|
-
|
|
734
|
-
const block: Block = JSON.parse(jsonString)
|
|
585
|
+
const insHandler = processor.getInstructionHandler(parsedInstruction)
|
|
586
|
+
if (insHandler == null) {
|
|
587
|
+
continue
|
|
588
|
+
}
|
|
589
|
+
const res = await processor.handleInstruction(
|
|
590
|
+
parsedInstruction,
|
|
591
|
+
instruction.accounts,
|
|
592
|
+
insHandler,
|
|
593
|
+
instruction.slot
|
|
594
|
+
)
|
|
735
595
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const promise = this.blockHandlers[handlerId](block).catch((e) => {
|
|
739
|
-
throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\n' + errorString(e))
|
|
740
|
-
})
|
|
741
|
-
promises.push(promise)
|
|
596
|
+
promises.push(Promise.resolve(res))
|
|
597
|
+
}
|
|
742
598
|
}
|
|
743
599
|
return mergeProcessResults(await Promise.all(promises))
|
|
744
600
|
}
|
|
745
601
|
|
|
746
|
-
|
|
747
|
-
async processBlockNew(binding: DataBinding): Promise<ProcessResult> {
|
|
602
|
+
async processBlock(binding: DataBinding): Promise<ProcessResult> {
|
|
748
603
|
if (!binding.data) {
|
|
749
604
|
throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
|
|
750
605
|
}
|
|
751
|
-
if (binding.handlerIds.length == 0) {
|
|
752
|
-
binding.handlerIds = [binding.handlerId]
|
|
753
|
-
}
|
|
754
606
|
|
|
755
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
607
|
+
const jsonString = Utf8ArrayToStr(binding.data.ethBlock?.data || binding.data.raw)
|
|
756
608
|
|
|
757
609
|
const block: Block = JSON.parse(jsonString)
|
|
758
610
|
|
|
@@ -786,10 +638,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
786
638
|
if (!binding.data) {
|
|
787
639
|
throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be empty")
|
|
788
640
|
}
|
|
789
|
-
|
|
790
|
-
binding.handlerIds = [binding.handlerId]
|
|
791
|
-
}
|
|
792
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
641
|
+
const jsonString = Utf8ArrayToStr(binding.data.ethTrace?.data || binding.data.raw)
|
|
793
642
|
const trace: Trace = JSON.parse(jsonString)
|
|
794
643
|
|
|
795
644
|
const promises: Promise<ProcessResult>[] = []
|
|
@@ -809,7 +658,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
809
658
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
810
659
|
}
|
|
811
660
|
const promises: Promise<ProcessResult>[] = []
|
|
812
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
661
|
+
const jsonString = Utf8ArrayToStr(binding.data.aptEvent?.data || binding.data.raw)
|
|
813
662
|
const event = JSON.parse(jsonString)
|
|
814
663
|
|
|
815
664
|
for (const handlerId of binding.handlerIds) {
|
|
@@ -827,7 +676,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
827
676
|
if (!binding.data) {
|
|
828
677
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
829
678
|
}
|
|
830
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
679
|
+
const jsonString = Utf8ArrayToStr(binding.data.aptResource?.data || binding.data.raw)
|
|
831
680
|
const json = JSON.parse(jsonString) as MoveResourcesWithVersionPayload
|
|
832
681
|
const promises: Promise<ProcessResult>[] = []
|
|
833
682
|
for (const handlerId of binding.handlerIds) {
|
|
@@ -844,7 +693,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
844
693
|
if (!binding.data) {
|
|
845
694
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
846
695
|
}
|
|
847
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
696
|
+
const jsonString = Utf8ArrayToStr(binding.data.aptCall?.data || binding.data.raw)
|
|
848
697
|
const call = JSON.parse(jsonString)
|
|
849
698
|
|
|
850
699
|
const promises: Promise<ProcessResult>[] = []
|