@sentio/sdk 1.25.0 → 1.25.2
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/network.js +1 -1
- package/lib/aptos/network.js.map +1 -1
- package/lib/cli/webpack.config.js +1 -2
- package/lib/core/event-tracker.js +1 -2
- package/lib/core/event-tracker.js.map +1 -1
- package/lib/core/logger.d.ts +5 -5
- package/lib/core/logger.js +8 -8
- package/lib/core/logger.js.map +1 -1
- package/lib/core/meter.d.ts +1 -0
- package/lib/core/meter.js +4 -0
- package/lib/core/meter.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +22 -4
- package/lib/gen/processor/protos/processor.js +161 -10
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/service.js +1 -1
- package/lib/service.js.map +1 -1
- package/lib/tests/aptos.test.js +1 -0
- package/lib/tests/aptos.test.js.map +1 -1
- package/lib/tests/souffl3.js +3 -1
- package/lib/tests/souffl3.js.map +1 -1
- package/package.json +1 -1
- package/src/aptos/network.ts +1 -1
- package/src/cli/webpack.config.js +1 -2
- package/src/core/event-tracker.ts +1 -1
- package/src/core/logger.ts +9 -9
- package/src/core/meter.ts +4 -0
- package/src/gen/processor/protos/processor.ts +191 -9
- package/src/service.ts +1 -1
- package/src/tests/aptos.test.ts +1 -0
- package/src/tests/souffl3.ts +4 -1
@@ -13,6 +13,7 @@ export enum HandlerType {
|
|
13
13
|
ETH_TRACE = 5,
|
14
14
|
APT_EVENT = 6,
|
15
15
|
APT_CALL = 7,
|
16
|
+
APT_RESOURCE = 8,
|
16
17
|
UNRECOGNIZED = -1,
|
17
18
|
}
|
18
19
|
|
@@ -42,6 +43,9 @@ export function handlerTypeFromJSON(object: any): HandlerType {
|
|
42
43
|
case 7:
|
43
44
|
case "APT_CALL":
|
44
45
|
return HandlerType.APT_CALL;
|
46
|
+
case 8:
|
47
|
+
case "APT_RESOURCE":
|
48
|
+
return HandlerType.APT_RESOURCE;
|
45
49
|
case -1:
|
46
50
|
case "UNRECOGNIZED":
|
47
51
|
default:
|
@@ -67,6 +71,8 @@ export function handlerTypeToJSON(object: HandlerType): string {
|
|
67
71
|
return "APT_EVENT";
|
68
72
|
case HandlerType.APT_CALL:
|
69
73
|
return "APT_CALL";
|
74
|
+
case HandlerType.APT_RESOURCE:
|
75
|
+
return "APT_RESOURCE";
|
70
76
|
case HandlerType.UNRECOGNIZED:
|
71
77
|
default:
|
72
78
|
return "UNRECOGNIZED";
|
@@ -211,9 +217,20 @@ export interface MetricConfig {
|
|
211
217
|
description: string;
|
212
218
|
unit: string;
|
213
219
|
sparse: boolean;
|
220
|
+
resolutionInSeconds: number;
|
214
221
|
}
|
215
222
|
|
216
|
-
export interface AccountConfig {
|
223
|
+
export interface AccountConfig {
|
224
|
+
chainId: string;
|
225
|
+
address: string;
|
226
|
+
startBlock: Long;
|
227
|
+
aptosOnVersionConfigs: AptosOnVersionConfig[];
|
228
|
+
}
|
229
|
+
|
230
|
+
export interface AptosOnVersionConfig {
|
231
|
+
handlerId: number;
|
232
|
+
step: number;
|
233
|
+
}
|
217
234
|
|
218
235
|
export interface ContractInfo {
|
219
236
|
name: string;
|
@@ -350,6 +367,7 @@ export interface DataDescriptor {
|
|
350
367
|
description: string;
|
351
368
|
unit: string;
|
352
369
|
sparse: boolean;
|
370
|
+
resolutionInSeconds: number;
|
353
371
|
}
|
354
372
|
|
355
373
|
export interface RecordMetaData {
|
@@ -1205,7 +1223,13 @@ export const EventTrackingConfig = {
|
|
1205
1223
|
};
|
1206
1224
|
|
1207
1225
|
function createBaseMetricConfig(): MetricConfig {
|
1208
|
-
return {
|
1226
|
+
return {
|
1227
|
+
name: "",
|
1228
|
+
description: "",
|
1229
|
+
unit: "",
|
1230
|
+
sparse: false,
|
1231
|
+
resolutionInSeconds: 0,
|
1232
|
+
};
|
1209
1233
|
}
|
1210
1234
|
|
1211
1235
|
export const MetricConfig = {
|
@@ -1225,6 +1249,9 @@ export const MetricConfig = {
|
|
1225
1249
|
if (message.sparse === true) {
|
1226
1250
|
writer.uint32(32).bool(message.sparse);
|
1227
1251
|
}
|
1252
|
+
if (message.resolutionInSeconds !== 0) {
|
1253
|
+
writer.uint32(40).int32(message.resolutionInSeconds);
|
1254
|
+
}
|
1228
1255
|
return writer;
|
1229
1256
|
},
|
1230
1257
|
|
@@ -1247,6 +1274,9 @@ export const MetricConfig = {
|
|
1247
1274
|
case 4:
|
1248
1275
|
message.sparse = reader.bool();
|
1249
1276
|
break;
|
1277
|
+
case 5:
|
1278
|
+
message.resolutionInSeconds = reader.int32();
|
1279
|
+
break;
|
1250
1280
|
default:
|
1251
1281
|
reader.skipType(tag & 7);
|
1252
1282
|
break;
|
@@ -1261,6 +1291,9 @@ export const MetricConfig = {
|
|
1261
1291
|
description: isSet(object.description) ? String(object.description) : "",
|
1262
1292
|
unit: isSet(object.unit) ? String(object.unit) : "",
|
1263
1293
|
sparse: isSet(object.sparse) ? Boolean(object.sparse) : false,
|
1294
|
+
resolutionInSeconds: isSet(object.resolutionInSeconds)
|
1295
|
+
? Number(object.resolutionInSeconds)
|
1296
|
+
: 0,
|
1264
1297
|
};
|
1265
1298
|
},
|
1266
1299
|
|
@@ -1271,6 +1304,8 @@ export const MetricConfig = {
|
|
1271
1304
|
(obj.description = message.description);
|
1272
1305
|
message.unit !== undefined && (obj.unit = message.unit);
|
1273
1306
|
message.sparse !== undefined && (obj.sparse = message.sparse);
|
1307
|
+
message.resolutionInSeconds !== undefined &&
|
1308
|
+
(obj.resolutionInSeconds = Math.round(message.resolutionInSeconds));
|
1274
1309
|
return obj;
|
1275
1310
|
},
|
1276
1311
|
|
@@ -1280,19 +1315,37 @@ export const MetricConfig = {
|
|
1280
1315
|
message.description = object.description ?? "";
|
1281
1316
|
message.unit = object.unit ?? "";
|
1282
1317
|
message.sparse = object.sparse ?? false;
|
1318
|
+
message.resolutionInSeconds = object.resolutionInSeconds ?? 0;
|
1283
1319
|
return message;
|
1284
1320
|
},
|
1285
1321
|
};
|
1286
1322
|
|
1287
1323
|
function createBaseAccountConfig(): AccountConfig {
|
1288
|
-
return {
|
1324
|
+
return {
|
1325
|
+
chainId: "",
|
1326
|
+
address: "",
|
1327
|
+
startBlock: Long.UZERO,
|
1328
|
+
aptosOnVersionConfigs: [],
|
1329
|
+
};
|
1289
1330
|
}
|
1290
1331
|
|
1291
1332
|
export const AccountConfig = {
|
1292
1333
|
encode(
|
1293
|
-
|
1334
|
+
message: AccountConfig,
|
1294
1335
|
writer: _m0.Writer = _m0.Writer.create()
|
1295
1336
|
): _m0.Writer {
|
1337
|
+
if (message.chainId !== "") {
|
1338
|
+
writer.uint32(10).string(message.chainId);
|
1339
|
+
}
|
1340
|
+
if (message.address !== "") {
|
1341
|
+
writer.uint32(18).string(message.address);
|
1342
|
+
}
|
1343
|
+
if (!message.startBlock.isZero()) {
|
1344
|
+
writer.uint32(24).uint64(message.startBlock);
|
1345
|
+
}
|
1346
|
+
for (const v of message.aptosOnVersionConfigs) {
|
1347
|
+
AptosOnVersionConfig.encode(v!, writer.uint32(34).fork()).ldelim();
|
1348
|
+
}
|
1296
1349
|
return writer;
|
1297
1350
|
},
|
1298
1351
|
|
@@ -1303,6 +1356,20 @@ export const AccountConfig = {
|
|
1303
1356
|
while (reader.pos < end) {
|
1304
1357
|
const tag = reader.uint32();
|
1305
1358
|
switch (tag >>> 3) {
|
1359
|
+
case 1:
|
1360
|
+
message.chainId = reader.string();
|
1361
|
+
break;
|
1362
|
+
case 2:
|
1363
|
+
message.address = reader.string();
|
1364
|
+
break;
|
1365
|
+
case 3:
|
1366
|
+
message.startBlock = reader.uint64() as Long;
|
1367
|
+
break;
|
1368
|
+
case 4:
|
1369
|
+
message.aptosOnVersionConfigs.push(
|
1370
|
+
AptosOnVersionConfig.decode(reader, reader.uint32())
|
1371
|
+
);
|
1372
|
+
break;
|
1306
1373
|
default:
|
1307
1374
|
reader.skipType(tag & 7);
|
1308
1375
|
break;
|
@@ -1311,17 +1378,114 @@ export const AccountConfig = {
|
|
1311
1378
|
return message;
|
1312
1379
|
},
|
1313
1380
|
|
1314
|
-
fromJSON(
|
1315
|
-
return {
|
1381
|
+
fromJSON(object: any): AccountConfig {
|
1382
|
+
return {
|
1383
|
+
chainId: isSet(object.chainId) ? String(object.chainId) : "",
|
1384
|
+
address: isSet(object.address) ? String(object.address) : "",
|
1385
|
+
startBlock: isSet(object.startBlock)
|
1386
|
+
? Long.fromValue(object.startBlock)
|
1387
|
+
: Long.UZERO,
|
1388
|
+
aptosOnVersionConfigs: Array.isArray(object?.aptosOnVersionConfigs)
|
1389
|
+
? object.aptosOnVersionConfigs.map((e: any) =>
|
1390
|
+
AptosOnVersionConfig.fromJSON(e)
|
1391
|
+
)
|
1392
|
+
: [],
|
1393
|
+
};
|
1316
1394
|
},
|
1317
1395
|
|
1318
|
-
toJSON(
|
1396
|
+
toJSON(message: AccountConfig): unknown {
|
1319
1397
|
const obj: any = {};
|
1398
|
+
message.chainId !== undefined && (obj.chainId = message.chainId);
|
1399
|
+
message.address !== undefined && (obj.address = message.address);
|
1400
|
+
message.startBlock !== undefined &&
|
1401
|
+
(obj.startBlock = (message.startBlock || Long.UZERO).toString());
|
1402
|
+
if (message.aptosOnVersionConfigs) {
|
1403
|
+
obj.aptosOnVersionConfigs = message.aptosOnVersionConfigs.map((e) =>
|
1404
|
+
e ? AptosOnVersionConfig.toJSON(e) : undefined
|
1405
|
+
);
|
1406
|
+
} else {
|
1407
|
+
obj.aptosOnVersionConfigs = [];
|
1408
|
+
}
|
1320
1409
|
return obj;
|
1321
1410
|
},
|
1322
1411
|
|
1323
|
-
fromPartial(
|
1412
|
+
fromPartial(object: DeepPartial<AccountConfig>): AccountConfig {
|
1324
1413
|
const message = createBaseAccountConfig();
|
1414
|
+
message.chainId = object.chainId ?? "";
|
1415
|
+
message.address = object.address ?? "";
|
1416
|
+
message.startBlock =
|
1417
|
+
object.startBlock !== undefined && object.startBlock !== null
|
1418
|
+
? Long.fromValue(object.startBlock)
|
1419
|
+
: Long.UZERO;
|
1420
|
+
message.aptosOnVersionConfigs =
|
1421
|
+
object.aptosOnVersionConfigs?.map((e) =>
|
1422
|
+
AptosOnVersionConfig.fromPartial(e)
|
1423
|
+
) || [];
|
1424
|
+
return message;
|
1425
|
+
},
|
1426
|
+
};
|
1427
|
+
|
1428
|
+
function createBaseAptosOnVersionConfig(): AptosOnVersionConfig {
|
1429
|
+
return { handlerId: 0, step: 0 };
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
export const AptosOnVersionConfig = {
|
1433
|
+
encode(
|
1434
|
+
message: AptosOnVersionConfig,
|
1435
|
+
writer: _m0.Writer = _m0.Writer.create()
|
1436
|
+
): _m0.Writer {
|
1437
|
+
if (message.handlerId !== 0) {
|
1438
|
+
writer.uint32(8).int32(message.handlerId);
|
1439
|
+
}
|
1440
|
+
if (message.step !== 0) {
|
1441
|
+
writer.uint32(16).int32(message.step);
|
1442
|
+
}
|
1443
|
+
return writer;
|
1444
|
+
},
|
1445
|
+
|
1446
|
+
decode(
|
1447
|
+
input: _m0.Reader | Uint8Array,
|
1448
|
+
length?: number
|
1449
|
+
): AptosOnVersionConfig {
|
1450
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
1451
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
1452
|
+
const message = createBaseAptosOnVersionConfig();
|
1453
|
+
while (reader.pos < end) {
|
1454
|
+
const tag = reader.uint32();
|
1455
|
+
switch (tag >>> 3) {
|
1456
|
+
case 1:
|
1457
|
+
message.handlerId = reader.int32();
|
1458
|
+
break;
|
1459
|
+
case 2:
|
1460
|
+
message.step = reader.int32();
|
1461
|
+
break;
|
1462
|
+
default:
|
1463
|
+
reader.skipType(tag & 7);
|
1464
|
+
break;
|
1465
|
+
}
|
1466
|
+
}
|
1467
|
+
return message;
|
1468
|
+
},
|
1469
|
+
|
1470
|
+
fromJSON(object: any): AptosOnVersionConfig {
|
1471
|
+
return {
|
1472
|
+
handlerId: isSet(object.handlerId) ? Number(object.handlerId) : 0,
|
1473
|
+
step: isSet(object.step) ? Number(object.step) : 0,
|
1474
|
+
};
|
1475
|
+
},
|
1476
|
+
|
1477
|
+
toJSON(message: AptosOnVersionConfig): unknown {
|
1478
|
+
const obj: any = {};
|
1479
|
+
message.handlerId !== undefined &&
|
1480
|
+
(obj.handlerId = Math.round(message.handlerId));
|
1481
|
+
message.step !== undefined && (obj.step = Math.round(message.step));
|
1482
|
+
return obj;
|
1483
|
+
},
|
1484
|
+
|
1485
|
+
fromPartial(object: DeepPartial<AptosOnVersionConfig>): AptosOnVersionConfig {
|
1486
|
+
const message = createBaseAptosOnVersionConfig();
|
1487
|
+
message.handlerId = object.handlerId ?? 0;
|
1488
|
+
message.step = object.step ?? 0;
|
1325
1489
|
return message;
|
1326
1490
|
},
|
1327
1491
|
};
|
@@ -3204,7 +3368,13 @@ export const ProcessResult = {
|
|
3204
3368
|
};
|
3205
3369
|
|
3206
3370
|
function createBaseDataDescriptor(): DataDescriptor {
|
3207
|
-
return {
|
3371
|
+
return {
|
3372
|
+
name: "",
|
3373
|
+
description: "",
|
3374
|
+
unit: "",
|
3375
|
+
sparse: false,
|
3376
|
+
resolutionInSeconds: 0,
|
3377
|
+
};
|
3208
3378
|
}
|
3209
3379
|
|
3210
3380
|
export const DataDescriptor = {
|
@@ -3224,6 +3394,9 @@ export const DataDescriptor = {
|
|
3224
3394
|
if (message.sparse === true) {
|
3225
3395
|
writer.uint32(32).bool(message.sparse);
|
3226
3396
|
}
|
3397
|
+
if (message.resolutionInSeconds !== 0) {
|
3398
|
+
writer.uint32(40).int32(message.resolutionInSeconds);
|
3399
|
+
}
|
3227
3400
|
return writer;
|
3228
3401
|
},
|
3229
3402
|
|
@@ -3246,6 +3419,9 @@ export const DataDescriptor = {
|
|
3246
3419
|
case 4:
|
3247
3420
|
message.sparse = reader.bool();
|
3248
3421
|
break;
|
3422
|
+
case 5:
|
3423
|
+
message.resolutionInSeconds = reader.int32();
|
3424
|
+
break;
|
3249
3425
|
default:
|
3250
3426
|
reader.skipType(tag & 7);
|
3251
3427
|
break;
|
@@ -3260,6 +3436,9 @@ export const DataDescriptor = {
|
|
3260
3436
|
description: isSet(object.description) ? String(object.description) : "",
|
3261
3437
|
unit: isSet(object.unit) ? String(object.unit) : "",
|
3262
3438
|
sparse: isSet(object.sparse) ? Boolean(object.sparse) : false,
|
3439
|
+
resolutionInSeconds: isSet(object.resolutionInSeconds)
|
3440
|
+
? Number(object.resolutionInSeconds)
|
3441
|
+
: 0,
|
3263
3442
|
};
|
3264
3443
|
},
|
3265
3444
|
|
@@ -3270,6 +3449,8 @@ export const DataDescriptor = {
|
|
3270
3449
|
(obj.description = message.description);
|
3271
3450
|
message.unit !== undefined && (obj.unit = message.unit);
|
3272
3451
|
message.sparse !== undefined && (obj.sparse = message.sparse);
|
3452
|
+
message.resolutionInSeconds !== undefined &&
|
3453
|
+
(obj.resolutionInSeconds = Math.round(message.resolutionInSeconds));
|
3273
3454
|
return obj;
|
3274
3455
|
},
|
3275
3456
|
|
@@ -3279,6 +3460,7 @@ export const DataDescriptor = {
|
|
3279
3460
|
message.description = object.description ?? "";
|
3280
3461
|
message.unit = object.unit ?? "";
|
3281
3462
|
message.sparse = object.sparse ?? false;
|
3463
|
+
message.resolutionInSeconds = object.resolutionInSeconds ?? 0;
|
3282
3464
|
return message;
|
3283
3465
|
},
|
3284
3466
|
};
|
package/src/service.ts
CHANGED
@@ -676,7 +676,7 @@ function mergeProcessResults(results: ProcessResult[]): ProcessResult {
|
|
676
676
|
res.counters = res.counters.concat(r.counters)
|
677
677
|
res.gauges = res.gauges.concat(r.gauges)
|
678
678
|
res.logs = res.logs.concat(r.logs)
|
679
|
-
res.events = res.events.concat(
|
679
|
+
res.events = res.events.concat(r.events)
|
680
680
|
}
|
681
681
|
return res
|
682
682
|
}
|
package/src/tests/aptos.test.ts
CHANGED
@@ -75,6 +75,7 @@ describe('Test Aptos Example', () => {
|
|
75
75
|
expect(res.result?.counters).length(1)
|
76
76
|
expect(res.result?.gauges).length(0)
|
77
77
|
expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034)
|
78
|
+
expect(res.result?.events).length(1)
|
78
79
|
})
|
79
80
|
|
80
81
|
test('Check token deposit event dispatch', async () => {
|
package/src/tests/souffl3.ts
CHANGED
@@ -2,6 +2,9 @@ import { SouffleChefCampaign, CandyMachine } from './types/aptos/souffle'
|
|
2
2
|
import { token } from '../builtin/aptos/0x3'
|
3
3
|
import { voting } from '../builtin/aptos/0x1'
|
4
4
|
import { TYPE_REGISTRY } from '../aptos/types'
|
5
|
+
import { AccountEventTracker } from '@sentio/sdk'
|
6
|
+
|
7
|
+
const accountTracker = AccountEventTracker.register('pull')
|
5
8
|
|
6
9
|
SouffleChefCampaign.bind({ startVersion: 3212312 })
|
7
10
|
.onEntryPullTokenV2((call: SouffleChefCampaign.PullTokenV2Payload, ctx) => {
|
@@ -9,8 +12,8 @@ SouffleChefCampaign.bind({ startVersion: 3212312 })
|
|
9
12
|
ctx.meter.Counter('pulled').add(call.arguments_typed[3])
|
10
13
|
})
|
11
14
|
.onEventPullTokenEvent((evt, ctx) => {
|
12
|
-
console.log(evt.data_typed.receiver)
|
13
15
|
ctx.meter.Counter('burned').add(1)
|
16
|
+
accountTracker.trackEvent(ctx, { distinctId: ctx.transaction.sender })
|
14
17
|
})
|
15
18
|
.onEvent(
|
16
19
|
(event, ctx) => {
|