@midnight-ntwrk/midnight-js-protocol 5.0.0-beta.7 → 5.0.0-beta.8

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.
@@ -0,0 +1,467 @@
1
+ /**
2
+ * The two ledger runtimes midnight-js can talk to. `v8` backs the node 1.x
3
+ * line; `v9` backs the 2.x line. This is a closed, exhaustive set — see
4
+ * `protocolVersionToLedger` (`../version.ts`) for how a raw `protocolVersion`
5
+ * integer maps onto it.
6
+ *
7
+ * @see {@link SharedTableDiscipline} for why the array is frozen.
8
+ * @see {@link ModuleGraphAndLazyLoading} for why the constant is declared in
9
+ * this leaf module and re-exported by `../version.ts`.
10
+ */
11
+ declare const LEDGER_VERSIONS: readonly ["v8", "v9"];
12
+ type LedgerVersion = (typeof LEDGER_VERSIONS)[number];
13
+
14
+ /**
15
+ * Stable error-code strings for this package. Every error class in this module
16
+ * carries one of these on its `code` field, which is the field a consumer
17
+ * switches on to tell one failure from another.
18
+ *
19
+ * @see {@link SharedTableDiscipline}
20
+ */
21
+ declare const PROTOCOL_ERROR_CODES: Readonly<{
22
+ readonly UNKNOWN_PROTOCOL_VERSION_READ: "MIDNIGHT_JS_P_UNKNOWN_PROTOCOL_VERSION_READ";
23
+ readonly UNKNOWN_PROTOCOL_VERSION_CONSTRUCT: "MIDNIGHT_JS_P_UNKNOWN_PROTOCOL_VERSION_CONSTRUCT";
24
+ readonly LEDGER8_INSTANCE_MISMATCH: "MIDNIGHT_JS_P_LEDGER8_INSTANCE_MISMATCH";
25
+ readonly LEDGER8_RUNTIME_MISSING: "MIDNIGHT_JS_P_LEDGER8_RUNTIME_MISSING";
26
+ readonly DOWN_CONVERT_FAILED: "MIDNIGHT_JS_P_DOWN_CONVERT_FAILED";
27
+ readonly MERKLE_NOT_REHASHED: "MIDNIGHT_JS_P_MERKLE_NOT_REHASHED";
28
+ readonly COMPOSE_FAILED: "MIDNIGHT_JS_P_COMPOSE_FAILED";
29
+ readonly COMPOSE_OPTION_INVALID: "MIDNIGHT_JS_P_COMPOSE_OPTION_INVALID";
30
+ readonly STATE_DECODE_FAILED: "MIDNIGHT_JS_P_STATE_DECODE_FAILED";
31
+ readonly UNKNOWN_LEDGER_VERSION: "MIDNIGHT_JS_P_UNKNOWN_LEDGER_VERSION";
32
+ readonly LEDGER8_RUNTIME_INVALID: "MIDNIGHT_JS_P_LEDGER8_RUNTIME_INVALID";
33
+ readonly UNKNOWN_LEDGER8_AXIS: "MIDNIGHT_JS_P_UNKNOWN_LEDGER8_AXIS";
34
+ readonly PAYLOAD_NOT_A_TRANSACTION: "MIDNIGHT_JS_P_PAYLOAD_NOT_A_TRANSACTION";
35
+ }>;
36
+ /** The union of every value in {@link PROTOCOL_ERROR_CODES}; the type of every error class's `code` field. */
37
+ type ProtocolErrorCode = (typeof PROTOCOL_ERROR_CODES)[keyof typeof PROTOCOL_ERROR_CODES];
38
+ /**
39
+ * Which call path asked for a ledger version:
40
+ * - `'read'` — the version was taken off an existing record.
41
+ * - `'construct'` — the version was chosen to build something new against the
42
+ * network's current head.
43
+ */
44
+ type VersionResolutionPath = 'read' | 'construct';
45
+ /**
46
+ * Why `protocolVersionToLedger` could not resolve a ledger version:
47
+ * - `'malformed'` — the input was not even a well-formed protocolVersion
48
+ * value (not a non-negative integer).
49
+ * - `'unknown'` — the input was a well-formed integer, but outside every
50
+ * range this framework version knows how to map.
51
+ */
52
+ type ProtocolVersionUnknownReason = 'unknown' | 'malformed';
53
+ /**
54
+ * Thrown by `protocolVersionToLedger` (and, transitively, `versionOfRecord` /
55
+ * `networkHeadVersion`) when a raw `protocolVersion` integer cannot be
56
+ * resolved to a `LedgerVersion`. Those live in `./version`, which imports this
57
+ * module -- the dependency stays one-way, so they are named here rather than
58
+ * linked.
59
+ *
60
+ * `code` is the field to switch on to tell all four cases apart: it splits
61
+ * `reason` by the `path` that produced it.
62
+ *
63
+ * @param protocolVersion The raw `protocolVersion` value that could not be
64
+ * resolved. Carried for programmatic use, and rendered in the message.
65
+ * @param path Which call path asked for the version — see
66
+ * {@link VersionResolutionPath}.
67
+ * @param reason A malformed input (wrong shape or type, not a
68
+ * protocol-version problem at all) or a well-formed but genuinely unknown
69
+ * version (a real protocol version this framework build does not support
70
+ * yet) — see {@link ProtocolVersionUnknownReason}.
71
+ */
72
+ declare class UnknownProtocolVersionError extends Error {
73
+ readonly protocolVersion: number;
74
+ readonly path: VersionResolutionPath;
75
+ readonly reason: ProtocolVersionUnknownReason;
76
+ readonly code: typeof PROTOCOL_ERROR_CODES.UNKNOWN_PROTOCOL_VERSION_READ | typeof PROTOCOL_ERROR_CODES.UNKNOWN_PROTOCOL_VERSION_CONSTRUCT;
77
+ constructor(protocolVersion: number, path: VersionResolutionPath, reason: ProtocolVersionUnknownReason);
78
+ }
79
+ /**
80
+ * Which lazily-loaded subpath export {@link Ledger8RuntimeMissingError} failed
81
+ * to acquire. Each chunk pulls a different set of retained-era dependencies, so
82
+ * naming the wrong one sends an operator to an entry point that loaded fine.
83
+ *
84
+ * @see {@link ModuleGraphAndLazyLoading}
85
+ */
86
+ type RetainedEraSubpath = '/v8' | '/engine';
87
+ /**
88
+ * Thrown when a lazily-loaded subpath export carrying the retained pre-fork
89
+ * runtime could not be acquired at all. Raised by `loadLedger8`
90
+ * (`lib/v8/load.ts`) and `loadLedger8Engine` (`lib/v8/load-engine.ts`), and
91
+ * surfaced through `createLedger8Engine` and `loadLedgerEra('v8')`.
92
+ *
93
+ * A failed acquisition is not memoised: the next call retries the import.
94
+ * Distinct from {@link Ledger8RuntimeInvalidError}, which reports a runtime
95
+ * that WAS acquired and then handed over incomplete.
96
+ *
97
+ * @param subpath Which chunk failed to load — see {@link RetainedEraSubpath}.
98
+ * @param cause The underlying module-resolution or initialisation failure,
99
+ * preserved unchanged. Read it for which module actually failed.
100
+ * @see {@link ModuleGraphAndLazyLoading}
101
+ * @see {@link EraSeam}
102
+ */
103
+ declare class Ledger8RuntimeMissingError extends Error {
104
+ readonly subpath: RetainedEraSubpath;
105
+ readonly code: "MIDNIGHT_JS_P_LEDGER8_RUNTIME_MISSING";
106
+ constructor(subpath: RetainedEraSubpath, cause: unknown);
107
+ }
108
+ /**
109
+ * Which physical-copy axis `assertSharedLedger8Instance`
110
+ * (`lib/v8/instance-guard.ts`) detected two distinct instances on.
111
+ *
112
+ * `'onchain-runtime-v3'` is the only member this framework version checks.
113
+ *
114
+ * @see {@link DualInstantiationGuard}
115
+ */
116
+ type Ledger8InstanceAxis = 'onchain-runtime-v3';
117
+ /**
118
+ * Thrown by `assertSharedLedger8Instance` (`lib/v8/instance-guard.ts`)
119
+ * when the same-named WASM package resolved to two physically distinct copies
120
+ * in this process (a dual-instantiation).
121
+ *
122
+ * Carries no `cause`: this is a direct reference-equality assertion failure,
123
+ * not a wrapped lower-level exception.
124
+ *
125
+ * @param axis Which physical-copy axis the check ran on — see
126
+ * {@link Ledger8InstanceAxis}. It also selects the package names the
127
+ * message tells the reader to trace.
128
+ * @see {@link DualInstantiationGuard}
129
+ */
130
+ declare class Ledger8InstanceMismatchError extends Error {
131
+ readonly axis: Ledger8InstanceAxis;
132
+ readonly code: "MIDNIGHT_JS_P_LEDGER8_INSTANCE_MISMATCH";
133
+ constructor(axis: Ledger8InstanceAxis);
134
+ }
135
+ /**
136
+ * Which step of the down-convert pipeline a {@link DownConvertFailedError}
137
+ * came from. A closed union, so a consumer can `switch` on `stage`
138
+ * exhaustively.
139
+ *
140
+ * @see {@link FailClosedDecoding}
141
+ */
142
+ type DownConvertStage = 'v8 envelope extraction' | 'v9 envelope extraction' | 'state down-convert';
143
+ /**
144
+ * Thrown by the down-convert engine (`lib/era/envelope.ts`,
145
+ * `lib/v8/down-convert.ts`) when it cannot turn a raw contract-state
146
+ * envelope, or an already-extracted `EncodedStateValue`, into an executable
147
+ * pre-fork state. Raised by `extractV9EncodedStateValue` (`lib/era/envelope.ts`)
148
+ * and `downConvertForExecution` (`lib/v8/down-convert.ts`).
149
+ *
150
+ * Renders no raw hex and no decoded state contents — only the stage name and
151
+ * the wrapped `cause`.
152
+ *
153
+ * @param stage Which step failed — see {@link DownConvertStage}.
154
+ * @param cause The runtime's own failure, preserved unchanged. It is what
155
+ * distinguishes a tag mismatch from truncated, trailing, or empty input.
156
+ * @see {@link FailClosedDecoding}
157
+ */
158
+ declare class DownConvertFailedError extends Error {
159
+ readonly stage: DownConvertStage;
160
+ readonly code: "MIDNIGHT_JS_P_DOWN_CONVERT_FAILED";
161
+ constructor(stage: DownConvertStage, cause: unknown);
162
+ }
163
+ /**
164
+ * Thrown by `checkRoot` (`lib/v8/down-convert.ts`) when a bounded Merkle
165
+ * tree's root is read before the tree has been rehashed. Reaches a caller
166
+ * through `assertMerkleTreesRehashed` and `downConvertForExecution`, which
167
+ * assert it on every tree they decode.
168
+ *
169
+ * The remediation is always the caller's: call `rehash()` on the tree before
170
+ * executing against it. Nothing here repairs the tree.
171
+ *
172
+ * @param cause The runtime's own failure, when reading the root threw. Absent
173
+ * when `root()` returned nothing instead of throwing.
174
+ * @see {@link FailClosedDecoding}
175
+ * @see {@link RetainedEraExecution}
176
+ */
177
+ declare class MerkleNotRehashedError extends Error {
178
+ readonly code: "MIDNIGHT_JS_P_MERKLE_NOT_REHASHED";
179
+ constructor(cause?: unknown);
180
+ }
181
+ /**
182
+ * What `circuitId` a {@link ComposeFailedError} names when the failure happened
183
+ * before any circuit was looked up — only `'call-empty'` reaches this today.
184
+ *
185
+ * Exported, and one literal rather than a per-module copy, so a consumer
186
+ * reading `circuitId` off a caught error can compare against it instead of
187
+ * matching a string this package could change, and so it can never be mistaken
188
+ * for a real entry point a caller might try to resolve.
189
+ *
190
+ * @see {@link ComposeRefusalOrder}
191
+ */
192
+ declare const NO_CIRCUIT = "(none)";
193
+ /**
194
+ * Which composition step {@link ComposeFailedError} failed at.
195
+ *
196
+ * Call stages:
197
+ * - `'call-empty'` — a call transaction was requested with no calls in it.
198
+ * The one stage that names no circuit: it is raised before any circuit is
199
+ * looked up, so it names {@link NO_CIRCUIT}.
200
+ * - `'call-operation'` — a call leg could not resolve a registered operation
201
+ * for the call's circuit on the given contract state.
202
+ * - `'call-verifier-key'` — a call leg resolved a registered operation for the
203
+ * call's circuit, but that operation carries no verifier key, so no ledger
204
+ * could verify a call against it.
205
+ * - `'call-contract-state'` — the call's pre-call state could not be bridged
206
+ * into the target era's own state algebra. Carries the decoder's failure on
207
+ * `cause`.
208
+ * - `'call-transcript-empty'` — a caller-supplied partitioned transcript
209
+ * carried neither a guaranteed nor a fallible half, so the call would record
210
+ * no operations at all.
211
+ * - `'call-partition-context'` — the era rejected the query-context state the
212
+ * call recorded (its block, its starting effects, or one of the commitment
213
+ * indices it registered for a coin received in-contract) while bridging it
214
+ * onto the context the transcript is partitioned against. Carries the
215
+ * runtime's own failure on `cause`.
216
+ * - `'call-partition'` — the ledger rejected the public transcript supplied
217
+ * for a call while splitting it into its guaranteed and fallible halves.
218
+ * Carries the runtime's own failure on `cause`.
219
+ * - `'call-prototype'` — the ledger rejected the call's own inputs while
220
+ * constructing the call prototype. Carries the runtime's failure on `cause`.
221
+ * - `'call-dust-payout'` — a transcript claimed an unshielded spend to a user
222
+ * address in DUST, which has no raw token type to be paid out in.
223
+ * - `'call-unsupported-payout'` — a transcript claimed an unshielded spend to
224
+ * a user address in a token type that cannot be paid out as an unshielded
225
+ * UTXO at all (a shielded token type today).
226
+ *
227
+ * Deploy stages:
228
+ * - `'deploy-verifier-key'` — a deploy leg was given no verifier key for a
229
+ * circuit the contract state declares.
230
+ * - `'deploy-unknown-circuit'` — the verifier-key map handed to a deploy leg
231
+ * names a circuit the contract state does not declare. Registering it would
232
+ * add an entry point the compiled contract never had, and silently change
233
+ * the deployed contract's address.
234
+ * - `'deploy-ambiguous-circuit'` — two entry points the contract state
235
+ * declares resolve to the same name, so the verifier-key map (keyed by
236
+ * name) cannot address them apart. Registering under the shared name would
237
+ * key one slot and leave the other blank.
238
+ * - `'deploy-verifier-key-blob'` — the ledger rejected the verifier-key bytes
239
+ * supplied for a circuit.
240
+ *
241
+ * Keep-state stage:
242
+ * - `'wrap-call'` — the keep-state leg could not resolve a registered
243
+ * operation for the transcript's circuit on the given contract state.
244
+ *
245
+ * Which ledger era the failure happened on is carried separately, on the
246
+ * error's `version` field. Every stage but `'wrap-call'` is reachable on both
247
+ * eras; `'wrap-call'` is only ever raised for `'v9'`.
248
+ *
249
+ * @see {@link ComposeRefusalOrder}
250
+ * @see {@link VerifierKeys}
251
+ */
252
+ type ComposeStage = 'wrap-call' | 'call-empty' | 'call-transcript-empty' | 'call-partition-context' | 'call-partition' | 'call-prototype' | 'call-dust-payout' | 'call-unsupported-payout' | 'call-operation' | 'call-contract-state' | 'call-verifier-key' | 'deploy-verifier-key' | 'deploy-unknown-circuit' | 'deploy-ambiguous-circuit' | 'deploy-verifier-key-blob';
253
+ /**
254
+ * Thrown when a transaction cannot be composed because a circuit's operation
255
+ * is missing, under-registered, or names a circuit the contract does not have.
256
+ * `stage` (see {@link ComposeStage}) names which composition step failed and is
257
+ * a closed union, so a consumer can `switch` on it exhaustively; `version`
258
+ * names the ledger era the composition was running against.
259
+ *
260
+ * Most stages are direct assertion failures (a missing lookup, not a wrapped
261
+ * lower-level exception) and carry no `cause`, like
262
+ * {@link Ledger8InstanceMismatchError}. The exceptions are the stages where
263
+ * the ledger itself rejected caller-supplied bytes — enumerated under `cause`
264
+ * below: that failure is preserved on `cause`, the same way
265
+ * {@link DownConvertFailedError} preserves its runtime's own message.
266
+ *
267
+ * `circuitId` names the entry point, never its raw contents: this class
268
+ * renders no hex and no byte-array dump. `'call-empty'` is the one stage with
269
+ * no circuit to name, and its message names none.
270
+ *
271
+ * @param version The ledger era the composition was running against.
272
+ * @param stage Which composition step failed — see {@link ComposeStage}. A
273
+ * closed union, so a consumer can `switch` on it exhaustively.
274
+ * @param circuitId The entry-point name, already decoded. {@link NO_CIRCUIT}
275
+ * for `'call-empty'`, the one stage raised before any circuit is looked up.
276
+ * @param cause The runtime's own failure, present only for the stages where
277
+ * the ledger itself rejected caller-supplied bytes: `'call-contract-state'`,
278
+ * `'call-partition-context'`, `'call-partition'`, `'call-prototype'` and
279
+ * `'deploy-verifier-key-blob'`.
280
+ * @see {@link ComposeRefusalOrder}
281
+ * @see {@link VerifierKeys}
282
+ */
283
+ declare class ComposeFailedError extends Error {
284
+ readonly version: LedgerVersion;
285
+ readonly stage: ComposeStage;
286
+ readonly circuitId: string;
287
+ readonly code: "MIDNIGHT_JS_P_COMPOSE_FAILED";
288
+ constructor(version: LedgerVersion, stage: ComposeStage, circuitId: string, cause?: unknown);
289
+ private static readonly MESSAGES;
290
+ }
291
+ /**
292
+ * Which option handed to a composition leg was unusable:
293
+ * - `'contractState'` — the state could not be bridged into the target
294
+ * ledger era (its serialized envelope was rejected by the era's decoder).
295
+ * - `'networkId'` — the network id was empty. The ledger accepts an empty
296
+ * string and bakes it into the transaction, so a caller that forgot to
297
+ * resolve one would only find out at submission.
298
+ * - `'ttl'` — the time-to-live was not a valid instant. `new Date('...')` on
299
+ * an unparseable value yields an Invalid Date, which the ledger silently
300
+ * records as the Unix epoch: a transaction that is already expired when it
301
+ * is composed.
302
+ * - `'calls'` — the call list is not one the target era can compose. The
303
+ * retained pre-fork era composes exactly one call: a cross-contract call is a
304
+ * ledger-9-only feature that a pre-fork contract cannot emit, so that era has
305
+ * no call tree to express.
306
+ * - `'verifierKeys'` — a deploy was requested with no verifier-key map, and the
307
+ * state it was given needs one. Raised on BOTH eras, for two different
308
+ * reasons: the retained era's deploy leg has to register the compiled
309
+ * contract's keys itself and so always needs the map, while the current era
310
+ * accepts its omission for a state that already carries its keys and refuses
311
+ * it only for a state still declaring a blank-keyed entry point.
312
+ * - `'zswapOffer'` — the supplied offer bytes were rejected by the target era's
313
+ * decoder. Raised on BOTH eras, for the same reason and with the same
314
+ * remediation: pass the bytes that era's own offer serialization produced.
315
+ *
316
+ * @see {@link ComposeRefusalOrder}
317
+ * @see {@link VerifierKeys}
318
+ */
319
+ type ComposeOption = 'calls' | 'contractState' | 'ledgerParameters' | 'networkId' | 'ttl' | 'verifierKeys' | 'zswapOffer';
320
+ /**
321
+ * Thrown by the composition legs when one of their options cannot be used at
322
+ * all, as opposed to {@link ComposeFailedError}, which reports a circuit whose
323
+ * operation is missing or under-registered.
324
+ *
325
+ * These are the well-formedness checks the ledger itself does not make.
326
+ *
327
+ * Like {@link DownConvertFailedError}, this class renders no input contents of
328
+ * its own.
329
+ *
330
+ * @param version The ledger era the option was being used against.
331
+ * @param option Which option was unusable — see {@link ComposeOption}. A
332
+ * closed union, so a consumer can `switch` on it exhaustively.
333
+ * @param cause The decoder's own failure, present only for `'contractState'`
334
+ * and `'zswapOffer'`, where caller-supplied bytes were rejected.
335
+ * @see {@link ComposeRefusalOrder}
336
+ * @see {@link VerifierKeys}
337
+ */
338
+ declare class ComposeOptionError extends Error {
339
+ readonly version: LedgerVersion;
340
+ readonly option: ComposeOption;
341
+ readonly code: "MIDNIGHT_JS_P_COMPOSE_OPTION_INVALID";
342
+ constructor(version: LedgerVersion, option: ComposeOption, cause?: unknown);
343
+ private static readonly MESSAGES;
344
+ }
345
+ /**
346
+ * Thrown when a raw, serialized contract-state envelope could not be read by
347
+ * the ledger era it was requested for. Raised by both of the facade's read
348
+ * paths, `extractState` and `decodeContractState`
349
+ * (`lib/shared/contract-state.ts`), so a caller writes one handler for both.
350
+ *
351
+ * Renders no hex and no byte dump of its own.
352
+ *
353
+ * @param version The era whose decoder rejected the envelope.
354
+ * @param cause The decoder's own diagnosis, preserved unchanged. It is what
355
+ * distinguishes a tag mismatch from truncated, trailing or empty input.
356
+ * @see {@link FailClosedDecoding}
357
+ */
358
+ declare class StateDecodeFailedError extends Error {
359
+ readonly version: LedgerVersion;
360
+ readonly code: "MIDNIGHT_JS_P_STATE_DECODE_FAILED";
361
+ constructor(version: LedgerVersion, cause: unknown);
362
+ }
363
+ /**
364
+ * Thrown by `extractEncodedStateValue` (`lib/era/envelope.ts`) when the
365
+ * injected pre-fork runtime cannot be used — it was not passed at all, or the
366
+ * binding the decoder needs is absent from it. Also raised by
367
+ * `downConvertForExecution` (`lib/v8/down-convert.ts`) and
368
+ * `assertSharedLedger8Instance` (`lib/v8/instance-guard.ts`), the latter for a
369
+ * nullish instance probe.
370
+ *
371
+ * Nothing is wrong with the caller's input here. Distinct from
372
+ * {@link Ledger8RuntimeMissingError}, which reports the v8 chunk failing to
373
+ * load at all, and from {@link DownConvertFailedError}, which reports an
374
+ * envelope or state that could not be turned into an executable pre-fork
375
+ * state.
376
+ *
377
+ * @param missingMember Which binding was absent. One of this module's own
378
+ * literals, never caller-supplied text, so it is safe to log.
379
+ * @see {@link FailClosedDecoding}
380
+ * @see {@link DualInstantiationGuard}
381
+ */
382
+ declare class Ledger8RuntimeInvalidError extends Error {
383
+ readonly missingMember: string;
384
+ readonly code: "MIDNIGHT_JS_P_LEDGER8_RUNTIME_INVALID";
385
+ constructor(missingMember: string);
386
+ }
387
+ /**
388
+ * Thrown by `assertSharedLedger8Instance` (`lib/v8/instance-guard.ts`)
389
+ * when the `axis` it was handed is not a member of {@link Ledger8InstanceAxis}.
390
+ *
391
+ * A TypeScript caller cannot produce this — `axis` is typed as
392
+ * {@link Ledger8InstanceAxis}. It exists for the untyped JavaScript consumers
393
+ * this package also serves.
394
+ *
395
+ * @param requestedAxis The offending value that was passed. Carried for
396
+ * programmatic use only; it is deliberately kept out of the message.
397
+ * @see {@link DualInstantiationGuard}
398
+ */
399
+ declare class UnknownLedger8AxisError extends Error {
400
+ readonly requestedAxis: string;
401
+ readonly code: "MIDNIGHT_JS_P_UNKNOWN_LEDGER8_AXIS";
402
+ constructor(requestedAxis: string);
403
+ }
404
+ /**
405
+ * Thrown when a ledger era was requested by a value that is not a member of
406
+ * `LEDGER_VERSIONS`. Raised by `loadLedgerEra` (`lib/era/load-era.ts`) and by
407
+ * `extractEncodedStateValue` (`lib/era/envelope.ts`).
408
+ *
409
+ * A TypeScript caller cannot produce this: `version` is typed as
410
+ * `LedgerVersion`. It exists for the untyped JavaScript consumers this package
411
+ * also serves.
412
+ *
413
+ * Carries no `version` field, unlike every other era-aware error here — there
414
+ * is no valid era to name.
415
+ *
416
+ * @param requestedVersion The offending value that was passed. Carried for
417
+ * programmatic use only; it is deliberately kept out of the message.
418
+ * @see {@link SharedTableDiscipline}
419
+ * @see {@link FailClosedDecoding}
420
+ */
421
+ declare class UnknownLedgerVersionError extends Error {
422
+ readonly requestedVersion: string;
423
+ readonly code: "MIDNIGHT_JS_P_UNKNOWN_LEDGER_VERSION";
424
+ constructor(requestedVersion: string);
425
+ }
426
+ /**
427
+ * The opening of the tag every serialized ledger transaction carries, on both
428
+ * eras.
429
+ *
430
+ * Stops before the bracketed version deliberately: a `[vN]` is the wire-schema
431
+ * version of the serialized OBJECT and never a ledger era — the retained era's
432
+ * transactions are tagged `transaction[v9]`.
433
+ *
434
+ * @see packages/contracts/docs/verification-path.md for the same rule stated
435
+ * about verifier-key tags.
436
+ */
437
+ declare const TRANSACTION_TAG_PREFIX = "midnight:transaction[";
438
+ /**
439
+ * Thrown when a payload handed to a proving seam is not a serialized
440
+ * transaction at all.
441
+ *
442
+ * Distinct from a decode failure inside the ledger runtime: this is raised
443
+ * before any runtime is asked to read the bytes, so it says the caller sent the
444
+ * wrong KIND of payload rather than a damaged one. It covers three ways that
445
+ * can happen — a `txBytes` field that is not a byte string, a byte string
446
+ * shorter than the tag prefix, and one that does not open with the prefix.
447
+ *
448
+ * @remarks Raised by `proveV8Transaction`, so it reaches application code as a
449
+ * `proveTx` rejection. Match it with `hasErrorCode` against
450
+ * `PROTOCOL_ERROR_CODES.PAYLOAD_NOT_A_TRANSACTION` rather than constructing it.
451
+ */
452
+ declare class PayloadNotATransactionError extends Error {
453
+ readonly code: "MIDNIGHT_JS_P_PAYLOAD_NOT_A_TRANSACTION";
454
+ private constructor();
455
+ /**
456
+ * The `txBytes` field of a `v8` payload was not a `Uint8Array`. Reachable
457
+ * from JavaScript, from a consumer built against a pre-5.0.0
458
+ * `midnight-js-types`, or across an untyped boundary — so it is refused with
459
+ * a code rather than left to become a bare `TypeError`.
460
+ */
461
+ static notBytes(received: unknown): PayloadNotATransactionError;
462
+ /** The payload is a byte string, but does not open with a transaction's tag. */
463
+ static wrongTag(byteLength: number): PayloadNotATransactionError;
464
+ }
465
+
466
+ export { ComposeFailedError, ComposeOptionError, DownConvertFailedError, Ledger8InstanceMismatchError, Ledger8RuntimeInvalidError, Ledger8RuntimeMissingError, MerkleNotRehashedError, NO_CIRCUIT, PROTOCOL_ERROR_CODES, PayloadNotATransactionError, StateDecodeFailedError, TRANSACTION_TAG_PREFIX, UnknownLedger8AxisError, UnknownLedgerVersionError, UnknownProtocolVersionError };
467
+ export type { ComposeOption, ComposeStage, DownConvertStage, Ledger8InstanceAxis, ProtocolErrorCode, ProtocolVersionUnknownReason, RetainedEraSubpath, VersionResolutionPath };