@o1-labs/mina-archive-node-graphql 0.0.6 → 2.0.0

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 (176) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +92 -268
  3. package/build/src/blockchain/utils.js.map +1 -1
  4. package/build/src/config.js +86 -0
  5. package/build/src/config.js.map +1 -0
  6. package/build/src/db/archive-node-adapter/archive-node-adapter.js +29 -2
  7. package/build/src/db/archive-node-adapter/archive-node-adapter.js.map +1 -1
  8. package/build/src/db/archive-node-adapter/postgres-options.js +35 -0
  9. package/build/src/db/archive-node-adapter/postgres-options.js.map +1 -0
  10. package/build/src/db/sql/best-chain.js +5 -0
  11. package/build/src/db/sql/best-chain.js.map +1 -0
  12. package/build/src/db/sql/events-actions/queries.js +102 -21
  13. package/build/src/db/sql/events-actions/queries.js.map +1 -1
  14. package/build/src/db/sql/verification-key-updates/queries.js +100 -0
  15. package/build/src/db/sql/verification-key-updates/queries.js.map +1 -0
  16. package/build/src/db/sql/zkapp-commands/queries.js +363 -0
  17. package/build/src/db/sql/zkapp-commands/queries.js.map +1 -0
  18. package/build/src/db/sql/zkapp-commands/types.js +2 -0
  19. package/build/src/db/sql/zkapp-commands/types.js.map +1 -0
  20. package/build/src/errors/error.js +4 -1
  21. package/build/src/errors/error.js.map +1 -1
  22. package/build/src/index.js +44 -7
  23. package/build/src/index.js.map +1 -1
  24. package/build/src/resolvers.js +42 -23
  25. package/build/src/resolvers.js.map +1 -1
  26. package/build/src/schema-version.js +2 -0
  27. package/build/src/schema-version.js.map +1 -0
  28. package/build/src/server/cors.js +41 -0
  29. package/build/src/server/cors.js.map +1 -0
  30. package/build/src/server/graceful-shutdown.js +42 -0
  31. package/build/src/server/graceful-shutdown.js.map +1 -0
  32. package/build/src/server/graphql-armor.js +39 -0
  33. package/build/src/server/graphql-armor.js.map +1 -0
  34. package/build/src/server/logger.js +45 -0
  35. package/build/src/server/logger.js.map +1 -0
  36. package/build/src/server/metrics.js +72 -0
  37. package/build/src/server/metrics.js.map +1 -0
  38. package/build/src/server/plugins.js +31 -15
  39. package/build/src/server/plugins.js.map +1 -1
  40. package/build/src/server/rate-limit.js +143 -0
  41. package/build/src/server/rate-limit.js.map +1 -0
  42. package/build/src/server/readiness.js +45 -0
  43. package/build/src/server/readiness.js.map +1 -0
  44. package/build/src/server/request-logging.js +58 -0
  45. package/build/src/server/request-logging.js.map +1 -0
  46. package/build/src/server/server.js +38 -13
  47. package/build/src/server/server.js.map +1 -1
  48. package/build/src/services/actions-service/actions-service.js +26 -15
  49. package/build/src/services/actions-service/actions-service.js.map +1 -1
  50. package/build/src/services/blocks-service/blocks-service.js +10 -9
  51. package/build/src/services/blocks-service/blocks-service.js.map +1 -1
  52. package/build/src/services/network-service/network-service.js +17 -9
  53. package/build/src/services/network-service/network-service.js.map +1 -1
  54. package/build/src/services/verification-key-updates-service/verification-key-updates-service.interface.js +2 -0
  55. package/build/src/services/verification-key-updates-service/verification-key-updates-service.interface.js.map +1 -0
  56. package/build/src/services/verification-key-updates-service/verification-key-updates-service.js +41 -0
  57. package/build/src/services/verification-key-updates-service/verification-key-updates-service.js.map +1 -0
  58. package/build/src/services/zkapp-commands-service/zkapp-commands-service.interface.js +2 -0
  59. package/build/src/services/zkapp-commands-service/zkapp-commands-service.interface.js.map +1 -0
  60. package/build/src/services/zkapp-commands-service/zkapp-commands-service.js +115 -0
  61. package/build/src/services/zkapp-commands-service/zkapp-commands-service.js.map +1 -0
  62. package/build/src/tracing/jaeger-tracing.js +2 -1
  63. package/build/src/tracing/jaeger-tracing.js.map +1 -1
  64. package/build/tests/devnet-dump/action-state-invariants.js +165 -0
  65. package/build/tests/devnet-dump/action-state-invariants.js.map +1 -0
  66. package/build/tests/devnet-dump/devnet-dump.test.js +24 -10
  67. package/build/tests/devnet-dump/devnet-dump.test.js.map +1 -1
  68. package/build/tests/devnet-dump/setup.js +63 -17
  69. package/build/tests/devnet-dump/setup.js.map +1 -1
  70. package/build/tests/integration/action-state-ordering.test.js +139 -0
  71. package/build/tests/integration/action-state-ordering.test.js.map +1 -0
  72. package/build/tests/integration/action-state-setup.js +48 -0
  73. package/build/tests/integration/action-state-setup.js.map +1 -0
  74. package/build/tests/integration/consensus-vs-chain.test.js +81 -0
  75. package/build/tests/integration/consensus-vs-chain.test.js.map +1 -0
  76. package/build/tests/integration/integration.test.js +166 -2
  77. package/build/tests/integration/integration.test.js.map +1 -1
  78. package/build/tests/integration/postgres-timeout.test.js +92 -0
  79. package/build/tests/integration/postgres-timeout.test.js.map +1 -0
  80. package/build/tests/integration/setup.js +58 -1
  81. package/build/tests/integration/setup.js.map +1 -1
  82. package/build/tests/integration/verification-key-setup.js +49 -0
  83. package/build/tests/integration/verification-key-setup.js.map +1 -0
  84. package/build/tests/integration/verification-key-updates.test.js +159 -0
  85. package/build/tests/integration/verification-key-updates.test.js.map +1 -0
  86. package/build/tests/live-api/events.test.js +11 -7
  87. package/build/tests/live-api/events.test.js.map +1 -1
  88. package/build/tests/live-api/networkState.test.js +1 -0
  89. package/build/tests/live-api/networkState.test.js.map +1 -1
  90. package/build/tests/live-network/live-network.test.js +1 -0
  91. package/build/tests/live-network/live-network.test.js.map +1 -1
  92. package/build/tests/resolvers.test.js +65 -37
  93. package/build/tests/resolvers.test.js.map +1 -1
  94. package/build/tests/services/verification-key-updates-service/verification-key-updates-service.test.js +35 -0
  95. package/build/tests/services/verification-key-updates-service/verification-key-updates-service.test.js.map +1 -0
  96. package/build/tests/services/zkapp-commands-service/zkapp-commands-service.test.js +159 -0
  97. package/build/tests/services/zkapp-commands-service/zkapp-commands-service.test.js.map +1 -0
  98. package/build/tests/test-helpers.js +15 -0
  99. package/build/tests/test-helpers.js.map +1 -1
  100. package/build/tests/unit/best-chain-anchor.test.js +70 -0
  101. package/build/tests/unit/best-chain-anchor.test.js.map +1 -0
  102. package/build/tests/unit/config.test.js +106 -0
  103. package/build/tests/unit/config.test.js.map +1 -0
  104. package/build/tests/unit/cors.test.js +95 -0
  105. package/build/tests/unit/cors.test.js.map +1 -0
  106. package/build/tests/unit/error-masking.test.js +119 -0
  107. package/build/tests/unit/error-masking.test.js.map +1 -0
  108. package/build/tests/unit/graceful-shutdown.test.js +99 -0
  109. package/build/tests/unit/graceful-shutdown.test.js.map +1 -0
  110. package/build/tests/unit/graphql-armor.test.js +121 -0
  111. package/build/tests/unit/graphql-armor.test.js.map +1 -0
  112. package/build/tests/unit/logging.test.js +120 -0
  113. package/build/tests/unit/logging.test.js.map +1 -0
  114. package/build/tests/unit/metrics.test.js +114 -0
  115. package/build/tests/unit/metrics.test.js.map +1 -0
  116. package/build/tests/unit/network-service.test.js +66 -0
  117. package/build/tests/unit/network-service.test.js.map +1 -0
  118. package/build/tests/unit/postgres-options.test.js +56 -0
  119. package/build/tests/unit/postgres-options.test.js.map +1 -0
  120. package/build/tests/unit/rate-limit.test.js +271 -0
  121. package/build/tests/unit/rate-limit.test.js.map +1 -0
  122. package/build/tests/unit/readiness.test.js +75 -0
  123. package/build/tests/unit/readiness.test.js.map +1 -0
  124. package/build/tests/unit/schema-nullability.test.js +40 -0
  125. package/build/tests/unit/schema-nullability.test.js.map +1 -0
  126. package/build/tests/unit/schema-version.test.js +48 -0
  127. package/build/tests/unit/schema-version.test.js.map +1 -0
  128. package/build/tests/unit/yoga-http-contract.test.js +30 -0
  129. package/build/tests/unit/yoga-http-contract.test.js.map +1 -0
  130. package/build/tests/unit/zkapp-commands-gating.test.js +38 -0
  131. package/build/tests/unit/zkapp-commands-gating.test.js.map +1 -0
  132. package/build/zkapp/utils.js +2 -0
  133. package/build/zkapp/utils.js.map +1 -1
  134. package/package.json +33 -14
  135. package/schema.graphql +126 -8
  136. package/src/blockchain/types.ts +65 -1
  137. package/src/blockchain/utils.ts +26 -2
  138. package/src/config.ts +133 -0
  139. package/src/db/archive-node-adapter/archive-node-adapter.interface.ts +26 -3
  140. package/src/db/archive-node-adapter/archive-node-adapter.ts +65 -2
  141. package/src/db/archive-node-adapter/postgres-options.ts +90 -0
  142. package/src/db/sql/best-chain.ts +34 -0
  143. package/src/db/sql/events-actions/queries.ts +168 -24
  144. package/src/db/sql/verification-key-updates/queries.ts +132 -0
  145. package/src/db/sql/zkapp-commands/queries.ts +406 -0
  146. package/src/db/sql/zkapp-commands/types.ts +43 -0
  147. package/src/envionment.d.ts +20 -0
  148. package/src/errors/error.ts +17 -1
  149. package/src/index.ts +64 -7
  150. package/src/resolvers-types.ts +311 -24
  151. package/src/resolvers.ts +70 -34
  152. package/src/schema-version.ts +24 -0
  153. package/src/server/cors.ts +97 -0
  154. package/src/server/graceful-shutdown.ts +76 -0
  155. package/src/server/graphql-armor.ts +78 -0
  156. package/src/server/logger.ts +72 -0
  157. package/src/server/metrics.ts +104 -0
  158. package/src/server/plugins.ts +53 -19
  159. package/src/server/rate-limit.ts +274 -0
  160. package/src/server/readiness.ts +78 -0
  161. package/src/server/request-logging.ts +83 -0
  162. package/src/server/server.ts +70 -15
  163. package/src/services/actions-service/actions-service.ts +87 -24
  164. package/src/services/blocks-service/blocks-service.ts +16 -14
  165. package/src/services/network-service/network-service.ts +30 -12
  166. package/src/services/verification-key-updates-service/verification-key-updates-service.interface.ts +9 -0
  167. package/src/services/verification-key-updates-service/verification-key-updates-service.ts +72 -0
  168. package/src/services/zkapp-commands-service/zkapp-commands-service.interface.ts +9 -0
  169. package/src/services/zkapp-commands-service/zkapp-commands-service.ts +181 -0
  170. package/src/tracing/jaeger-tracing.ts +2 -1
  171. package/build/tests/consensus/run-compare.js +0 -40
  172. package/build/tests/consensus/run-compare.js.map +0 -1
  173. package/build/tests/consensus/select-consensus-precomputed.js +0 -80
  174. package/build/tests/consensus/select-consensus-precomputed.js.map +0 -1
  175. package/build/tests/consensus/types.js +0 -15
  176. package/build/tests/consensus/types.js.map +0 -1
