@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,531 @@
|
|
|
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
|
+
* Contract execution, parameterised on an era pair.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* `ContractExecutable.ts` used to *be* this module, written directly against the `Ledger` and
|
|
20
|
+
* `CompactRuntime` facades — which resolve each seam's `current.ts`. That made the executable a
|
|
21
|
+
* singleton bound to whichever era the build happened to bind, and it is the reason `/v8/effect`
|
|
22
|
+
* could offer every other module but not this one: exporting it there would have handed back
|
|
23
|
+
* ledger-9-bound objects from a path named v8 (midnight-sdk#387/#388).
|
|
24
|
+
*
|
|
25
|
+
* The bodies now take both bindings as parameters, the way `internal/ledger/conversions.ts` does,
|
|
26
|
+
* and every era-varying type in the public API is **derived** from those two arguments rather than
|
|
27
|
+
* declared alongside them — see {@link ExecutableTypes}. Deriving matters: a hand-written type
|
|
28
|
+
* surface is a second place to state the era, and the two drift silently. Here, passing
|
|
29
|
+
* `(V8, V0_16)` makes `CallResult.zswapLocalState` the 0.16 zswap state as a consequence of the
|
|
30
|
+
* argument, with nothing to keep in step.
|
|
31
|
+
*
|
|
32
|
+
* Deliberately **above both seams**: this module imports neither facade, so it has no era of its
|
|
33
|
+
* own. The instantiations live in `effect/ContractExecutable.ts` (the bound era) and
|
|
34
|
+
* `internal/era/v{8,9}Executable.ts` (the era-pinned entries).
|
|
35
|
+
*/
|
|
36
|
+
import * as CoinPublicKey from '@midnight-ntwrk/platform-js/effect/CoinPublicKey';
|
|
37
|
+
import * as Configuration from '@midnight-ntwrk/platform-js/effect/Configuration';
|
|
38
|
+
import * as ContractAddress from '@midnight-ntwrk/platform-js/effect/ContractAddress';
|
|
39
|
+
import * as SigningKey from '@midnight-ntwrk/platform-js/effect/SigningKey';
|
|
40
|
+
import { Clock, Effect, Either, Option } from 'effect';
|
|
41
|
+
import { dual, identity } from 'effect/Function';
|
|
42
|
+
import { pipeArguments } from 'effect/Pipeable';
|
|
43
|
+
import * as Contract from '../Contract.js';
|
|
44
|
+
import * as ContractConfigurationError from '../ContractConfigurationError.js';
|
|
45
|
+
import { validateEvents } from '../ContractEventValidator.js';
|
|
46
|
+
import * as ContractRuntimeError from '../ContractRuntimeError.js';
|
|
47
|
+
import { ZKConfiguration } from '../ZKConfiguration.js';
|
|
48
|
+
import { tryBoundary } from './boundary.js';
|
|
49
|
+
import * as CompactContextInternal from './compactContext.js';
|
|
50
|
+
const DEFAULT_CMA_THRESHOLD = 1;
|
|
51
|
+
const DEFAULT_SIGNATURE_INDEX = 0n;
|
|
52
|
+
// The maintenance authority's counter, off whichever era's contract state. Every ledger era
|
|
53
|
+
// compact-js binds exposes it identically (a `bigint` on `contractState.maintenanceAuthority`), and
|
|
54
|
+
// `ExecutableRuntime` keeps the state itself opaque so that a binding's own class type reaches the
|
|
55
|
+
// public API unchanged — so the narrowing lives here, once, instead of at each of its two uses.
|
|
56
|
+
const authorityCounterOf = (contractState) => contractState.maintenanceAuthority.counter;
|
|
57
|
+
/**
|
|
58
|
+
* Builds the contract-execution API for one era pair.
|
|
59
|
+
*
|
|
60
|
+
* @param ledger The era's ledger facade (`internal/era/v8Ledger.ts`, `effect/Ledger.ts`, …).
|
|
61
|
+
* @param runtime The compact-runtime facade that era pairs with.
|
|
62
|
+
*/
|
|
63
|
+
export const makeExecutable = (ledger, runtime) => {
|
|
64
|
+
// Partition the public transcripts of every call in the trace in a single batch.
|
|
65
|
+
//
|
|
66
|
+
// `partitionTranscripts` builds a caller->callee call graph across the whole batch by matching
|
|
67
|
+
// each callee's communication commitment against the commitments its caller claimed, so it must
|
|
68
|
+
// see every call at once (see midnight-ledger `construct.rs::partition_transcripts`). The
|
|
69
|
+
// commitment rides on the *callee's* pre-transcript (`commCommData.commComm`); the root call has
|
|
70
|
+
// no commitment and becomes the graph root. The returned array is in the same order as `trace`.
|
|
71
|
+
const partitionAllTranscripts = (
|
|
72
|
+
// The era-neutral trace-entry type supplied by whichever runtime line is bound. On 0.21 it is
|
|
73
|
+
// the runtime's own `CallProofData`; on 0.16 it is synthesised by that binding's
|
|
74
|
+
// `readExecution` from the flat frame.
|
|
75
|
+
trace, ledgerParameters) => Effect.gen(function* () {
|
|
76
|
+
// Each pre-transcript is built from the *initial* context (whose own commitments arrive with
|
|
77
|
+
// its `block`), then given the *final* context's commitments on top — the set the partitioner
|
|
78
|
+
// matches callers to callees on.
|
|
79
|
+
const preTranscripts = yield* Effect.forEach(trace, (entry) => ledger.fromRuntimeQueryContext(entry.initialQueryContext).pipe(Effect.flatMap((initialContext) => tryBoundary('Unexpected error building call pre-transcript', () => {
|
|
80
|
+
const finalQueryContext = entry.finalQueryContext;
|
|
81
|
+
return new ledger.PreTranscript(Array.from(finalQueryContext.comIndices).reduce((queryContext, comEntry) => queryContext.insertCommitment(...comEntry), initialContext), [...entry.publicTranscript],
|
|
82
|
+
// The commitment itself, not the pair it arrives in: `commCommData` also carries
|
|
83
|
+
// the caller's randomness, which stays private. `undefined` for the root call,
|
|
84
|
+
// which is no one's callee.
|
|
85
|
+
entry.commCommData?.commComm);
|
|
86
|
+
}))));
|
|
87
|
+
const partitioned = yield* tryBoundary('Unexpected error partitioning call transcripts', () => ledger.partitionTranscripts(preTranscripts, (ledgerParameters ?? ledger.LedgerParameters.initialParameters())));
|
|
88
|
+
return partitioned.length === trace.length
|
|
89
|
+
? partitioned
|
|
90
|
+
: yield* ContractRuntimeError.make(`Expected ${trace.length} transcript partition pairs, received: ${partitioned.length}`);
|
|
91
|
+
});
|
|
92
|
+
class ContractExecutableImpl {
|
|
93
|
+
compiledContract;
|
|
94
|
+
transform;
|
|
95
|
+
// Read off the binding this factory was applied to, so `provide`'s rebuilt instance carries the
|
|
96
|
+
// same era without it having to be threaded through the constructor.
|
|
97
|
+
era = ledger.era;
|
|
98
|
+
constructor(compiledContract, transform = identity) {
|
|
99
|
+
this.compiledContract = compiledContract;
|
|
100
|
+
this.transform = transform;
|
|
101
|
+
}
|
|
102
|
+
pipe() {
|
|
103
|
+
return pipeArguments(this, arguments); // eslint-disable-line prefer-rest-params
|
|
104
|
+
}
|
|
105
|
+
initialize(initialPrivateState, ...args) {
|
|
106
|
+
return Effect.all({
|
|
107
|
+
zkConfigReader: ZKConfiguration.pipe(Effect.andThen((zkConfig) => zkConfig.createReader(this.compiledContract))),
|
|
108
|
+
keyConfig: Configuration.Keys,
|
|
109
|
+
contract: this.createContract()
|
|
110
|
+
}).pipe(Effect.flatMap(({ zkConfigReader, keyConfig, contract }) =>
|
|
111
|
+
// Three unrelated operations, each with its own failure. Folded into one `try` they all
|
|
112
|
+
// reported the *first* one's message: a dApp author whose witness has a typo, or who does
|
|
113
|
+
// `throw 'insufficient balance'`, was sent to check their wallet configuration. Only
|
|
114
|
+
// `createConstructorContext` has anything to do with a coin public key.
|
|
115
|
+
Effect.try({
|
|
116
|
+
try: () => runtime.createConstructorContext(initialPrivateState, CoinPublicKey.asHex(keyConfig.coinPublicKey)),
|
|
117
|
+
catch: (err) => ContractConfigurationError.make('Failed to configure constructor context with coin public key', undefined, err)
|
|
118
|
+
}).pipe(
|
|
119
|
+
// Runs the contract's constructor, and with it the user's witnesses. Anything it throws
|
|
120
|
+
// is an initialization failure, whether or not the runtime wrapped it in a
|
|
121
|
+
// `CompactError` — the `instanceof` that used to make that distinction also fails for a
|
|
122
|
+
// legitimate `CompactError` thrown by a second copy of compact-runtime, which is the
|
|
123
|
+
// nested `node_modules` case the era seam exists to surface.
|
|
124
|
+
//
|
|
125
|
+
// Read back as *this executable's* era. `Contract` describes a compiled contract
|
|
126
|
+
// era-free — it has to, since one description must cover every era compact-js binds —
|
|
127
|
+
// so it promises only `currentPrivateState`. The remaining members are era types, and
|
|
128
|
+
// the era that applies is the one whose `createConstructorContext` built the argument:
|
|
129
|
+
// a contract compiled for another line throws `checkRuntimeVersion` when its module is
|
|
130
|
+
// imported, long before this call.
|
|
131
|
+
Effect.flatMap((constructorContext) => Effect.tryPromise({
|
|
132
|
+
// `async` rather than returning the call directly: `Contract.initialState` *settles
|
|
133
|
+
// to* its result, and compactc 0.31.1 generates a synchronous constructor.
|
|
134
|
+
try: async () => (await contract.initialState(constructorContext, ...args)),
|
|
135
|
+
catch: (err) => ContractRuntimeError.make('Failed to initialize contract', err)
|
|
136
|
+
})), Effect.flatMap(({ currentContractState, currentPrivateState, currentZswapLocalState }) =>
|
|
137
|
+
// Decoded through the seam's wrapper rather than inside the callback above, so a
|
|
138
|
+
// rejected zswap local state is not reported as a failed constructor.
|
|
139
|
+
tryBoundary('Failed to decode the zswap local state returned by the contract constructor', () => runtime.decodeZswapLocalState(currentZswapLocalState)).pipe(Effect.map((zswapLocalState) => ({
|
|
140
|
+
contractState: currentContractState,
|
|
141
|
+
privateState: currentPrivateState,
|
|
142
|
+
zswapLocalState
|
|
143
|
+
})))), Effect.flatMap(({ contractState, privateState, zswapLocalState }) => Effect.gen(this, function* () {
|
|
144
|
+
// Add the verifier keys.
|
|
145
|
+
const verifierKeys = yield* zkConfigReader.getVerifierKeys(Contract.getProvableCircuitIds(contract));
|
|
146
|
+
// The era's contract state, as the members used below: every line compact-js binds
|
|
147
|
+
// exposes the same three, and they are reached through one narrowing rather than
|
|
148
|
+
// one per statement.
|
|
149
|
+
const state = contractState;
|
|
150
|
+
for (const [provableCircuitId, verifierKey] of verifierKeys) {
|
|
151
|
+
// If there is no verifier key for this circuit, raise an error.
|
|
152
|
+
if (Option.isNone(verifierKey)) {
|
|
153
|
+
return yield* ContractConfigurationError.make(`Failed to find a verifier key for circuit '${provableCircuitId}'`, contractState);
|
|
154
|
+
}
|
|
155
|
+
// `operation()` crosses the runtime WASM boundary, so it throws on a state built
|
|
156
|
+
// against a second instantiation rather than returning `undefined`. Unguarded in
|
|
157
|
+
// this generator body that throw would be a defect, escaping the declared error
|
|
158
|
+
// channel — the `undefined` check below only covers the circuit-not-found case.
|
|
159
|
+
let operation;
|
|
160
|
+
try {
|
|
161
|
+
operation = state.operation(provableCircuitId);
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
return yield* ContractConfigurationError.make(`Failed to read the operation for circuit '${provableCircuitId}' from the given contract state`, contractState, err);
|
|
165
|
+
}
|
|
166
|
+
if (!operation) {
|
|
167
|
+
return yield* ContractConfigurationError.make(`Circuit '${provableCircuitId}' is undefined for the given contract state`, contractState);
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
operation.verifierKey = verifierKey.value;
|
|
171
|
+
state.setOperation(provableCircuitId, operation);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
return yield* ContractConfigurationError.make(`Failed to configure verifier key for circuit '${provableCircuitId}' for the given contract state`, contractState, err);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const [cma, signingKey] = yield* this.createMaintenanceAuthority(keyConfig.getSigningKey());
|
|
178
|
+
// A runtime WASM setter, and the one that reports `expected instance of
|
|
179
|
+
// ContractMaintenanceAuthority` when the state and the authority come from two
|
|
180
|
+
// copies of the runtime. Guarded for the same reason as `setOperation` above.
|
|
181
|
+
try {
|
|
182
|
+
state.maintenanceAuthority = cma;
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
return yield* ContractConfigurationError.make('Failed to set the maintenance authority on the given contract state', contractState, err);
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
public: {
|
|
189
|
+
contractState
|
|
190
|
+
},
|
|
191
|
+
private: {
|
|
192
|
+
signingKey,
|
|
193
|
+
privateState,
|
|
194
|
+
zswapLocalState
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
})))), this.transform);
|
|
198
|
+
}
|
|
199
|
+
circuit(provableCircuitId, circuitContext, ...args) {
|
|
200
|
+
return Effect.all({
|
|
201
|
+
keyConfig: Configuration.Keys,
|
|
202
|
+
contract: this.createContract(),
|
|
203
|
+
nowMillis: Clock.currentTimeMillis
|
|
204
|
+
}).pipe(Effect.flatMap(({ keyConfig, contract, nowMillis }) => Effect.tryPromise({
|
|
205
|
+
try: async () => {
|
|
206
|
+
// Narrowed to *this executable's* era, for the same reason `initialize` narrows the
|
|
207
|
+
// constructor result: `Contract` describes a circuit era-free (an opaque context in,
|
|
208
|
+
// `{ result }` out), while `readExecution` below reads the line's own results object.
|
|
209
|
+
const circuit = contract.provableCircuits[provableCircuitId];
|
|
210
|
+
if (!circuit) {
|
|
211
|
+
throw new Error(`Circuit ${this.compiledContract.tag}#${provableCircuitId} could not be found.`);
|
|
212
|
+
}
|
|
213
|
+
const zswapLocalState = circuitContext.zswapLocalState
|
|
214
|
+
? runtime.encodeZswapLocalState(circuitContext.zswapLocalState)
|
|
215
|
+
: runtime.emptyZswapLocalState(CoinPublicKey.asHex(keyConfig.coinPublicKey));
|
|
216
|
+
// Both the context build and the result projection go through the runtime seam's
|
|
217
|
+
// execution adapter rather than `createCircuitContext`/`context.callProofDataTrace`
|
|
218
|
+
// directly. The two lines disagree on the argument order, on whether a circuit id is
|
|
219
|
+
// even a parameter, and on where proof data lands; the adapter presents one view of
|
|
220
|
+
// both. `readExecution` is called inside this `try` so an era that cannot honour the
|
|
221
|
+
// request (0.16 given a cross-contract state provider) surfaces through the
|
|
222
|
+
// `ContractRuntimeError` mapping below instead of escaping as a defect.
|
|
223
|
+
const runtimeContext = runtime.createExecutionContext({
|
|
224
|
+
circuitId: provableCircuitId,
|
|
225
|
+
address: circuitContext.address,
|
|
226
|
+
zswapLocalState,
|
|
227
|
+
contractState: circuitContext.contractState,
|
|
228
|
+
privateState: circuitContext.privateState,
|
|
229
|
+
stateProvider: circuitContext.stateProvider,
|
|
230
|
+
moduleProvider: circuitContext.moduleProvider,
|
|
231
|
+
parentBlockHash: circuitContext.parentBlockHash,
|
|
232
|
+
// Seconds, not milliseconds — the unit both lines' `time` parameter takes.
|
|
233
|
+
time: Math.floor(nowMillis / 1_000),
|
|
234
|
+
queryGasLimit: circuitContext.queryGasLimit
|
|
235
|
+
});
|
|
236
|
+
return runtime.readExecution((await circuit(runtimeContext, ...args)));
|
|
237
|
+
},
|
|
238
|
+
catch: identity
|
|
239
|
+
}).pipe(Effect.flatMap((execution) => Effect.gen(function* () {
|
|
240
|
+
// Every call made while executing the circuit, in trace order (callees first, the
|
|
241
|
+
// root call last). For a circuit with no cross-contract calls this has length 1 —
|
|
242
|
+
// which is the only case a ledger 8 build can produce.
|
|
243
|
+
const trace = execution.trace;
|
|
244
|
+
const zswapLocalState = execution.zswapLocalState;
|
|
245
|
+
if (zswapLocalState === undefined) {
|
|
246
|
+
return yield* ContractRuntimeError.make(`Circuit '${provableCircuitId}' returned no zswap local state`);
|
|
247
|
+
}
|
|
248
|
+
// Validate the log events emitted by the VM before surfacing them: they are
|
|
249
|
+
// untrusted VM output and are serialized verbatim for external (indexer/DApp)
|
|
250
|
+
// consumption. A structural failure is funnelled through the `ContractRuntimeError`
|
|
251
|
+
// mapping below. Events are a single execution-wide list, each tagged with the
|
|
252
|
+
// emitting contract's address; a per-call view is a filter over that address (see
|
|
253
|
+
// compact-runtime). On a line that cannot emit events the list is statically empty,
|
|
254
|
+
// so this is a no-op there rather than a capability this module assumes.
|
|
255
|
+
yield* validateEvents(execution.events);
|
|
256
|
+
// Partition all calls' transcripts together (the partitioner needs the whole batch
|
|
257
|
+
// to reconstruct the caller/callee graph).
|
|
258
|
+
const partitioned = yield* partitionAllTranscripts(trace, circuitContext.ledgerParameters);
|
|
259
|
+
const calls = yield* Effect.forEach(trace, (entry, i) => Effect.gen(function* () {
|
|
260
|
+
const partitionedTranscript = partitioned[i];
|
|
261
|
+
if (partitionedTranscript === undefined) {
|
|
262
|
+
// Unreachable: `partitionAllTranscripts` guarantees one partition pair per
|
|
263
|
+
// trace entry. Guarded so the mapping is sound under
|
|
264
|
+
// `noUncheckedIndexedAccess`.
|
|
265
|
+
return yield* ContractRuntimeError.make(`Missing partitioned transcript for call ${i} ('${entry.circuitId}')`);
|
|
266
|
+
}
|
|
267
|
+
// Every read below crosses the WASM boundary: these are wasm-bindgen getters on
|
|
268
|
+
// live `QueryContext`s — `ChargedState.state` compiles to
|
|
269
|
+
// `wasm.chargedstate_state(this.__wbg_ptr)` — so they trap on a freed or foreign
|
|
270
|
+
// pointer rather than returning, and this generator body is inside
|
|
271
|
+
// `Effect.forEach`, where a throw is a defect. (The remaining fields read off
|
|
272
|
+
// `entry` further down are plain-JS trace members and need no wrapper.)
|
|
273
|
+
//
|
|
274
|
+
// **One wrapper per context, not one for all the reads.** The two query contexts
|
|
275
|
+
// are separate objects with separate lifetimes, and the trap message is the same
|
|
276
|
+
// either way — `null pointer passed to rust` names neither. A single wrapper
|
|
277
|
+
// spanning both would leave a caller unable to tell a freed pre-execution
|
|
278
|
+
// context from a freed post-execution one, which are different bugs with
|
|
279
|
+
// different causes. Within one context the reads share a lifetime, so grouping
|
|
280
|
+
// them there hides no distinction.
|
|
281
|
+
//
|
|
282
|
+
// Each context is cast to `PartitionInputs` — the shape `conformance.ts` already
|
|
283
|
+
// asserts every line's `QueryContext` satisfies — rather than to an inline
|
|
284
|
+
// literal, so the members are stated once. The *return* types stay literal
|
|
285
|
+
// because they flatten `state.state`, and because `Types[…]` members are
|
|
286
|
+
// deferred conditionals over the query context: annotating with one would have
|
|
287
|
+
// `tryBoundary`'s own conditional parameter type match on it and infer `A` as
|
|
288
|
+
// the context instead of the value.
|
|
289
|
+
const preExecution = yield* tryBoundary(`Failed to read the pre-execution partition inputs of the call to ` +
|
|
290
|
+
`'${entry.circuitId}' on '${entry.contractAddress}'`, () => {
|
|
291
|
+
const initial = entry.initialQueryContext;
|
|
292
|
+
return { state: initial.state.state, block: initial.block, effects: initial.effects };
|
|
293
|
+
});
|
|
294
|
+
const postExecution = yield* tryBoundary(`Failed to read the post-execution state and partition inputs of the call to ` +
|
|
295
|
+
`'${entry.circuitId}' on '${entry.contractAddress}'`, () => {
|
|
296
|
+
const final = entry.finalQueryContext;
|
|
297
|
+
return { state: final.state.state, comIndices: final.comIndices };
|
|
298
|
+
});
|
|
299
|
+
// Wrapped for the same reason as the root's decode below: a throw here is a
|
|
300
|
+
// defect, not a `ContractExecutionError`.
|
|
301
|
+
const callZswapLocalState = yield* tryBoundary(`Failed to decode the zswap local state of the call to '${entry.circuitId}' ` +
|
|
302
|
+
`on '${entry.contractAddress}'`, () => runtime.decodeZswapLocalState(entry.zswapLocalState));
|
|
303
|
+
return {
|
|
304
|
+
contractAddress: ContractAddress.ContractAddress(entry.contractAddress),
|
|
305
|
+
circuitId: entry.circuitId,
|
|
306
|
+
public: {
|
|
307
|
+
contractState: postExecution.state,
|
|
308
|
+
// Copied because the era-neutral trace exposes a readonly view while the
|
|
309
|
+
// public `ContractCall` field is mutable; narrowing that field would be a
|
|
310
|
+
// breaking type change for consumers.
|
|
311
|
+
publicTranscript: [...entry.publicTranscript],
|
|
312
|
+
partitionedTranscript,
|
|
313
|
+
partitionInputs: {
|
|
314
|
+
state: preExecution.state,
|
|
315
|
+
block: preExecution.block,
|
|
316
|
+
effects: preExecution.effects,
|
|
317
|
+
comIndices: postExecution.comIndices
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
private: {
|
|
321
|
+
input: entry.input,
|
|
322
|
+
output: entry.output,
|
|
323
|
+
privateTranscriptOutputs: [...entry.privateTranscriptOutputs],
|
|
324
|
+
zswapLocalState: callZswapLocalState
|
|
325
|
+
},
|
|
326
|
+
communicationCommitment: Option.fromNullable(entry.commCommData)
|
|
327
|
+
};
|
|
328
|
+
}));
|
|
329
|
+
// Unlike the runtime calls that build the context above, this one runs in the
|
|
330
|
+
// generator body rather than inside `Effect.tryPromise`'s callback, so it needs the
|
|
331
|
+
// seam's wrapper: an unwrapped throw here would be a defect, and the terminating
|
|
332
|
+
// `Effect.mapError` below maps the error channel only. That would make this
|
|
333
|
+
// method's declared `ContractExecutionError` channel unsound for consumers.
|
|
334
|
+
const decodedZswapLocalState = yield* tryBoundary(`Failed to decode the zswap local state returned by circuit '${provableCircuitId}'`, () => runtime.decodeZswapLocalState(zswapLocalState));
|
|
335
|
+
// `result`, `privateState`, and `zswapLocalState` belong to the root contract;
|
|
336
|
+
// `events` is the whole execution's log-event list (each tagged with its emitter).
|
|
337
|
+
return {
|
|
338
|
+
result: execution.result,
|
|
339
|
+
privateState: execution.privateState,
|
|
340
|
+
zswapLocalState: decodedZswapLocalState,
|
|
341
|
+
// Copied rather than narrowing `CallResult.events` to `readonly`: the adapter
|
|
342
|
+
// hands back a readonly view, and changing the public field's mutability would be
|
|
343
|
+
// a breaking type change for consumers. On a line that cannot emit events this is
|
|
344
|
+
// `never[]`, so the copy is of an empty array.
|
|
345
|
+
events: [...execution.events],
|
|
346
|
+
calls,
|
|
347
|
+
gasCosts: execution.gasCosts
|
|
348
|
+
};
|
|
349
|
+
})), Effect.mapError((err) => ContractRuntimeError.make(`Error executing circuit '${provableCircuitId}'`, err)))), this.transform);
|
|
350
|
+
}
|
|
351
|
+
circuitId(id) {
|
|
352
|
+
return Contract.ProvableCircuitId(id);
|
|
353
|
+
}
|
|
354
|
+
getProvableCircuitIds() {
|
|
355
|
+
return Contract.getProvableCircuitIds(Effect.runSync(this.createContract()));
|
|
356
|
+
}
|
|
357
|
+
replaceContractMaintenanceAuthority(newSigningKey, contractContext) {
|
|
358
|
+
return Effect.all({
|
|
359
|
+
keyConfig: Configuration.Keys
|
|
360
|
+
}).pipe(Effect.flatMap(({ keyConfig }) => Effect.gen(this, function* () {
|
|
361
|
+
const { contractState } = contractContext;
|
|
362
|
+
const [cma, signingKey] = yield* this.createMaintenanceAuthority(newSigningKey, contractState);
|
|
363
|
+
const ledger_cma = yield* ledger.fromRuntimeMaintenanceAuthority(cma);
|
|
364
|
+
const update = yield* this.createSignedMaintenanceUpdate(() => {
|
|
365
|
+
return Either.right([new ledger.ReplaceAuthority(ledger_cma)]);
|
|
366
|
+
}, keyConfig, contractContext);
|
|
367
|
+
return {
|
|
368
|
+
...update,
|
|
369
|
+
private: {
|
|
370
|
+
...update.private,
|
|
371
|
+
signingKey // We need to include the new signing key in the result (rather than the current).
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
})), this.transform);
|
|
375
|
+
}
|
|
376
|
+
removeContractOperation(provableCircuitId, contractContext) {
|
|
377
|
+
return Effect.all({
|
|
378
|
+
keyConfig: Configuration.Keys
|
|
379
|
+
}).pipe(Effect.flatMap(({ keyConfig }) => Effect.gen(this, function* () {
|
|
380
|
+
return yield* this.createSignedMaintenanceUpdate(() => {
|
|
381
|
+
return Either.right([
|
|
382
|
+
new ledger.VerifierKeyRemove(provableCircuitId, ledger.makeContractOperationVersion())
|
|
383
|
+
]);
|
|
384
|
+
}, keyConfig, contractContext);
|
|
385
|
+
})), this.transform);
|
|
386
|
+
}
|
|
387
|
+
addOrReplaceContractOperation(provableCircuitId, verifierKey, contractContext) {
|
|
388
|
+
return Effect.all({
|
|
389
|
+
keyConfig: Configuration.Keys
|
|
390
|
+
}).pipe(Effect.flatMap(({ keyConfig }) => Effect.gen(this, function* () {
|
|
391
|
+
return yield* this.createSignedMaintenanceUpdate(() => {
|
|
392
|
+
return Either.right([
|
|
393
|
+
new ledger.VerifierKeyInsert(provableCircuitId, ledger.makeVersionedVerifierKey(verifierKey))
|
|
394
|
+
]);
|
|
395
|
+
}, keyConfig, contractContext);
|
|
396
|
+
})), this.transform);
|
|
397
|
+
}
|
|
398
|
+
createSignedMaintenanceUpdate(createUpdateFn, keyConfig, contractContext) {
|
|
399
|
+
const { address, contractState } = contractContext;
|
|
400
|
+
const currentSigningKey = keyConfig.getSigningKey();
|
|
401
|
+
if (Option.isNone(currentSigningKey)) {
|
|
402
|
+
return Either.left(ContractConfigurationError.make('Signing key required to authorize contract maintenance update', contractState));
|
|
403
|
+
}
|
|
404
|
+
const signingKey = currentSigningKey.value;
|
|
405
|
+
const ledgerSigningKey = ledger.fromPlatformSigningKey(signingKey, contractState);
|
|
406
|
+
if (Either.isLeft(ledgerSigningKey))
|
|
407
|
+
return Either.left(ledgerSigningKey.left);
|
|
408
|
+
// `createUpdateFn` builds ledger `SingleUpdate`s, so it crosses the ledger boundary: a
|
|
409
|
+
// `VerifierKeyInsert` over a key the era rejects throws here. `Contract.VerifierKey` is
|
|
410
|
+
// `Brand.nominal` and validates nothing, so any file a caller reads reaches this line.
|
|
411
|
+
let update;
|
|
412
|
+
try {
|
|
413
|
+
update = createUpdateFn();
|
|
414
|
+
}
|
|
415
|
+
catch (err) {
|
|
416
|
+
return Either.left(ContractConfigurationError.make('Failed to build the contract maintenance update', contractState, err));
|
|
417
|
+
}
|
|
418
|
+
if (Either.isLeft(update))
|
|
419
|
+
return Either.left(update.left);
|
|
420
|
+
// The constructor validates `address` and the updates, and the counter read is a runtime WASM
|
|
421
|
+
// getter — all three reject by throwing.
|
|
422
|
+
let maintenanceUpdate;
|
|
423
|
+
try {
|
|
424
|
+
maintenanceUpdate = new ledger.MaintenanceUpdate(address, update.right, authorityCounterOf(contractState));
|
|
425
|
+
}
|
|
426
|
+
catch (err) {
|
|
427
|
+
return Either.left(ContractConfigurationError.make(`Failed to create a maintenance update for contract '${address}'`, contractState, err));
|
|
428
|
+
}
|
|
429
|
+
// Three WASM operations, three messages. Only the middle one is about key material, and the
|
|
430
|
+
// CLI prints the message first with the cause under a `(cause)` header — so folding all three
|
|
431
|
+
// into one `try` sends a consumer whose real fault is a duplicated ledger dependency
|
|
432
|
+
// (`expected instance of Signature`, `null pointer passed to rust`) off to audit their keys,
|
|
433
|
+
// which is the diagnosis the era seam exists to prevent.
|
|
434
|
+
let dataToSign;
|
|
435
|
+
try {
|
|
436
|
+
dataToSign = maintenanceUpdate.dataToSign;
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
return Either.left(ContractConfigurationError.make(`Failed to read the data to sign from the maintenance update for contract '${address}'`, contractState, err));
|
|
440
|
+
}
|
|
441
|
+
let signature;
|
|
442
|
+
try {
|
|
443
|
+
signature = ledger.signData(ledgerSigningKey.right, dataToSign);
|
|
444
|
+
}
|
|
445
|
+
catch (err) {
|
|
446
|
+
return Either.left(ContractConfigurationError.make(`Failed to sign contract maintenance update with a '${signingKey.tag}' signing key`, contractState, err));
|
|
447
|
+
}
|
|
448
|
+
// Rejects a signature whose scheme the era's authority does not accept — and equally a
|
|
449
|
+
// `Signature` built against a second copy of the ledger package, or an update already
|
|
450
|
+
// consumed.
|
|
451
|
+
try {
|
|
452
|
+
return Either.right({
|
|
453
|
+
public: {
|
|
454
|
+
maintenanceUpdate: maintenanceUpdate.addSignature(DEFAULT_SIGNATURE_INDEX, signature)
|
|
455
|
+
},
|
|
456
|
+
private: {
|
|
457
|
+
signingKey
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
catch (err) {
|
|
462
|
+
return Either.left(ContractConfigurationError.make(`Failed to attach the signature to the maintenance update for contract '${address}'`, contractState, err));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
createMaintenanceAuthority(key, contractState) {
|
|
466
|
+
// `makeSampleSigningKey` crosses the runtime boundary and rejects a scheme the bound line
|
|
467
|
+
// cannot sample. Guarded here rather than in the `try` below, which starts after the key is
|
|
468
|
+
// already needed — an unguarded throw in this `Either`-returning helper is a defect at every
|
|
469
|
+
// caller.
|
|
470
|
+
let signingKey;
|
|
471
|
+
try {
|
|
472
|
+
signingKey = Option.match(key, {
|
|
473
|
+
onSome: identity,
|
|
474
|
+
// Tag the sampled key with the era's scheme too: `SigningKey.make` otherwise defaults the
|
|
475
|
+
// tag to platform-js's own constant, which would label an era's non-schnorr sample as
|
|
476
|
+
// schnorr and sign with the wrong scheme while still passing the allowlist check below.
|
|
477
|
+
// Sampled through the seam's `makeSampleSigningKey`/`signingKeyHex` pair rather than the
|
|
478
|
+
// runtime's own `sampleSigningKey`, because that function is era-varying on both sides:
|
|
479
|
+
// onchain-runtime-v3 takes no argument and returns a bare hex string, v4 takes a scheme
|
|
480
|
+
// and returns `{ tag, value }`. Reading `.value` here would compile against only one line.
|
|
481
|
+
onNone: () => SigningKey.make(runtime.signingKeyHex(runtime.makeSampleSigningKey(ledger.era.defaultCmaSignatureKind)), ledger.era.defaultCmaSignatureKind)
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
catch (err) {
|
|
485
|
+
return Either.left(ContractConfigurationError.make(`Failed to sample a '${ledger.era.defaultCmaSignatureKind}' contract maintenance authority signing key`, contractState, err));
|
|
486
|
+
}
|
|
487
|
+
const ledgerSigningKey = ledger.fromPlatformSigningKey(signingKey, contractState);
|
|
488
|
+
if (Either.isLeft(ledgerSigningKey))
|
|
489
|
+
return Either.left(ledgerSigningKey.left);
|
|
490
|
+
try {
|
|
491
|
+
return Either.right([
|
|
492
|
+
new runtime.ContractMaintenanceAuthority([runtime.signatureVerifyingKey(ledgerSigningKey.right)], DEFAULT_CMA_THRESHOLD, (contractState ? authorityCounterOf(contractState) + 1n : 0n)),
|
|
493
|
+
signingKey
|
|
494
|
+
]);
|
|
495
|
+
}
|
|
496
|
+
catch (err) {
|
|
497
|
+
return Either.left(ContractConfigurationError.make(
|
|
498
|
+
// Scheme and byte length, never the value: this is a *secret* key. The length is what
|
|
499
|
+
// makes the message actionable — the realistic failure here is a key the brand admits
|
|
500
|
+
// (32..=35 bytes) but the ledger rejects, reported as 'Not all bytes read'.
|
|
501
|
+
`Failed to create a signature verifying key for a '${signingKey.tag}' signing key of ` +
|
|
502
|
+
`${signingKey.value.length / 2} bytes`, contractState, err));
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
createContract() {
|
|
506
|
+
// No `mapError` here any more: `createContract` fails with a `ContractRuntimeError` of its
|
|
507
|
+
// own, naming the contract and the witnesses. The mapping that used to sit here could never
|
|
508
|
+
// fire — the channel was `never` — and re-wrapping now would bury that message as a cause
|
|
509
|
+
// under a `String(err)` stringification of itself.
|
|
510
|
+
return (this.contract ??= CompactContextInternal.createContract(this.compiledContract).pipe(Effect.cached, Effect.runSync));
|
|
511
|
+
}
|
|
512
|
+
contract; // Backing property for `createContract`.
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Takes a Compact compiled contract, and makes it executable against this era pair.
|
|
516
|
+
*
|
|
517
|
+
* @param compiledContract A `CompiledContract`.
|
|
518
|
+
* @returns A `ContractExecutable` for `compiledContract`.
|
|
519
|
+
*
|
|
520
|
+
* @category constructors
|
|
521
|
+
*/
|
|
522
|
+
const make = (compiledContract) => new ContractExecutableImpl(compiledContract);
|
|
523
|
+
/**
|
|
524
|
+
* Provides a layer to the executable contract.
|
|
525
|
+
*
|
|
526
|
+
* @category combinators
|
|
527
|
+
*/
|
|
528
|
+
const provide = dual(2, (self, layer) => new ContractExecutableImpl(self.compiledContract, (e) => Effect.provide(e, layer)));
|
|
529
|
+
return { make, provide };
|
|
530
|
+
};
|
|
531
|
+
//# sourceMappingURL=executable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executable.js","sourceRoot":"","sources":["../../../../src/effect/internal/executable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,aAAa,MAAM,kDAAkD,CAAC;AAClF,OAAO,KAAK,aAAa,MAAM,kDAAkD,CAAC;AAClF,OAAO,KAAK,eAAe,MAAM,oDAAoD,CAAC;AACtF,OAAO,KAAK,UAAU,MAAM,+CAA+C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAiB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,0BAA0B,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,oBAAoB,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAkD,MAAM,uB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C;QACO,QAAQ,CAA+D,CAAC,yCAAyC;KAC1H;IAED;;;;;;;OAOG;IACH,MAAM,IAAI,GAE8D,CACtE,gBAAgD,EAChD,EAAE,CAAC,IAAI,sBAAsB,CAAyC,gBAAgB,CAAC,CAAC;IAE1F;;;;OAIG;IACH,MAAM,OAAO,GAUT,IAAI,CACN,CAAC,EACD,CACE,IAA4C,EAC5C,KAA8B,EAC9B,EAAE,CACF,IAAI,sBAAsB,CAAsC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC3F,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CACzB,CACJ,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAW,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export {};
|
|
16
|
+
// The funding classes (`DustActions`, `UnshieldedOffer`) are pinned per era in `conformance.ts`
|
|
17
|
+
// rather than here. Both slots are generic in their markers, so projecting them through `M`
|
|
18
|
+
// widens past the concrete pair `Intent` accepts and the relation stops discriminating — a check
|
|
19
|
+
// that cannot fail is worse than none.
|
|
20
|
+
//# sourceMappingURL=binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../../../../src/effect/internal/ledger/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AA8QD,gGAAgG;AAChG,4FAA4F;AAC5F,iGAAiG;AACjG,uCAAuC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../../../../src/effect/internal/ledger/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|