@midnight-ntwrk/midnight-js-types 4.1.1 → 5.0.0-beta.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.
@@ -45,6 +45,19 @@ export type BlockHashConfig = {
45
45
  */
46
46
  readonly blockHash: string;
47
47
  };
48
+ /**
49
+ * Minimal identifying information for a block.
50
+ */
51
+ export type BlockInfo = {
52
+ /**
53
+ * The hex-encoded block hash.
54
+ */
55
+ readonly hash: string;
56
+ /**
57
+ * The block height.
58
+ */
59
+ readonly height: number;
60
+ };
48
61
  /**
49
62
  * The configuration for a contract state observable. The corresponding observables may begin at different
50
63
  * places (e.g. after a specific transaction identifier / block height) depending on the configuration, but
@@ -58,11 +71,191 @@ export type ContractStateObservableConfig = ((TxIdConfig | BlockHashConfig | Blo
58
71
  */
59
72
  readonly inclusive?: boolean;
60
73
  }) | Latest | All;
74
+ /**
75
+ * The eleven contract event variants surfaced by the indexer (MIP-0002 public
76
+ * contract log emission). The variant *set* is identical to compact-js's
77
+ * `LogEventType`; only the string casing differs (PascalCase here, kebab-case
78
+ * in compact-js, SCREAMING_SNAKE on the indexer wire). Adding a variant is a
79
+ * breaking change — the mapping, filter translation, and exhaustiveness guards
80
+ * all key off this union.
81
+ */
82
+ export type ContractEventType = 'ShieldedSpend' | 'ShieldedReceive' | 'ShieldedMint' | 'ShieldedBurn' | 'UnshieldedSpend' | 'UnshieldedReceive' | 'UnshieldedMint' | 'UnshieldedBurn' | 'Paused' | 'Unpaused' | 'Misc';
83
+ /**
84
+ * A `sender` / `recipient` on an unshielded event. The indexer returns a tagged
85
+ * union (`Either<ZswapCoinPublicKey, ContractAddress>`); this preserves the
86
+ * discriminator so consumers can tell a user address from a contract address
87
+ * rather than receiving a bare, ambiguous string.
88
+ */
89
+ export interface ContractEventAddress {
90
+ /** Which kind of address `value` holds. */
91
+ readonly kind: 'user' | 'contract';
92
+ /** The hex-encoded address. */
93
+ readonly value: string;
94
+ }
95
+ /**
96
+ * Fields common to every {@link ContractEvent} variant, regardless of type.
97
+ */
98
+ export interface ContractEventBase {
99
+ /**
100
+ * Monotonic indexer cursor for this event. Inclusive resumption point — to
101
+ * resume *after* this event, pass `{ fromId: id + 1 }`.
102
+ */
103
+ readonly id: number;
104
+ /**
105
+ * Highest event id the indexer currently knows (the chain tip for events).
106
+ * Compare against {@link id} to detect catch-up / whether more events exist.
107
+ */
108
+ readonly maxId: number;
109
+ /**
110
+ * Payload schema version — selects the (future) per-event payload decoder.
111
+ * Iteration-1 events are `version: 1`.
112
+ */
113
+ readonly version: number;
114
+ /** Address of the contract that emitted the event. */
115
+ readonly contractAddress: ContractAddress;
116
+ /**
117
+ * Indexer-internal `BIGSERIAL` row id of the emitting transaction — **not**
118
+ * the chain transaction hash. To fetch the chain transaction, issue a
119
+ * separate query. Note the asymmetry with {@link ContractEventFilterBase.transactionHash},
120
+ * which narrows by chain hash.
121
+ */
122
+ readonly transactionId: number;
123
+ /**
124
+ * Opaque hex `VersionedLogItem` bytes, carried verbatim. Never decoded or
125
+ * validated by this provider — the forward bridge to a future compact-js
126
+ * payload decoder.
127
+ */
128
+ readonly raw: string;
129
+ }
130
+ /**
131
+ * A decoded contract event. Discriminated union keyed on `eventType`; narrow on
132
+ * it to access the variant-specific payload fields.
133
+ *
134
+ * `amount` is always a `string` (encodes up to a 16-byte integer) — never round
135
+ * it through `Number()`. Absent nullable fields are normalized to `undefined`
136
+ * (never `null`).
137
+ */
138
+ export type ContractEvent = (ContractEventBase & {
139
+ readonly eventType: 'ShieldedSpend';
140
+ readonly nullifier: string;
141
+ }) | (ContractEventBase & {
142
+ readonly eventType: 'ShieldedReceive';
143
+ readonly commitment: string;
144
+ readonly ciphertext?: string;
145
+ readonly receivingContractAddress?: string;
146
+ }) | (ContractEventBase & {
147
+ readonly eventType: 'ShieldedMint';
148
+ readonly commitment: string;
149
+ readonly domainSep: string;
150
+ readonly amount?: string;
151
+ }) | (ContractEventBase & {
152
+ readonly eventType: 'ShieldedBurn';
153
+ readonly nullifier: string;
154
+ readonly amount?: string;
155
+ }) | (ContractEventBase & {
156
+ readonly eventType: 'UnshieldedSpend';
157
+ readonly sender: ContractEventAddress;
158
+ readonly domainSep: string;
159
+ readonly tokenType: string;
160
+ readonly amount: string;
161
+ }) | (ContractEventBase & {
162
+ readonly eventType: 'UnshieldedReceive';
163
+ readonly recipient: ContractEventAddress;
164
+ readonly domainSep: string;
165
+ readonly tokenType: string;
166
+ readonly amount: string;
167
+ }) | (ContractEventBase & {
168
+ readonly eventType: 'UnshieldedMint';
169
+ readonly domainSep: string;
170
+ readonly tokenType: string;
171
+ readonly amount: string;
172
+ }) | (ContractEventBase & {
173
+ readonly eventType: 'UnshieldedBurn';
174
+ readonly sender: ContractEventAddress;
175
+ readonly tokenType: string;
176
+ readonly amount: string;
177
+ }) | (ContractEventBase & {
178
+ readonly eventType: 'Paused';
179
+ }) | (ContractEventBase & {
180
+ readonly eventType: 'Unpaused';
181
+ }) | (ContractEventBase & {
182
+ readonly eventType: 'Misc';
183
+ readonly name: string;
184
+ readonly payload: string;
185
+ });
186
+ /**
187
+ * A single prefix filter on an indexed field of a standard event. `prefix` is
188
+ * hex-encoded; the empty string matches all values.
189
+ */
190
+ export interface ContractEventFieldPrefix {
191
+ readonly fieldName: string;
192
+ readonly prefix: string;
193
+ }
194
+ /**
195
+ * Filter fields shared by the query and the subscription.
196
+ */
197
+ export interface ContractEventFilterBase {
198
+ /** Required: the contract whose events to return. */
199
+ readonly contractAddress: ContractAddress;
200
+ /**
201
+ * Optional subset of event types. Omit to mean "all types". An empty array
202
+ * is rejected (it would silently match nothing).
203
+ */
204
+ readonly types?: ContractEventType[];
205
+ /**
206
+ * Optional prefix filters on indexed fields. Accepted only when every
207
+ * filtered type is a standard (non-`Misc`) variant — see method docs.
208
+ */
209
+ readonly fieldPrefixes?: ContractEventFieldPrefix[];
210
+ /** Optional: narrow to events emitted from the transaction with this chain hash. */
211
+ readonly transactionHash?: string;
212
+ }
213
+ /**
214
+ * Filter for {@link PublicDataProvider.queryContractEvents}. `fromBlock` /
215
+ * `toBlock` are inclusive block-height bounds for a finite, point-in-time read.
216
+ */
217
+ export interface ContractEventQueryFilter extends ContractEventFilterBase {
218
+ readonly fromBlock?: number;
219
+ readonly toBlock?: number;
220
+ }
221
+ /**
222
+ * Filter for {@link PublicDataProvider.contractEventsObservable}. The stream
223
+ * start is supplied separately via {@link ContractEventCursor}; `toBlock`
224
+ * terminates the stream once the chain reaches that height.
225
+ */
226
+ export interface ContractEventSubscriptionFilter extends ContractEventFilterBase {
227
+ readonly toBlock?: number;
228
+ }
229
+ /**
230
+ * Where a subscription begins. Exactly one addressing mode per call — two
231
+ * competing start points are unrepresentable by construction.
232
+ */
233
+ export type ContractEventCursor = {
234
+ readonly fromId: number;
235
+ } | {
236
+ readonly fromBlock: number;
237
+ };
238
+ /**
239
+ * Pagination window for {@link PublicDataProvider.queryContractEvents}.
240
+ * `offset` is only stable within a window with a fixed upper bound — pin
241
+ * `toBlock` for multi-page reads.
242
+ */
243
+ export interface ContractEventsPage {
244
+ readonly limit?: number;
245
+ readonly offset?: number;
246
+ }
61
247
  /**
62
248
  * Interface for a public data service. This service retrieves public data from the blockchain.
63
249
  * TODO: Add timeouts or retry limits to 'watchFor' queries.
64
250
  */
