@sentio/sdk 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 (98) hide show
  1. package/lib/aptos/codegen/types.test.js.map +1 -1
  2. package/lib/aptos/ext/coin-event.test.js.map +1 -1
  3. package/lib/aptos/ext/coin.test.js.map +1 -1
  4. package/lib/core/event-logger.test.js.map +1 -1
  5. package/lib/core/normalization.test.js.map +1 -1
  6. package/lib/core/numberish.test.js.map +1 -1
  7. package/lib/eth/account-processor.d.ts +14 -8
  8. package/lib/eth/account-processor.d.ts.map +1 -1
  9. package/lib/eth/account-processor.js +43 -21
  10. package/lib/eth/account-processor.js.map +1 -1
  11. package/lib/eth/base-processor-template.d.ts +9 -6
  12. package/lib/eth/base-processor-template.d.ts.map +1 -1
  13. package/lib/eth/base-processor-template.js +25 -12
  14. package/lib/eth/base-processor-template.js.map +1 -1
  15. package/lib/eth/base-processor.d.ts +13 -8
  16. package/lib/eth/base-processor.d.ts.map +1 -1
  17. package/lib/eth/base-processor.js +109 -28
  18. package/lib/eth/base-processor.js.map +1 -1
  19. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -32
  20. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  21. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +62 -62
  22. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  23. package/lib/eth/builtin/internal/erc1155-processor.d.ts +17 -17
  24. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  25. package/lib/eth/builtin/internal/erc1155-processor.js +32 -32
  26. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  27. package/lib/eth/builtin/internal/erc20-processor.d.ts +25 -25
  28. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  29. package/lib/eth/builtin/internal/erc20-processor.js +48 -48
  30. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  31. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -14
  32. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  33. package/lib/eth/builtin/internal/erc20bytes-processor.js +26 -26
  34. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  35. package/lib/eth/builtin/internal/erc721-processor.d.ts +21 -21
  36. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  37. package/lib/eth/builtin/internal/erc721-processor.js +40 -40
  38. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  39. package/lib/eth/builtin/internal/weth9-processor.d.ts +20 -20
  40. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  41. package/lib/eth/builtin/internal/weth9-processor.js +38 -38
  42. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  43. package/lib/eth/codegen/event-handler.d.ts.map +1 -1
  44. package/lib/eth/codegen/event-handler.js +3 -2
  45. package/lib/eth/codegen/event-handler.js.map +1 -1
  46. package/lib/eth/codegen/file.d.ts.map +1 -1
  47. package/lib/eth/codegen/file.js +6 -4
  48. package/lib/eth/codegen/file.js.map +1 -1
  49. package/lib/eth/codegen/functions-handler.js +4 -3
  50. package/lib/eth/codegen/functions-handler.js.map +1 -1
  51. package/lib/eth/context.d.ts +6 -5
  52. package/lib/eth/context.d.ts.map +1 -1
  53. package/lib/eth/context.js +7 -5
  54. package/lib/eth/context.js.map +1 -1
  55. package/lib/eth/eth-plugin.d.ts +22 -10
  56. package/lib/eth/eth-plugin.d.ts.map +1 -1
  57. package/lib/eth/eth-plugin.js +105 -10
  58. package/lib/eth/eth-plugin.js.map +1 -1
  59. package/lib/eth/eth.js +1 -1
  60. package/lib/eth/eth.js.map +1 -1
  61. package/lib/eth/eth.test.js.map +1 -1
  62. package/lib/eth/generic-processor.test.js.map +1 -1
  63. package/lib/eth/index.d.ts +2 -2
  64. package/lib/eth/index.d.ts.map +1 -1
  65. package/lib/eth/index.js +2 -2
  66. package/lib/eth/index.js.map +1 -1
  67. package/lib/eth/provider.d.ts.map +1 -1
  68. package/lib/eth/provider.js +12 -18
  69. package/lib/eth/provider.js.map +1 -1
  70. package/lib/eth/provider.test.js.map +1 -1
  71. package/lib/store/convert.test.js.map +1 -1
  72. package/lib/store/schema.js +1 -1
  73. package/lib/store/store.d.ts.map +1 -1
  74. package/lib/store/store.js +2 -1
  75. package/lib/store/store.js.map +1 -1
  76. package/lib/utils/dex-price.test.js.map +1 -1
  77. package/lib/utils/erc20.test.js.map +1 -1
  78. package/lib/utils/price.test.js.map +1 -1
  79. package/package.json +6 -7
  80. package/src/eth/account-processor.ts +93 -22
  81. package/src/eth/base-processor-template.ts +60 -14
  82. package/src/eth/base-processor.ts +181 -37
  83. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +302 -62
  84. package/src/eth/builtin/internal/erc1155-processor.ts +137 -32
  85. package/src/eth/builtin/internal/erc20-processor.ts +235 -48
  86. package/src/eth/builtin/internal/erc20bytes-processor.ts +124 -26
  87. package/src/eth/builtin/internal/erc721-processor.ts +191 -40
  88. package/src/eth/builtin/internal/weth9-processor.ts +170 -38
  89. package/src/eth/codegen/event-handler.ts +3 -2
  90. package/src/eth/codegen/file.ts +6 -4
  91. package/src/eth/codegen/functions-handler.ts +4 -3
  92. package/src/eth/context.ts +23 -7
  93. package/src/eth/eth-plugin.ts +142 -14
  94. package/src/eth/eth.ts +1 -1
  95. package/src/eth/index.ts +2 -2
  96. package/src/eth/provider.ts +15 -19
  97. package/src/store/schema.ts +1 -1
  98. package/src/store/store.ts +22 -13
