@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
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright 2025 Midnight Foundation
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
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
|
+
|
package/README.md
CHANGED
|
@@ -1,3 +1,159 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Compact.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Renamed at 4.0.0.** This package was `@midnight-ntwrk/compact-js` and is now
|
|
5
|
+
> `@midnightntwrk/compact-js` — note the missing hyphen — published to npmjs rather than
|
|
6
|
+
> GitHub Packages. Update the dependency and every import, including the one at the top of
|
|
7
|
+
> your `contract.config.ts`. The old name stops at `3.0.2`, and because the two are
|
|
8
|
+
> different packages, using both in one project loads two copies of the library with no
|
|
9
|
+
> warning.
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
|
|
13
|
+
Compact.js provides a Typescript-based execution environment for smart contracts
|
|
14
|
+
compiled with the [Compact](https://docs.midnight.network/develop/reference/compact/) language.
|
|
15
|
+
When a Compact smart contract is compiled with `compactc`, part of the output includes:
|
|
16
|
+
|
|
17
|
+
1. A JavaScript file.
|
|
18
|
+
2. A TypeScript [declaration file](https://www.typescriptlang.org/docs/handbook/2/type-declarations.html).
|
|
19
|
+
|
|
20
|
+
The JavaScript file contains:
|
|
21
|
+
|
|
22
|
+
- The execution logic for each circuit in the source contract,
|
|
23
|
+
- Logic for constructing the contract’s initial state,
|
|
24
|
+
- Utilities for converting on-chain contract state into a JavaScript representation.
|
|
25
|
+
|
|
26
|
+
Compact.js uses this file at run time to execute the circuits. The circuit execution results are
|
|
27
|
+
then used by higher level tools and frameworks (such as Midnight.js) in order to create and submit
|
|
28
|
+
transactions to the Midnight blockchain. At compile time, the types and utilities of Compact.js use
|
|
29
|
+
the TypeScript declaration file and the definitions it contains, to map types that make working with
|
|
30
|
+
the contract and its circuits more convenient, and TypeScript idiomatic.
|
|
31
|
+
|
|
32
|
+
> [!NOTE]
|
|
33
|
+
> The term _runtime_ is often used to describe the JavaScript executable for a contract. This is
|
|
34
|
+
> distinct from the package `@midnight-ntwrk/compact-runtime`, which provides the utilities that each
|
|
35
|
+
> of these JavaScript executables use.
|
|
36
|
+
|
|
37
|
+
## Ledger eras
|
|
38
|
+
|
|
39
|
+
The version suffix on an era-pinned entry names the **ledger era** it targets, not this package's
|
|
40
|
+
own version: `@midnightntwrk/compact-js/v9` (and `/v9/effect`) targets **ledger 9**, and
|
|
41
|
+
`/v8` (with `/v8/effect`) targets **ledger 8**.
|
|
42
|
+
|
|
43
|
+
The bound era is inspectable at run time via `Ledger.era`, from any entry.
|
|
44
|
+
|
|
45
|
+
### What each entry gives you
|
|
46
|
+
|
|
47
|
+
| Entry | Ledger era | compact-runtime | Surface |
|
|
48
|
+
| --- | --- | --- | --- |
|
|
49
|
+
| `.` / `./effect` | the build's bound era (ledger 9 today) | 0.21 | Full |
|
|
50
|
+
| `/v9` / `/v9/effect` | ledger 9 | 0.21 | Full |
|
|
51
|
+
| `/v8` / `/v8/effect` | ledger 8 | 0.16 | `Ledger` and `CompactRuntime` seams only |
|
|
52
|
+
|
|
53
|
+
`/v8/effect` binds ledger 8 directly rather than following the package's bound era, so the two
|
|
54
|
+
era facades can be live in one process.
|
|
55
|
+
|
|
56
|
+
> [!NOTE]
|
|
57
|
+
> `/v9` and the unsuffixed entries still resolve the package's *bound* era. They agree today
|
|
58
|
+
> because that era is ledger 9; when it advances, `/v9` must be repointed at a pinned ledger 9
|
|
59
|
+
> binding the way `/v8` is pinned now.
|
|
60
|
+
|
|
61
|
+
### Running both eras in one process
|
|
62
|
+
|
|
63
|
+
This works, and it is mostly not a compact-js concern — which is the important thing to understand
|
|
64
|
+
before designing around it.
|
|
65
|
+
|
|
66
|
+
Every contract `compactc` emits begins with the same two lines, differing only in the version:
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
|
|
70
|
+
__compactRuntime.checkRuntimeVersion('0.16.0');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
That is a **bare specifier in generated code**, and `checkRuntimeVersion` refuses any other minor
|
|
74
|
+
version. So a contract's era is decided by *how that specifier resolves where the contract file
|
|
75
|
+
lives* — not by which compact-js entry your application imported. Importing `/v8/effect` cannot
|
|
76
|
+
change it, because an entry point has no reach into generated code's imports.
|
|
77
|
+
|
|
78
|
+
The pattern, therefore: give each era's contracts a **resolution scope** whose
|
|
79
|
+
`@midnight-ntwrk/compact-runtime` is that era's line. Any of these does it:
|
|
80
|
+
|
|
81
|
+
- a nested `node_modules` beside that era's artifacts (Node resolves bare specifiers by walking up
|
|
82
|
+
from the importing file);
|
|
83
|
+
- a bundler alias scoped to that directory;
|
|
84
|
+
- a separate workspace or package per era, each pinning its own runtime.
|
|
85
|
+
|
|
86
|
+
Pin `@midnightntwrk/compact-js` the same way in that scope if you want the full executable surface
|
|
87
|
+
for that era, rather than just the seams `/v8/effect` gives you.
|
|
88
|
+
|
|
89
|
+
Two things are easy to get wrong:
|
|
90
|
+
|
|
91
|
+
- **Copy the artifacts into the scope; do not symlink them.** Node resolves a module to its real
|
|
92
|
+
path before resolving *its* imports, so a symlinked artifact resolves its runtime from the
|
|
93
|
+
original location and fails the version check.
|
|
94
|
+
- **The scope needs its own `package.json` with `"type": "module"`**, or the emitted ESM is parsed
|
|
95
|
+
as CommonJS.
|
|
96
|
+
|
|
97
|
+
A scope is additive — it redirects only what resolves from inside it, leaving your application's own
|
|
98
|
+
runtime untouched. `test/effect/DualEraResolution.test.ts` builds one and executes an era 8 and an
|
|
99
|
+
era 9 circuit in the same process; read it as the executable version of this section.
|
|
100
|
+
|
|
101
|
+
### Ledger 8 limitations
|
|
102
|
+
|
|
103
|
+
Two kinds, worth keeping apart.
|
|
104
|
+
|
|
105
|
+
**Era-impossible — these will never exist on ledger 8.** Contract events and cross-contract calls.
|
|
106
|
+
onchain-runtime-v3's `log` payload carries no emitting-contract address or versioning and nothing
|
|
107
|
+
accumulates them, and there is no `crossContractCall` at all. `createExecutionContext` *rejects* a
|
|
108
|
+
cross-contract state provider rather than ignoring it.
|
|
109
|
+
|
|
110
|
+
**Scope-pinned rather than entry-pinned.** `ContractExecutable`, `CompiledContract` and the
|
|
111
|
+
configuration services are not exported from `/v8/effect`. They resolve the `Ledger` and
|
|
112
|
+
`CompactRuntime` facades by module path, so they follow the package's bound era, and exporting them
|
|
113
|
+
under `/v8` would hand back ledger-9-bound objects from a path named v8.
|
|
114
|
+
|
|
115
|
+
This is deliberate rather than a gap. Executing a ledger 8 contract already requires a ledger 8
|
|
116
|
+
resolution scope — see the section above, it is forced by the generated artifact — and inside that
|
|
117
|
+
scope compact-js is pinned to ledger 8 too, so the executable is era-correct with no extra
|
|
118
|
+
machinery. `/v8/effect` covers what is useful *without* a dedicated scope: decoding and converting
|
|
119
|
+
ledger 8 state alongside ledger 9, in one process, which is what cross-era history reads need.
|
|
120
|
+
|
|
121
|
+
Ledger 8 execution itself is verified: the suite compiles `counter.compact` with compactc 0.31.1 and
|
|
122
|
+
runs a circuit on the 0.16 line.
|
|
123
|
+
|
|
124
|
+
## Contract log events
|
|
125
|
+
|
|
126
|
+
Contracts emit typed log events via the Compact `emit` expression. Each circuit result
|
|
127
|
+
carries the raw events for the whole call tree on `result.events`, each tagged with its emitting
|
|
128
|
+
contract's `address`.
|
|
129
|
+
|
|
130
|
+
- **`ContractLog`** decodes raw events into typed, discriminated `ContractEvent`s. Decoding
|
|
131
|
+
**never throws**: an oversized, malformed, or dropped payload degrades gracefully
|
|
132
|
+
(`degraded: true`) rather than failing the batch.
|
|
133
|
+
- **`ContractEventStore`** is an in-process accumulator over decoded events. It assigns a monotonic
|
|
134
|
+
`id` on `append`, supports `query` with a MIP-aligned filter (contract address, event type,
|
|
135
|
+
indexed-field hex prefixes, resume cursor), and a live, resumable `subscribe` stream that replays
|
|
136
|
+
matching history then tails new events.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { ContractEventStore, ContractLog } from '@midnightntwrk/compact-js/effect';
|
|
140
|
+
import { Effect, Stream } from 'effect';
|
|
141
|
+
|
|
142
|
+
const program = Effect.gen(function* () {
|
|
143
|
+
const store = yield* ContractEventStore.ContractEventStore;
|
|
144
|
+
|
|
145
|
+
// Decode a circuit result's raw events and accumulate them.
|
|
146
|
+
const result = yield* contract.circuit(circuitId, ctx, ...args);
|
|
147
|
+
yield* store.append(ContractLog.decodeAll(result.events));
|
|
148
|
+
|
|
149
|
+
// Query accumulated events with a MIP-aligned filter.
|
|
150
|
+
const mints = yield* store.query({ eventType: 'unshielded-mint' });
|
|
151
|
+
|
|
152
|
+
// Or subscribe to a live, resumable feed (replay from a cursor, then tail).
|
|
153
|
+
yield* store
|
|
154
|
+
.subscribe({ eventType: 'unshielded-mint', fromId: 1n })
|
|
155
|
+
.pipe(Stream.runForEach((event) => Effect.log(event.id)));
|
|
156
|
+
|
|
157
|
+
return mints;
|
|
158
|
+
}).pipe(Effect.provide(ContractEventStore.layer));
|
|
159
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Contract } from './Contract.js';
|
|
2
|
+
/**
|
|
3
|
+
* Witness configuration.
|
|
4
|
+
*/
|
|
5
|
+
export type Witnesses<in C extends Contract.Any, W = Contract.Witnesses<C>> = {
|
|
6
|
+
/**
|
|
7
|
+
* An implementation of the witnesses of `C`.
|
|
8
|
+
*/
|
|
9
|
+
readonly witnesses: W;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Compiled asset path configuration.
|
|
13
|
+
*/
|
|
14
|
+
export type CompiledAssetsPath = {
|
|
15
|
+
/**
|
|
16
|
+
* A path to the compiled assets produced by the Compact compiler.
|
|
17
|
+
*/
|
|
18
|
+
readonly compiledAssetsPath: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=CompactContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompactContext.d.ts","sourceRoot":"","sources":["../../../src/effect/CompactContext.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;IAC5E;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compact-runtime seam.
|
|
3
|
+
*
|
|
4
|
+
* All `@midnight-ntwrk/compact-runtime` types and functions used by compact-js (and its sibling
|
|
5
|
+
* packages) are reached through this module rather than the package directly. The concrete line is
|
|
6
|
+
* bound in `internal/runtime/current.ts`. The facade re-exports a curated list of runtime names: if
|
|
7
|
+
* one you need is missing, widen the binding (`internal/runtime/v0_21.ts`) rather than importing
|
|
8
|
+
* the package around the seam. Tests may import it directly where they must compare module
|
|
9
|
+
* identity.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This is the twin of the {@link Ledger} seam, and exists for the same reason: the compact-runtime
|
|
13
|
+
* line is era-paired with the ledger (0.21 with ledger 9, over onchain-runtime-v4), so a build that
|
|
14
|
+
* targets a different ledger era needs a different runtime line too. Routing every call site
|
|
15
|
+
* through one module is what lets an era-scoped entry rebind both by editing two `current.ts`
|
|
16
|
+
* files, instead of hunting nine import sites across three packages (midnight-sdk#387/#388).
|
|
17
|
+
*
|
|
18
|
+
* Like the ledger seam, this is deliberately a module rather than an injected service: which
|
|
19
|
+
* runtime line a build speaks is a packaging-level fact — one line per build artifact — not a
|
|
20
|
+
* runtime dependency to vary per effect. Downstream multi-era consumers select between era-scoped
|
|
21
|
+
* entries instead.
|
|
22
|
+
*
|
|
23
|
+
* Sibling packages (`compact-js-node`, `compact-js-command`) reach the runtime *through* this
|
|
24
|
+
* facade, so a swap here reaches them too and they cannot drift onto a second copy of the WASM.
|
|
25
|
+
* Each pins compact-runtime only as a `devDependency`, for its own tests; that pin and this
|
|
26
|
+
* package's `dependencies` entry must stay in lockstep (`RuntimeIdentity.test.ts` states the same
|
|
27
|
+
* rule, and is what catches them diverging).
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { CompactRuntime } from '@midnightntwrk/compact-js/effect';
|
|
32
|
+
* import { Effect } from 'effect';
|
|
33
|
+
*
|
|
34
|
+
* // Through the wrapper, not bare: the facade resolves the binding, it does not make the call
|
|
35
|
+
* // safe — see `tryRuntime`.
|
|
36
|
+
* const program = Effect.gen(function* () {
|
|
37
|
+
* const encoded = yield* CompactRuntime.tryRuntime(
|
|
38
|
+
* 'Failed to encode the zswap local state',
|
|
39
|
+
* () => CompactRuntime.encodeZswapLocalState(zswapLocalState)
|
|
40
|
+
* );
|
|
41
|
+
* return encoded;
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import { type Effect } from 'effect';
|
|
46
|
+
import type * as ContractRuntimeError from './ContractRuntimeError.js';
|
|
47
|
+
export { type RuntimeLine } from './internal/era.js';
|
|
48
|
+
export * from './internal/runtime/current.js';
|
|
49
|
+
/**
|
|
50
|
+
* Wraps a call across the compact-runtime (WASM) boundary so that a rejection becomes a typed
|
|
51
|
+
* failure rather than a defect.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Routing a call through this facade makes it *look* protected without making it so: the seam only
|
|
55
|
+
* changes where the binding is resolved, and compact-runtime still signals rejection by throwing.
|
|
56
|
+
* A throw evaluated in an `Effect.gen` body is a defect, which escapes the caller's declared error
|
|
57
|
+
* channel — `ContractExecutable.circuit`'s `ContractExecutionError` becomes unsound at that point,
|
|
58
|
+
* and the CLI (which runs with `disableErrorReporting`) exits non-zero printing nothing at all.
|
|
59
|
+
* Every runtime call is held in the error channel one of three ways: inside an
|
|
60
|
+
* `Effect.try`/`Effect.tryPromise` callback, through this wrapper, or — in `ContractExecutable`'s
|
|
61
|
+
* synchronous `Either`-returning maintenance helpers, which have no `Effect` to wrap — inside a
|
|
62
|
+
* plain `try`/`catch` yielding a `ContractConfigurationError`. Reach for this one by default; the
|
|
63
|
+
* third applies only where the surrounding function is not an `Effect`.
|
|
64
|
+
*
|
|
65
|
+
* This is the ledger seam's {@link Ledger.tryConvert} under the name the runtime side knows it by
|
|
66
|
+
* — one copy of the boundary handling, shared (see `internal/boundary.ts` for why it lives above
|
|
67
|
+
* both facades rather than in either).
|
|
68
|
+
*
|
|
69
|
+
* @param message A message describing the operation, used as the failure's message.
|
|
70
|
+
* @param evaluate A thunk that performs the runtime call.
|
|
71
|
+
* @returns An `Effect` that yields the result of `evaluate`, failing with a
|
|
72
|
+
* {@link ContractRuntimeError.ContractRuntimeError} if the runtime rejects it.
|
|
73
|
+
* @category combinators
|
|
74
|
+
*/
|
|
75
|
+
export declare const tryRuntime: <A>(message: string, evaluate: () => A extends PromiseLike<unknown> ? never : A) => Effect.Effect<A, ContractRuntimeError.ContractRuntimeError>;
|
|
76
|
+
//# sourceMappingURL=CompactRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompactRuntime.d.ts","sourceRoot":"","sources":["../../../src/effect/CompactRuntime.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,cAAc,+BAA+B,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EACzB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,KACvD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,oBAAoB,CAAC,oBAAoB,CAAwB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Types } from 'effect';
|
|
2
|
+
import { type Pipeable } from 'effect/Pipeable';
|
|
3
|
+
import type * as CompactContext from './CompactContext.js';
|
|
4
|
+
import type { Contract } from './Contract.js';
|
|
5
|
+
import * as CompactContextInternal from './internal/compactContext.js';
|
|
6
|
+
export declare const TypeId: unique symbol;
|
|
7
|
+
export type TypeId = typeof TypeId;
|
|
8
|
+
/**
|
|
9
|
+
* A binding to a Compact compiled contract.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Alongside the imported type and contract instance, we also need to provide an implementation of the
|
|
13
|
+
* witnesses that the contract expects, along with a mechanism to retrieve the compiled ZK assets associated
|
|
14
|
+
* with the compiled contract. A {@link CompiledContract} represents such a container within a hosting
|
|
15
|
+
* TypeScript program. In order to make a contract executable, you should use the `ContractExecutable` module.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link getContext} to retrieve the publicly visible properties associated with the compiled contract.
|
|
18
|
+
*/
|
|
19
|
+
export interface CompiledContract<in out C extends Contract<PS>, in out PS, out R = never> extends CompiledContract.Variance<C, PS, R>, Pipeable {
|
|
20
|
+
/**
|
|
21
|
+
* Gets the tag assigned to this compiled contract.
|
|
22
|
+
*/
|
|
23
|
+
readonly tag: string;
|
|
24
|
+
readonly [CompactContextInternal.TypeId]: Partial<CompactContextInternal.Context<C>>;
|
|
25
|
+
}
|
|
26
|
+
export declare namespace CompiledContract {
|
|
27
|
+
type Variance<in out C, in out PS, out R> = {
|
|
28
|
+
readonly [TypeId]: {
|
|
29
|
+
readonly _C: Types.Invariant<C>;
|
|
30
|
+
readonly _PS: Types.Invariant<PS>;
|
|
31
|
+
readonly _R: Types.Covariant<R>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The context required to fully build a {@link CompiledContract}.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* When looking to use a Compact compiled contract in a TypeScript program, we need to provide path
|
|
39
|
+
* information to where the generated ZK assets can be found, along with an implementation of the witnesses
|
|
40
|
+
* expected by the contract.
|
|
41
|
+
*/
|
|
42
|
+
type Context<C extends Contract.Any> = CompactContext.Witnesses<C> | CompactContext.CompiledAssetsPath;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Initializes an object that represents a binding to a Compact compiled contract.
|
|
46
|
+
*
|
|
47
|
+
* @param tag A unique identifier that represents this type of contract.
|
|
48
|
+
* @param ctor The contract constructor, as imported from the compiled Compact output.
|
|
49
|
+
* @returns A {@link CompiledContract}.
|
|
50
|
+
*
|
|
51
|
+
* @category constructors
|
|
52
|
+
*/
|
|
53
|
+
export declare const make: <C extends Contract<PS>, PS = Contract.PrivateState<C>, R = CompiledContract.Context<C>>(tag: string, ctor: Types.Ctor<C>) => CompiledContract<C, PS, R>;
|
|
54
|
+
/**
|
|
55
|
+
* Associates an object that implements the contract witnesses for the Compact compiled contract.
|
|
56
|
+
*
|
|
57
|
+
* @category combinators
|
|
58
|
+
*/
|
|
59
|
+
export declare const withWitnesses: {
|
|
60
|
+
/**
|
|
61
|
+
* @param witnesses An object implementing the witness functions required by the Compact compiled contract.
|
|
62
|
+
* @returns A function that receives the {@link CompiledContract} that `witnesses` will be attached to.
|
|
63
|
+
*/
|
|
64
|
+
<C extends Contract<PS>, PS, R>(witnesses: R extends CompactContext.Witnesses<C, infer W> ? W : never): (self: CompiledContract<C, PS, R>) => CompiledContract<C, PS, Exclude<R, CompactContext.Witnesses<C>>>;
|
|
65
|
+
/**
|
|
66
|
+
* @param self The {@link CompiledContract} that `witnesses` will be attached to.
|
|
67
|
+
* @param witnesses An object implementing the witness functions required by the Compact compiled contract.
|
|
68
|
+
*/
|
|
69
|
+
<C extends Contract<PS>, PS, R>(self: CompiledContract<C, PS, R>, witnesses: R extends CompactContext.Witnesses<C, infer W> ? W : never): CompiledContract<C, PS, Exclude<R, CompactContext.Witnesses<C>>>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Associates _vacant_ witnesses with a Compact compiled contract that specifies no witnesses.
|
|
73
|
+
*
|
|
74
|
+
* @param self The {@link CompiledContract} for which no witnesses are required.
|
|
75
|
+
*
|
|
76
|
+
* @category combinators
|
|
77
|
+
*/
|
|
78
|
+
export declare const withVacantWitnesses: <C extends Contract<PS>, PS, R>(self: CompiledContract<C, PS, R>) => CompiledContract<C, PS, Exclude<R, CompactContext.Witnesses<C>>>;
|
|
79
|
+
/**
|
|
80
|
+
* Associates a file path of where to find the compiled assets for the Compact compiled contract.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Relative file paths will be resolved relative to the base paths provided to each service that accesses
|
|
84
|
+
* the compiled file assets.
|
|
85
|
+
*
|
|
86
|
+
* @category combinators
|
|
87
|
+
*/
|
|
88
|
+
export declare const withCompiledFileAssets: {
|
|
89
|
+
/**
|
|
90
|
+
* @param compiledAssetsPath The file path.
|
|
91
|
+
* @returns A function that receives the {@link CompiledContract} that `compiledAssetsPath` will be attached to.
|
|
92
|
+
*/
|
|
93
|
+
<C extends Contract<PS>, PS, R>(compiledAssetsPath: R extends CompactContext.CompiledAssetsPath ? string : never): (self: CompiledContract<C, PS, R>) => CompiledContract<C, PS, Exclude<R, CompactContext.CompiledAssetsPath>>;
|
|
94
|
+
/**
|
|
95
|
+
* @param self The {@link CompiledContract} that `compiledAssetsPath` will be attached to.
|
|
96
|
+
* @param compiledAssetsPath The file path.
|
|
97
|
+
*/
|
|
98
|
+
<C extends Contract<PS>, PS, R>(self: CompiledContract<C, PS, R>, compiledAssetsPath: R extends CompactContext.CompiledAssetsPath ? string : never): CompiledContract<C, PS, Exclude<R, CompactContext.CompiledAssetsPath>>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves a path to file based assets associated with a compiled contract.
|
|
102
|
+
*
|
|
103
|
+
* @param self The {@link CompiledContract} from which the assets path should be retrieved.
|
|
104
|
+
* @returns A string representing a path to the file assets configured for `self`.
|
|
105
|
+
*/
|
|
106
|
+
export declare const getCompiledAssetsPath: <C extends Contract<PS>, PS>(self: CompiledContract<C, PS>) => string;
|
|
107
|
+
//# sourceMappingURL=CompiledContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompiledContract.d.ts","sourceRoot":"","sources":["../../../src/effect/CompiledContract.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,sBAAsB,MAAM,8BAA8B,CAAC;AAEvE,eAAO,MAAM,MAAM,eAA4C,CAAC;AAChE,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,CACvF,SAAQ,gBAAgB,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ;IACrD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,OAAO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AE,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChH;;;OAGG;IACH,CAAC,CAAC,SAAS,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAC5B,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAChC,kBAAkB,EAAE,CAAC,SAAS,cAAc,CAAC,kBAAkB,GAAG,MAAM,GAAG,KAAK,GAC/E,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAe3E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,SAAS,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,MAIhG,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides types and utilities for working directly with Compact generated contract executables.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Brand } from 'effect';
|
|
7
|
+
/**
|
|
8
|
+
* The context a Compact witness receives.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Declared here rather than re-exported from the {@link CompactRuntime} seam, and stated exactly:
|
|
12
|
+
* compact-runtime 0.16 and 0.21 declare this identically (`ContractAddress` is `string` on both
|
|
13
|
+
* onchain-runtime majors), so naming the shape costs no precision and keeps this module off the
|
|
14
|
+
* seam — see the note on {@link Contract}.
|
|
15
|
+
*/
|
|
16
|
+
export interface WitnessContext<L, PS> {
|
|
17
|
+
readonly ledger: L;
|
|
18
|
+
readonly privateState: PS;
|
|
19
|
+
readonly contractAddress: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The context a Compact circuit receives — deliberately opaque.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* This is the one shape that genuinely differs between runtime lines: 0.16 passes a flat, single
|
|
26
|
+
* contract frame (`currentPrivateState`, `currentQueryContext`, `currentZswapLocalState`) and 0.21
|
|
27
|
+
* passes a call tree (`callContext`, `queryContexts`, `callProofDataTrace`, `events`). Beyond
|
|
28
|
+
* `costModel` and `gasLimit` they have nothing in common, so neither is assignable to the other and
|
|
29
|
+
* naming either one pins the spine to an era.
|
|
30
|
+
*
|
|
31
|
+
* It is a *parameter* type, so `any` rather than `unknown`: parameters are contravariant, and a
|
|
32
|
+
* circuit that accepts its own line's context must remain assignable to this signature. `unknown`
|
|
33
|
+
* would reject every real contract. Nothing in compact-js reads a circuit context through this
|
|
34
|
+
* type — the executable builds one through its era's `createExecutionContext` and hands it straight
|
|
35
|
+
* back to the circuit — so the looseness is confined to the description of a value this package
|
|
36
|
+
* only ever passes through.
|
|
37
|
+
*/
|
|
38
|
+
export type CircuitContext = any;
|
|
39
|
+
/**
|
|
40
|
+
* What a Compact circuit resolves to, as much of it as is era-free.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* A *return* type, so it is stated as the structural minimum both lines satisfy rather than as
|
|
44
|
+
* `any`: `result` is the value callers actually want, and returning it is what makes
|
|
45
|
+
* {@link Contract.CircuitReturnType} work on either era. The rest of the era's results object
|
|
46
|
+
* (0.16's `proofData`, both lines' `context` and `gasCost`) is intentionally not described here —
|
|
47
|
+
* it is read by the era's `readExecution`, which is typed against the binding that produced it.
|
|
48
|
+
*/
|
|
49
|
+
export interface CircuitResults<U> {
|
|
50
|
+
readonly result: U;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What a Compact contract's constructor resolves to, as much of it as is era-free.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* `currentPrivateState` is named because it is the only anchor that keeps `PS` inferable from a
|
|
57
|
+
* contract with no witnesses; the contract state and Zswap local state it sits beside are era
|
|
58
|
+
* types, so they are left to the executable's binding.
|
|
59
|
+
*/
|
|
60
|
+
export interface ConstructorResult<PS> {
|
|
61
|
+
readonly currentPrivateState: PS;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A value, or a promise of one.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* The second thing about a compiled contract that varies by era, alongside the circuit context.
|
|
68
|
+
* compactc 0.31.1 (Compact 0.23, the ledger 8 / runtime 0.16 pairing) generates **synchronous**
|
|
69
|
+
* circuits and `initialState`; 0.34 generates `Promise`-returning ones. Diff the `Contract` classes
|
|
70
|
+
* in the two `.d.ts` files a single `counter.compact` produces —
|
|
71
|
+
* `test/contract/managed-v8/counter/contract/index.d.ts` against
|
|
72
|
+
* `test/contract/managed/counter/contract/index.d.ts` — and that is the entire difference.
|
|
73
|
+
*
|
|
74
|
+
* So the spine says "settles to", not "resolves to". Naming `Promise` here is what previously kept
|
|
75
|
+
* a real ledger 8 artifact from satisfying `Contract<PS>` at all — `Witnesses<C>` collapsed to
|
|
76
|
+
* `never` and `CompiledContract.make` was uncallable — even after the era-varying *types* were
|
|
77
|
+
* removed. Reading a result through the union costs nothing: everything in compact-js that calls a
|
|
78
|
+
* circuit or the constructor already `await`s it, and `await` on a non-promise is the value.
|
|
79
|
+
*/
|
|
80
|
+
export type Awaitable<A> = A | Promise<A>;
|
|
81
|
+
export type Witness<PS, U = any> = (context: WitnessContext<U, PS>, ...args: any[]) => [PS, U];
|
|
82
|
+
export type Witnesses<PS> = Record<string, Witness<PS>>;
|
|
83
|
+
export type Circuit<U = any> = (context: CircuitContext, ...args: any[]) => Awaitable<CircuitResults<U>>;
|
|
84
|
+
export type Circuits = Record<string, Circuit>;
|
|
85
|
+
export type ProvableCircuit<U = any> = (context: CircuitContext, ...args: any[]) => Awaitable<CircuitResults<U>>;
|
|
86
|
+
export type ProvableCircuits = Record<string, ProvableCircuit>;
|
|
87
|
+
export type VerifierKey = Uint8Array & Brand.Brand<'VerifierKey'>;
|
|
88
|
+
export declare const VerifierKey: Brand.Brand.Constructor<VerifierKey>;
|
|
89
|
+
export type ZKIR = Uint8Array & Brand.Brand<'ZKIR'>;
|
|
90
|
+
export declare const ZKIR: Brand.Brand.Constructor<ZKIR>;
|
|
91
|
+
/**
|
|
92
|
+
* A circuit id, branded, optionally narrowed to the one circuit it names. `K` is constrained
|
|
93
|
+
* because {@link Contract.CircuitParameters} and {@link Contract.CircuitReturnType} index by it —
|
|
94
|
+
* left open, a mistyped name is well-formed here and fails only downstream. The brand tag omits
|
|
95
|
+
* `C`: it marks circuit ids, not which contract they came from.
|
|
96
|
+
*/
|
|
97
|
+
export type ProvableCircuitId<C extends Contract.Any = Contract.Any, K extends Contract.ProvableCircuitId<C> = Contract.ProvableCircuitId<C>> = K & Brand.Brand<'ProvableCircuitId'>;
|
|
98
|
+
/**
|
|
99
|
+
* Brands a circuit id, optionally narrowed to the single circuit it names.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* `K` is second and defaulted so a call site can name `C` alone. TypeScript has no *partial*
|
|
103
|
+
* type-argument inference, so naming `C` fixes `K` to its default — the union of every circuit `C`
|
|
104
|
+
* declares, which rejects arguments no circuit takes but still accepts one circuit's for another.
|
|
105
|
+
* Naming both narrows to the one literal. Naming neither — what the CLI does, from a `string`
|
|
106
|
+
* variable — leaves `C` at `Contract.Any` and brands the id over `string`.
|
|
107
|
+
*/
|
|
108
|
+
export declare const ProvableCircuitId: <C extends Contract.Any, K extends Contract.ProvableCircuitId<C> = Contract.ProvableCircuitId<C>>(id: K) => ProvableCircuitId<C, K>;
|
|
109
|
+
/**
|
|
110
|
+
* The shape of a contract executable, as `compactc` generates it.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* Stated **era-free**: nothing in this module reaches the {@link CompactRuntime} or {@link Ledger}
|
|
114
|
+
* seams, so one description covers a contract compiled for any ledger era compact-js binds, and the
|
|
115
|
+
* era-pinned entries (`/v8/effect`, `/v9/effect`) hand back the same type rather than each other's.
|
|
116
|
+
*
|
|
117
|
+
* That is not a loosening for its own sake. The era is a property of the *executable* — which
|
|
118
|
+
* binding builds the circuit context, partitions transcripts, converts states and signs maintenance
|
|
119
|
+
* updates — not of the contract description, and a compiled artifact's own `.d.ts` imports
|
|
120
|
+
* `@midnight-ntwrk/compact-runtime` by bare specifier, so its era is decided by how that resolves
|
|
121
|
+
* where the artifact lives and not by which compact-js entry the application imported. A spine that
|
|
122
|
+
* named one line's `CircuitContext` could only ever agree with contracts compiled for that line
|
|
123
|
+
* (midnight-sdk#387/#388). `test/typetests/effect/Contract.tst.ts` pins both eras against this
|
|
124
|
+
* type.
|
|
125
|
+
*/
|
|
126
|
+
export interface Contract<PS, W extends Witnesses<PS> = Witnesses<PS>> {
|
|
127
|
+
witnesses: W;
|
|
128
|
+
circuits: Circuits;
|
|
129
|
+
provableCircuits: ProvableCircuits;
|
|
130
|
+
initialState(context: any, ...args: any[]): Awaitable<ConstructorResult<PS>>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A circuit id with the {@link ProvableCircuitId} brand taken back off, for use as an index.
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* A brand is an *intersection*, so `provableCircuits['increment' & Brand<'ProvableCircuitId'>]` does
|
|
137
|
+
* not resolve to the declared method that `provableCircuits['increment']` does; indexing the key as
|
|
138
|
+
* given collapsed arguments to `unknown[]` and results to `unknown` (midnight-sdk#402). Every key
|
|
139
|
+
* the *runtime* API hands out is branded; plain literals also work, and always did — `Unbranded`
|
|
140
|
+
* passes them through untouched. Kept outside the namespace, whose members are implicitly exported.
|
|
141
|
+
*/
|
|
142
|
+
type CircuitKey<K> = Brand.Brand.Unbranded<K>;
|
|
143
|
+
export declare namespace Contract {
|
|
144
|
+
type Any = Contract<any>;
|
|
145
|
+
type PrivateState<C> = C extends Contract<infer PS> ? PS : never;
|
|
146
|
+
type Witnesses<C> = C extends Contract<any, infer W> ? (keyof W extends never ? never : W) : never;
|
|
147
|
+
type InitializeParameters<C extends Contract<any>> = Parameters<C['initialState']> extends [any, ...infer A] ? A : never;
|
|
148
|
+
type ProvableCircuitId<C extends Contract<any>> = keyof C['provableCircuits'] & string;
|
|
149
|
+
type CircuitParameters<C extends Contract<any>, K extends ProvableCircuitId<C>> = Parameters<C['provableCircuits'][CircuitKey<K>]> extends [any, ...infer A] ? A : never;
|
|
150
|
+
type CircuitReturnType<C extends Contract<any>, K extends ProvableCircuitId<C>> = Awaited<ReturnType<C['provableCircuits'][CircuitKey<K>]>> extends CircuitResults<infer U> ? U : never;
|
|
151
|
+
}
|
|
152
|
+
export declare const getProvableCircuitIds: <C extends Contract.Any>(contract: C) => ProvableCircuitId<C>[];
|
|
153
|
+
export {};
|
|
154
|
+
//# sourceMappingURL=Contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../../src/effect/Contract.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,EAAE;IACnC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB,CAAC,EAAE;IACnC,QAAQ,CAAC,mBAAmB,EAAE,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,SAA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K,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IAI1G,KAAY,oBAAoB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,IACtD,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAEtE,KAAY,iBAAiB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;IAE9F,KAAY,iBAAiB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,IACnF,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAEzF,KAAY,iBAAiB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,IACnF,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;CACzG;AAED,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC,EAClC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contract state carried on a configuration error, as diagnostic payload.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Deliberately `unknown` rather than the {@link CompactRuntime} seam's `ContractState`. This error
|
|
6
|
+
* is raised by the executable, which since midnight-sdk#387 exists once per era pair — so the state
|
|
7
|
+
* it carries is *whichever* era's, and naming one of them would tie this module (and with it the
|
|
8
|
+
* era-free surface both era entries share) back to a single ledger era.
|
|
9
|
+
*
|
|
10
|
+
* Nothing in the SDK reads it: it exists to be attached to a report. A consumer that wants to
|
|
11
|
+
* inspect it narrows through the era entry it built the executable from.
|
|
12
|
+
*/
|
|
13
|
+
export type ContractState = unknown;
|
|
14
|
+
declare const TypeId: unique symbol;
|
|
15
|
+
type TypeId = typeof TypeId;
|
|
16
|
+
declare const ContractConfigurationError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof TypeId, typeof TypeId> & {
|
|
17
|
+
readonly _tag: "ContractConfigurationError";
|
|
18
|
+
} & Readonly<A>;
|
|
19
|
+
/**
|
|
20
|
+
* An error occurred while executing a constructor, or a circuit, of an executable contract with regards to
|
|
21
|
+
* its configuration.
|
|
22
|
+
*
|
|
23
|
+
* @category errors
|
|
24
|
+
*/
|
|
25
|
+
export declare class ContractConfigurationError extends ContractConfigurationError_base<{
|
|
26
|
+
/** A displayable message. */
|
|
27
|
+
readonly message: string;
|
|
28
|
+
/** Indicates a more specific cause of the error. */
|
|
29
|
+
readonly cause?: unknown;
|
|
30
|
+
/** The current state of the contract. */
|
|
31
|
+
readonly contractState?: ContractState | undefined;
|
|
32
|
+
}> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Determines if a value is a contract configuration error.
|
|
36
|
+
*
|
|
37
|
+
* @param u The value to check.
|
|
38
|
+
* @returns `true` if `u` is a {@link ContractConfigurationError}; `false` otherwise.
|
|
39
|
+
*
|
|
40
|
+
* @category guards
|
|
41
|
+
*/
|
|
42
|
+
export declare const isConfigurationError: (u: unknown) => u is ContractConfigurationError;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new {@link ContractConfigurationError}.
|
|
45
|
+
*
|
|
46
|
+
* @category constructors
|
|
47
|
+
*/
|
|
48
|
+
export declare const make: {
|
|
49
|
+
(message: string): ContractConfigurationError;
|
|
50
|
+
(message: string, contractState: ContractState | undefined): ContractConfigurationError;
|
|
51
|
+
(message: string, contractState: ContractState | undefined, cause: unknown): ContractConfigurationError;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=ContractConfigurationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractConfigurationError.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractConfigurationError.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC;AAEpC,QAAA,MAAM,MAAM,EAAE,OAAO,MAAmE,CAAC;AACzF,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;;;;AAE5B;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,gCAAwD;IACtG,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACpD,CAAC;CAAI;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,0BAAoD,CAAC;AAE5G;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,OAAO,EAAE,MAAM,GAAG,0BAA0B,CAAC;IAC9C,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,0BAA0B,CAAC;IACxF,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAAC;CAEvC,CAAC"}
|