@sentio/sdk 1.27.7 → 1.27.9

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.
@@ -150,6 +150,7 @@ export interface ProcessConfigResponse {
150
150
  export interface ContractConfig {
151
151
  contract: ContractInfo | undefined;
152
152
  blockConfigs: BlockHandlerConfig[];
153
+ intervalConfigs: OnIntervalConfig[];
153
154
  logConfigs: LogHandlerConfig[];
154
155
  traceConfigs: TraceHandlerConfig[];
155
156
  aptosEventConfigs: AptosEventHandlerConfig[];
@@ -230,8 +231,8 @@ export interface AccountConfig {
230
231
  chainId: string;
231
232
  address: string;
232
233
  startBlock: Long;
233
- onIntervalConfigs: OnIntervalConfig[];
234
- onAptosIntervalConfigs: AptosOnIntervalConfig[];
234
+ intervalConfigs: OnIntervalConfig[];
235
+ aptosIntervalConfigs: AptosOnIntervalConfig[];
235
236
  }
236
237
 
237
238
  export interface OnIntervalConfig {
@@ -759,6 +760,7 @@ function createBaseContractConfig(): ContractConfig {
759
760
  return {
760
761
  contract: undefined,
761
762
  blockConfigs: [],
763
+ intervalConfigs: [],
762
764
  logConfigs: [],
763
765
  traceConfigs: [],
764
766
  aptosEventConfigs: [],
@@ -781,6 +783,9 @@ export const ContractConfig = {
781
783
  for (const v of message.blockConfigs) {
782
784
  BlockHandlerConfig.encode(v!, writer.uint32(58).fork()).ldelim();
783
785
  }
786
+ for (const v of message.intervalConfigs) {
787
+ OnIntervalConfig.encode(v!, writer.uint32(90).fork()).ldelim();
788
+ }
784
789
  for (const v of message.logConfigs) {
785
790
  LogHandlerConfig.encode(v!, writer.uint32(26).fork()).ldelim();
786
791
  }
@@ -826,6 +831,11 @@ export const ContractConfig = {
826
831
  BlockHandlerConfig.decode(reader, reader.uint32())
827
832
  );
828
833
  break;
834
+ case 11:
835
+ message.intervalConfigs.push(
836
+ OnIntervalConfig.decode(reader, reader.uint32())
837
+ );
838
+ break;
829
839
  case 3:
830
840
  message.logConfigs.push(
831
841
  LogHandlerConfig.decode(reader, reader.uint32())
@@ -877,6 +887,9 @@ export const ContractConfig = {
877
887
  blockConfigs: Array.isArray(object?.blockConfigs)
878
888
  ? object.blockConfigs.map((e: any) => BlockHandlerConfig.fromJSON(e))
879
889
  : [],
890
+ intervalConfigs: Array.isArray(object?.intervalConfigs)
891
+ ? object.intervalConfigs.map((e: any) => OnIntervalConfig.fromJSON(e))
892
+ : [],
880
893
  logConfigs: Array.isArray(object?.logConfigs)
881
894
  ? object.logConfigs.map((e: any) => LogHandlerConfig.fromJSON(e))
882
895
  : [],
@@ -921,6 +934,13 @@ export const ContractConfig = {
921
934
  } else {
922
935
  obj.blockConfigs = [];
923
936
  }
937
+ if (message.intervalConfigs) {
938
+ obj.intervalConfigs = message.intervalConfigs.map((e) =>
939
+ e ? OnIntervalConfig.toJSON(e) : undefined
940
+ );
941
+ } else {
942
+ obj.intervalConfigs = [];
943
+ }
924
944
  if (message.logConfigs) {
925
945
  obj.logConfigs = message.logConfigs.map((e) =>
926
946
  e ? LogHandlerConfig.toJSON(e) : undefined
@@ -970,6 +990,8 @@ export const ContractConfig = {
970
990
  : undefined;
971
991
  message.blockConfigs =
972
992
  object.blockConfigs?.map((e) => BlockHandlerConfig.fromPartial(e)) || [];
993
+ message.intervalConfigs =
994
+ object.intervalConfigs?.map((e) => OnIntervalConfig.fromPartial(e)) || [];
973
995
  message.logConfigs =
974
996
  object.logConfigs?.map((e) => LogHandlerConfig.fromPartial(e)) || [];
975
997
  message.traceConfigs =
@@ -1427,8 +1449,8 @@ function createBaseAccountConfig(): AccountConfig {
1427
1449
  chainId: "",
1428
1450
  address: "",
1429
1451
  startBlock: Long.UZERO,
1430
- onIntervalConfigs: [],
1431
- onAptosIntervalConfigs: [],
1452
+ intervalConfigs: [],
1453
+ aptosIntervalConfigs: [],
1432
1454
  };
1433
1455
  }
1434
1456
 
@@ -1446,10 +1468,10 @@ export const AccountConfig = {
1446
1468
  if (!message.startBlock.isZero()) {
1447
1469
  writer.uint32(24).uint64(message.startBlock);
1448
1470
  }
1449
- for (const v of message.onIntervalConfigs) {
1471
+ for (const v of message.intervalConfigs) {
1450
1472
  OnIntervalConfig.encode(v!, writer.uint32(34).fork()).ldelim();
1451
1473
  }
1452
- for (const v of message.onAptosIntervalConfigs) {
1474
+ for (const v of message.aptosIntervalConfigs) {
1453
1475
  AptosOnIntervalConfig.encode(v!, writer.uint32(42).fork()).ldelim();
1454
1476
  }
1455
1477
  return writer;
@@ -1472,12 +1494,12 @@ export const AccountConfig = {
1472
1494
  message.startBlock = reader.uint64() as Long;
1473
1495
  break;
1474
1496
  case 4:
1475
- message.onIntervalConfigs.push(
1497
+ message.intervalConfigs.push(
1476
1498
  OnIntervalConfig.decode(reader, reader.uint32())
1477
1499
  );
1478
1500
  break;
1479
1501
  case 5:
1480
- message.onAptosIntervalConfigs.push(
1502
+ message.aptosIntervalConfigs.push(
1481
1503
  AptosOnIntervalConfig.decode(reader, reader.uint32())
1482
1504
  );
1483
1505
  break;
@@ -1496,11 +1518,11 @@ export const AccountConfig = {
1496
1518
  startBlock: isSet(object.startBlock)
1497
1519
  ? Long.fromValue(object.startBlock)
1498
1520
  : Long.UZERO,
1499
- onIntervalConfigs: Array.isArray(object?.onIntervalConfigs)
1500
- ? object.onIntervalConfigs.map((e: any) => OnIntervalConfig.fromJSON(e))
1521
+ intervalConfigs: Array.isArray(object?.intervalConfigs)
1522
+ ? object.intervalConfigs.map((e: any) => OnIntervalConfig.fromJSON(e))
1501
1523
  : [],
1502
- onAptosIntervalConfigs: Array.isArray(object?.onAptosIntervalConfigs)
1503
- ? object.onAptosIntervalConfigs.map((e: any) =>
1524
+ aptosIntervalConfigs: Array.isArray(object?.aptosIntervalConfigs)
1525
+ ? object.aptosIntervalConfigs.map((e: any) =>
1504
1526
  AptosOnIntervalConfig.fromJSON(e)
1505
1527
  )
1506
1528
  : [],
@@ -1513,19 +1535,19 @@ export const AccountConfig = {
1513
1535
  message.address !== undefined && (obj.address = message.address);
1514
1536
  message.startBlock !== undefined &&
1515
1537
  (obj.startBlock = (message.startBlock || Long.UZERO).toString());
1516
- if (message.onIntervalConfigs) {
1517
- obj.onIntervalConfigs = message.onIntervalConfigs.map((e) =>
1538
+ if (message.intervalConfigs) {
1539
+ obj.intervalConfigs = message.intervalConfigs.map((e) =>
1518
1540
  e ? OnIntervalConfig.toJSON(e) : undefined
1519
1541
  );
1520
1542
  } else {
1521
- obj.onIntervalConfigs = [];
1543
+ obj.intervalConfigs = [];
1522
1544
  }
1523
- if (message.onAptosIntervalConfigs) {
1524
- obj.onAptosIntervalConfigs = message.onAptosIntervalConfigs.map((e) =>
1545
+ if (message.aptosIntervalConfigs) {
1546
+ obj.aptosIntervalConfigs = message.aptosIntervalConfigs.map((e) =>
1525
1547
  e ? AptosOnIntervalConfig.toJSON(e) : undefined
1526
1548
  );
1527
1549
  } else {
1528
- obj.onAptosIntervalConfigs = [];
1550
+ obj.aptosIntervalConfigs = [];
1529
1551
  }
1530
1552
  return obj;
1531
1553
  },
@@ -1538,11 +1560,10 @@ export const AccountConfig = {
1538
1560
  object.startBlock !== undefined && object.startBlock !== null
1539
1561
  ? Long.fromValue(object.startBlock)
1540
1562
  : Long.UZERO;
1541
- message.onIntervalConfigs =
1542
- object.onIntervalConfigs?.map((e) => OnIntervalConfig.fromPartial(e)) ||
1543
- [];
1544
- message.onAptosIntervalConfigs =
1545
- object.onAptosIntervalConfigs?.map((e) =>
1563
+ message.intervalConfigs =
1564
+ object.intervalConfigs?.map((e) => OnIntervalConfig.fromPartial(e)) || [];
1565
+ message.aptosIntervalConfigs =
1566
+ object.aptosIntervalConfigs?.map((e) =>
1546
1567
  AptosOnIntervalConfig.fromPartial(e)
1547
1568
  ) || [];
1548
1569
  return message;
package/src/service.ts CHANGED
@@ -141,6 +141,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
141
141
  abi: '',
142
142
  },
143
143
  blockConfigs: [],
144
+ intervalConfigs: [],
144
145
  logConfigs: [],
145
146
  traceConfigs: [],
146
147
  startBlock: processor.config.startBlock,
@@ -155,10 +156,12 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
155
156
 
156
157
  // Step 1. Prepare all the block handlers
157
158
  for (const blockHandler of processor.blockHandlers) {
158
- const handlerId = this.blockHandlers.push(blockHandler) - 1
159
+ const handlerId = this.blockHandlers.push(blockHandler.handler) - 1
159
160
  // TODO wrap the block handler into one
160
161
 
161
- contractConfig.blockConfigs.push({
162
+ contractConfig.intervalConfigs.push({
163
+ slot: blockHandler.blockInterval || 1,
164
+ minutes: blockHandler.timeIntervalInMinutes || 0,
162
165
  handlerId: handlerId,
163
166
  })
164
167
  }
@@ -220,6 +223,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
220
223
  blockConfigs: [],
221
224
  logConfigs: [],
222
225
  traceConfigs: [],
226
+ intervalConfigs: [],
223
227
  startBlock: solanaProcessor.config.startSlot,
224
228
  endBlock: DEFAULT_MAX_BLOCK,
225
229
  instructionConfig: {
@@ -245,6 +249,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
245
249
  },
246
250
  blockConfigs: [],
247
251
  logConfigs: [],
252
+ intervalConfigs: [],
248
253
  traceConfigs: [],
249
254
  startBlock: suiProcessor.config.startSeqNumber,
250
255
  endBlock: DEFAULT_MAX_BLOCK,
@@ -266,6 +271,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
266
271
  abi: '',
267
272
  },
268
273
  blockConfigs: [],
274
+ intervalConfigs: [],
269
275
  logConfigs: [],
270
276
  traceConfigs: [],
271
277
  startBlock: Long.fromString(aptosProcessor.config.startVersion.toString()),
@@ -313,12 +319,12 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
313
319
  address: aptosProcessor.config.address,
314
320
  chainId: aptosProcessor.getChainId(),
315
321
  startBlock: Long.fromValue(aptosProcessor.config.startVersion.toString()),
316
- onAptosIntervalConfigs: [],
317
- onIntervalConfigs: [],
322
+ aptosIntervalConfigs: [],
323
+ intervalConfigs: [],
318
324
  }
319
325
  for (const handler of aptosProcessor.resourcesHandlers) {
320
326
  const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1
321
- accountConfig.onAptosIntervalConfigs.push({
327
+ accountConfig.aptosIntervalConfigs.push({
322
328
  intervalConfig: {
323
329
  handlerId: handlerId,
324
330
  minutes: handler.timeIntervalInMinutes || 0,
@@ -231,7 +231,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
231
231
  continue
232
232
  }
233
233
 
234
- for (const config of contract.blockConfigs) {
234
+ for (const config of contract.intervalConfigs) {
235
235
  binding.handlerIds.push(config.handlerId)
236
236
  }
237
237
  }
@@ -9,7 +9,7 @@ const rewardPerBlock = new Gauge('reward_per_block', {
9
9
  })
10
10
  const tokenCounter = new Counter('token')
11
11
 
12
- X2y2Processor.bind({ address: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1' }).onBlock(async (_, ctx) => {
12
+ X2y2Processor.bind({ address: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1' }).onBlockInterval(async (_, ctx) => {
13
13
  const phase = (await ctx.contract.currentPhase()).toString()
14
14
  const reward = token.scaleDown(await ctx.contract.rewardPerBlockForStaking(), 18)
15
15
  rewardPerBlock.record(ctx, reward, { phase })