@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,286 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { Effect } from 'effect';
|
|
16
|
+
import { TreeFormatter } from 'effect/ParseResult';
|
|
17
|
+
import * as Schema from 'effect/Schema';
|
|
18
|
+
import * as ZKManifestError from './ZKManifestError.js';
|
|
19
|
+
/** The only manifest format version this parser understands. */
|
|
20
|
+
export const SUPPORTED_MANIFEST_VERSION = '1';
|
|
21
|
+
/** Reserved top-level keys carrying manifest metadata; every other top-level key is a directory. */
|
|
22
|
+
const MANIFEST_VERSION_KEY = 'manifest-version';
|
|
23
|
+
const COMPILER_VERSION_KEY = 'compiler-version';
|
|
24
|
+
const LANGUAGE_VERSION_KEY = 'language-version';
|
|
25
|
+
const RUNTIME_VERSION_KEY = 'runtime-version';
|
|
26
|
+
/** A non-negative byte count. */
|
|
27
|
+
const SizeSchema = Schema.Int.pipe(Schema.nonNegative());
|
|
28
|
+
/** A lower-case hex-encoded SHA-256 digest (32 bytes → 64 hex chars). */
|
|
29
|
+
const HashSchema = Schema.String.pipe(Schema.pattern(/^[0-9a-f]{64}$/));
|
|
30
|
+
/** Leaf node: `{ "type": "file", "size": n, "hash": "…" }`. */
|
|
31
|
+
const ManifestFileSchema = Schema.Struct({
|
|
32
|
+
type: Schema.Literal('file'),
|
|
33
|
+
size: SizeSchema,
|
|
34
|
+
hash: HashSchema
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Directory node: a `"type": "directory"` marker (a bare string) alongside file leaves. Modelling
|
|
38
|
+
* every value as a union of the marker or a file leaf sidesteps the awkward typing of a struct
|
|
39
|
+
* whose known key (`type`) differs from its index signature.
|
|
40
|
+
*
|
|
41
|
+
* Note: this intentionally supports only a single level of directory nesting (matching the layout
|
|
42
|
+
* `compactc` emits). A nested sub-directory object matches neither the `'directory'` marker nor a
|
|
43
|
+
* file leaf, so it is rejected by decode rather than silently ignored.
|
|
44
|
+
*/
|
|
45
|
+
const ManifestDirectorySchema = Schema.Record({
|
|
46
|
+
key: Schema.String,
|
|
47
|
+
value: Schema.Union(Schema.Literal('directory'), ManifestFileSchema)
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Whole document: reserved metadata keys carry strings (e.g. `manifest-version`); every other
|
|
51
|
+
* top-level key is a directory node.
|
|
52
|
+
*
|
|
53
|
+
* This stays an open `string | directory` record because the distinction between reserved metadata
|
|
54
|
+
* keys and directory keys is carried by the *key*, which a value schema cannot see — and a
|
|
55
|
+
* `Struct` index signature in {@link Schema} is applied to the declared fields too, so it cannot
|
|
56
|
+
* model "these keys are strings, all others are objects". The key-dependent invariants (metadata
|
|
57
|
+
* must be strings; every other key must be a directory, not a bare string) are therefore enforced
|
|
58
|
+
* as typed post-decode checks in {@link parse}.
|
|
59
|
+
*/
|
|
60
|
+
const ManifestDocumentSchema = Schema.Record({
|
|
61
|
+
key: Schema.String,
|
|
62
|
+
value: Schema.Union(Schema.String, ManifestDirectorySchema)
|
|
63
|
+
});
|
|
64
|
+
/** Top-level keys carrying metadata strings; every other top-level key is a directory node. */
|
|
65
|
+
const RESERVED_KEYS = new Set([
|
|
66
|
+
MANIFEST_VERSION_KEY,
|
|
67
|
+
COMPILER_VERSION_KEY,
|
|
68
|
+
LANGUAGE_VERSION_KEY,
|
|
69
|
+
RUNTIME_VERSION_KEY
|
|
70
|
+
]);
|
|
71
|
+
// The JSON parse happens inside the decode boundary via {@link Schema.parseJson}, rather than a
|
|
72
|
+
// hand-rolled `JSON.parse`: Effect's decoder is safe against prototype pollution (a `__proto__` key
|
|
73
|
+
// is dropped, never assigned, so it cannot rewrite the object's prototype), so no manual key scanning
|
|
74
|
+
// is needed. `onExcessProperty: 'error'` rejects unknown keys on the file-leaf struct, in keeping
|
|
75
|
+
// with the "reject what we cannot interpret" posture. (Records match every key via their index
|
|
76
|
+
// signature, so this only tightens `ManifestFileSchema`.)
|
|
77
|
+
const decodeManifestDocument = Schema.decodeUnknown(Schema.parseJson(ManifestDocumentSchema), {
|
|
78
|
+
errors: 'all',
|
|
79
|
+
onExcessProperty: 'error'
|
|
80
|
+
});
|
|
81
|
+
const isFileNode = (value) => typeof value !== 'string';
|
|
82
|
+
/**
|
|
83
|
+
* Whether a directory or file name is a single path segment safe to join into a relative asset path:
|
|
84
|
+
* non-empty, not a `.`/`..` traversal component, and free of path separators or NUL. `compactc` only
|
|
85
|
+
* ever emits plain names, so anything else is a malformed (or malicious) manifest. Enforcing this
|
|
86
|
+
* keeps every flattened {@link ZKManifest.files} key a simple `"<dir>/<file>"` relative path that a
|
|
87
|
+
* consumer cannot be tricked into resolving outside the assets directory.
|
|
88
|
+
*/
|
|
89
|
+
const isSafeSegment = (segment) => segment.length > 0 &&
|
|
90
|
+
segment !== '.' &&
|
|
91
|
+
segment !== '..' &&
|
|
92
|
+
!segment.includes('/') &&
|
|
93
|
+
!segment.includes('\\') &&
|
|
94
|
+
!segment.includes('\0');
|
|
95
|
+
/**
|
|
96
|
+
* Renders a decode failure for display. {@link TreeFormatter.formatErrorSync} walks the parse-error
|
|
97
|
+
* tree recursively, so a pathologically deep manifest can overflow the call stack here — a thrown
|
|
98
|
+
* `RangeError` would escape as an untyped defect rather than the {@link ZKManifestError.ZKManifestError}
|
|
99
|
+
* this boundary promises. Catching it degrades to a generic message while keeping the failure typed.
|
|
100
|
+
*/
|
|
101
|
+
const formatParseError = (parseError) => {
|
|
102
|
+
try {
|
|
103
|
+
return TreeFormatter.formatErrorSync(parseError);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return 'the manifest structure is invalid';
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Scans raw JSON text for a duplicated object key — the one layer where the ambiguity is still
|
|
111
|
+
* visible. `JSON.parse` (and therefore {@link Schema.parseJson}) silently collapses duplicate keys
|
|
112
|
+
* within an object, keeping the last occurrence; a forged shadow entry with a tampered hash thus
|
|
113
|
+
* overwrites the honest one before any structural check runs. For an integrity manifest that is a
|
|
114
|
+
* classic tampering vector, so duplicates are rejected here, against the raw text, where they can
|
|
115
|
+
* still be seen — a `JSON.parse` reviver runs only *after* the merge and cannot help.
|
|
116
|
+
*
|
|
117
|
+
* The scan is a single iterative pass (no recursion — a pathologically deep manifest cannot overflow
|
|
118
|
+
* the call stack here) that tracks object/array nesting and, per object, the set of keys already
|
|
119
|
+
* seen. It is deliberately total: any input it cannot make sense of yields `undefined`, deferring the
|
|
120
|
+
* canonical syntax error to {@link Schema.parseJson}. Key tokens are decoded via `JSON.parse` so that
|
|
121
|
+
* escape-equivalent spellings (`"a"` and `"a"`) compare equal, matching how `JSON.parse` itself
|
|
122
|
+
* would collapse them.
|
|
123
|
+
*
|
|
124
|
+
* @returns The first duplicated key encountered, or `undefined` if there is none.
|
|
125
|
+
*/
|
|
126
|
+
const findDuplicateKey = (json) => {
|
|
127
|
+
const stack = []; // Set → keys seen in an object frame; null → array frame
|
|
128
|
+
let awaitingKey = false;
|
|
129
|
+
const n = json.length;
|
|
130
|
+
let i = 0;
|
|
131
|
+
while (i < n) {
|
|
132
|
+
const ch = json[i];
|
|
133
|
+
switch (ch) {
|
|
134
|
+
case '{':
|
|
135
|
+
stack.push(new Set());
|
|
136
|
+
awaitingKey = true;
|
|
137
|
+
i++;
|
|
138
|
+
break;
|
|
139
|
+
case '[':
|
|
140
|
+
stack.push(null);
|
|
141
|
+
awaitingKey = false;
|
|
142
|
+
i++;
|
|
143
|
+
break;
|
|
144
|
+
case '}':
|
|
145
|
+
case ']':
|
|
146
|
+
stack.pop();
|
|
147
|
+
awaitingKey = false;
|
|
148
|
+
i++;
|
|
149
|
+
break;
|
|
150
|
+
case ',':
|
|
151
|
+
awaitingKey = stack[stack.length - 1] instanceof Set;
|
|
152
|
+
i++;
|
|
153
|
+
break;
|
|
154
|
+
case ':':
|
|
155
|
+
awaitingKey = false;
|
|
156
|
+
i++;
|
|
157
|
+
break;
|
|
158
|
+
case '"': {
|
|
159
|
+
// Find the closing quote, honouring backslash escapes so a `"` (or a `{`/`}`) inside a string
|
|
160
|
+
// value is never mistaken for structure.
|
|
161
|
+
const start = i++;
|
|
162
|
+
while (i < n && json[i] !== '"') {
|
|
163
|
+
if (json[i] === '\\')
|
|
164
|
+
i++; // skip the escaped character
|
|
165
|
+
i++;
|
|
166
|
+
}
|
|
167
|
+
if (i >= n)
|
|
168
|
+
return undefined; // unterminated string → let Schema.parseJson report it
|
|
169
|
+
i++; // consume the closing quote
|
|
170
|
+
const top = stack[stack.length - 1];
|
|
171
|
+
if (awaitingKey && top instanceof Set) {
|
|
172
|
+
let key;
|
|
173
|
+
try {
|
|
174
|
+
key = JSON.parse(json.slice(start, i)); // decode escapes for a faithful compare
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
if (top.has(key))
|
|
180
|
+
return key;
|
|
181
|
+
top.add(key);
|
|
182
|
+
}
|
|
183
|
+
awaitingKey = false;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
default:
|
|
187
|
+
i++;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return undefined;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Parses and validates the raw JSON contents of a ZK artifact manifest, flattening its
|
|
195
|
+
* directory-nested entries into {@link ZKManifest.files}.
|
|
196
|
+
*
|
|
197
|
+
* The manifest reaches this boundary as untrusted input, so it is decoded with a {@link Schema} —
|
|
198
|
+
* yielding structural validation and a typed failure rather than hand-rolled checks. An unknown or
|
|
199
|
+
* missing {@link SUPPORTED_MANIFEST_VERSION | manifest-version} fails the parse, since a manifest we
|
|
200
|
+
* cannot interpret must not be treated as a passing integrity check.
|
|
201
|
+
*
|
|
202
|
+
* @param rawJson The raw JSON text of the manifest file.
|
|
203
|
+
* @returns An {@link Effect} that yields a {@link ZKManifest}, or fails with a
|
|
204
|
+
* {@link ZKManifestError.ZKManifestError}.
|
|
205
|
+
*
|
|
206
|
+
* @category constructors
|
|
207
|
+
*/
|
|
208
|
+
export const parse = (rawJson) => Effect.suspend(() => {
|
|
209
|
+
// Reject duplicate keys before decoding: `JSON.parse` would have already collapsed them to the
|
|
210
|
+
// last occurrence, letting a forged shadow entry silently overwrite the honest one. This is the
|
|
211
|
+
// only layer where that ambiguity is still visible.
|
|
212
|
+
const duplicateKey = findDuplicateKey(rawJson);
|
|
213
|
+
if (duplicateKey !== undefined) {
|
|
214
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest contains a duplicate key '${duplicateKey}'; an ambiguous manifest cannot be trusted as an integrity check.`));
|
|
215
|
+
}
|
|
216
|
+
return decodeManifestDocument(rawJson).pipe(Effect.mapError((parseError) => ZKManifestError.make(`Invalid ZK artifact manifest: ${formatParseError(parseError)}`, parseError)));
|
|
217
|
+
}).pipe(Effect.flatMap((document) => {
|
|
218
|
+
// Reserved keys must hold strings. Reject a present-but-malformed value (e.g. an object that
|
|
219
|
+
// matched the directory arm of the union) rather than silently coercing it to "absent", which
|
|
220
|
+
// would misreport a malformed `manifest-version` as missing.
|
|
221
|
+
for (const key of RESERVED_KEYS) {
|
|
222
|
+
const value = document[key];
|
|
223
|
+
if (value !== undefined && typeof value !== 'string') {
|
|
224
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest metadata '${key}' must be a string.`));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Safe now that the loop above has rejected any non-string reserved value.
|
|
228
|
+
const readMetadata = (key) => {
|
|
229
|
+
const value = document[key];
|
|
230
|
+
return typeof value === 'string' ? value : undefined;
|
|
231
|
+
};
|
|
232
|
+
// Guard the version up front, before any flattening work: a missing or unsupported version
|
|
233
|
+
// means a manifest we cannot interpret, which must not be treated as a passing integrity check.
|
|
234
|
+
const manifestVersion = readMetadata(MANIFEST_VERSION_KEY);
|
|
235
|
+
if (manifestVersion === undefined) {
|
|
236
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest is missing '${MANIFEST_VERSION_KEY}'.`));
|
|
237
|
+
}
|
|
238
|
+
if (manifestVersion !== SUPPORTED_MANIFEST_VERSION) {
|
|
239
|
+
return Effect.fail(ZKManifestError.make(`Unsupported ZK artifact manifest version '${manifestVersion}'; expected '${SUPPORTED_MANIFEST_VERSION}'.`));
|
|
240
|
+
}
|
|
241
|
+
const files = new Map();
|
|
242
|
+
for (const [key, value] of Object.entries(document)) {
|
|
243
|
+
if (RESERVED_KEYS.has(key))
|
|
244
|
+
continue;
|
|
245
|
+
// Every non-reserved key must be a directory node. A bare string here (e.g. a directory
|
|
246
|
+
// truncated to just its `'directory'` marker) would otherwise contribute no files and let
|
|
247
|
+
// an entire directory's assets pass unverified.
|
|
248
|
+
if (typeof value === 'string') {
|
|
249
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest entry '${key}' must be a directory, not the string '${value}'.`));
|
|
250
|
+
}
|
|
251
|
+
// The directory name is the first segment of every flattened path; reject anything that could
|
|
252
|
+
// escape the assets directory (`..`, path separators) before it is joined.
|
|
253
|
+
if (!isSafeSegment(key)) {
|
|
254
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest directory name '${key}' is not a valid path segment.`));
|
|
255
|
+
}
|
|
256
|
+
// A directory node: collect its file leaves, skipping the `type: 'directory'` marker.
|
|
257
|
+
for (const [fileName, fileNode] of Object.entries(value)) {
|
|
258
|
+
if (!isFileNode(fileNode)) {
|
|
259
|
+
// The only non-file the schema admits is the bare `'directory'` marker, and it is
|
|
260
|
+
// legitimate only as `type: 'directory'`. Any other bare-string leaf (e.g.
|
|
261
|
+
// `"clear.prover": "directory"`) would be silently skipped, dropping that asset's
|
|
262
|
+
// integrity record while the parse still "passes" — the same harm the top-level check above
|
|
263
|
+
// guards, one level down.
|
|
264
|
+
if (fileName === 'type')
|
|
265
|
+
continue;
|
|
266
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest entry '${key}/${fileName}' must be a file, not the string '${fileNode}'.`));
|
|
267
|
+
}
|
|
268
|
+
// The file name is the second segment of the flattened path; same containment check.
|
|
269
|
+
if (!isSafeSegment(fileName)) {
|
|
270
|
+
return Effect.fail(ZKManifestError.make(`ZK artifact manifest file name '${key}/${fileName}' is not a valid path segment.`));
|
|
271
|
+
}
|
|
272
|
+
// With both segments validated as separator-free, and duplicate keys already rejected up
|
|
273
|
+
// front by {@link findDuplicateKey}, each `<dir>/<file>` path is necessarily unique, so no
|
|
274
|
+
// collision check is needed here.
|
|
275
|
+
files.set(`${key}/${fileName}`, { size: fileNode.size, hash: fileNode.hash });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return Effect.succeed({
|
|
279
|
+
manifestVersion: SUPPORTED_MANIFEST_VERSION,
|
|
280
|
+
compilerVersion: readMetadata(COMPILER_VERSION_KEY),
|
|
281
|
+
languageVersion: readMetadata(LANGUAGE_VERSION_KEY),
|
|
282
|
+
runtimeVersion: readMetadata(RUNTIME_VERSION_KEY),
|
|
283
|
+
files
|
|
284
|
+
});
|
|
285
|
+
}));
|
|
286
|
+
//# sourceMappingURL=ZKManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKManifest.js","sourceRoot":"","sources":["../../../src/effect/ZKManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAmB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AAExD,gEAAgE;AAChE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C,oGAAoG;AACpG,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAChD,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C;QACjD,KAAK;KACe,CAAC,CAAC;AAC1B,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import * as Error from '@effect/platform/Error';
|
|
16
|
+
import { hasProperty } from 'effect/Predicate';
|
|
17
|
+
const TypeId = Symbol.for('compact-js/effect/ZKManifestError');
|
|
18
|
+
/**
|
|
19
|
+
* An error that occurred while parsing a ZK artifact manifest.
|
|
20
|
+
*
|
|
21
|
+
* @category errors
|
|
22
|
+
*/
|
|
23
|
+
export class ZKManifestError extends Error.TypeIdError(TypeId, 'ZKManifestError') {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Determines if a value is a ZK manifest error.
|
|
27
|
+
*
|
|
28
|
+
* @param msg The value to check.
|
|
29
|
+
* @returns `true` if `msg` is a {@link ZKManifestError}; `false` otherwise.
|
|
30
|
+
*
|
|
31
|
+
* @category guards
|
|
32
|
+
*/
|
|
33
|
+
export const isManifestError = (msg) => hasProperty(msg, TypeId);
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new {@link ZKManifestError}.
|
|
36
|
+
*
|
|
37
|
+
* @category constructors
|
|
38
|
+
*/
|
|
39
|
+
export const make = (message, cause) => new ZKManifestError({ message, cause });
|
|
40
|
+
//# sourceMappingURL=ZKManifestError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKManifestError.js","sourceRoot":"","sources":["../../../src/effect/ZKManifestError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAG9E;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAK9E;CAAG;AAEL;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAY,EAA0B,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAElG;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAA0D,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAC5F,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The unsuffixed `/effect` entry, which targets whichever era this build is bound to — ledger 9
|
|
17
|
+
* today.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Composed from the two capability levels rather than listing modules directly, so that an
|
|
21
|
+
* era-scoped entry can take only the levels its runtime line supports
|
|
22
|
+
* (midnight-sdk#387/#388):
|
|
23
|
+
*
|
|
24
|
+
* - `eraNeutralSurface` — everything any bound era can provide.
|
|
25
|
+
* - `contractEventsSurface` — contract events, which are era-impossible below ledger 9 (see that
|
|
26
|
+
* module for why) and so are absent from an older era's entry rather than present and failing
|
|
27
|
+
* at run time.
|
|
28
|
+
*
|
|
29
|
+
* The composed surface is identical to what this entry exported before the split;
|
|
30
|
+
* `LedgerEra.test.ts` pins both that equivalence and the split itself. When the bound era
|
|
31
|
+
* advances past a level, drop the corresponding line here — do not re-add modules individually,
|
|
32
|
+
* or the levels stop describing the eras.
|
|
33
|
+
*/
|
|
34
|
+
export * from './internal/contractEventsSurface.js';
|
|
35
|
+
export * from './internal/eraNeutralSurface.js';
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/effect/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { Effect } from 'effect';
|
|
16
|
+
import * as ContractRuntimeError from '../ContractRuntimeError.js';
|
|
17
|
+
/**
|
|
18
|
+
* Wraps a call across a WASM boundary so that a rejection becomes a typed failure rather than a
|
|
19
|
+
* defect.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Both era seams need this, and it lives above both rather than in either. The dependency between
|
|
23
|
+
* the facades runs one way — `Ledger` imports `CompactRuntime` (it is where the two era-paired
|
|
24
|
+
* halves meet), not the reverse — so a wrapper owned by `Ledger` would make `CompactRuntime`'s
|
|
25
|
+
* import of it a cycle. Owning it in `CompactRuntime` would not cycle, but it would route every
|
|
26
|
+
* *ledger* rejection through the runtime facade and make the runtime seam load-bearing for the
|
|
27
|
+
* ledger one, which is the layering the two-seam split exists to avoid. Each facade re-exports it
|
|
28
|
+
* under the name that documents its own package's failure mode — `Ledger.tryConvert` and
|
|
29
|
+
* `CompactRuntime.tryRuntime` — so there is exactly one copy of the boundary handling.
|
|
30
|
+
*
|
|
31
|
+
* Every ledger and compact-runtime binding signals rejection by throwing. A throw evaluated in an
|
|
32
|
+
* `Effect.gen` body (or a bare `Effect.map` callback) is a defect, and a defect escapes the
|
|
33
|
+
* caller's declared error channel: a dApp's `catchAll` over `ContractExecutionError` never sees
|
|
34
|
+
* it, and the CLI — which runs with `disableErrorReporting` — exits non-zero printing nothing at
|
|
35
|
+
* all.
|
|
36
|
+
*
|
|
37
|
+
* `evaluate` is constrained to a synchronous thunk. `Effect.try` does not await, so an `async`
|
|
38
|
+
* thunk would infer `A = Promise<X>`: the effect *succeeds* carrying a pending promise, the
|
|
39
|
+
* rejection never reaches the error channel, and the caller gets an unhandled rejection plus a
|
|
40
|
+
* `Promise` where a value was expected — the very defect this function exists to prevent, arrived
|
|
41
|
+
* at through the wrapper meant to stop it. Use `Effect.tryPromise` for an async boundary call.
|
|
42
|
+
*
|
|
43
|
+
* @param message A message describing the operation, used as the failure's message.
|
|
44
|
+
* @param evaluate A synchronous thunk that performs the boundary call.
|
|
45
|
+
* @returns An `Effect` that yields the result of `evaluate`, failing with a
|
|
46
|
+
* {@link ContractRuntimeError.ContractRuntimeError} if the boundary rejects it.
|
|
47
|
+
*/
|
|
48
|
+
// Deliberately carries no internal-marker JSDoc tag. The builds run with `stripInternal`, and both
|
|
49
|
+
// facades re-export this declaration by reference (`Ledger.tryConvert` is the alias re-exported
|
|
50
|
+
// from `conversions.ts`), so the marker deletes it from the emitted `.d.ts` and leaves those public
|
|
51
|
+
// names pointing at nothing. Privacy comes from `package.json` `exports` blocking
|
|
52
|
+
// `./effect/internal/*` instead, which is a packaging fact rather than a typing one.
|
|
53
|
+
//
|
|
54
|
+
// Note the marker is honoured in *any* leading comment, including a `//` one that only mentions it
|
|
55
|
+
// — which is why this note spells it out rather than naming the tag. `verify-exports` compares the
|
|
56
|
+
// ESM emit's exports against the typings and fails the build if a declaration goes missing.
|
|
57
|
+
export const tryBoundary = (message, evaluate) => Effect.try({
|
|
58
|
+
try: evaluate,
|
|
59
|
+
catch: (err) => ContractRuntimeError.make(message, err)
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundary.js","sourceRoot":"","sources":["../../../../src/effect/internal/boundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,oBAAoB,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,mGAAmG;AACnG,gGAAgG;AAChG,oGAAoG;AACpG,kFAAkF;AAClF,qFAAqF;AACrF,EAAE;AACF,mGAAmG;AACnG,mGAAmG;AACnG,4FAA4F;AAC5F,MAAM,CAAC,MAAM,WAAW,GAG2C,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CACvF,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC;CACxD,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { Effect } from 'effect';
|
|
16
|
+
import * as ContractRuntimeError from '../ContractRuntimeError.js';
|
|
17
|
+
// None of the declarations below carry an internal-marker JSDoc tag, deliberately.
|
|
18
|
+
// `CompiledContract`'s public interface indexes by `TypeId` and holds a `Partial<Context<C>>`, so
|
|
19
|
+
// under `stripInternal` the marker erases them from this module's `.d.ts` while
|
|
20
|
+
// `CompiledContract.d.ts` still names them — typings that only look sound because most consumers
|
|
21
|
+
// build with `skipLibCheck`. Privacy comes from `package.json` `exports` blocking
|
|
22
|
+
// `./effect/internal/*`; `verify-exports` fails the build if the marker comes back. See
|
|
23
|
+
// `internal/boundary.ts` for why this note does not spell the tag out.
|
|
24
|
+
export const TypeId = Symbol();
|
|
25
|
+
export const getContractContext = (compiledContract) => compiledContract[TypeId];
|
|
26
|
+
/**
|
|
27
|
+
* Instantiates the compactc-generated contract class from a {@link CompiledContract}.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* `Effect.try`, not `Effect.sync`, and the declared error channel is load-bearing. The generated
|
|
31
|
+
* constructor **throws** a `CompactError` when the supplied witnesses are missing, misspelled or
|
|
32
|
+
* not functions — an ordinary mistake in a hand-written `contract.config.ts`, not an invariant
|
|
33
|
+
* breach. Under `Effect.sync` that throw became a *defect* on an effect declared `Effect<C>`: it
|
|
34
|
+
* passed `ContractExecutable`'s `ContractExecutionError` channel, passed any consumer's `catchAll`
|
|
35
|
+
* over it, and in the CLI — which runs with `disableErrorReporting` — produced exit 1 with no
|
|
36
|
+
* output at all. The `Effect.mapError` that sat at the call site looked like the guard and could
|
|
37
|
+
* never fire, because it was mapping a `never`.
|
|
38
|
+
*
|
|
39
|
+
* The message names the contract and points at the witnesses, since those are the one part of a
|
|
40
|
+
* `CompiledContract` the caller supplies.
|
|
41
|
+
*/
|
|
42
|
+
export const createContract = (compiledContract) => Effect.try({
|
|
43
|
+
try: () => {
|
|
44
|
+
const context = getContractContext(compiledContract);
|
|
45
|
+
if (!context.ctor)
|
|
46
|
+
throw new Error('the compiled contract carries no constructor');
|
|
47
|
+
return new context.ctor(context.witnesses);
|
|
48
|
+
},
|
|
49
|
+
catch: (err) => ContractRuntimeError.make(`Failed to construct contract '${compiledContract.tag}'; check the witnesses supplied by ` +
|
|
50
|
+
'the contract configuration', err)
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=compactContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compactContext.js","sourceRoot":"","sources":["../../../../src/effect/internal/compactContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAK5C,OAAO,KAAK,oBAAoB,MAAM,4BAA4B,CAAC;AAEnE,mFAAmF;AACnF,kGAAkG;AAClG,gFAAgF;AAChF,iGAAiG;AACjG,kFAAkF;AAClF,wFAAwF;AACxF,uEAAuE;AACvE,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;AAQ/B,MAAM,CAAC,MAAM,kBAAkB,GAEa,CAA6B,gBAAyC,EAAE,EAAE,CACpH,gBAAgB,CAAC,MAAM,CAAyB,CAAC;AAEnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,cAAc,GAEwC,CACjE,gBAAyC,EACzC,EAAE,CACF,MAAM,CAAC,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,EAAE;QACR,MAAM,OAAO,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;QAErD,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACnF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CACb,oBAAoB,CAAC,IAAI,CACvB,iCAAiC,gBAAgB,CAAC,GAAG,qCAAqC;QACxF,4BAA4B,EAC9B,GAAG,CACJ;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The **ledger 9 and later** half of the `/effect` surface: contract events.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Kept separate from `eraNeutralSurface.ts` because contract events are era-impossible below
|
|
20
|
+
* ledger 9, not merely unimplemented there:
|
|
21
|
+
*
|
|
22
|
+
* - compact-runtime 0.16 has no `LogEvent` type and accumulates nothing on its circuit context,
|
|
23
|
+
* so there is no value for these modules to be built on.
|
|
24
|
+
* - The VM-level `log` gather op *does* exist under onchain-runtime-v3, but its payload is a bare
|
|
25
|
+
* `EncodedStateValue`, against onchain-runtime-v4's `{ version, eventType, data }`, and it
|
|
26
|
+
* carries no emitting-contract address. Events on ledger 8 would have to be rebuilt against a
|
|
27
|
+
* different payload, not bound — so these types could not describe them even if a value existed.
|
|
28
|
+
*
|
|
29
|
+
* The gate is **the omission itself**: an era entry that cannot support events does not compose
|
|
30
|
+
* this module, which is what #388 means by a member being absent rather than runtime-failing.
|
|
31
|
+
*
|
|
32
|
+
* It is *not* structural, and an earlier version of this note claimed otherwise — that "every
|
|
33
|
+
* module re-exported here reaches `LogEvent` through the compact-runtime seam, so composing this
|
|
34
|
+
* barrel on an era whose runtime line lacks it fails the build". Composing it on `/v8/effect`
|
|
35
|
+
* compiles cleanly; that was verified rather than assumed. Three of the four modules name no
|
|
36
|
+
* runtime type at all, and the fourth (`ContractLog`) reached the *bound* facade rather than a
|
|
37
|
+
* binding argument — so on an older era the barrel would have compiled and handed back the wrong
|
|
38
|
+
* era's events, which is the opposite of a gate.
|
|
39
|
+
*
|
|
40
|
+
* `CallTreeRuntimeBinding` (`internal/runtime/binding.ts`) is the type-level gate that backs the
|
|
41
|
+
* omission up: `internal/runtime/conformance.ts` asserts 0.21 satisfies it and **0.16 does not**, so
|
|
42
|
+
* a line that cannot accumulate events cannot claim it.
|
|
43
|
+
*
|
|
44
|
+
* These modules are era-free in their own right. `ContractLog` used to take `LogEvent` from the
|
|
45
|
+
* bound facade — which would have made an era-pinned entry's decoder follow `current.ts` — and now
|
|
46
|
+
* reads the structural minimum it decodes, recovering the caller's own event type by inference. So
|
|
47
|
+
* composing this barrel on a later era is correct by construction rather than by coincidence.
|
|
48
|
+
*
|
|
49
|
+
* Internal by design, for the same reasons as its era-neutral sibling — and, like it, without an
|
|
50
|
+
* internal-marker JSDoc tag, which `stripInternal` would apply to the first export below (see
|
|
51
|
+
* `eraFreeSurface.ts`).
|
|
52
|
+
*/
|
|
53
|
+
export * as ContractEventStore from '../ContractEventStore.js';
|
|
54
|
+
export * as ContractEventValidationError from '../ContractEventValidationError.js';
|
|
55
|
+
export * from '../ContractEventValidator.js';
|
|
56
|
+
export * as ContractLog from '../ContractLog.js';
|
|
57
|
+
//# sourceMappingURL=contractEventsSurface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contractEventsSurface.js","sourceRoot":"","sources":["../../../../src/effect/internal/contractEventsSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,4BAA4B,MAAM,oCAAoC,CAAC;AACnF,cAAc,8BAA8B,CAAC;AAC7C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of midnight-sdk.
|
|
3
|
+
* Copyright (C) 2025 Midnight Foundation
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* You may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import * as Internal from '../executable.js';
|
|
16
|
+
import * as Ledger from './v8Ledger.js';
|
|
17
|
+
import * as Runtime from './v8Runtime.js';
|
|
18
|
+
const executable = Internal.makeExecutable(Ledger, Runtime);
|
|
19
|
+
/**
|
|
20
|
+
* Takes a Compact compiled contract, and makes it executable against ledger 8.
|
|
21
|
+
*
|
|
22
|
+
* @category constructors
|
|
23
|
+
*/
|
|
24
|
+
export const make = executable.make;
|
|
25
|
+
/**
|
|
26
|
+
* Provides a layer to the executable contract.
|
|
27
|
+
*
|
|
28
|
+
* @category combinators
|
|
29
|
+
*/
|
|
30
|
+
export const provide = executable.provide;
|
|
31
|
+
//# sourceMappingURL=v8Executable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v8Executable.js","sourceRoot":"","sources":["../../../../../src/effect/internal/era/v8Executable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAkBH,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAK1C,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA0C5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC"}
|