65
251
  export interface PublicDataProvider {
252
+ /**
253
+ * Retrieves a block. If no block hash or block height is provided, the latest block is returned.
254
+ * Immediately returns null if no matching block is found.
255
+ * @param config The configuration of the query identifying the block of interest.
256
+ * If `undefined` returns the latest block.
257
+ */
258
+ queryBlock(config?: BlockHeightConfig | BlockHashConfig): Promise<BlockInfo | null>;
66
259
  /**
67
260
  * Retrieves the on-chain state of a contract. If no block hash or block height are provided, the
68
261
  * contract state at the address in the latest block is returned.
@@ -159,5 +352,55 @@ export interface PublicDataProvider {
159
352
  * @return {Observable<UnshieldedBalances>} An observable that emits the unshielded balances for the provided address.
160
353
  */
161
354
  unshieldedBalancesObservable(address: ContractAddress, config: ContractStateObservableConfig): Observable<UnshieldedBalances>;
355
+ /**
356
+ * Queries contract events for a contract address — a finite, paginated,
357
+ * point-in-time read.
358
+ *
359
+ * Results are returned in ascending `id` order. The result is a plain array
360
+ * with no total count: detect the end via `result.length < limit`, and read
361
+ * `maxId` on the last item to see how far the tip is.
362
+ *
363
+ * When `page.limit` is omitted an implementation-defined default page size is
364
+ * applied (never an undocumented server default). `offset` is only stable
365
+ * within a window with a fixed upper bound — pin `filter.toBlock` for
366
+ * multi-page reads, or prefer the `getAllContractEvents` helper / the
367
+ * subscription for tailing.
368
+ *
369
+ * Fails fast (synchronously, before any network call) on an invalid
370
+ * `contractAddress`, an empty `types` array, `fieldPrefixes` combined with
371
+ * `Misc` (or with `types` omitted), or an unknown `fieldName`. Network /
372
+ * GraphQL errors reject the promise — an empty array always means "no
373
+ * matching events", never a swallowed error.
374
+ *
375
+ * @param filter The events to return; `contractAddress` is required.
376
+ * @param page Optional pagination window.
377
+ */
378
+ queryContractEvents(filter: ContractEventQueryFilter, page?: ContractEventsPage): Promise<ContractEvent[]>;
379
+ /**
380
+ * Streams contract events for a contract address — replay from a cursor, then
381
+ * live, in one continuous stream.
382
+ *
383
+ * The start is supplied via `opts.startAt`: `{ fromId }` resumes inclusively
384
+ * from a known event id, `{ fromBlock }` starts from a block height. Omitting
385
+ * `startAt` streams from the start of history. The indexer replays historical
386
+ * events from that point in monotonic `id` order, then continues live — there
387
+ * is no separate backfill query and no client-side dedup.
388
+ *
389
+ * `{ fromId }` is **inclusive**; to resume *after* the last seen event pass
390
+ * `{ fromId: lastSeenId + 1 }`.
391
+ *
392
+ * `filter.toBlock` completes the stream once the chain reaches that height;
393
+ * without it the stream runs until unsubscribed or the provider is disposed.
394
+ * Delivery is **at-least-once** across transport reconnects (the provider
395
+ * does not advance the cursor) — persisting consumers should dedup by `id`.
396
+ * Transport failures surface as an observable `error`, never a silent
397
+ * completion.
398
+ *
399
+ * @param filter The events to stream; `contractAddress` is required.
400
+ * @param opts Optional stream start.
401
+ */
402
+ contractEventsObservable(filter: ContractEventSubscriptionFilter, opts?: {
403
+ startAt?: ContractEventCursor;
404
+ }): Observable<ContractEvent>;
162
405
  }