@@ -10,6 +10,8 @@ import {
10
10
  HandlerType,
11
11
  LogFilter,
12
12
  LogHandlerConfig,
13
+ PreparedData,
14
+ PreprocessResult,
13
15
  ProcessConfigResponse,
14
16
  ProcessResult,
15
17
  StartRequest
@@ -19,17 +21,24 @@ import { ServerError, Status } from 'nice-grpc'
19
21
  import { EthProcessorState } from './binds.js'
20
22
  import { AccountProcessorState } from './account-processor-state.js'
21
23
  import { ProcessorTemplateProcessorState } from './base-processor-template.js'
22
- import { GlobalProcessorState } from './base-processor.js'
24
+ import { defaultPreprocessHandler, GlobalProcessorState } from './base-processor.js'
23
25
  import { validateAndNormalizeAddress } from './eth.js'
24
26
  import { EthChainId } from '@sentio/chain'
25
27
  import { EthContext } from './context.js'
26
28
  import { TemplateInstanceState } from '../core/template.js'
27
29
 
28
30
  interface Handlers {
29
- eventHandlers: ((event: Data_EthLog) => Promise<ProcessResult>)[]
30
- traceHandlers: ((trace: Data_EthTrace) => Promise<ProcessResult>)[]
31
- blockHandlers: ((block: Data_EthBlock) => Promise<ProcessResult>)[]
32
- transactionHandlers: ((trace: Data_EthTransaction) => Promise<ProcessResult>)[]
31
+ eventHandlers: ((event: Data_EthLog, preparedData?: PreparedData) => Promise<ProcessResult>)[]
32
+ traceHandlers: ((trace: Data_EthTrace, preparedData?: PreparedData) => Promise<ProcessResult>)[]
33
+ blockHandlers: ((block: Data_EthBlock, preparedData?: PreparedData) => Promise<ProcessResult>)[]
34
+ transactionHandlers: ((trace: Data_EthTransaction, preparedData?: PreparedData) => Promise<ProcessResult>)[]
35
+ }
36
+
37
+ interface PreprocessHandlers {
38
+ eventHandlers: ((event: Data_EthLog) => Promise<PreprocessResult>)[]
39
+ traceHandlers: ((trace: Data_EthTrace) => Promise<PreprocessResult>)[]
40
+ blockHandlers: ((block: Data_EthBlock) => Promise<PreprocessResult>)[]
41
+ transactionHandlers: ((txn: Data_EthTransaction) => Promise<PreprocessResult>)[]
33
42
  }
34
43
 
35
44
  export class EthPlugin extends Plugin {
@@ -40,6 +49,12 @@ export class EthPlugin extends Plugin {
40
49
  traceHandlers: [],
41
50
  transactionHandlers: []
42
51
  }
52
+ preprocessHandlers: PreprocessHandlers = {
53
+ blockHandlers: [],
54
+ eventHandlers: [],
55
+ traceHandlers: [],
56
+ transactionHandlers: []
57
+ }
43
58
 
44
59
  async configure(config: ProcessConfigResponse) {
45
60
  const handlers: Handlers = {
@@ -48,6 +63,12 @@ export class EthPlugin extends Plugin {
48
63
  traceHandlers: [],
49
64
  transactionHandlers: []
50
65
  }
66
+ const preprocessHandlers: PreprocessHandlers = {
67
+ blockHandlers: [],
68
+ eventHandlers: [],
69
+ traceHandlers: [],
70
+ transactionHandlers: []
71
+ }
51
72
 
52
73
  for (const processor of EthProcessorState.INSTANCE.getValues()) {
53
74
  // If server favor incremental update this need to change
@@ -69,6 +90,7 @@ export class EthPlugin extends Plugin {
69
90
 
70
91
  // Step 1. Prepare all the block handlers
71
92
  for (const blockHandler of processor.blockHandlers) {
93
+ preprocessHandlers.blockHandlers.push(blockHandler.preprocessHandler ?? defaultPreprocessHandler)
72
94
  const handlerId = handlers.blockHandlers.push(blockHandler.handler) - 1
73
95
  // TODO wrap the block handler into one
74
96
 
@@ -84,6 +106,7 @@ export class EthPlugin extends Plugin {
84
106
 
85
107
  // Step 2. Prepare all trace handlers
86
108
  for (const traceHandler of processor.traceHandlers) {
109
+ preprocessHandlers.traceHandlers.push(traceHandler.preprocessHandler ?? defaultPreprocessHandler)
87
110
  const handlerId = handlers.traceHandlers.push(traceHandler.handler) - 1
88
111
  for (const signature of traceHandler.signatures) {
89
112
  contractConfig.traceConfigs.push({
@@ -97,6 +120,7 @@ export class EthPlugin extends Plugin {
97
120
  // Step 3. Prepare all the event handlers
98
121
  for (const eventsHandler of processor.eventHandlers) {
99
122
  // associate id with filter
123
+ preprocessHandlers.eventHandlers.push(eventsHandler.preprocessHandler ?? defaultPreprocessHandler)
100
124
  const handlerId = handlers.eventHandlers.push(eventsHandler.handler) - 1
101
125
  const logConfig: LogHandlerConfig = {
102
126
  handlerId: handlerId,
@@ -192,6 +216,7 @@ export class EthPlugin extends Plugin {
192
216
  // TODO add interval
193
217
  for (const eventsHandler of processor.eventHandlers) {
194
218
  // associate id with filter
219
+ preprocessHandlers.eventHandlers.push(eventsHandler.preprocessHandler ?? defaultPreprocessHandler)
195
220
  const handlerId = handlers.eventHandlers.push(eventsHandler.handler) - 1
196
221
  const logConfig: LogHandlerConfig = {
197
222
  handlerId: handlerId,
@@ -232,21 +257,37 @@ export class EthPlugin extends Plugin {
232
257
  }
233
258
 
234
259
  this.handlers = handlers
260
+ this.preprocessHandlers = preprocessHandlers
235
261
  }
236
262
 
237
263
  supportedHandlers = [HandlerType.ETH_LOG, HandlerType.ETH_BLOCK, HandlerType.ETH_TRACE, HandlerType.ETH_TRANSACTION]
238
264
 
239
- processBinding(request: DataBinding): Promise<ProcessResult> {
265
+ processBinding(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
240
266
  // return Promise.resolve(undefined);
241
267
  switch (request.handlerType) {
242
268
  case HandlerType.ETH_LOG:
243
- return this.processLog(request)
269
+ return this.processLog(request, preparedData)
270
+ case HandlerType.ETH_TRACE:
271
+ return this.processTrace(request, preparedData)
272
+ case HandlerType.ETH_BLOCK:
273
+ return this.processBlock(request, preparedData)
274
+ case HandlerType.ETH_TRANSACTION:
275
+ return this.processTransaction(request, preparedData)
276
+ default:
277
+ throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
278
+ }
279
+ }
280
+
281
+ preprocessBinding(request: DataBinding): Promise<PreprocessResult> {
282
+ switch (request.handlerType) {
283
+ case HandlerType.ETH_LOG:
284
+ return this.preprocessLog(request)
244
285
  case HandlerType.ETH_TRACE:
245
- return this.processTrace(request)
286
+ return this.preprocessTrace(request)
246
287
  case HandlerType.ETH_BLOCK:
247
- return this.processBlock(request)
288
+ return this.preprocessBlock(request)
248
289
  case HandlerType.ETH_TRANSACTION:
249
- return this.processTransaction(request)
290
+ return this.preprocessTransaction(request)
250
291
  default:
251
292
  throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
252
293
  }
@@ -285,7 +326,86 @@ export class EthPlugin extends Plugin {
285
326
  return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
286
327
  }
287
328
 
288
- async processLog(request: DataBinding): Promise<ProcessResult> {
329
+ async preprocessLog(request: DataBinding): Promise<PreprocessResult> {
330
+ if (!request.data?.ethLog?.log) {
331
+ throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
332
+ }
333
+ const ethLog = request.data.ethLog
334
+
335
+ const promises: Promise<PreprocessResult>[] = []
336
+ for (const handlerId of request.handlerIds) {
337
+ const handler = this.preprocessHandlers.eventHandlers[handlerId]
338
+ const promise = handler(ethLog).catch((e) => {
339
+ throw new ServerError(
340
+ Status.INTERNAL,
341
+ 'error processing log: ' + JSON.stringify(ethLog.log) + '\n' + errorString(e)
342
+ )
343
+ })
344
+ promises.push(promise)
345
+ }
346
+ return mergePreprocessResults(await Promise.all(promises))
347
+ }
348
+
349
+ async preprocessTrace(binding: DataBinding): Promise<PreprocessResult> {
350
+ if (!binding.data?.ethTrace?.trace) {
351
+ throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be null")
352
+ }
353
+ const ethTrace = binding.data.ethTrace
354
+
355
+ const promises: Promise<PreprocessResult>[] = []
356
+
357
+ for (const handlerId of binding.handlerIds) {
358
+ const promise = this.preprocessHandlers.traceHandlers[handlerId](ethTrace).catch((e) => {
359
+ throw new ServerError(
360
+ Status.INTERNAL,
361
+ 'error processing trace: ' + JSON.stringify(ethTrace.trace) + '\n' + errorString(e)
362
+ )
363
+ })
364
+ promises.push(promise)
365
+ }
366
+ return mergePreprocessResults(await Promise.all(promises))
367
+ }
368
+
369
+ async preprocessBlock(binding: DataBinding): Promise<PreprocessResult> {
370
+ if (!binding.data?.ethBlock?.block) {
371
+ throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
372
+ }
373
+ const ethBlock = binding.data.ethBlock
374
+
375
+ const promises: Promise<PreprocessResult>[] = []
376
+ for (const handlerId of binding.handlerIds) {
377
+ const promise = this.preprocessHandlers.blockHandlers[handlerId](ethBlock).catch((e) => {
378
+ throw new ServerError(
379
+ Status.INTERNAL,
380
+ 'error processing block: ' + ethBlock.block?.number + '\n' + errorString(e)
381
+ )
382
+ })
383
+ promises.push(promise)
384
+ }
385
+ return mergePreprocessResults(await Promise.all(promises))
386
+ }
387
+
388
+ async preprocessTransaction(binding: DataBinding): Promise<PreprocessResult> {
389
+ if (!binding.data?.ethTransaction?.transaction) {
390
+ throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
391
+ }
392
+ const ethTransaction = binding.data.ethTransaction
393
+
394
+ const promises: Promise<PreprocessResult>[] = []
395
+
396
+ for (const handlerId of binding.handlerIds) {
397
+ const promise = this.preprocessHandlers.transactionHandlers[handlerId](ethTransaction).catch((e) => {
398
+ throw new ServerError(
399
+ Status.INTERNAL,
400
+ 'error processing transaction: ' + JSON.stringify(ethTransaction.transaction) + '\n' + errorString(e)
401
+ )
402
+ })
403
+ promises.push(promise)
404
+ }
405
+ return mergePreprocessResults(await Promise.all(promises))
406
+ }
407
+
408
+ async processLog(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
289
409
  if (!request.data?.ethLog?.log) {
290
410
  throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
291
411
  }
@@ -308,7 +428,7 @@ export class EthPlugin extends Plugin {
308
428
  return mergeProcessResults(await Promise.all(promises))
309
429
  }
310
430
 
311
- async processTrace(binding: DataBinding): Promise<ProcessResult> {
431
+ async processTrace(binding: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
312
432
  if (!binding.data?.ethTrace?.trace) {
313
433
  throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be null")
314
434
  }
@@ -331,7 +451,7 @@ export class EthPlugin extends Plugin {
331
451
  return mergeProcessResults(await Promise.all(promises))
332
452
  }
333
453
 
334
- async processBlock(binding: DataBinding): Promise<ProcessResult> {
454
+ async processBlock(binding: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
335
455
  if (!binding.data?.ethBlock?.block) {
336
456
  throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
337
457
  }
@@ -353,7 +473,7 @@ export class EthPlugin extends Plugin {
353
473
  return mergeProcessResults(await Promise.all(promises))
354
474
  }
355
475
 
356
- async processTransaction(binding: DataBinding): Promise<ProcessResult> {
476
+ async processTransaction(binding: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult> {
357
477
  if (!binding.data?.ethTransaction?.transaction) {
358
478
  throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
359
479
  }
@@ -388,3 +508,11 @@ class NoopContext extends EthContext {
388
508
  return ''
389
509
  }
390
510
  }
511
+
512
+ function mergePreprocessResults(results: PreprocessResult[]): PreprocessResult {
513
+ const res: PreprocessResult = { ethCallParams: [] }
514
+ for (const r of results) {
515
+ res.ethCallParams = res.ethCallParams.concat(r.ethCallParams)
516
+ }
517
+ return res
518
+ }
package/src/eth/eth.ts CHANGED
@@ -71,7 +71,7 @@ export function transformEtherError(e: Error, ctx: ContractContext<any, any> | u
71
71
  }
72
72
  return new SimpleEthersError(msg, err, stack)
73
73
  } else {
74
- return new SimpleEthersError(`eth call error, ${checkPage}:\n${err.message}`, err, stack)
74
+ return new SimpleEthersError(`eth call error, ${checkPage}:\n${JSON.stringify(err)}`, err, stack)
75
75
  }
76
76
  }
77
77
 
package/src/eth/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { BaseProcessor, GlobalProcessor } from './base-processor.js'
1
+ export { BaseProcessor, GlobalProcessor, defaultPreprocessHandler } from './base-processor.js'
2
2
  export { GenericProcessor } from './generic-processor.js'
3
3
  export { BaseProcessorTemplate } from './base-processor-template.js'
4
4
  export { AccountProcessor } from './account-processor.js'
@@ -11,6 +11,6 @@ export { AccountContext, ContractContext, GlobalContext, ContractView, BoundCont
11
11
 
12
12
  export { EthPlugin } from './eth-plugin.js'
13
13
 
14
- export { EthFetchConfig } from '@sentio/protos'
14
+ export { EthFetchConfig, PreprocessResult } from '@sentio/protos'
15
15
 
16
16
  export { EthChainId } from '@sentio/chain'
@@ -4,9 +4,17 @@ import PQueue from 'p-queue'
4
4
  import { Endpoints } from '@sentio/runtime'
5
5
  import { EthChainId } from '@sentio/chain'
6
6
  import { LRUCache } from 'lru-cache'
7
+ import { metrics } from '@opentelemetry/api'
7
8
 
8
9
  export const DummyProvider = new JsonRpcProvider('', Network.from(1))
9
10
 
11
+ const meter = metrics.getMeter('processor_provider')
12
+ const hit_count = meter.createCounter('provider_hit_count')
13
+ const miss_count = meter.createCounter('provider_miss_count')
14
+ const queue_size = meter.createGauge('provider_queue_size')
15
+ const total_duration = meter.createCounter('provider_total_duration')
16
+ const total_queued = meter.createCounter('provider_total_queued')
17
+
10
18
  const providers = new Map<string, JsonRpcProvider>()
11
19
 
12
20
  // export function getEthChainId(networkish?: EthContext | EthChainId): EthChainId {
@@ -97,10 +105,6 @@ class QueuedStaticJsonRpcProvider extends JsonRpcProvider {
97
105
  // return 1024
98
106
  // }
99
107
  })
100
- hits = 0
101
- misses = 0
102
- totalDuration = 0
103
- totalQueued = 0
104
108
 
105
109
  constructor(url: string, network: Network, concurrency: number, batchCount = 1) {
106
110
  // TODO re-enable match when possible
@@ -116,13 +120,14 @@ class QueuedStaticJsonRpcProvider extends JsonRpcProvider {
116
120
  const block = params[params.length - 1]
117
121
  let perform = this.#performCache.get(tag)
118
122
  if (!perform) {
119
- this.misses++
123
+ miss_count.add(1)
120
124
  const queued: number = Date.now()
121
125
  perform = this.executor.add(() => {
122
126
  const started = Date.now()
123
- this.totalQueued += started - queued
127
+ total_queued.add(started - queued)
128
+
124
129
  return super.send(method, params).finally(() => {
125
- this.totalDuration += Date.now() - started
130
+ total_duration.add(Date.now() - started)
126
131
  })
127
132
  })
128
133
  perform.catch((e) => {
@@ -134,6 +139,8 @@ class QueuedStaticJsonRpcProvider extends JsonRpcProvider {
134
139
  }, 1000)
135
140
  })
136
141
 
142
+ queue_size.record(this.executor.size)
143
+
137
144
  this.#performCache.set(tag, perform)
138
145
  // For non latest block call, we cache permanently, otherwise we cache for one minute
139
146
  if (block === 'latest') {
@@ -144,7 +151,7 @@ class QueuedStaticJsonRpcProvider extends JsonRpcProvider {
144
151
  }, 60 * 1000)
145
152
  }
146
153
  } else {
147
- this.hits++
154
+ hit_count.add(1)
148
155
  }
149
156
 
150
157
  const result = await perform
@@ -153,15 +160,4 @@ class QueuedStaticJsonRpcProvider extends JsonRpcProvider {
153
160
  }
154
161
  return result
155
162
  }
156
-
157
- stats() {
158
- const count = this.hits + this.misses
159
- return {
160
- queueSize: this.executor.size,
161
- hits: this.hits,
162
- misses: this.misses,
163
- avgDuration: count == 0 ? 0 : this.totalDuration / count,
164
- avgQueued: count == 0 ? 0 : this.totalQueued / count
165
- }
166
- }
167
163
  }
@@ -6,7 +6,7 @@ const customScalars = ['BigInt', 'BigDecimal', 'Timestamp', 'JSON', 'Bytes', 'ID
6
6
 
7
7
  const baseSchema = buildASTSchema(
8
8
  parse(`
9
- directive @entity on OBJECT
9
+ directive @entity(immutable: Boolean! = false, sparse: Boolean! = false) on OBJECT
10
10
  directive @query on INTERFACE
11
11
  directive @derivedFrom(field: String!) on FIELD_DEFINITION
12
12
  directive @unique on FIELD_DEFINITION
@@ -107,6 +107,12 @@ export class Store {
107
107
  for (const data of response.entityList?.entities || []) {
108
108
  yield this.newEntity(entity, data)
109
109
  }
110
+ console.debug(
111
+ 'list returned ',
112
+ response.entityList?.entities?.length,
113
+ ' entities, next cursor',
114
+ response?.nextCursor
115
+ )
110
116
  if (!response.nextCursor) {
111
117
  break
112
118
  }
@@ -138,19 +144,22 @@ export class Store {
138
144
  cursor: string | undefined,
139
145
  pageSize?: number
140
146
  ): Promise<DBResponse> {
141
- return (await this.context.sendRequest({
142
- list: {
143
- entity: getEntityName(entity),
144
- cursor,
145
- pageSize,
146
- filters:
147
- filters?.map((f) => ({
148
- field: f.field as string,
149
- op: ops[f.op],
150
- value: { values: Array.isArray(f.value) ? f.value.map((v) => serialize(v)) : [serialize(f.value)] }
151
- })) || []
152
- }
153
- })) as DBResponse
147
+ return (await this.context.sendRequest(
148
+ {
149
+ list: {
150
+ entity: getEntityName(entity),
151
+ cursor,
152
+ pageSize,
153
+ filters:
154
+ filters?.map((f) => ({
155
+ field: f.field as string,
156
+ op: ops[f.op],
157
+ value: { values: Array.isArray(f.value) ? f.value.map((v) => serialize(v)) : [serialize(f.value)] }
158
+ })) || []
159
+ }
160
+ },
161
+ 60
162
+ )) as DBResponse
154
163
  }
155
164
 
156
165
  async list<T extends Entity, P extends keyof T, O extends Operators<T[P]>>(