@@ -44,7 +44,7 @@ export type Scalars = {
44
44
  export type ActionData = {
45
45
  __typename?: 'ActionData';
46
46
  accountUpdateId: Scalars['String']['output'];
47
- data: Array<Maybe<Scalars['String']['output']>>;
47
+ data: Array<Scalars['String']['output']>;
48
48
  transactionInfo?: Maybe<TransactionInfo>;
49
49
  };
50
50
 
@@ -70,7 +70,7 @@ export type ActionFilterOptionsInput = {
70
70
 
71
71
  export type ActionOutput = {
72
72
  __typename?: 'ActionOutput';
73
- actionData?: Maybe<Array<Maybe<ActionData>>>;
73
+ actionData?: Maybe<Array<ActionData>>;
74
74
  actionState: ActionStates;
75
75
  blockInfo?: Maybe<BlockInfo>;
76
76
  transactionInfo?: Maybe<TransactionInfo>;
@@ -142,7 +142,7 @@ export type BlockTransactions = {
142
142
  export type EventData = {
143
143
  __typename?: 'EventData';
144
144
  accountUpdateId: Scalars['String']['output'];
145
- data: Array<Maybe<Scalars['String']['output']>>;
145
+ data: Array<Scalars['String']['output']>;
146
146
  transactionInfo?: Maybe<TransactionInfo>;
147
147
  };
148
148
 
@@ -165,7 +165,7 @@ export type EventFilterOptionsInput = {
165
165
  export type EventOutput = {
166
166
  __typename?: 'EventOutput';
167
167
  blockInfo?: Maybe<BlockInfo>;
168
- eventData?: Maybe<Array<Maybe<EventData>>>;
168
+ eventData?: Maybe<Array<EventData>>;
169
169
  };
170
170
 
171
171
  export type FeeTransfer = {
@@ -190,10 +190,24 @@ export type NetworkStateOutput = {
190
190
 
191
191
  export type Query = {
192
192
  __typename?: 'Query';
193
- actions: Array<Maybe<ActionOutput>>;
194
- blocks: Array<Maybe<Block>>;
195
- events: Array<Maybe<EventOutput>>;
193
+ actions: Array<ActionOutput>;
194
+ blocks: Array<Block>;
195
+ events: Array<EventOutput>;
196
196
  networkState: NetworkStateOutput;
197
+ /**
198
+ * The `MAJOR.MINOR` version of this schema.
199
+ *
200
+ * Clients compare it with the schema version they were built against: an equal
201
+ * major means the contract they code against still holds, and a higher minor
202
+ * means this server has additive changes they may not know about yet.
203
+ *
204
+ * Always available, even when `ENABLED_QUERIES` restricts which data queries
205
+ * this server exposes — a compatibility check that can itself be switched off
206
+ * is of no use to a client.
207
+ */
208
+ schemaVersion: Scalars['String']['output'];
209
+ verificationKeyUpdates: Array<VerificationKeyUpdate>;
210
+ zkappCommands: Array<ZkappCommandOutput>;
197
211
  };
198
212
 
199
213
  export type QueryActionsArgs = {
@@ -210,6 +224,14 @@ export type QueryEventsArgs = {
210
224
  input: EventFilterOptionsInput;
211
225
  };
212
226
 
227
+ export type QueryVerificationKeyUpdatesArgs = {
228
+ input: VerificationKeyUpdateFilterInput;
229
+ };
230
+
231
+ export type QueryZkappCommandsArgs = {
232
+ input: ZkappCommandFilterOptionsInput;
233
+ };
234
+
213
235
  export type TransactionInfo = {
214
236
  __typename?: 'TransactionInfo';
215
237
  authorizationKind: Scalars['String']['output'];
@@ -217,7 +239,7 @@ export type TransactionInfo = {
217
239
  memo: Scalars['String']['output'];
218
240
  sequenceNumber: Scalars['Int']['output'];
219
241
  status: Scalars['String']['output'];
220
- zkappAccountUpdateIds: Array<Maybe<Scalars['Int']['output']>>;
242
+ zkappAccountUpdateIds: Array<Scalars['Int']['output']>;
221
243
  };
222
244
 
223
245
  export type UserCommand = {
@@ -234,6 +256,29 @@ export type UserCommand = {
234
256
  to: Scalars['String']['output'];
235
257
  };
236
258
 
259
+ export type VerificationKeyUpdate = {
260
+ __typename?: 'VerificationKeyUpdate';
261
+ accountUpdateId: Scalars['String']['output'];
262
+ address: Scalars['String']['output'];
263
+ blockInfo: BlockInfo;
264
+ tokenId: Scalars['String']['output'];
265
+ transactionInfo: TransactionInfo;
266
+ verificationKeyHash: Scalars['String']['output'];
267
+ };
268
+
269
+ /**
270
+ * Find applied account updates that set a specific verification key.
271
+ *
272
+ * The block range is required and limited by the server's configured maximum.
273
+ * `from` is inclusive and `to` is exclusive.
274
+ */
275
+ export type VerificationKeyUpdateFilterInput = {
276
+ from: Scalars['Int']['input'];
277
+ status?: InputMaybe<BlockStatusFilter>;
278
+ to: Scalars['Int']['input'];
279
+ verificationKeyHash: Scalars['String']['input'];
280
+ };
281
+
237
282
  export type ZkAppCommand = {
238
283
  __typename?: 'ZkAppCommand';
239
284
  failureReason?: Maybe<Scalars['String']['output']>;
@@ -244,6 +289,80 @@ export type ZkAppCommand = {
244
289
  status: Scalars['String']['output'];
245
290
  };
246
291
 
292
+ export type ZkappAccountPrecondition = {
293
+ __typename?: 'ZkappAccountPrecondition';
294
+ actionState?: Maybe<ZkappFieldArray>;
295
+ isNew?: Maybe<Scalars['Boolean']['output']>;
296
+ provedState?: Maybe<Scalars['Boolean']['output']>;
297
+ state?: Maybe<ZkappFieldArray>;
298
+ };
299
+
300
+ export type ZkappAccountUpdateOutput = {
301
+ __typename?: 'ZkappAccountUpdateOutput';
302
+ accountPrecondition?: Maybe<ZkappAccountPrecondition>;
303
+ actions: Array<ZkappFieldArray>;
304
+ appState?: Maybe<ZkappFieldArray>;
305
+ authorizationKind: Scalars['String']['output'];
306
+ balanceChange: Scalars['String']['output'];
307
+ callDepth: Scalars['Int']['output'];
308
+ events: Array<ZkappFieldArray>;
309
+ id: Scalars['String']['output'];
310
+ incrementNonce: Scalars['Boolean']['output'];
311
+ networkPrecondition?: Maybe<ZkappNetworkPrecondition>;
312
+ publicKey: Scalars['String']['output'];
313
+ tokenId: Scalars['String']['output'];
314
+ };
315
+
316
+ /**
317
+ * Filter successful zkApp commands by block range.
318
+ *
319
+ * Both `from` and `to` are required. The range is bounded by `ZKAPP_COMMAND_RANGE_SIZE`, and the server may reject dense ranges that expand to too many account updates.
320
+ */
321
+ export type ZkappCommandFilterOptionsInput = {
322
+ /** Optional account update public key filter. */
323
+ accountPublicKey?: InputMaybe<Scalars['String']['input']>;
324
+ blockStatus?: InputMaybe<BlockStatusFilter>;
325
+ /** Mina block height to filter zkApp commands from, inclusive */
326
+ from: Scalars['Int']['input'];
327
+ /** Mina block height to filter zkApp commands to, exclusive */
328
+ to: Scalars['Int']['input'];
329
+ /** Optional account update token id filter. */
330
+ tokenId?: InputMaybe<Scalars['String']['input']>;
331
+ };
332
+
333
+ export type ZkappCommandOutput = {
334
+ __typename?: 'ZkappCommandOutput';
335
+ accountUpdates: Array<ZkappAccountUpdateOutput>;
336
+ blockInfo: BlockInfo;
337
+ fee: Scalars['String']['output'];
338
+ feePayer: Scalars['String']['output'];
339
+ hash: Scalars['String']['output'];
340
+ memo: Scalars['String']['output'];
341
+ sequenceNumber: Scalars['Int']['output'];
342
+ };
343
+
344
+ /**
345
+ * Raw field array from the archive database.
346
+ *
347
+ * An empty `fields` array means the archive row exists but contains no field values.
348
+ * Nullable entries mean the corresponding nullable archive state slot has no field value.
349
+ */
350
+ export type ZkappFieldArray = {
351
+ __typename?: 'ZkappFieldArray';
352
+ fields: Array<Maybe<Scalars['String']['output']>>;
353
+ };
354
+
355
+ export type ZkappGlobalSlotBounds = {
356
+ __typename?: 'ZkappGlobalSlotBounds';
357
+ lowerBound?: Maybe<Scalars['Int']['output']>;
358
+ upperBound?: Maybe<Scalars['Int']['output']>;
359
+ };
360
+
361
+ export type ZkappNetworkPrecondition = {
362
+ __typename?: 'ZkappNetworkPrecondition';
363
+ globalSlotSinceGenesis?: Maybe<ZkappGlobalSlotBounds>;
364
+ };
365
+
247
366
  export type ResolverTypeWrapper<T> = Promise<T> | T;
248
367
 
249
368
  export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
@@ -386,7 +505,16 @@ export type ResolversTypes = {
386
505
  String: ResolverTypeWrapper<Scalars['String']['output']>;
387
506
  TransactionInfo: ResolverTypeWrapper<TransactionInfo>;
388
507
  UserCommand: ResolverTypeWrapper<UserCommand>;
508
+ VerificationKeyUpdate: ResolverTypeWrapper<VerificationKeyUpdate>;
509
+ VerificationKeyUpdateFilterInput: VerificationKeyUpdateFilterInput;
389
510
  ZkAppCommand: ResolverTypeWrapper<ZkAppCommand>;
511
+ ZkappAccountPrecondition: ResolverTypeWrapper<ZkappAccountPrecondition>;
512
+ ZkappAccountUpdateOutput: ResolverTypeWrapper<ZkappAccountUpdateOutput>;
513
+ ZkappCommandFilterOptionsInput: ZkappCommandFilterOptionsInput;
514
+ ZkappCommandOutput: ResolverTypeWrapper<ZkappCommandOutput>;
515
+ ZkappFieldArray: ResolverTypeWrapper<ZkappFieldArray>;
516
+ ZkappGlobalSlotBounds: ResolverTypeWrapper<ZkappGlobalSlotBounds>;
517
+ ZkappNetworkPrecondition: ResolverTypeWrapper<ZkappNetworkPrecondition>;
390
518
  };
391
519
 
392
520
  /** Mapping between all available schema types and the resolvers parents */
@@ -412,7 +540,16 @@ export type ResolversParentTypes = {
412
540
  String: Scalars['String']['output'];
413
541
  TransactionInfo: TransactionInfo;
414
542
  UserCommand: UserCommand;
543
+ VerificationKeyUpdate: VerificationKeyUpdate;
544
+ VerificationKeyUpdateFilterInput: VerificationKeyUpdateFilterInput;
415
545
  ZkAppCommand: ZkAppCommand;
546
+ ZkappAccountPrecondition: ZkappAccountPrecondition;
547
+ ZkappAccountUpdateOutput: ZkappAccountUpdateOutput;
548
+ ZkappCommandFilterOptionsInput: ZkappCommandFilterOptionsInput;
549
+ ZkappCommandOutput: ZkappCommandOutput;
550
+ ZkappFieldArray: ZkappFieldArray;
551
+ ZkappGlobalSlotBounds: ZkappGlobalSlotBounds;
552
+ ZkappNetworkPrecondition: ZkappNetworkPrecondition;
416
553
  };
417
554
 
418
555
  export type ActionDataResolvers<
@@ -421,11 +558,7 @@ export type ActionDataResolvers<
421
558
  ResolversParentTypes['ActionData'] = ResolversParentTypes['ActionData'],
422
559
  > = {
423
560
  accountUpdateId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
424
- data?: Resolver<
425
- Array<Maybe<ResolversTypes['String']>>,
426
- ParentType,
427
- ContextType
428
- >;
561
+ data?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>;
429
562
  transactionInfo?: Resolver<
430
563
  Maybe<ResolversTypes['TransactionInfo']>,
431
564
  ParentType,
@@ -439,7 +572,7 @@ export type ActionOutputResolvers<
439
572
  ResolversParentTypes['ActionOutput'] = ResolversParentTypes['ActionOutput'],
440
573
  > = {
441
574
  actionData?: Resolver<
442
- Maybe<Array<Maybe<ResolversTypes['ActionData']>>>,
575
+ Maybe<Array<ResolversTypes['ActionData']>>,
443
576
  ParentType,
444
577
  ContextType
445
578
  >;
@@ -576,11 +709,7 @@ export type EventDataResolvers<
576
709
  ResolversParentTypes['EventData'] = ResolversParentTypes['EventData'],
577
710
  > = {
578
711
  accountUpdateId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
579
- data?: Resolver<
580
- Array<Maybe<ResolversTypes['String']>>,
581
- ParentType,
582
- ContextType
583
- >;
712
+ data?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>;
584
713
  transactionInfo?: Resolver<
585
714
  Maybe<ResolversTypes['TransactionInfo']>,
586
715
  ParentType,
@@ -599,7 +728,7 @@ export type EventOutputResolvers<
599
728
  ContextType
600
729
  >;
601
730
  eventData?: Resolver<
602
- Maybe<Array<Maybe<ResolversTypes['EventData']>>>,
731
+ Maybe<Array<ResolversTypes['EventData']>>,
603
732
  ParentType,
604
733
  ContextType
605
734
  >;
@@ -650,19 +779,19 @@ export type QueryResolvers<
650
779
  ResolversParentTypes['Query'] = ResolversParentTypes['Query'],
651
780
  > = {
652
781
  actions?: Resolver<
653
- Array<Maybe<ResolversTypes['ActionOutput']>>,
782
+ Array<ResolversTypes['ActionOutput']>,
654
783
  ParentType,
655
784
  ContextType,
656
785
  RequireFields<QueryActionsArgs, 'input'>
657
786
  >;
658
787
  blocks?: Resolver<
659
- Array<Maybe<ResolversTypes['Block']>>,
788
+ Array<ResolversTypes['Block']>,
660
789
  ParentType,
661
790
  ContextType,
662
791
  Partial<QueryBlocksArgs>
663
792
  >;
664
793
  events?: Resolver<
665
- Array<Maybe<ResolversTypes['EventOutput']>>,
794
+ Array<ResolversTypes['EventOutput']>,
666
795
  ParentType,
667
796
  ContextType,
668
797
  RequireFields<QueryEventsArgs, 'input'>
@@ -672,6 +801,19 @@ export type QueryResolvers<
672
801
  ParentType,
673
802
  ContextType
674
803
  >;
804
+ schemaVersion?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
805
+ verificationKeyUpdates?: Resolver<
806
+ Array<ResolversTypes['VerificationKeyUpdate']>,
807
+ ParentType,
808
+ ContextType,
809
+ RequireFields<QueryVerificationKeyUpdatesArgs, 'input'>
810
+ >;
811
+ zkappCommands?: Resolver<
812
+ Array<ResolversTypes['ZkappCommandOutput']>,
813
+ ParentType,
814
+ ContextType,
815
+ RequireFields<QueryZkappCommandsArgs, 'input'>
816
+ >;
675
817
  };
676
818
 
677
819
  export type TransactionInfoResolvers<
@@ -689,7 +831,7 @@ export type TransactionInfoResolvers<
689
831
  sequenceNumber?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
690
832
  status?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
691
833
  zkappAccountUpdateIds?: Resolver<
692
- Array<Maybe<ResolversTypes['Int']>>,
834
+ Array<ResolversTypes['Int']>,
693
835
  ParentType,
694
836
  ContextType
695
837
  >;
@@ -716,6 +858,27 @@ export type UserCommandResolvers<
716
858
  to?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
717
859
  };
718
860
 
861
+ export type VerificationKeyUpdateResolvers<
862
+ ContextType = GraphQLContext,
863
+ ParentType extends
864
+ ResolversParentTypes['VerificationKeyUpdate'] = ResolversParentTypes['VerificationKeyUpdate'],
865
+ > = {
866
+ accountUpdateId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
867
+ address?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
868
+ blockInfo?: Resolver<ResolversTypes['BlockInfo'], ParentType, ContextType>;
869
+ tokenId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
870
+ transactionInfo?: Resolver<
871
+ ResolversTypes['TransactionInfo'],
872
+ ParentType,
873
+ ContextType
874
+ >;
875
+ verificationKeyHash?: Resolver<
876
+ ResolversTypes['String'],
877
+ ParentType,
878
+ ContextType
879
+ >;
880
+ };
881
+
719
882
  export type ZkAppCommandResolvers<
720
883
  ContextType = GraphQLContext,
721
884
  ParentType extends
@@ -733,6 +896,123 @@ export type ZkAppCommandResolvers<
733
896
  status?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
734
897
  };
735
898
 
899
+ export type ZkappAccountPreconditionResolvers<
900
+ ContextType = GraphQLContext,
901
+ ParentType extends
902
+ ResolversParentTypes['ZkappAccountPrecondition'] = ResolversParentTypes['ZkappAccountPrecondition'],
903
+ > = {
904
+ actionState?: Resolver<
905
+ Maybe<ResolversTypes['ZkappFieldArray']>,
906
+ ParentType,
907
+ ContextType
908
+ >;
909
+ isNew?: Resolver<Maybe<ResolversTypes['Boolean']>, ParentType, ContextType>;
910
+ provedState?: Resolver<
911
+ Maybe<ResolversTypes['Boolean']>,
912
+ ParentType,
913
+ ContextType
914
+ >;
915
+ state?: Resolver<
916
+ Maybe<ResolversTypes['ZkappFieldArray']>,
917
+ ParentType,
918
+ ContextType
919
+ >;
920
+ };
921
+
922
+ export type ZkappAccountUpdateOutputResolvers<
923
+ ContextType = GraphQLContext,
924
+ ParentType extends
925
+ ResolversParentTypes['ZkappAccountUpdateOutput'] = ResolversParentTypes['ZkappAccountUpdateOutput'],
926
+ > = {
927
+ accountPrecondition?: Resolver<
928
+ Maybe<ResolversTypes['ZkappAccountPrecondition']>,
929
+ ParentType,
930
+ ContextType
931
+ >;
932
+ actions?: Resolver<
933
+ Array<ResolversTypes['ZkappFieldArray']>,
934
+ ParentType,
935
+ ContextType
936
+ >;
937
+ appState?: Resolver<
938
+ Maybe<ResolversTypes['ZkappFieldArray']>,
939
+ ParentType,
940
+ ContextType
941
+ >;
942
+ authorizationKind?: Resolver<
943
+ ResolversTypes['String'],
944
+ ParentType,
945
+ ContextType
946
+ >;
947
+ balanceChange?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
948
+ callDepth?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
949
+ events?: Resolver<
950
+ Array<ResolversTypes['ZkappFieldArray']>,
951
+ ParentType,
952
+ ContextType
953
+ >;
954
+ id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
955
+ incrementNonce?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
956
+ networkPrecondition?: Resolver<
957
+ Maybe<ResolversTypes['ZkappNetworkPrecondition']>,
958
+ ParentType,
959
+ ContextType
960
+ >;
961
+ publicKey?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
962
+ tokenId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
963
+ };
964
+
965
+ export type ZkappCommandOutputResolvers<
966
+ ContextType = GraphQLContext,
967
+ ParentType extends
968
+ ResolversParentTypes['ZkappCommandOutput'] = ResolversParentTypes['ZkappCommandOutput'],
969
+ > = {
970
+ accountUpdates?: Resolver<
971
+ Array<ResolversTypes['ZkappAccountUpdateOutput']>,
972
+ ParentType,
973
+ ContextType
974
+ >;
975
+ blockInfo?: Resolver<ResolversTypes['BlockInfo'], ParentType, ContextType>;
976
+ fee?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
977
+ feePayer?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
978
+ hash?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
979
+ memo?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
980
+ sequenceNumber?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
981
+ };
982
+
983
+ export type ZkappFieldArrayResolvers<
984
+ ContextType = GraphQLContext,
985
+ ParentType extends
986
+ ResolversParentTypes['ZkappFieldArray'] = ResolversParentTypes['ZkappFieldArray'],
987
+ > = {
988
+ fields?: Resolver<
989
+ Array<Maybe<ResolversTypes['String']>>,
990
+ ParentType,
991
+ ContextType
992
+ >;
993
+ };
994
+
995
+ export type ZkappGlobalSlotBoundsResolvers<
996
+ ContextType = GraphQLContext,
997
+ ParentType extends
998
+ ResolversParentTypes['ZkappGlobalSlotBounds'] = ResolversParentTypes['ZkappGlobalSlotBounds'],
999
+ > = {
1000
+ lowerBound?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
1001
+ upperBound?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
1002
+ };
1003
+
1004
+ export type ZkappNetworkPreconditionResolvers<
1005
+ ContextType = GraphQLContext,
1006
+ ParentType extends
1007
+ ResolversParentTypes['ZkappNetworkPrecondition'] = ResolversParentTypes['ZkappNetworkPrecondition'],
1008
+ > = {
1009
+ globalSlotSinceGenesis?: Resolver<
1010
+ Maybe<ResolversTypes['ZkappGlobalSlotBounds']>,
1011
+ ParentType,
1012
+ ContextType
1013
+ >;
1014
+ };
1015
+
736
1016
  export type Resolvers<ContextType = GraphQLContext> = {
737
1017
  ActionData?: ActionDataResolvers<ContextType>;
738
1018
  ActionOutput?: ActionOutputResolvers<ContextType>;
@@ -750,5 +1030,12 @@ export type Resolvers<ContextType = GraphQLContext> = {
750
1030
  Query?: QueryResolvers<ContextType>;
751
1031
  TransactionInfo?: TransactionInfoResolvers<ContextType>;
752
1032
  UserCommand?: UserCommandResolvers<ContextType>;
1033
+ VerificationKeyUpdate?: VerificationKeyUpdateResolvers<ContextType>;
753
1034
  ZkAppCommand?: ZkAppCommandResolvers<ContextType>;
1035
+ ZkappAccountPrecondition?: ZkappAccountPreconditionResolvers<ContextType>;
1036
+ ZkappAccountUpdateOutput?: ZkappAccountUpdateOutputResolvers<ContextType>;
1037
+ ZkappCommandOutput?: ZkappCommandOutputResolvers<ContextType>;
1038
+ ZkappFieldArray?: ZkappFieldArrayResolvers<ContextType>;
1039
+ ZkappGlobalSlotBounds?: ZkappGlobalSlotBoundsResolvers<ContextType>;
1040
+ ZkappNetworkPrecondition?: ZkappNetworkPreconditionResolvers<ContextType>;
754
1041
  };
package/src/resolvers.ts CHANGED
@@ -8,13 +8,26 @@ import {
8
8
  TracingState,
9
9
  setSpanNameFromGraphQLContext,
10
10
  } from './tracing/tracer.js';
11
+ import { parseBoolean } from './config.js';
12
+ import { SCHEMA_VERSION } from './schema-version.js';
11
13
 
12
14
  const __filename = fileURLToPath(import.meta.url);
13
15
  const __dirname = path.dirname(__filename);
14
16
  const schemaPath = path.resolve(__dirname, '../../schema.graphql');
17
+ // Dedicated switch, not ENABLE_BLOCK_TRANSACTION_DETAILS. This query walks a
18
+ // block range and expands account updates, so it is much heavier than block
19
+ // transaction detail; an operator must be able to take one without the other.
20
+ // Default off.
21
+ //
22
+ // parseBoolean, not `=== 'true'`: ad-hoc truthiness is the bug #74 fixed, where
23
+ // the string "false" read as true.
24
+ const ENABLE_ZKAPP_COMMANDS_QUERY = parseBoolean(
25
+ process.env.ENABLE_ZKAPP_COMMANDS_QUERY
26
+ );
15
27
 
16
28
  const fullResolvers: Resolvers = {
17
29
  Query: {
30
+ schemaVersion: () => SCHEMA_VERSION,
18
31
  events: async (_, { input }, context) => {
19
32
  const graphQLSpan = setSpanNameFromGraphQLContext(
20
33
  context,
@@ -33,6 +46,24 @@ const fullResolvers: Resolvers = {
33
46
  tracingState: new TracingState(graphQLSpan),
34
47
  });
35
48
  },
49
+ verificationKeyUpdates: async (_, { input }, context) => {
50
+ const graphQLSpan = setSpanNameFromGraphQLContext(
51
+ context,
52
+ 'verificationKeyUpdates.graphql'
53
+ );
54
+ return context.db_client.getVerificationKeyUpdates(input, {
55
+ tracingState: new TracingState(graphQLSpan),
56
+ });
57
+ },
58
+ zkappCommands: async (_, { input }, context) => {
59
+ const graphQLSpan = setSpanNameFromGraphQLContext(
60
+ context,
61
+ 'zkappCommands.graphql'
62
+ );
63
+ return context.db_client.getZkappCommands(input, {
64
+ tracingState: new TracingState(graphQLSpan),
65
+ });
66
+ },
36
67
  networkState: async (_, __, context) => {
37
68
  const graphQLSpan = setSpanNameFromGraphQLContext(
38
69
  context,
@@ -54,49 +85,54 @@ const fullResolvers: Resolvers = {
54
85
  },
55
86
  };
56
87
 
57
- let resolvers: Resolvers = fullResolvers;
58
- let typeDefs: string | undefined = undefined;
88
+ let enabledQueries = Object.keys(fullResolvers.Query || {});
89
+
90
+ // schemaVersion is a compatibility handshake, not a data query, so it survives
91
+ // ENABLED_QUERIES. A client that cannot ask which schema it is talking to has
92
+ // to guess, which is the situation the field exists to end.
93
+ const ALWAYS_ENABLED = ['schemaVersion'];
59
94
 
60
- // If the ENABLED_QUERIES environment variable is set, filter the schema and resolvers.
61
95
  if (process.env.ENABLED_QUERIES !== undefined) {
62
- const enabledQueries = process.env.ENABLED_QUERIES.split(',').map((q) =>
63
- q.trim()
96
+ enabledQueries = [
97
+ ...ALWAYS_ENABLED,
98
+ ...process.env.ENABLED_QUERIES.split(',').map((q) => q.trim()),
99
+ ];
100
+ }
101
+
102
+ if (!ENABLE_ZKAPP_COMMANDS_QUERY) {
103
+ enabledQueries = enabledQueries.filter(
104
+ (queryName) => queryName !== 'zkappCommands'
64
105
  );
106
+ }
65
107
 
66
- // If the list is not empty, filter the resolvers.
67
- if (enabledQueries.length > 0) {
68
- resolvers = {
69
- Query: Object.fromEntries(
70
- Object.entries(fullResolvers.Query || {}).filter(([queryName]) =>
71
- enabledQueries.includes(queryName)
72
- )
73
- ),
74
- };
108
+ const resolvers: Resolvers = {
109
+ Query: Object.fromEntries(
110
+ Object.entries(fullResolvers.Query || {}).filter(([queryName]) =>
111
+ enabledQueries.includes(queryName)
112
+ )
113
+ ),
114
+ };
75
115
 
76
- // Filter the schema AST.
77
- const typeDefsString = fs.readFileSync(schemaPath, 'utf-8');
78
- const typeDefsAst = parse(typeDefsString);
79
- const modifiedAst = visit(typeDefsAst, {
80
- ObjectTypeDefinition(node) {
81
- if (node.name.value === 'Query') {
82
- return {
83
- ...node,
84
- fields: node.fields?.filter((field) =>
85
- enabledQueries.includes(field.name.value)
86
- ),
87
- };
88
- }
89
- return node;
90
- },
91
- });
92
- typeDefs = print(modifiedAst);
93
- }
94
- }
116
+ const typeDefsString = fs.readFileSync(schemaPath, 'utf-8');
117
+ const typeDefsAst = parse(typeDefsString);
118
+ const modifiedAst = visit(typeDefsAst, {
119
+ ObjectTypeDefinition(node) {
120
+ if (node.name.value === 'Query') {
121
+ return {
122
+ ...node,
123
+ fields: node.fields?.filter((field) =>
124
+ enabledQueries.includes(field.name.value)
125
+ ),
126
+ };
127
+ }
128
+ return node;
129
+ },
130
+ });
95
131
 
96
132
  // Create the executable schema.
97
133
  const schema = makeExecutableSchema({
98
134
  resolvers: [resolvers],
99
- typeDefs: typeDefs || fs.readFileSync(schemaPath, 'utf-8'),
135
+ typeDefs: print(modifiedAst),
100
136
  });
101
137
 
102
138
  export { resolvers, schema };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The version of the GraphQL schema this server serves, as `MAJOR.MINOR`.
3
+ *
4
+ * This is **not** the package version. The package version describes this
5
+ * server's own surface — its flags, its defaults, its behaviour. This constant
6
+ * describes only the contract a client codes against: the types, fields and
7
+ * arguments in `schema.graphql`.
8
+ *
9
+ * The client SDKs pin the schema version they were written against
10
+ * (`SCHEMA_VERSION` in the JS and Rust SDKs, `SchemaVersion` in the Go one) and
11
+ * compare it with what this server reports through the `schemaVersion` query.
12
+ * Before that query existed, the pin was an assertion no client could check.
13
+ *
14
+ * When to change it:
15
+ *
16
+ * - **MINOR** for an additive change: a new query, a new optional argument, a
17
+ * new field on an output type. A client written against an older minor of the
18
+ * same major keeps working.
19
+ * - **MAJOR** for a change that can break a client: a removed or renamed field,
20
+ * a narrowed type, an argument that becomes required, or a field that becomes
21
+ * nullable when clients were entitled to assume it was not. Also when the
22
+ * package or the SDKs take a major: they all share one (docs/versioning.md).
23
+ */
24
+ export const SCHEMA_VERSION = '2.0';