163
406
  //# sourceMappingURL=public-data-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-data-provider.d.ts","sourceRoot":"","sources":["../src/public-data-provider.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACrI,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GACrC,CAAC,CAAC,UAAU,G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C,kBAAkB,GAAG,IAAI,CAAC,CAAC;IAEtC;;;;OAIG;IACH,qBAAqB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAEhF;;;;;OAKG;IACH,0BAA0B,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAE1F;;;;;;;;;;;;;OAaG;IACH,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEjF;;;;;;;;;;;;;;;;;;OAkBG;IACH,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,uBAAuB,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,6BAA6B,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAEpH;;;;;;OAMG;IACH,4BAA4B,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,6BAA6B,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAE9H;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,mBAAmB,CAAC,MAAM,EAAE,wBAAwB,EAAE,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAE3G;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,wBAAwB,CACtB,MAAM,EAAE,+BAA+B,EACvC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,mBAAmB,CAAA;KAAE,GACvC,UAAU,CAAC,aAAa,CAAC,CAAC;CAC9B"}
@@ -0,0 +1,62 @@
1
+ import type { ZKConfig } from './midnight-types';
2
+ import type { KeyMaterialProvider, ZKConfigProvider } from './zk-config-provider';
3
+ import { type ContractKeyLocation } from './zk-key-location';
4
+ /**
5
+ * Thrown when a contract key location parses but no artifact source contains a bundle whose
6
+ * verifier key matches the deployed one — i.e. the local artifacts have drifted from (or were
7
+ * never compiled for) the deployed contract.
8
+ */
9
+ export declare class ZKArtifactNotFoundError extends Error {
10
+ readonly keyLocation: ContractKeyLocation;
11
+ constructor(keyLocation: ContractKeyLocation);
12
+ }
13
+ /**
14
+ * Resolves canonical contract key locations to ZK artifacts across a *set* of compiled-contract
15
+ * artifact sources.
16
+ *
17
+ * A cross-contract call transaction carries one proof per contract in the call tree, so proving
18
+ * requires artifacts for several compiled contracts, keyed by `(contractAddress, circuitId)`. No
19
+ * registration of addresses is required: the binding is *derived* by joining on the verifier key.
20
+ * Each location embeds the SHA-256 of the call's deployed verifier key (known at transaction
21
+ * assembly from the contract's resolved on-chain state), and resolution selects the source whose
22
+ * local verifier key for the circuit matches. The join is sound because it is the predicate the
23
+ * chain itself enforces — a proof must verify against the deployed key — and it makes the
24
+ * resolution immune to redeploys, multiple deployments of one contract, and circuit-name
25
+ * collisions across contracts.
26
+ *
27
+ * The sources are the per-contract {@link ZKConfigProvider}s the application already constructs;
28
+ * resolutions are memoized per location.
29
+ */
30
+ export declare class ZKConfigRegistry {
31
+ private readonly sources;
32
+ private readonly resolved;
33
+ /**
34
+ * @param sources The compiled-contract artifact sources to resolve against — one per compiled
35
+ * contract the application can call (its own contracts and any cross-contract call targets).
36
+ */
37
+ constructor(sources: Iterable<ZKConfigProvider<string>>);
38
+ /**
39
+ * Resolves the ZK artifacts for a structured contract key.
40
+ *
41
+ * @param location The contract address, circuit, and deployed verifier key hash to resolve.
42
+ * @throws ZKArtifactNotFoundError If no source's verifier key for the circuit matches.
43
+ */
44
+ get(location: ContractKeyLocation): Promise<ZKConfig<string>>;
45
+ /**
46
+ * Resolves the ZK artifacts for a key-location string from a proof preimage.
47
+ *
48
+ * @param keyLocation The key-location string.
49
+ * @returns The matched artifacts, or `undefined` if `keyLocation` is not a contract key
50
+ * location (for example, a `midnight/` protocol builtin, which provers resolve elsewhere).
51
+ * @throws ZKArtifactNotFoundError If `keyLocation` is a contract key location but no source's
52
+ * verifier key for the circuit matches the embedded hash.
53
+ */
54
+ resolveKeyLocation(keyLocation: string): Promise<ZKConfig<string> | undefined>;
55
+ /**
56
+ * Adapts this registry to the DApp connector's {@link KeyMaterialProvider}, allowing a wallet
57
+ * to resolve the key locations of a transaction assembled by this application.
58
+ */
59
+ asKeyMaterialProvider(): KeyMaterialProvider;
60
+ private resolve;
61
+ }
62
+ //# sourceMappingURL=zk-config-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zk-config-registry.d.ts","sourceRoot":"","sources":["../src/zk-config-registry.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,KAAK,mBAAmB,EAAwE,MAAM,mBAAmB,CAAC;AAEnI;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IACpC,QAAQ,CAAC,WAAW,EAAE,mBAAmB;gBAAhC,WAAW,EAAE,mBAAmB;CAQtD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsC;IAE9D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuC;IAEhE;;;OAGG;gBACS,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAIvD;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAI7D;;;;;;;;OAQG;IACG,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAQpF;;;OAGG;IACH,qBAAqB,IAAI,mBAAmB;YAe9B,OAAO;CAsBtB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The canonical key-location grammar for contract calls.
3
+ *
4
+ * The grammar is defined once, upstream, in `@midnight-ntwrk/compact-js` (the
5
+ * `ContractKeyLocation` module) so that every transaction assembler and prover shares a single
6
+ * definition; this module re-exports it. See the upstream module for the full specification:
7
+ * each contract call's proof preimage carries the canonical, self-describing location
8
+ * `contract:<address-hex>/<circuitId>?vk=<sha-256 of the deployed verifier key>`, which provers
9
+ * resolve by verifier-key content rather than by circuit name (see `ZKConfigRegistry`).
10
+ */
11
+ export { type ContractKeyLocation, encodeContractKeyLocation, hashVerifierKey, parseContractKeyLocation } from '@midnight-ntwrk/midnight-js-protocol/compact-js';
12
+ //# sourceMappingURL=zk-key-location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zk-key-location.d.ts","sourceRoot":"","sources":["../src/zk-key-location.ts"],"names":[],"mappings":"AAeA;;;;;;;;;GASG;AACH,OAAO,EACL,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACzB,MAAM,iDAAiD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midnight-ntwrk/midnight-js-types",
3
- "version": "4.1.1",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "Shared data types and interfaces for MidnightJS modules",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "dist/"
30
30
  ],
31
31
  "dependencies": {
32
- "@midnight-ntwrk/midnight-js-protocol": "4.1.1",
32
+ "@midnight-ntwrk/midnight-js-protocol": "5.0.0-beta.1",
33
33
  "effect": "^3.20.0",
34
34
  "pino": "^10.3.1",
35
35
  "rxjs": "^7.8.2"