@midnightntwrk/compact-js 0.0.0-stage → 4.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.
- package/LICENSE +14 -0
- package/README.md +158 -2
- package/dist/dts/effect/CompactContext.d.ts +20 -0
- package/dist/dts/effect/CompactContext.d.ts.map +1 -0
- package/dist/dts/effect/CompactRuntime.d.ts +76 -0
- package/dist/dts/effect/CompactRuntime.d.ts.map +1 -0
- package/dist/dts/effect/CompiledContract.d.ts +107 -0
- package/dist/dts/effect/CompiledContract.d.ts.map +1 -0
- package/dist/dts/effect/Contract.d.ts +154 -0
- package/dist/dts/effect/Contract.d.ts.map +1 -0
- package/dist/dts/effect/ContractConfigurationError.d.ts +54 -0
- package/dist/dts/effect/ContractConfigurationError.d.ts.map +1 -0
- package/dist/dts/effect/ContractEventStore.d.ts +167 -0
- package/dist/dts/effect/ContractEventStore.d.ts.map +1 -0
- package/dist/dts/effect/ContractEventValidationError.d.ts +34 -0
- package/dist/dts/effect/ContractEventValidationError.d.ts.map +1 -0
- package/dist/dts/effect/ContractEventValidator.d.ts +18 -0
- package/dist/dts/effect/ContractEventValidator.d.ts.map +1 -0
- package/dist/dts/effect/ContractExecutable.d.ts +99 -0
- package/dist/dts/effect/ContractExecutable.d.ts.map +1 -0
- package/dist/dts/effect/ContractExecutableRuntime.d.ts +4 -0
- package/dist/dts/effect/ContractExecutableRuntime.d.ts.map +1 -0
- package/dist/dts/effect/ContractKeyLocation.d.ts +55 -0
- package/dist/dts/effect/ContractKeyLocation.d.ts.map +1 -0
- package/dist/dts/effect/ContractLog.d.ts +273 -0
- package/dist/dts/effect/ContractLog.d.ts.map +1 -0
- package/dist/dts/effect/ContractRuntimeError.d.ts +34 -0
- package/dist/dts/effect/ContractRuntimeError.d.ts.map +1 -0
- package/dist/dts/effect/Ledger.d.ts +104 -0
- package/dist/dts/effect/Ledger.d.ts.map +1 -0
- package/dist/dts/effect/MalformedHexPrefixError.d.ts +37 -0
- package/dist/dts/effect/MalformedHexPrefixError.d.ts.map +1 -0
- package/dist/dts/effect/ZKConfiguration.d.ts +52 -0
- package/dist/dts/effect/ZKConfiguration.d.ts.map +1 -0
- package/dist/dts/effect/ZKConfigurationReadError.d.ts +45 -0
- package/dist/dts/effect/ZKConfigurationReadError.d.ts.map +1 -0
- package/dist/dts/effect/ZKManifest.d.ts +50 -0
- package/dist/dts/effect/ZKManifest.d.ts.map +1 -0
- package/dist/dts/effect/ZKManifestError.d.ts +34 -0
- package/dist/dts/effect/ZKManifestError.d.ts.map +1 -0
- package/dist/dts/effect/index.d.ts +22 -0
- package/dist/dts/effect/index.d.ts.map +1 -0
- package/dist/dts/effect/internal/boundary.d.ts +35 -0
- package/dist/dts/effect/internal/boundary.d.ts.map +1 -0
- package/dist/dts/effect/internal/compactContext.d.ts +29 -0
- package/dist/dts/effect/internal/compactContext.d.ts.map +1 -0
- package/dist/dts/effect/internal/contractEventsSurface.d.ts +43 -0
- package/dist/dts/effect/internal/contractEventsSurface.d.ts.map +1 -0
- package/dist/dts/effect/internal/era/v8Executable.d.ts +65 -0
- package/dist/dts/effect/internal/era/v8Executable.d.ts.map +1 -0
- package/dist/dts/effect/internal/era/v8Ledger.d.ts +76 -0
- package/dist/dts/effect/internal/era/v8Ledger.d.ts.map +1 -0
- package/dist/dts/effect/internal/era/v8Runtime.d.ts +26 -0
- package/dist/dts/effect/internal/era/v8Runtime.d.ts.map +1 -0
- package/dist/dts/effect/internal/era/v9Executable.d.ts +65 -0
- package/dist/dts/effect/internal/era/v9Executable.d.ts.map +1 -0
- package/dist/dts/effect/internal/era/v9Ledger.d.ts +76 -0
- package/dist/dts/effect/internal/era/v9Ledger.d.ts.map +1 -0
- package/dist/dts/effect/internal/era/v9Runtime.d.ts +15 -0
- package/dist/dts/effect/internal/era/v9Runtime.d.ts.map +1 -0
- package/dist/dts/effect/internal/era.d.ts +117 -0
- package/dist/dts/effect/internal/era.d.ts.map +1 -0
- package/dist/dts/effect/internal/eraFreeSurface.d.ts +49 -0
- package/dist/dts/effect/internal/eraFreeSurface.d.ts.map +1 -0
- package/dist/dts/effect/internal/eraNeutralSurface.d.ts +35 -0
- package/dist/dts/effect/internal/eraNeutralSurface.d.ts.map +1 -0
- package/dist/dts/effect/internal/executable.d.ts +371 -0
- package/dist/dts/effect/internal/executable.d.ts.map +1 -0
- package/dist/dts/effect/internal/ledger/binding.d.ts +2 -0
- package/dist/dts/effect/internal/ledger/binding.d.ts.map +1 -0
- package/dist/dts/effect/internal/ledger/conformance.d.ts +2 -0
- package/dist/dts/effect/internal/ledger/conformance.d.ts.map +1 -0
- package/dist/dts/effect/internal/ledger/conversions.d.ts +167 -0
- package/dist/dts/effect/internal/ledger/conversions.d.ts.map +1 -0
- package/dist/dts/effect/internal/ledger/current.d.ts +8 -0
- package/dist/dts/effect/internal/ledger/current.d.ts.map +1 -0
- package/dist/dts/effect/internal/ledger/v8.d.ts +100 -0
- package/dist/dts/effect/internal/ledger/v8.d.ts.map +1 -0
- package/dist/dts/effect/internal/ledger/v9.d.ts +66 -0
- package/dist/dts/effect/internal/ledger/v9.d.ts.map +1 -0
- package/dist/dts/effect/internal/runtime/binding.d.ts +2 -0
- package/dist/dts/effect/internal/runtime/binding.d.ts.map +1 -0
- package/dist/dts/effect/internal/runtime/conformance.d.ts +2 -0
- package/dist/dts/effect/internal/runtime/conformance.d.ts.map +1 -0
- package/dist/dts/effect/internal/runtime/current.d.ts +11 -0
- package/dist/dts/effect/internal/runtime/current.d.ts.map +1 -0
- package/dist/dts/effect/internal/runtime/execution.d.ts +176 -0
- package/dist/dts/effect/internal/runtime/execution.d.ts.map +1 -0
- package/dist/dts/effect/internal/runtime/v0_16.d.ts +169 -0
- package/dist/dts/effect/internal/runtime/v0_16.d.ts.map +1 -0
- package/dist/dts/effect/internal/runtime/v0_21.d.ts +81 -0
- package/dist/dts/effect/internal/runtime/v0_21.d.ts.map +1 -0
- package/dist/dts/effect/internal/typeAssertions.d.ts +2 -0
- package/dist/dts/effect/internal/typeAssertions.d.ts.map +1 -0
- package/dist/dts/index.d.ts +7 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/v8/effect.d.ts +50 -0
- package/dist/dts/v8/effect.d.ts.map +1 -0
- package/dist/dts/v8/index.d.ts +10 -0
- package/dist/dts/v8/index.d.ts.map +1 -0
- package/dist/dts/v9/effect.d.ts +28 -0
- package/dist/dts/v9/effect.d.ts.map +1 -0
- package/dist/dts/v9/index.d.ts +16 -0
- package/dist/dts/v9/index.d.ts.map +1 -0
- package/dist/esm/effect/CompactContext.js +16 -0
- package/dist/esm/effect/CompactContext.js.map +1 -0
- package/dist/esm/effect/CompactRuntime.js +44 -0
- package/dist/esm/effect/CompactRuntime.js.map +1 -0
- package/dist/esm/effect/CompiledContract.js +102 -0
- package/dist/esm/effect/CompiledContract.js.map +1 -0
- package/dist/esm/effect/Contract.js +40 -0
- package/dist/esm/effect/Contract.js.map +1 -0
- package/dist/esm/effect/ContractConfigurationError.js +41 -0
- package/dist/esm/effect/ContractConfigurationError.js.map +1 -0
- package/dist/esm/effect/ContractEventStore.js +150 -0
- package/dist/esm/effect/ContractEventStore.js.map +1 -0
- package/dist/esm/effect/ContractEventValidationError.js +40 -0
- package/dist/esm/effect/ContractEventValidationError.js.map +1 -0
- package/dist/esm/effect/ContractEventValidator.js +49 -0
- package/dist/esm/effect/ContractEventValidator.js.map +1 -0
- package/dist/esm/effect/ContractExecutable.js +50 -0
- package/dist/esm/effect/ContractExecutable.js.map +1 -0
- package/dist/esm/effect/ContractExecutableRuntime.js +17 -0
- package/dist/esm/effect/ContractExecutableRuntime.js.map +1 -0
- package/dist/esm/effect/ContractKeyLocation.js +67 -0
- package/dist/esm/effect/ContractKeyLocation.js.map +1 -0
- package/dist/esm/effect/ContractLog.js +268 -0
- package/dist/esm/effect/ContractLog.js.map +1 -0
- package/dist/esm/effect/ContractRuntimeError.js +40 -0
- package/dist/esm/effect/ContractRuntimeError.js.map +1 -0
- package/dist/esm/effect/Ledger.js +115 -0
- package/dist/esm/effect/Ledger.js.map +1 -0
- package/dist/esm/effect/MalformedHexPrefixError.js +43 -0
- package/dist/esm/effect/MalformedHexPrefixError.js.map +1 -0
- package/dist/esm/effect/ZKConfiguration.js +23 -0
- package/dist/esm/effect/ZKConfiguration.js.map +1 -0
- package/dist/esm/effect/ZKConfigurationReadError.js +46 -0
- package/dist/esm/effect/ZKConfigurationReadError.js.map +1 -0
- package/dist/esm/effect/ZKManifest.js +286 -0
- package/dist/esm/effect/ZKManifest.js.map +1 -0
- package/dist/esm/effect/ZKManifestError.js +40 -0
- package/dist/esm/effect/ZKManifestError.js.map +1 -0
- package/dist/esm/effect/index.js +36 -0
- package/dist/esm/effect/index.js.map +1 -0
- package/dist/esm/effect/internal/boundary.js +61 -0
- package/dist/esm/effect/internal/boundary.js.map +1 -0
- package/dist/esm/effect/internal/compactContext.js +52 -0
- package/dist/esm/effect/internal/compactContext.js.map +1 -0
- package/dist/esm/effect/internal/contractEventsSurface.js +57 -0
- package/dist/esm/effect/internal/contractEventsSurface.js.map +1 -0
- package/dist/esm/effect/internal/era/v8Executable.js +31 -0
- package/dist/esm/effect/internal/era/v8Executable.js.map +1 -0
- package/dist/esm/effect/internal/era/v8Ledger.js +85 -0
- package/dist/esm/effect/internal/era/v8Ledger.js.map +1 -0
- package/dist/esm/effect/internal/era/v8Runtime.js +39 -0
- package/dist/esm/effect/internal/era/v8Runtime.js.map +1 -0
- package/dist/esm/effect/internal/era/v9Executable.js +31 -0
- package/dist/esm/effect/internal/era/v9Executable.js.map +1 -0
- package/dist/esm/effect/internal/era/v9Ledger.js +83 -0
- package/dist/esm/effect/internal/era/v9Ledger.js.map +1 -0
- package/dist/esm/effect/internal/era/v9Runtime.js +28 -0
- package/dist/esm/effect/internal/era/v9Runtime.js.map +1 -0
- package/dist/esm/effect/internal/era.js +16 -0
- package/dist/esm/effect/internal/era.js.map +1 -0
- package/dist/esm/effect/internal/eraFreeSurface.js +63 -0
- package/dist/esm/effect/internal/eraFreeSurface.js.map +1 -0
- package/dist/esm/effect/internal/eraNeutralSurface.js +49 -0
- package/dist/esm/effect/internal/eraNeutralSurface.js.map +1 -0
- package/dist/esm/effect/internal/executable.js +531 -0
- package/dist/esm/effect/internal/executable.js.map +1 -0
- package/dist/esm/effect/internal/ledger/binding.js +20 -0
- package/dist/esm/effect/internal/ledger/binding.js.map +1 -0
- package/dist/esm/effect/internal/ledger/conformance.js +16 -0
- package/dist/esm/effect/internal/ledger/conformance.js.map +1 -0
- package/dist/esm/effect/internal/ledger/conversions.js +119 -0
- package/dist/esm/effect/internal/ledger/conversions.js.map +1 -0
- package/dist/esm/effect/internal/ledger/current.js +22 -0
- package/dist/esm/effect/internal/ledger/current.js.map +1 -0
- package/dist/esm/effect/internal/ledger/v8.js +101 -0
- package/dist/esm/effect/internal/ledger/v8.js.map +1 -0
- package/dist/esm/effect/internal/ledger/v9.js +91 -0
- package/dist/esm/effect/internal/ledger/v9.js.map +1 -0
- package/dist/esm/effect/internal/runtime/binding.js +16 -0
- package/dist/esm/effect/internal/runtime/binding.js.map +1 -0
- package/dist/esm/effect/internal/runtime/conformance.js +16 -0
- package/dist/esm/effect/internal/runtime/conformance.js.map +1 -0
- package/dist/esm/effect/internal/runtime/current.js +25 -0
- package/dist/esm/effect/internal/runtime/current.js.map +1 -0
- package/dist/esm/effect/internal/runtime/execution.js +16 -0
- package/dist/esm/effect/internal/runtime/execution.js.map +1 -0
- package/dist/esm/effect/internal/runtime/v0_16.js +178 -0
- package/dist/esm/effect/internal/runtime/v0_16.js.map +1 -0
- package/dist/esm/effect/internal/runtime/v0_21.js +129 -0
- package/dist/esm/effect/internal/runtime/v0_21.js.map +1 -0
- package/dist/esm/effect/internal/typeAssertions.js +16 -0
- package/dist/esm/effect/internal/typeAssertions.js.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/v8/effect.js +64 -0
- package/dist/esm/v8/effect.js.map +1 -0
- package/dist/esm/v8/index.js +24 -0
- package/dist/esm/v8/index.js.map +1 -0
- package/dist/esm/v9/effect.js +47 -0
- package/dist/esm/v9/effect.js.map +1 -0
- package/dist/esm/v9/index.js +30 -0
- package/dist/esm/v9/index.js.map +1 -0
- package/effect/CompactContext/package.json +5 -0
- package/effect/CompactRuntime/package.json +5 -0
- package/effect/CompiledContract/package.json +5 -0
- package/effect/Contract/package.json +5 -0
- package/effect/ContractConfigurationError/package.json +5 -0
- package/effect/ContractEventStore/package.json +5 -0
- package/effect/ContractEventValidationError/package.json +5 -0
- package/effect/ContractEventValidator/package.json +5 -0
- package/effect/ContractExecutable/package.json +5 -0
- package/effect/ContractExecutableRuntime/package.json +5 -0
- package/effect/ContractKeyLocation/package.json +5 -0
- package/effect/ContractLog/package.json +5 -0
- package/effect/ContractRuntimeError/package.json +5 -0
- package/effect/Ledger/package.json +5 -0
- package/effect/MalformedHexPrefixError/package.json +5 -0
- package/effect/ZKConfiguration/package.json +5 -0
- package/effect/ZKConfigurationReadError/package.json +5 -0
- package/effect/ZKManifest/package.json +5 -0
- package/effect/ZKManifestError/package.json +5 -0
- package/effect/index/package.json +5 -0
- package/effect/package.json +5 -0
- package/package.json +220 -4
- package/v8/effect/package.json +5 -0
- package/v8/package.json +5 -0
- package/v9/effect/package.json +5 -0
- package/v9/package.json +5 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed domain model for the contract log events emitted from Compact contracts via the `emit`
|
|
3
|
+
* expression (MIP-0002).
|
|
4
|
+
*
|
|
5
|
+
* Events flow from contract emission → ledger wrapping → indexer storage → DApp queries. This
|
|
6
|
+
* module turns the raw, on-chain-encoded {@link LogEvent} surfaced on a circuit result into a
|
|
7
|
+
* typed, discriminated {@link ContractEvent} whose `payload` is decoded per event type.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* - **Event version**: Phase-1 wire format is `version: 1`. Version `0` is reserved on-chain for
|
|
11
|
+
* the decoder's malformed-input fallback, so it is treated here as degraded/unknown, never an
|
|
12
|
+
* error.
|
|
13
|
+
* - **Graceful degradation** (MIP-0002): an oversized or malformed payload is dropped on-chain
|
|
14
|
+
* (surfaced as an empty `{ tag: 'null' }` `data`, or a short buffer). Decoding **never throws**
|
|
15
|
+
* and never fails a batch — such events decode to a {@link ContractEvent} with `degraded: true`
|
|
16
|
+
* and `payload: undefined`. Absence is normal.
|
|
17
|
+
* - **Indexed fields** are derived from the event type (not marked by the author); see
|
|
18
|
+
* {@link indexedFields}. `Misc` and lifecycle events index nothing.
|
|
19
|
+
* - **Non-consensus**: events are NOT consensus state; retention is a downstream (indexer) policy.
|
|
20
|
+
* - **Wire layout**: the intra-`data` field byte-offsets read by {@link decode} follow the
|
|
21
|
+
* corrected field-aligned layout from issue #278 — a 65-byte `Either` (`[is_left:1][left:32][right:32]`,
|
|
22
|
+
* `is_left=1` → coin-public-key), little-endian `Uint<128>` with trailing zeros stripped (buffers
|
|
23
|
+
* are right-padded to canonical width before slicing), and the post-compact#590 `shielded-receive`
|
|
24
|
+
* field order `(commitment, ciphertext, contractAddress)`. See the layout table in
|
|
25
|
+
* `test/effect/logEventFixtures.ts`. The authoritative reference is the indexer's Rust decoder
|
|
26
|
+
* (`ledger_state.rs`); the end-to-end cross-check against a live `emit` (see that file's provenance
|
|
27
|
+
* note) is the final validation gate. A wrong offset decodes **silently** to a wrong value rather
|
|
28
|
+
* than degrading.
|
|
29
|
+
*
|
|
30
|
+
* @packageDocumentation
|
|
31
|
+
*/
|
|
32
|
+
import * as ContractAddress from '@midnight-ntwrk/platform-js/effect/ContractAddress';
|
|
33
|
+
import { Option } from 'effect';
|
|
34
|
+
import * as Schema from 'effect/Schema';
|
|
35
|
+
/**
|
|
36
|
+
* The `EncodedStateValue` arms this module discriminates.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Only the `cell` arm carries a payload to decode; every other arm means the event's data was
|
|
40
|
+
* dropped on-chain or is not a byte buffer, which {@link decode} surfaces as a degraded event. The
|
|
41
|
+
* remaining tags are named rather than widened to `string` so that `data.tag === 'cell'` narrows.
|
|
42
|
+
*
|
|
43
|
+
* @category model
|
|
44
|
+
*/
|
|
45
|
+
export type LogEventData = {
|
|
46
|
+
readonly tag: 'cell';
|
|
47
|
+
readonly content: {
|
|
48
|
+
readonly value: readonly Uint8Array[];
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
readonly tag: 'null' | 'map' | 'array' | 'boundedMerkleTree';
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The raw log event a circuit result carries — stated **era-free**, as the structural minimum this
|
|
55
|
+
* module reads.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* This used to be re-exported from the {@link CompactRuntime} seam, which resolves
|
|
59
|
+
* `internal/runtime/current.ts`. That made it the one era-varying type on an era-pinned entry that
|
|
60
|
+
* was *not* derived from a binding argument: `/v9/effect` exported `ContractExecutable`'s
|
|
61
|
+
* `CallResult.events` as ledger 9's (correctly derived) while its `ContractLog` would have followed
|
|
62
|
+
* the build's bound era. Harmless while the two coincide, and wrong in exactly the situation the
|
|
63
|
+
* era-pinned entries exist for — a fork window, where a consumer holds the retained era and the new
|
|
64
|
+
* one in one process and the retained era's path is the one that must keep working
|
|
65
|
+
* (midnight-sdk#388).
|
|
66
|
+
*
|
|
67
|
+
* Stating the minimum rather than naming a line is the same choice `Contract.CircuitResults` makes,
|
|
68
|
+
* and it costs nothing here: {@link decode} and {@link decodeAll} are generic in the event they are
|
|
69
|
+
* given, so a caller passing an era's own `LogEvent` gets it back on {@link ContractEventBase.raw}
|
|
70
|
+
* unchanged. `internal/runtime/conformance.ts` asserts each events-capable line still satisfies it.
|
|
71
|
+
*
|
|
72
|
+
* @category model
|
|
73
|
+
*/
|
|
74
|
+
export interface LogEvent {
|
|
75
|
+
/** The wire-format version (`1` for Phase 1; `0` is the reserved fallback). */
|
|
76
|
+
readonly version: number;
|
|
77
|
+
/** The emitting contract's address, unvalidated as the runtime supplied it. */
|
|
78
|
+
readonly address: string;
|
|
79
|
+
readonly eventType: LogEventType;
|
|
80
|
+
readonly data: LogEventData;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Schema for the standard `LogEventType` discriminants emitted by Compact contracts — the single
|
|
84
|
+
* source of truth for the event-type literals, imported by `ContractEventValidator`.
|
|
85
|
+
*
|
|
86
|
+
* @category model
|
|
87
|
+
*/
|
|
88
|
+
export declare const LogEventTypeSchema: Schema.Literal<["shielded-spend", "shielded-receive", "shielded-mint", "shielded-burn", "unshielded-spend", "unshielded-receive", "unshielded-mint", "unshielded-burn", "paused", "unpaused", "misc"]>;
|
|
89
|
+
/**
|
|
90
|
+
* The standard event types emitted by Compact contracts.
|
|
91
|
+
*
|
|
92
|
+
* @category model
|
|
93
|
+
*/
|
|
94
|
+
export type LogEventType = typeof LogEventTypeSchema.Type;
|
|
95
|
+
/**
|
|
96
|
+
* The recipient/sender side of an unshielded event — an `Either<ZswapCoinPublicKey, ContractAddress>`.
|
|
97
|
+
* `kind` is the `Either` discriminant; `bytes` are the raw 32-byte address.
|
|
98
|
+
*
|
|
99
|
+
* @category model
|
|
100
|
+
*/
|
|
101
|
+
export interface EitherAddress {
|
|
102
|
+
readonly kind: 'coin-public-key' | 'contract-address';
|
|
103
|
+
readonly bytes: Uint8Array;
|
|
104
|
+
}
|
|
105
|
+
/** @category model */
|
|
106
|
+
export interface ShieldedSpendPayload {
|
|
107
|
+
readonly nullifier: Uint8Array;
|
|
108
|
+
}
|
|
109
|
+
/** @category model */
|
|
110
|
+
export interface ShieldedReceivePayload {
|
|
111
|
+
readonly commitment: Uint8Array;
|
|
112
|
+
readonly contractAddress: Option.Option<Uint8Array>;
|
|
113
|
+
readonly ciphertext: Option.Option<Uint8Array>;
|
|
114
|
+
}
|
|
115
|
+
/** @category model */
|
|
116
|
+
export interface ShieldedMintPayload {
|
|
117
|
+
readonly commitment: Uint8Array;
|
|
118
|
+
readonly domainSep: Uint8Array;
|
|
119
|
+
readonly amount: Option.Option<bigint>;
|
|
120
|
+
}
|
|
121
|
+
/** @category model */
|
|
122
|
+
export interface ShieldedBurnPayload {
|
|
123
|
+
readonly nullifier: Uint8Array;
|
|
124
|
+
readonly amount: Option.Option<bigint>;
|
|
125
|
+
}
|
|
126
|
+
/** @category model */
|
|
127
|
+
export interface UnshieldedSpendPayload {
|
|
128
|
+
readonly sender: EitherAddress;
|
|
129
|
+
/** The 32-byte domain separator carried on the wire (not an indexed field). */
|
|
130
|
+
readonly domainSep: Uint8Array;
|
|
131
|
+
readonly tokenType: Uint8Array;
|
|
132
|
+
readonly amount: bigint;
|
|
133
|
+
}
|
|
134
|
+
/** @category model */
|
|
135
|
+
export interface UnshieldedReceivePayload {
|
|
136
|
+
readonly recipient: EitherAddress;
|
|
137
|
+
/** The 32-byte domain separator carried on the wire (not an indexed field). */
|
|
138
|
+
readonly domainSep: Uint8Array;
|
|
139
|
+
readonly tokenType: Uint8Array;
|
|
140
|
+
readonly amount: bigint;
|
|
141
|
+
}
|
|
142
|
+
/** @category model */
|
|
143
|
+
export interface UnshieldedMintPayload {
|
|
144
|
+
readonly domainSep: Uint8Array;
|
|
145
|
+
readonly tokenType: Uint8Array;
|
|
146
|
+
readonly amount: bigint;
|
|
147
|
+
}
|
|
148
|
+
/** @category model */
|
|
149
|
+
export interface UnshieldedBurnPayload {
|
|
150
|
+
readonly sender: EitherAddress;
|
|
151
|
+
readonly tokenType: Uint8Array;
|
|
152
|
+
readonly amount: bigint;
|
|
153
|
+
}
|
|
154
|
+
/** Lifecycle events (`paused`/`unpaused`) carry no payload fields. @category model */
|
|
155
|
+
export type LifecyclePayload = Record<never, never>;
|
|
156
|
+
/** @category model */
|
|
157
|
+
export interface MiscPayload {
|
|
158
|
+
readonly name: Uint8Array;
|
|
159
|
+
readonly payload: Uint8Array;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Maps each {@link LogEventType} to its decoded payload type.
|
|
163
|
+
*
|
|
164
|
+
* @category model
|
|
165
|
+
*/
|
|
166
|
+
export interface PayloadMap {
|
|
167
|
+
readonly 'shielded-spend': ShieldedSpendPayload;
|
|
168
|
+
readonly 'shielded-receive': ShieldedReceivePayload;
|
|
169
|
+
readonly 'shielded-mint': ShieldedMintPayload;
|
|
170
|
+
readonly 'shielded-burn': ShieldedBurnPayload;
|
|
171
|
+
readonly 'unshielded-spend': UnshieldedSpendPayload;
|
|
172
|
+
readonly 'unshielded-receive': UnshieldedReceivePayload;
|
|
173
|
+
readonly 'unshielded-mint': UnshieldedMintPayload;
|
|
174
|
+
readonly 'unshielded-burn': UnshieldedBurnPayload;
|
|
175
|
+
readonly 'paused': LifecyclePayload;
|
|
176
|
+
readonly 'unpaused': LifecyclePayload;
|
|
177
|
+
readonly 'misc': MiscPayload;
|
|
178
|
+
}
|
|
179
|
+
/** The common fields carried by every {@link ContractEvent}. @category model */
|
|
180
|
+
export interface ContractEventBase<E extends LogEvent = LogEvent> {
|
|
181
|
+
/** The wire-format version (`1` for Phase 1). */
|
|
182
|
+
readonly version: number;
|
|
183
|
+
/**
|
|
184
|
+
* The address of the contract that emitted the event. Always a validated
|
|
185
|
+
* {@link ContractAddress.ContractAddress} on a {@link DecodedEvent}; on a {@link DegradedEvent}
|
|
186
|
+
* whose degradation was caused by a malformed envelope address, this is the unvalidated raw
|
|
187
|
+
* string as supplied by the runtime (also available on `raw.address`).
|
|
188
|
+
*/
|
|
189
|
+
readonly address: ContractAddress.ContractAddress;
|
|
190
|
+
/** The original, undecoded log event. */
|
|
191
|
+
readonly raw: E;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A successfully decoded contract event. Narrow on `eventType` to obtain the typed `payload`.
|
|
195
|
+
*
|
|
196
|
+
* @category model
|
|
197
|
+
*/
|
|
198
|
+
export type DecodedEvent<E extends LogEvent = LogEvent> = {
|
|
199
|
+
[K in LogEventType]: ContractEventBase<E> & {
|
|
200
|
+
readonly eventType: K;
|
|
201
|
+
readonly payload: PayloadMap[K];
|
|
202
|
+
readonly degraded: false;
|
|
203
|
+
};
|
|
204
|
+
}[LogEventType];
|
|
205
|
+
/**
|
|
206
|
+
* An event whose payload could not be decoded — dropped on-chain (`{ tag: 'null' }` data),
|
|
207
|
+
* truncated, carrying the reserved fallback `version: 0`, or bearing a malformed envelope address.
|
|
208
|
+
* Per MIP-0002 this is normal, not an error; the raw event is still available via
|
|
209
|
+
* {@link ContractEventBase.raw}.
|
|
210
|
+
*
|
|
211
|
+
* @category model
|
|
212
|
+
*/
|
|
213
|
+
export type DegradedEvent<E extends LogEvent = LogEvent> = ContractEventBase<E> & {
|
|
214
|
+
readonly eventType: LogEventType;
|
|
215
|
+
readonly payload: undefined;
|
|
216
|
+
readonly degraded: true;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* A typed contract event: either a {@link DecodedEvent} or a {@link DegradedEvent}. Discriminate
|
|
220
|
+
* on `degraded`, then narrow on `eventType`.
|
|
221
|
+
*
|
|
222
|
+
* @category model
|
|
223
|
+
*/
|
|
224
|
+
export type ContractEvent<E extends LogEvent = LogEvent> = DecodedEvent<E> | DegradedEvent<E>;
|
|
225
|
+
/**
|
|
226
|
+
* Decode a single raw {@link LogEvent} into a typed {@link ContractEvent}.
|
|
227
|
+
*
|
|
228
|
+
* This is a total, pure function: it **never throws**. A dropped (`{ tag: 'null' }`), truncated,
|
|
229
|
+
* or `version: 0` payload — or a malformed envelope address — decodes to a {@link DegradedEvent}
|
|
230
|
+
* (`degraded: true`, `payload: undefined`) per the MIP-0002 graceful-degradation rule; the raw
|
|
231
|
+
* event remains on `raw`.
|
|
232
|
+
*
|
|
233
|
+
* The `payload` field byte-offsets follow the corrected layout from issue #278 (see the module-level
|
|
234
|
+
* remarks). The end-to-end cross-check against a live `emit` is the final validation gate; a wrong
|
|
235
|
+
* offset decodes silently to a wrong value rather than degrading.
|
|
236
|
+
*
|
|
237
|
+
* @param raw The raw log event surfaced on a circuit result.
|
|
238
|
+
* @returns The decoded, typed event.
|
|
239
|
+
*
|
|
240
|
+
* @category decoding
|
|
241
|
+
*/
|
|
242
|
+
export declare const decode: <E extends LogEvent>(raw: E) => ContractEvent<E>;
|
|
243
|
+
/**
|
|
244
|
+
* Decode a batch of raw {@link LogEvent}s (e.g. `result.events`) into typed {@link ContractEvent}s.
|
|
245
|
+
*
|
|
246
|
+
* Like {@link decode}, this never throws — degraded events are preserved in place rather than
|
|
247
|
+
* dropped, so the returned array is index-aligned with the input.
|
|
248
|
+
*
|
|
249
|
+
* @param events The raw log events to decode.
|
|
250
|
+
* @returns The decoded, typed events, in input order.
|
|
251
|
+
*
|
|
252
|
+
* @category decoding
|
|
253
|
+
*/
|
|
254
|
+
export declare const decodeAll: <E extends LogEvent>(events: readonly E[]) => ContractEvent<E>[];
|
|
255
|
+
/**
|
|
256
|
+
* Derive the indexable fields of a decoded event, as raw byte values keyed by field name.
|
|
257
|
+
*
|
|
258
|
+
* Indexed fields are determined by the event type (MIP-0002), not marked by the author:
|
|
259
|
+
* - `shielded-spend`/`shielded-burn` → `nullifier`
|
|
260
|
+
* - `shielded-receive` → `commitment`
|
|
261
|
+
* - `shielded-mint` → `commitment`, `domainSep`
|
|
262
|
+
* - `unshielded-spend`/`unshielded-burn` → `sender`, `tokenType`
|
|
263
|
+
* - `unshielded-receive` → `recipient`, `tokenType`
|
|
264
|
+
* - `unshielded-mint` → `domainSep`, `tokenType`
|
|
265
|
+
* - `paused`/`unpaused`/`misc` and any degraded event → none
|
|
266
|
+
*
|
|
267
|
+
* @param event The decoded event.
|
|
268
|
+
* @returns A map of indexable field name to its raw bytes; empty when the type indexes nothing.
|
|
269
|
+
*
|
|
270
|
+
* @category indexing
|
|
271
|
+
*/
|
|
272
|
+
export declare const indexedFields: (event: ContractEvent) => Record<string, Uint8Array>;
|
|
273
|
+
//# sourceMappingURL=ContractLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractLog.d.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ContractRuntimeError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof TypeId, typeof TypeId> & {
|
|
4
|
+
readonly _tag: "ContractRuntimeError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
/**
|
|
7
|
+
* A runtime error occurred while executing a constructor, or a circuit, of an executable contract.
|
|
8
|
+
*
|
|
9
|
+
* @category errors
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContractRuntimeError extends ContractRuntimeError_base<{
|
|
12
|
+
/** A displayable message. */
|
|
13
|
+
readonly message: string;
|
|
14
|
+
/** Indicates a more specific cause of the error. */
|
|
15
|
+
readonly cause?: unknown;
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Determines if a value is a contract runtime error.
|
|
20
|
+
*
|
|
21
|
+
* @param u The value to check.
|
|
22
|
+
* @returns `true` if `u` is a {@link ContractRuntimeError}; `false` otherwise.
|
|
23
|
+
*
|
|
24
|
+
* @category guards
|
|
25
|
+
*/
|
|
26
|
+
export declare const isRuntimeError: (u: unknown) => u is ContractRuntimeError;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new {@link ContractRuntimeError}.
|
|
29
|
+
*
|
|
30
|
+
* @category constructors
|
|
31
|
+
*/
|
|
32
|
+
export declare const make: (message: string, cause?: unknown) => ContractRuntimeError;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=ContractRuntimeError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractRuntimeError.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractRuntimeError.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,MAAM,EAAE,OAAO,MAA6D,CAAC;AACnF,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;;;;AAE5B;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,0BAAkD;IAC1F,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;CAAI;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,oBAA8C,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,oBACX,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ledger era seam.
|
|
3
|
+
*
|
|
4
|
+
* All ledger types, constructors, and runtime↔ledger conversions used by compact-js (and its
|
|
5
|
+
* sibling packages) are reached through this module rather than a `@midnightntwrk/ledger-v<N>`
|
|
6
|
+
* package directly. The concrete era is bound in `internal/ledger/current.ts`. The facade
|
|
7
|
+
* re-exports a curated list of ledger names: if one you need is missing, widen the era binding
|
|
8
|
+
* (`internal/ledger/v9.ts`) rather than importing the ledger package around the seam. Tests may
|
|
9
|
+
* import the ledger package directly where they must compare module identity.
|
|
10
|
+
*
|
|
11
|
+
* The seam is deliberately a module, not an injected service: which ledger era a build speaks is
|
|
12
|
+
* a packaging-level fact — one era per build artifact — not a runtime dependency to vary per
|
|
13
|
+
* effect. Downstream multi-era consumers select between era-scoped entries instead.
|
|
14
|
+
*/
|
|
15
|
+
import { Effect } from 'effect';
|
|
16
|
+
import type * as CompactRuntime from './CompactRuntime.js';
|
|
17
|
+
import * as ContractRuntimeError from './ContractRuntimeError.js';
|
|
18
|
+
import * as CurrentEra from './internal/ledger/current.js';
|
|
19
|
+
export { type Era } from './internal/era.js';
|
|
20
|
+
export { tryConvert } from './internal/ledger/conversions.js';
|
|
21
|
+
export * from './internal/ledger/current.js';
|
|
22
|
+
/**
|
|
23
|
+
* Converts a runtime `ContractState` to this era's ledger `ContractState`.
|
|
24
|
+
*
|
|
25
|
+
* @category conversions
|
|
26
|
+
*/
|
|
27
|
+
export declare const fromRuntimeContractState: (contractState: CompactRuntime.ContractState) => Effect.Effect<CurrentEra.ContractState, ContractRuntimeError.ContractRuntimeError, never>;
|
|
28
|
+
/**
|
|
29
|
+
* Converts this era's ledger `ContractState` to a runtime `ContractState`.
|
|
30
|
+
*
|
|
31
|
+
* @category conversions
|
|
32
|
+
*/
|
|
33
|
+
export declare const toRuntimeContractState: (contractState: CurrentEra.ContractState) => Effect.Effect<CompactRuntime.ContractState, ContractRuntimeError.ContractRuntimeError, never>;
|
|
34
|
+
/**
|
|
35
|
+
* Deserializes ledger-serialized bytes into this era's ledger `ContractState`.
|
|
36
|
+
*
|
|
37
|
+
* @category conversions
|
|
38
|
+
*/
|
|
39
|
+
export declare const contractStateFromBytes: (bytes: Uint8Array) => Effect.Effect<CurrentEra.ContractState, ContractRuntimeError.ContractRuntimeError, never>;
|
|
40
|
+
/**
|
|
41
|
+
* Deserializes ledger-serialized bytes into this era's `LedgerParameters`.
|
|
42
|
+
*
|
|
43
|
+
* @category conversions
|
|
44
|
+
*/
|
|
45
|
+
export declare const parametersFromBytes: (bytes: Uint8Array) => Effect.Effect<CurrentEra.LedgerParameters, ContractRuntimeError.ContractRuntimeError, never>;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a runtime `ContractMaintenanceAuthority` to this era's ledger one.
|
|
48
|
+
*
|
|
49
|
+
* @category conversions
|
|
50
|
+
*/
|
|
51
|
+
export declare const fromRuntimeMaintenanceAuthority: (authority: CompactRuntime.ContractMaintenanceAuthority) => Effect.Effect<CurrentEra.ContractMaintenanceAuthority, ContractRuntimeError.ContractRuntimeError, never>;
|
|
52
|
+
/**
|
|
53
|
+
* Converts a runtime `StateValue` to this era's ledger `StateValue` via the shared binary
|
|
54
|
+
* encoding.
|
|
55
|
+
*
|
|
56
|
+
* @category conversions
|
|
57
|
+
*/
|
|
58
|
+
export declare const fromRuntimeStateValue: (value: {
|
|
59
|
+
encode(): unknown;
|
|
60
|
+
}) => Effect.Effect<CurrentEra.StateValue, ContractRuntimeError.ContractRuntimeError, never>;
|
|
61
|
+
/**
|
|
62
|
+
* Converts a runtime `QueryContext` to this era's ledger `QueryContext`, carrying `state`,
|
|
63
|
+
* `address`, `block`, `effects`, and the commitment indices (`comIndices`).
|
|
64
|
+
*
|
|
65
|
+
* @category conversions
|
|
66
|
+
*/
|
|
67
|
+
export declare const fromRuntimeQueryContext: (queryContext: {
|
|
68
|
+
readonly state: {
|
|
69
|
+
readonly state: {
|
|
70
|
+
encode(): unknown;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
readonly address: unknown;
|
|
74
|
+
block: unknown;
|
|
75
|
+
effects: unknown;
|
|
76
|
+
}) => Effect.Effect<CurrentEra.QueryContext, ContractRuntimeError.ContractRuntimeError, never>;
|
|
77
|
+
/**
|
|
78
|
+
* Adapts a platform-js signing key to this era's ledger `SigningKey`, failing when the signature
|
|
79
|
+
* scheme is not supported by the era's CMA path.
|
|
80
|
+
*
|
|
81
|
+
* @category conversions
|
|
82
|
+
*/
|
|
83
|
+
export declare const fromPlatformSigningKey: (signingKey: import("@midnight-ntwrk/platform-js/effect/SigningKey").SigningKey, contractState?: CompactRuntime.ContractState | undefined) => import("effect/Either").Either<CurrentEra.SigningKey, import("./ContractConfigurationError.js").ContractConfigurationError>;
|
|
84
|
+
/**
|
|
85
|
+
* Resolves the `ContractOperation` for a circuit from a contract's ledger state, failing with a
|
|
86
|
+
* {@link ContractRuntimeError.ContractRuntimeError} if absent. A state with no operation for the
|
|
87
|
+
* requested circuit (e.g. a state file for the wrong contract) would otherwise be cast from
|
|
88
|
+
* `undefined` and surface as an opaque native fault.
|
|
89
|
+
*
|
|
90
|
+
* Era-independent, so it stays here rather than in the conversions factory: it reads the era's own
|
|
91
|
+
* `ContractState` and needs no second binding.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Both of the ways a bad state file fails here are held in the error channel. `operation()`
|
|
95
|
+
* returning `undefined` is the wrong-contract case; `operation()` *throwing* is the
|
|
96
|
+
* wrong-WASM-instance case (`expected instance of ContractState`), and since this function's
|
|
97
|
+
* result is built while the caller's `Effect.gen` body runs, an unwrapped throw would be a defect
|
|
98
|
+
* that escapes the caller's `catchAll` entirely — the opaque fault this function exists to
|
|
99
|
+
* prevent.
|
|
100
|
+
*
|
|
101
|
+
* @category conversions
|
|
102
|
+
*/
|
|
103
|
+
export declare const operationForCircuit: (contractState: CurrentEra.ContractState, circuitId: string, contractAddress: string) => Effect.Effect<CurrentEra.ContractOperation, ContractRuntimeError.ContractRuntimeError>;
|
|
104
|
+
//# sourceMappingURL=Ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ledger.d.ts","sourceRoot":"","sources":["../../../src/effect/Ledger.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAGlE,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAI3D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,cAAc,8BAA8B,CAAC;AAkB7C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,4IAAuC,CAAC;AAE7E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,4IAAqC,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kHAAqC,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,qHAAkC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,sKAA8C,CAAC;AAE3F;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;4FAAoC,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;8FAAsC,CAAC;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,2QAAqC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,EAAE,CAChC,aAAa,EAAE,UAAU,CAAC,aAAa,EACvC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,KACpB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,oBAAoB,CAevF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare const TypeId: unique symbol;
|
|
2
|
+
type TypeId = typeof TypeId;
|
|
3
|
+
declare const MalformedHexPrefixError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof TypeId, typeof TypeId> & {
|
|
4
|
+
readonly _tag: "MalformedHexPrefixError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
/**
|
|
7
|
+
* A query supplied a `fieldPrefixes` prefix that is not valid hex. Unlike the never-throw contract
|
|
8
|
+
* for on-chain event decoding, a malformed query prefix is a caller programming error (a typo, or a
|
|
9
|
+
* non-hex blob such as a UUID) rather than a normal degraded input — surfacing it fails fast instead
|
|
10
|
+
* of silently matching nothing.
|
|
11
|
+
*
|
|
12
|
+
* @category errors
|
|
13
|
+
*/
|
|
14
|
+
export declare class MalformedHexPrefixError extends MalformedHexPrefixError_base<{
|
|
15
|
+
/** A displayable message. */
|
|
16
|
+
readonly message: string;
|
|
17
|
+
/** The offending prefix, normalized (lowercased, any leading `0x` stripped). */
|
|
18
|
+
readonly prefix: string;
|
|
19
|
+
}> {
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Determines if a value is a malformed hex prefix error.
|
|
23
|
+
*
|
|
24
|
+
* @param u The value to check.
|
|
25
|
+
* @returns `true` if `u` is a {@link MalformedHexPrefixError}; `false` otherwise.
|
|
26
|
+
*
|
|
27
|
+
* @category guards
|
|
28
|
+
*/
|
|
29
|
+
export declare const isMalformedHexPrefixError: (u: unknown) => u is MalformedHexPrefixError;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new {@link MalformedHexPrefixError} for the given (normalized) prefix.
|
|
32
|
+
*
|
|
33
|
+
* @category constructors
|
|
34
|
+
*/
|
|
35
|
+
export declare const make: (prefix: string) => MalformedHexPrefixError;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=MalformedHexPrefixError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MalformedHexPrefixError.d.ts","sourceRoot":"","sources":["../../../src/effect/MalformedHexPrefixError.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,MAAM,EAAE,OAAO,MAAgE,CAAC;AACtF,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;;;;AAE5B;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,6BAAqD;IAChG,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,uBAAiD,CAAC;AAE9G;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,uBACgE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Context, type Effect, type Option } from 'effect';
|
|
2
|
+
import type { CompiledContract } from './CompiledContract.js';
|
|
3
|
+
import type * as Contract from './Contract.js';
|
|
4
|
+
import type * as ZKConfigurationError from './ZKConfigurationReadError.js';
|
|
5
|
+
declare const ZKConfiguration_base: Context.TagClass<ZKConfiguration, "compact-js/ZKConfiguration", ZKConfiguration.Service>;
|
|
6
|
+
/**
|
|
7
|
+
* Provides utilities for working with the ZK assets of a compiled Compact contract.
|
|
8
|
+
*
|
|
9
|
+
* @category services
|
|
10
|
+
*/
|
|
11
|
+
export declare class ZKConfiguration extends ZKConfiguration_base {
|
|
12
|
+
}
|
|
13
|
+
export declare namespace ZKConfiguration {
|
|
14
|
+
/**
|
|
15
|
+
* Provides utilities for working with the ZK assets of a compiled Compact contract.
|
|
16
|
+
*/
|
|
17
|
+
interface Service {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a ZK asset reader for a given compiled Compact contract.
|
|
20
|
+
*
|
|
21
|
+
* @param compiledContract The Compact compiled contract.
|
|
22
|
+
* @returns An `Effect` that yields a {@link Reader}.
|
|
23
|
+
*/
|
|
24
|
+
readonly createReader: <C extends Contract.Contract<PS>, PS>(compiledContract: CompiledContract<C, PS, never>) => Effect.Effect<ZKConfiguration.Reader<C, PS>>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reads ZK assets.
|
|
28
|
+
*/
|
|
29
|
+
interface Reader<C extends Contract.Contract<PS>, PS> {
|
|
30
|
+
/**
|
|
31
|
+
* Reads a verifier key for a given circuit identifier.
|
|
32
|
+
*
|
|
33
|
+
* @param provableCircuitId The identifier of the circuit to be read.
|
|
34
|
+
* @returns An `Effect` that yields an `Option` containing a {@link Contract.VerifierKey | VerifierKey} for
|
|
35
|
+
* `provableCircuitId` if the compiled contract was configured for verifier key generation; or fails with a
|
|
36
|
+
* {@link ZKConfigurationError.ZKConfigurationReadError | ZKConfigurationReadError}.
|
|
37
|
+
*/
|
|
38
|
+
getVerifierKey(provableCircuitId: Contract.ProvableCircuitId<C>): Effect.Effect<Option.Option<Contract.VerifierKey>, ZKConfigurationError.ZKConfigurationReadError>;
|
|
39
|
+
/**
|
|
40
|
+
* Batch reads the verifier keys for an array of circuit identifiers.
|
|
41
|
+
*
|
|
42
|
+
* @param provableCircuitIds The identifiers of the circuits to be read.
|
|
43
|
+
* @returns An `Effect` that yields an array of tuples describing an `Option` containing a
|
|
44
|
+
* {@link Contract.VerifierKey | VerifierKey} and its associated circuit identifier if the compiled contract
|
|
45
|
+
* was configured for verifier key generation; or fails with a
|
|
46
|
+
* {@link ZKConfigurationError.ZKConfigurationReadError | ZKConfigurationReadError}.
|
|
47
|
+
*/
|
|
48
|
+
getVerifierKeys(provableCircuitIds: Contract.ProvableCircuitId<C>[]): Effect.Effect<readonly [Contract.ProvableCircuitId<C>, Option.Option<Contract.VerifierKey>][], ZKConfigurationError.ZKConfigurationReadError>;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=ZKConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKConfiguration.d.ts","sourceRoot":"","sources":["../../../src/effect/ZKConfiguration.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,KAAK,oBAAoB,MAAM,+BAA+B,CAAC;;AAE3E;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,oBAGlC;CAAG;AAEN,MAAM,CAAC,OAAO,WAAW,eAAe,CAAC;IACvC;;OAEG;IACH,UAAiB,OAAO;QACtB;;;;;WAKG;QACH,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EACzD,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,KAC7C,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;KACnD;IAED;;OAEG;IACH,UAAiB,MAAM,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE;QACzD;;;;;;;WAOG;QACH,cAAc,CACZ,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAC/C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;QAErG;;;;;;;;WAQG;QACH,eAAe,CACb,kBAAkB,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAClD,MAAM,CAAC,MAAM,CACd,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,EAC/E,oBAAoB,CAAC,wBAAwB,CAC9C,CAAC;KACH;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type * as Contract from './Contract.js';
|
|
2
|
+
declare const TypeId: unique symbol;
|
|
3
|
+
type TypeId = typeof TypeId;
|
|
4
|
+
/**
|
|
5
|
+
* Describes a type of ZK asset.
|
|
6
|
+
*/
|
|
7
|
+
export type AssetType = 'verifier-key' | 'ZKIR' | 'prover-key';
|
|
8
|
+
declare const ZKConfigurationReadError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof TypeId, typeof TypeId> & {
|
|
9
|
+
readonly _tag: "ZKConfigurationReadError";
|
|
10
|
+
} & Readonly<A>;
|
|
11
|
+
/**
|
|
12
|
+
* Error indicating a failure to read a ZK asset.
|
|
13
|
+
*
|
|
14
|
+
* @category errors
|
|
15
|
+
*/
|
|
16
|
+
export declare class ZKConfigurationReadError extends ZKConfigurationReadError_base<{
|
|
17
|
+
/** A displayable message. */
|
|
18
|
+
readonly message: string;
|
|
19
|
+
/** The underlying cause of the failed read operation. */
|
|
20
|
+
readonly cause?: unknown;
|
|
21
|
+
/** The tag of the compiled contract being read. */
|
|
22
|
+
readonly contractTag: string;
|
|
23
|
+
/** The circuit of the compiled contract being read. */
|
|
24
|
+
readonly provableCircuitId: Contract.ProvableCircuitId;
|
|
25
|
+
/** The type of asset that was being read. */
|
|
26
|
+
readonly assetType: AssetType;
|
|
27
|
+
}> {
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Determines if a value is a ZK configuration read error.
|
|
31
|
+
*
|
|
32
|
+
* @param u The value to check.
|
|
33
|
+
* @returns `true` if `u` is a {@link ZKConfigurationReadError}; `false` otherwise.
|
|
34
|
+
*
|
|
35
|
+
* @category guards
|
|
36
|
+
*/
|
|
37
|
+
export declare const isReadError: (u: unknown) => u is ZKConfigurationReadError;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new {@link ZKConfigurationReadError}.
|
|
40
|
+
*
|
|
41
|
+
* @category constructors
|
|
42
|
+
*/
|
|
43
|
+
export declare const make: <C extends Contract.Contract.Any>(contractTag: string, provableCircuitId: Contract.ProvableCircuitId<C>, assetType: AssetType, cause?: unknown) => ZKConfigurationReadError;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=ZKConfigurationReadError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKConfigurationReadError.d.ts","sourceRoot":"","sources":["../../../src/effect/ZKConfigurationReadError.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE/C,QAAA,MAAM,MAAM,EAAE,OAAO,MAAiE,CAAC;AACvF,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,GAAG,YAAY,CAAC;;;;AAE/D;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,8BAAsD;IAClG,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEzB,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,CAAC;IAEvD,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,CAAC;CAAI;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,wBAAkD,CAAC;AAEjG;;;;GAIG;AACH,eAAO,MAAO,IAAI,EAAE,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAClD,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAChD,SAAS,EAAE,SAAS,EACpB,KAAK,CAAC,EAAE,OAAO,KACZ,wBAOD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import * as ZKManifestError from './ZKManifestError.js';
|
|
3
|
+
/** The only manifest format version this parser understands. */
|
|
4
|
+
export declare const SUPPORTED_MANIFEST_VERSION = "1";
|
|
5
|
+
/** Integrity metadata for a single generated file. */
|
|
6
|
+
export interface ZKManifestFile {
|
|
7
|
+
/** The size of the file, in bytes. */
|
|
8
|
+
readonly size: number;
|
|
9
|
+
/** The lower-case hex-encoded SHA-256 digest of the file's bytes. */
|
|
10
|
+
readonly hash: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A parsed ZK artifact manifest — the integrity manifest emitted by `compactc` alongside the
|
|
14
|
+
* compiled contract assets.
|
|
15
|
+
*
|
|
16
|
+
* The on-disk format nests file entries under their directory (`keys`, `zkir`, `contract`,
|
|
17
|
+
* `compiler`); this parsed form flattens them into {@link files}, keyed by their POSIX relative
|
|
18
|
+
* path (e.g. `"keys/clear.verifier"`) so lookups line up with the paths assets are read from.
|
|
19
|
+
*
|
|
20
|
+
* @category models
|
|
21
|
+
*/
|
|
22
|
+
export interface ZKManifest {
|
|
23
|
+
/** The manifest format version — always {@link SUPPORTED_MANIFEST_VERSION} for a successful parse. */
|
|
24
|
+
readonly manifestVersion: typeof SUPPORTED_MANIFEST_VERSION;
|
|
25
|
+
/** The version of `compactc` that produced the assets, if recorded. */
|
|
26
|
+
readonly compilerVersion?: string;
|
|
27
|
+
/** The Compact language version the source targeted, if recorded. */
|
|
28
|
+
readonly languageVersion?: string;
|
|
29
|
+
/** The `@midnight-ntwrk/compact-runtime` version the assets target, if recorded. */
|
|
30
|
+
readonly runtimeVersion?: string;
|
|
31
|
+
/** File integrity entries keyed by `"<dir>/<file>"` relative path. */
|
|
32
|
+
readonly files: ReadonlyMap<string, ZKManifestFile>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses and validates the raw JSON contents of a ZK artifact manifest, flattening its
|
|
36
|
+
* directory-nested entries into {@link ZKManifest.files}.
|
|
37
|
+
*
|
|
38
|
+
* The manifest reaches this boundary as untrusted input, so it is decoded with a {@link Schema} —
|
|
39
|
+
* yielding structural validation and a typed failure rather than hand-rolled checks. An unknown or
|
|
40
|
+
* missing {@link SUPPORTED_MANIFEST_VERSION | manifest-version} fails the parse, since a manifest we
|
|
41
|
+
* cannot interpret must not be treated as a passing integrity check.
|
|
42
|
+
*
|
|
43
|
+
* @param rawJson The raw JSON text of the manifest file.
|
|
44
|
+
* @returns An {@link Effect} that yields a {@link ZKManifest}, or fails with a
|
|
45
|
+
* {@link ZKManifestError.ZKManifestError}.
|
|
46
|
+
*
|
|
47
|
+
* @category constructors
|
|
48
|
+
*/
|
|
49
|
+
export declare const parse: (rawJson: string) => Effect.Effect<ZKManifest, ZKManifestError.ZKManifestError>;
|
|
50
|
+
//# sourceMappingURL=ZKManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKManifest.d.ts","sourceRoot":"","sources":["../../../src/effect/ZKManifest.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AAExD,gEAAgE;AAChE,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAQ9C,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,sGAAsG;IACtG,QAAQ,CAAC,eAAe,EAAE,OAAO,0BAA0B,CAAC;IAC5D,uEAAuE;IACvE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,qEAAqE;IACrE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,oFAAoF;IACpF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACrD;AAiLD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,eAAe,CAuG9F,CAAC"}
|