@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.
Files changed (233) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +158 -2
  3. package/dist/dts/effect/CompactContext.d.ts +20 -0
  4. package/dist/dts/effect/CompactContext.d.ts.map +1 -0
  5. package/dist/dts/effect/CompactRuntime.d.ts +76 -0
  6. package/dist/dts/effect/CompactRuntime.d.ts.map +1 -0
  7. package/dist/dts/effect/CompiledContract.d.ts +107 -0
  8. package/dist/dts/effect/CompiledContract.d.ts.map +1 -0
  9. package/dist/dts/effect/Contract.d.ts +154 -0
  10. package/dist/dts/effect/Contract.d.ts.map +1 -0
  11. package/dist/dts/effect/ContractConfigurationError.d.ts +54 -0
  12. package/dist/dts/effect/ContractConfigurationError.d.ts.map +1 -0
  13. package/dist/dts/effect/ContractEventStore.d.ts +167 -0
  14. package/dist/dts/effect/ContractEventStore.d.ts.map +1 -0
  15. package/dist/dts/effect/ContractEventValidationError.d.ts +34 -0
  16. package/dist/dts/effect/ContractEventValidationError.d.ts.map +1 -0
  17. package/dist/dts/effect/ContractEventValidator.d.ts +18 -0
  18. package/dist/dts/effect/ContractEventValidator.d.ts.map +1 -0
  19. package/dist/dts/effect/ContractExecutable.d.ts +99 -0
  20. package/dist/dts/effect/ContractExecutable.d.ts.map +1 -0
  21. package/dist/dts/effect/ContractExecutableRuntime.d.ts +4 -0
  22. package/dist/dts/effect/ContractExecutableRuntime.d.ts.map +1 -0
  23. package/dist/dts/effect/ContractKeyLocation.d.ts +55 -0
  24. package/dist/dts/effect/ContractKeyLocation.d.ts.map +1 -0
  25. package/dist/dts/effect/ContractLog.d.ts +273 -0
  26. package/dist/dts/effect/ContractLog.d.ts.map +1 -0
  27. package/dist/dts/effect/ContractRuntimeError.d.ts +34 -0
  28. package/dist/dts/effect/ContractRuntimeError.d.ts.map +1 -0
  29. package/dist/dts/effect/Ledger.d.ts +104 -0
  30. package/dist/dts/effect/Ledger.d.ts.map +1 -0
  31. package/dist/dts/effect/MalformedHexPrefixError.d.ts +37 -0
  32. package/dist/dts/effect/MalformedHexPrefixError.d.ts.map +1 -0
  33. package/dist/dts/effect/ZKConfiguration.d.ts +52 -0
  34. package/dist/dts/effect/ZKConfiguration.d.ts.map +1 -0
  35. package/dist/dts/effect/ZKConfigurationReadError.d.ts +45 -0
  36. package/dist/dts/effect/ZKConfigurationReadError.d.ts.map +1 -0
  37. package/dist/dts/effect/ZKManifest.d.ts +50 -0
  38. package/dist/dts/effect/ZKManifest.d.ts.map +1 -0
  39. package/dist/dts/effect/ZKManifestError.d.ts +34 -0
  40. package/dist/dts/effect/ZKManifestError.d.ts.map +1 -0
  41. package/dist/dts/effect/index.d.ts +22 -0
  42. package/dist/dts/effect/index.d.ts.map +1 -0
  43. package/dist/dts/effect/internal/boundary.d.ts +35 -0
  44. package/dist/dts/effect/internal/boundary.d.ts.map +1 -0
  45. package/dist/dts/effect/internal/compactContext.d.ts +29 -0
  46. package/dist/dts/effect/internal/compactContext.d.ts.map +1 -0
  47. package/dist/dts/effect/internal/contractEventsSurface.d.ts +43 -0
  48. package/dist/dts/effect/internal/contractEventsSurface.d.ts.map +1 -0
  49. package/dist/dts/effect/internal/era/v8Executable.d.ts +65 -0
  50. package/dist/dts/effect/internal/era/v8Executable.d.ts.map +1 -0
  51. package/dist/dts/effect/internal/era/v8Ledger.d.ts +76 -0
  52. package/dist/dts/effect/internal/era/v8Ledger.d.ts.map +1 -0
  53. package/dist/dts/effect/internal/era/v8Runtime.d.ts +26 -0
  54. package/dist/dts/effect/internal/era/v8Runtime.d.ts.map +1 -0
  55. package/dist/dts/effect/internal/era/v9Executable.d.ts +65 -0
  56. package/dist/dts/effect/internal/era/v9Executable.d.ts.map +1 -0
  57. package/dist/dts/effect/internal/era/v9Ledger.d.ts +76 -0
  58. package/dist/dts/effect/internal/era/v9Ledger.d.ts.map +1 -0
  59. package/dist/dts/effect/internal/era/v9Runtime.d.ts +15 -0
  60. package/dist/dts/effect/internal/era/v9Runtime.d.ts.map +1 -0
  61. package/dist/dts/effect/internal/era.d.ts +117 -0
  62. package/dist/dts/effect/internal/era.d.ts.map +1 -0
  63. package/dist/dts/effect/internal/eraFreeSurface.d.ts +49 -0
  64. package/dist/dts/effect/internal/eraFreeSurface.d.ts.map +1 -0
  65. package/dist/dts/effect/internal/eraNeutralSurface.d.ts +35 -0
  66. package/dist/dts/effect/internal/eraNeutralSurface.d.ts.map +1 -0
  67. package/dist/dts/effect/internal/executable.d.ts +371 -0
  68. package/dist/dts/effect/internal/executable.d.ts.map +1 -0
  69. package/dist/dts/effect/internal/ledger/binding.d.ts +2 -0
  70. package/dist/dts/effect/internal/ledger/binding.d.ts.map +1 -0
  71. package/dist/dts/effect/internal/ledger/conformance.d.ts +2 -0
  72. package/dist/dts/effect/internal/ledger/conformance.d.ts.map +1 -0
  73. package/dist/dts/effect/internal/ledger/conversions.d.ts +167 -0
  74. package/dist/dts/effect/internal/ledger/conversions.d.ts.map +1 -0
  75. package/dist/dts/effect/internal/ledger/current.d.ts +8 -0
  76. package/dist/dts/effect/internal/ledger/current.d.ts.map +1 -0
  77. package/dist/dts/effect/internal/ledger/v8.d.ts +100 -0
  78. package/dist/dts/effect/internal/ledger/v8.d.ts.map +1 -0
  79. package/dist/dts/effect/internal/ledger/v9.d.ts +66 -0
  80. package/dist/dts/effect/internal/ledger/v9.d.ts.map +1 -0
  81. package/dist/dts/effect/internal/runtime/binding.d.ts +2 -0
  82. package/dist/dts/effect/internal/runtime/binding.d.ts.map +1 -0
  83. package/dist/dts/effect/internal/runtime/conformance.d.ts +2 -0
  84. package/dist/dts/effect/internal/runtime/conformance.d.ts.map +1 -0
  85. package/dist/dts/effect/internal/runtime/current.d.ts +11 -0
  86. package/dist/dts/effect/internal/runtime/current.d.ts.map +1 -0
  87. package/dist/dts/effect/internal/runtime/execution.d.ts +176 -0
  88. package/dist/dts/effect/internal/runtime/execution.d.ts.map +1 -0
  89. package/dist/dts/effect/internal/runtime/v0_16.d.ts +169 -0
  90. package/dist/dts/effect/internal/runtime/v0_16.d.ts.map +1 -0
  91. package/dist/dts/effect/internal/runtime/v0_21.d.ts +81 -0
  92. package/dist/dts/effect/internal/runtime/v0_21.d.ts.map +1 -0
  93. package/dist/dts/effect/internal/typeAssertions.d.ts +2 -0
  94. package/dist/dts/effect/internal/typeAssertions.d.ts.map +1 -0
  95. package/dist/dts/index.d.ts +7 -0
  96. package/dist/dts/index.d.ts.map +1 -0
  97. package/dist/dts/v8/effect.d.ts +50 -0
  98. package/dist/dts/v8/effect.d.ts.map +1 -0
  99. package/dist/dts/v8/index.d.ts +10 -0
  100. package/dist/dts/v8/index.d.ts.map +1 -0
  101. package/dist/dts/v9/effect.d.ts +28 -0
  102. package/dist/dts/v9/effect.d.ts.map +1 -0
  103. package/dist/dts/v9/index.d.ts +16 -0
  104. package/dist/dts/v9/index.d.ts.map +1 -0
  105. package/dist/esm/effect/CompactContext.js +16 -0
  106. package/dist/esm/effect/CompactContext.js.map +1 -0
  107. package/dist/esm/effect/CompactRuntime.js +44 -0
  108. package/dist/esm/effect/CompactRuntime.js.map +1 -0
  109. package/dist/esm/effect/CompiledContract.js +102 -0
  110. package/dist/esm/effect/CompiledContract.js.map +1 -0
  111. package/dist/esm/effect/Contract.js +40 -0
  112. package/dist/esm/effect/Contract.js.map +1 -0
  113. package/dist/esm/effect/ContractConfigurationError.js +41 -0
  114. package/dist/esm/effect/ContractConfigurationError.js.map +1 -0
  115. package/dist/esm/effect/ContractEventStore.js +150 -0
  116. package/dist/esm/effect/ContractEventStore.js.map +1 -0
  117. package/dist/esm/effect/ContractEventValidationError.js +40 -0
  118. package/dist/esm/effect/ContractEventValidationError.js.map +1 -0
  119. package/dist/esm/effect/ContractEventValidator.js +49 -0
  120. package/dist/esm/effect/ContractEventValidator.js.map +1 -0
  121. package/dist/esm/effect/ContractExecutable.js +50 -0
  122. package/dist/esm/effect/ContractExecutable.js.map +1 -0
  123. package/dist/esm/effect/ContractExecutableRuntime.js +17 -0
  124. package/dist/esm/effect/ContractExecutableRuntime.js.map +1 -0
  125. package/dist/esm/effect/ContractKeyLocation.js +67 -0
  126. package/dist/esm/effect/ContractKeyLocation.js.map +1 -0
  127. package/dist/esm/effect/ContractLog.js +268 -0
  128. package/dist/esm/effect/ContractLog.js.map +1 -0
  129. package/dist/esm/effect/ContractRuntimeError.js +40 -0
  130. package/dist/esm/effect/ContractRuntimeError.js.map +1 -0
  131. package/dist/esm/effect/Ledger.js +115 -0
  132. package/dist/esm/effect/Ledger.js.map +1 -0
  133. package/dist/esm/effect/MalformedHexPrefixError.js +43 -0
  134. package/dist/esm/effect/MalformedHexPrefixError.js.map +1 -0
  135. package/dist/esm/effect/ZKConfiguration.js +23 -0
  136. package/dist/esm/effect/ZKConfiguration.js.map +1 -0
  137. package/dist/esm/effect/ZKConfigurationReadError.js +46 -0
  138. package/dist/esm/effect/ZKConfigurationReadError.js.map +1 -0
  139. package/dist/esm/effect/ZKManifest.js +286 -0
  140. package/dist/esm/effect/ZKManifest.js.map +1 -0
  141. package/dist/esm/effect/ZKManifestError.js +40 -0
  142. package/dist/esm/effect/ZKManifestError.js.map +1 -0
  143. package/dist/esm/effect/index.js +36 -0
  144. package/dist/esm/effect/index.js.map +1 -0
  145. package/dist/esm/effect/internal/boundary.js +61 -0
  146. package/dist/esm/effect/internal/boundary.js.map +1 -0
  147. package/dist/esm/effect/internal/compactContext.js +52 -0
  148. package/dist/esm/effect/internal/compactContext.js.map +1 -0
  149. package/dist/esm/effect/internal/contractEventsSurface.js +57 -0
  150. package/dist/esm/effect/internal/contractEventsSurface.js.map +1 -0
  151. package/dist/esm/effect/internal/era/v8Executable.js +31 -0
  152. package/dist/esm/effect/internal/era/v8Executable.js.map +1 -0
  153. package/dist/esm/effect/internal/era/v8Ledger.js +85 -0
  154. package/dist/esm/effect/internal/era/v8Ledger.js.map +1 -0
  155. package/dist/esm/effect/internal/era/v8Runtime.js +39 -0
  156. package/dist/esm/effect/internal/era/v8Runtime.js.map +1 -0
  157. package/dist/esm/effect/internal/era/v9Executable.js +31 -0
  158. package/dist/esm/effect/internal/era/v9Executable.js.map +1 -0
  159. package/dist/esm/effect/internal/era/v9Ledger.js +83 -0
  160. package/dist/esm/effect/internal/era/v9Ledger.js.map +1 -0
  161. package/dist/esm/effect/internal/era/v9Runtime.js +28 -0
  162. package/dist/esm/effect/internal/era/v9Runtime.js.map +1 -0
  163. package/dist/esm/effect/internal/era.js +16 -0
  164. package/dist/esm/effect/internal/era.js.map +1 -0
  165. package/dist/esm/effect/internal/eraFreeSurface.js +63 -0
  166. package/dist/esm/effect/internal/eraFreeSurface.js.map +1 -0
  167. package/dist/esm/effect/internal/eraNeutralSurface.js +49 -0
  168. package/dist/esm/effect/internal/eraNeutralSurface.js.map +1 -0
  169. package/dist/esm/effect/internal/executable.js +531 -0
  170. package/dist/esm/effect/internal/executable.js.map +1 -0
  171. package/dist/esm/effect/internal/ledger/binding.js +20 -0
  172. package/dist/esm/effect/internal/ledger/binding.js.map +1 -0
  173. package/dist/esm/effect/internal/ledger/conformance.js +16 -0
  174. package/dist/esm/effect/internal/ledger/conformance.js.map +1 -0
  175. package/dist/esm/effect/internal/ledger/conversions.js +119 -0
  176. package/dist/esm/effect/internal/ledger/conversions.js.map +1 -0
  177. package/dist/esm/effect/internal/ledger/current.js +22 -0
  178. package/dist/esm/effect/internal/ledger/current.js.map +1 -0
  179. package/dist/esm/effect/internal/ledger/v8.js +101 -0
  180. package/dist/esm/effect/internal/ledger/v8.js.map +1 -0
  181. package/dist/esm/effect/internal/ledger/v9.js +91 -0
  182. package/dist/esm/effect/internal/ledger/v9.js.map +1 -0
  183. package/dist/esm/effect/internal/runtime/binding.js +16 -0
  184. package/dist/esm/effect/internal/runtime/binding.js.map +1 -0
  185. package/dist/esm/effect/internal/runtime/conformance.js +16 -0
  186. package/dist/esm/effect/internal/runtime/conformance.js.map +1 -0
  187. package/dist/esm/effect/internal/runtime/current.js +25 -0
  188. package/dist/esm/effect/internal/runtime/current.js.map +1 -0
  189. package/dist/esm/effect/internal/runtime/execution.js +16 -0
  190. package/dist/esm/effect/internal/runtime/execution.js.map +1 -0
  191. package/dist/esm/effect/internal/runtime/v0_16.js +178 -0
  192. package/dist/esm/effect/internal/runtime/v0_16.js.map +1 -0
  193. package/dist/esm/effect/internal/runtime/v0_21.js +129 -0
  194. package/dist/esm/effect/internal/runtime/v0_21.js.map +1 -0
  195. package/dist/esm/effect/internal/typeAssertions.js +16 -0
  196. package/dist/esm/effect/internal/typeAssertions.js.map +1 -0
  197. package/dist/esm/index.js +21 -0
  198. package/dist/esm/index.js.map +1 -0
  199. package/dist/esm/package.json +4 -0
  200. package/dist/esm/v8/effect.js +64 -0
  201. package/dist/esm/v8/effect.js.map +1 -0
  202. package/dist/esm/v8/index.js +24 -0
  203. package/dist/esm/v8/index.js.map +1 -0
  204. package/dist/esm/v9/effect.js +47 -0
  205. package/dist/esm/v9/effect.js.map +1 -0
  206. package/dist/esm/v9/index.js +30 -0
  207. package/dist/esm/v9/index.js.map +1 -0
  208. package/effect/CompactContext/package.json +5 -0
  209. package/effect/CompactRuntime/package.json +5 -0
  210. package/effect/CompiledContract/package.json +5 -0
  211. package/effect/Contract/package.json +5 -0
  212. package/effect/ContractConfigurationError/package.json +5 -0
  213. package/effect/ContractEventStore/package.json +5 -0
  214. package/effect/ContractEventValidationError/package.json +5 -0
  215. package/effect/ContractEventValidator/package.json +5 -0
  216. package/effect/ContractExecutable/package.json +5 -0
  217. package/effect/ContractExecutableRuntime/package.json +5 -0
  218. package/effect/ContractKeyLocation/package.json +5 -0
  219. package/effect/ContractLog/package.json +5 -0
  220. package/effect/ContractRuntimeError/package.json +5 -0
  221. package/effect/Ledger/package.json +5 -0
  222. package/effect/MalformedHexPrefixError/package.json +5 -0
  223. package/effect/ZKConfiguration/package.json +5 -0
  224. package/effect/ZKConfigurationReadError/package.json +5 -0
  225. package/effect/ZKManifest/package.json +5 -0
  226. package/effect/ZKManifestError/package.json +5 -0
  227. package/effect/index/package.json +5 -0
  228. package/effect/package.json +5 -0
  229. package/package.json +220 -4
  230. package/v8/effect/package.json +5 -0
  231. package/v8/package.json +5 -0
  232. package/v9/effect/package.json +5 -0
  233. package/v9/package.json +5 -0
@@ -0,0 +1,119 @@
1
+ /*
2
+ * This file is part of midnight-sdk.
3
+ * Copyright (C) 2025 Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { Either } from 'effect';
16
+ import * as ContractConfigurationError from '../../ContractConfigurationError.js';
17
+ import { tryBoundary as tryConvert } from '../boundary.js';
18
+ /**
19
+ * Wraps a call across the ledger (WASM) boundary so a rejection becomes a typed failure rather
20
+ * than a defect. This is `internal/boundary.ts`'s `tryBoundary` under the name the ledger side
21
+ * knows it by.
22
+ *
23
+ * @remarks
24
+ * Era-independent, so it lives outside {@link makeConversions}: ledger bindings signal rejection by
25
+ * throwing, and a throw inside `Effect.gen` or a bare `Effect.map` callback becomes a defect that
26
+ * escapes the caller's typed error handling.
27
+ *
28
+ * Re-exported rather than defined here so that both seams share *one* copy of the boundary
29
+ * handling — the compact-runtime seam exposes the same function as `CompactRuntime.tryRuntime`,
30
+ * and `CompactRuntime.test.ts` asserts the two are identical. A second definition also loses
31
+ * `tryBoundary`'s constraint rejecting an `async` thunk, which is the defect the wrapper exists to
32
+ * prevent.
33
+ *
34
+ * @category combinators
35
+ */
36
+ export { tryConvert };
37
+ /**
38
+ * Builds the runtime↔ledger conversions for one era pair.
39
+ *
40
+ * @param ledger The era's ledger binding (`v8.ts`, `v9.ts`, …).
41
+ * @param runtime The compact-runtime binding that era pairs with (`v0_16.ts`, `v0_21.ts`, …).
42
+ *
43
+ * @category constructors
44
+ */
45
+ export const makeConversions = (ledger, runtime) => {
46
+ // Unwrapped, for composing inside another conversion's `tryConvert`. Throws on an era-boundary
47
+ // decode failure, so every caller must already be inside one.
48
+ const decodeStateValue = (value) => ledger.StateValue.decode(value.encode());
49
+ return {
50
+ /** Converts a runtime contract state to this era's ledger `ContractState`. @category conversions */
51
+ fromRuntimeContractState: (contractState) => tryConvert('Unexpected error converting runtime contract state', () => ledger.ContractState.deserialize(contractState.serialize())),
52
+ /** Converts this era's ledger `ContractState` to a runtime contract state. @category conversions */
53
+ toRuntimeContractState: (contractState) => tryConvert('Unexpected error converting ledger contract state', () => runtime.ContractState.deserialize(contractState.serialize())),
54
+ /** Deserializes ledger-serialized bytes into this era's `ContractState`. @category conversions */
55
+ contractStateFromBytes: (bytes) => tryConvert('Unexpected error deserializing ledger contract state from bytes', () => ledger.ContractState.deserialize(bytes)),
56
+ /** Deserializes ledger-serialized bytes into this era's `LedgerParameters`. @category conversions */
57
+ parametersFromBytes: (bytes) => tryConvert('Unexpected error deserializing ledger parameters', () => ledger.LedgerParameters.deserialize(bytes)),
58
+ /**
59
+ * Converts a runtime contract maintenance authority to this era's ledger one.
60
+ * @category conversions
61
+ */
62
+ fromRuntimeMaintenanceAuthority: (authority) => tryConvert('Unexpected error converting runtime contract maintenance authority', () => ledger.ContractMaintenanceAuthority.deserialize(authority.serialize())),
63
+ /** Converts a runtime `StateValue` to this era's, via the shared binary encoding. @category conversions */
64
+ fromRuntimeStateValue: (value) => tryConvert('Unexpected error converting runtime state value', () => decodeStateValue(value)),
65
+ /**
66
+ * Converts a runtime `QueryContext` to this era's, carrying `state`, `address`, `block`,
67
+ * `effects` and the commitment indices (`comIndices`).
68
+ *
69
+ * @remarks
70
+ * `comIndices` is declared `readonly` and is only *writable* via `insertCommitment`, but it is
71
+ * carried here by the `block` assignment: the commitment map is part of the block-level call
72
+ * context, so assigning `block` restores it. Verified by `test/effect/Ledger.test.ts` — do not
73
+ * "fix" the apparent gap by re-inserting the entries, which would union two commitment sets at
74
+ * any call site that also supplies its own (see `ContractExecutable.partitionAllTranscripts`).
75
+ *
76
+ * @category conversions
77
+ */
78
+ fromRuntimeQueryContext: (queryContext) =>
79
+ // The thunk's return is annotated rather than inferred: construction widens it to
80
+ // `LedgerQueryContext & { block; effects }` (the settable props are cast in below), and
81
+ // `tryConvert`'s constraint rejecting an `async` thunk cannot resolve against an
82
+ // intersection of a deferred generic. The extra props are a construction detail, not part of
83
+ // what this conversion returns.
84
+ tryConvert('Unexpected error converting runtime query context', () => {
85
+ const ChargedState = ledger.ChargedState;
86
+ const QueryContext = ledger.QueryContext;
87
+ const ledgerQueryContext = new QueryContext(new ChargedState(decodeStateValue(queryContext.state.state)), queryContext.address);
88
+ // The constructor takes only the state and address; the remaining settable properties are
89
+ // copied manually. `block` also carries `comIndices` (see the note above).
90
+ ledgerQueryContext.block = queryContext.block;
91
+ ledgerQueryContext.effects = queryContext.effects;
92
+ return ledgerQueryContext;
93
+ }),
94
+ /**
95
+ * Adapts a platform-js signing key to this era's ledger `SigningKey`, failing when the scheme
96
+ * is not supported by the era's CMA path.
97
+ *
98
+ * @remarks
99
+ * The two halves live in different places on purpose. Admissibility is era-neutral policy and
100
+ * stays here: a scheme outside the era's allowlist fails rather than being silently coerced.
101
+ * The key's *shape* is era-varying — ledger 9 tags each key, ledger 8 uses a bare hex string —
102
+ * so construction is delegated to the binding's `makeSigningKey`.
103
+ *
104
+ * @category conversions
105
+ */
106
+ fromPlatformSigningKey: (signingKey, contractState) => ledger.era.supportsCmaSignatureKind(signingKey.tag)
107
+ ? Either.right(ledger.makeSigningKey(signingKey))
108
+ : Either.left(ContractConfigurationError.make(`Unsupported signature scheme '${signingKey.tag}' for a contract maintenance authority; ` +
109
+ `supported schemes are: ${ledger.era.cmaSignatureKindsDescription}`,
110
+ // The one genuine impedance mismatch left: `ContractConfigurationError` names the
111
+ // *bound* era's `ContractState`, while `R` here is whichever runtime this factory was
112
+ // given. The cast is narrow — the parameter above is the era's own contract state, so
113
+ // this can no longer launder an arbitrary value (a string, a signing key) into a field
114
+ // the type system reports as a `ContractState`. Removing it entirely needs the error
115
+ // type to be era-parameterised too.
116
+ contractState))
117
+ };
118
+ };
119
+ //# sourceMappingURL=conversions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversions.js","sourceRoot":"","sources":["../../../../../src/effect/internal/ledger/conversions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,KAAK,0BAA0B,MAAM,qCAAqC,CAAC;AAElF,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA0E3D;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAS7B,MAAS,EACT,OAAU,EACV,EAAE;IAUF,+FAA+F;IAC/F,8DAA8D;IAC9D,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAoB,EAAE,CACzE,MAAM,CAAC,UAAuD,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzF,OAAO;QACL,oGAAoG;QACpG,wBAAwB,EAAE,CACxB,aAAmC,EAC4C,EAAE,CACjF,UAAU,CACR,oDAAoD,EACpD,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,SAAS,EAAE,CAAwB,CACzF;QAEH,oGAAoG;QACpG,sBAAsB,EAAE,CACtB,aAAkC,EAC8C,EAAE,CAClF,UAAU,CACR,mDAAmD,EACnD,GAAG,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,aAA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AAC;YAC9C,kBAAkB,CAAC,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;YAClD,OAAO,kBAAkB,CAAC;QAC5B,CAAC,CAAC;QAEJ;;;;;;;;;;;WAWG;QACH,sBAAsB,EAAE,CACtB,UAA8B,EAC9B,aAAoC,EACoD,EAAE,CACzF,MAAM,CAAC,GAAG,CAAC,wBAAyE,CAAC,UAAU,CAAC,GAAG,CAAC;YACnG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAqB,CAAC;YACrE,CAAC,CAAC,MAAM,CAAC,IAAI,CACT,0BAA0B,CAAC,IAAI,CAC7B,iCAAiC,UAAU,CAAC,GAAG,0CAA0C;gBACvF,0BAA0B,MAAM,CAAC,GAAG,CAAC,4BAA4B,EAAE;YACrE,kFAAkF;YAClF,sFAAsF;YACtF,sFAAsF;YACtF,uFAAuF;YACvF,qFAAqF;YACrF,oCAAoC;YACpC,aAAsE,CACvE,CACF;KACR,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /*
2
+ * This file is part of midnight-sdk.
3
+ * Copyright (C) 2025 Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ /**
16
+ * The era currently bound to this build. Every entry — suffixed and unsuffixed — resolves the
17
+ * `Ledger` facade through this one module, so changing the export below changes the era for ALL
18
+ * of them, `/v9` included. Giving each era-pinned entry its own binding is the outstanding work
19
+ * (midnight-sdk#388).
20
+ */
21
+ export * from './v9.js';
22
+ //# sourceMappingURL=current.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current.js","sourceRoot":"","sources":["../../../../../src/effect/internal/ledger/current.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;GAKG;AACH,cAAc,SAAS,CAAC"}
@@ -0,0 +1,101 @@
1
+ /*
2
+ * This file is part of midnight-sdk.
3
+ * Copyright (C) 2025 Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { ContractMaintenanceAuthority as LedgerContractMaintenanceAuthority, ContractOperationVersion, ContractOperationVersionedVerifierKey, CostModel as LedgerCostModel } from '@midnightntwrk/ledger-v8';
16
+ // Matches the v9 twin except for `ContractMaintenanceAuthority` and `CostModel`, both declared
17
+ // below rather than re-exported here. See that file for why the proof/binding/signature markers
18
+ // are type-only.
19
+ export { ChargedState, communicationCommitmentRandomness, ContractCall, ContractCallPrototype, ContractDeploy, ContractState, DustActions, Intent, LedgerParameters, MaintenanceUpdate, partitionTranscripts, PreTranscript, QueryContext, ReplaceAuthority, signData, StateValue, Transaction, UnshieldedOffer, VerifierKeyInsert, VerifierKeyRemove, ZswapOffer } from '@midnightntwrk/ledger-v8';
20
+ /**
21
+ * Ledger 8's `ContractMaintenanceAuthority`, with `deserialize`'s return type repaired.
22
+ *
23
+ * @remarks
24
+ * `@midnightntwrk/ledger-v8@8.1.2` declares `static deserialize(raw: Uint8Array): ContractState` —
25
+ * an upstream mistake in the generated `.d.ts`. The WASM really returns a
26
+ * `ContractMaintenanceAuthority` (verified against 8.1.2: `deserialize(cma.serialize())` yields a
27
+ * value whose constructor is `ContractMaintenanceAuthority`, and which fails
28
+ * `instanceof ContractState`). Repaired here, at the seam, so every era presents the same
29
+ * relationship to `Ledger.fromRuntimeMaintenanceAuthority` and no call site has to know.
30
+ *
31
+ * Do not drop this in a routine "remove redundant cast" pass: `LedgerBindingViolations` fails the
32
+ * build without it, naming the broken round-trip. Re-check it on each v8 patch release — if
33
+ * upstream fixes the declaration, the cast becomes a no-op and can go.
34
+ */
35
+ const ContractMaintenanceAuthority = LedgerContractMaintenanceAuthority;
36
+ export { ContractMaintenanceAuthority };
37
+ const CostModel = LedgerCostModel;
38
+ export { CostModel };
39
+ /**
40
+ * The contract operation (verifier key) version this era's ledger expects. Same literal as v9: v8
41
+ * accepts only `'v3'`, and v9 accepts `'v3' | 'v4'` but compact-js emits `'v3'`.
42
+ */
43
+ const CONTRACT_OPERATION_VERSION = 'v3';
44
+ /**
45
+ * Ledger 8 CMA keys are BIP-340 only — the era has no tagged-key concept, so there is exactly one
46
+ * scheme to allow. Kept in the same shape as v9's allowlist so era-neutral code reads one API.
47
+ */
48
+ const CMA_SIGNATURE_KINDS = new Set(['schnorr']);
49
+ /**
50
+ * The ledger 8 {@link Era} descriptor.
51
+ *
52
+ * @remarks
53
+ * `supportsCmaSignatureKind` carries real weight here rather than being a formality: an ECDSA key
54
+ * configured against a v8 build has no representation in this era's `SigningKey` at all, so it must
55
+ * be rejected at the descriptor rather than coerced into a bare hex string.
56
+ *
57
+ * The key's *shape* is deliberately not expressed here: `Era` describes which *schemes* an era
58
+ * allows, not what its `SigningKey` looks like. That half lives in the binding instead —
59
+ * `fromPlatformSigningKey` splits, keeping the era-neutral allowlist check in `conversions.ts` and
60
+ * delegating construction to this module's {@link makeSigningKey}, which returns the bare `value`
61
+ * where v9 returns `{ tag, value }`.
62
+ */
63
+ export const era = {
64
+ ledger: 8,
65
+ runtime: '0.16',
66
+ supportsCmaSignatureKind: (kind) => CMA_SIGNATURE_KINDS.has(kind),
67
+ cmaSignatureKindsDescription: [...CMA_SIGNATURE_KINDS].join(', '),
68
+ defaultCmaSignatureKind: 'schnorr'
69
+ };
70
+ // Mirrors v9: a half-built binding must fail at import, not at first CMA signing.
71
+ if (!era.supportsCmaSignatureKind(era.defaultCmaSignatureKind)) {
72
+ throw new Error(`ledger ${era.ledger} era binding: default CMA signature kind '${era.defaultCmaSignatureKind}' is not in the era's allowlist`);
73
+ }
74
+ /**
75
+ * Creates the {@link ContractOperationVersion} for this era.
76
+ *
77
+ * @category constructors
78
+ */
79
+ export const makeContractOperationVersion = () => new ContractOperationVersion(CONTRACT_OPERATION_VERSION);
80
+ /**
81
+ * Creates a {@link ContractOperationVersionedVerifierKey} for `verifierKey` at this era's
82
+ * operation version.
83
+ *
84
+ * @category constructors
85
+ */
86
+ export const makeVersionedVerifierKey = (verifierKey) => new ContractOperationVersionedVerifierKey(CONTRACT_OPERATION_VERSION, verifierKey);
87
+ /**
88
+ * Adapts a platform-js signing key to ledger 8's `SigningKey`.
89
+ *
90
+ * @remarks
91
+ * This is the one era difference that reaches compact-js's public API. Ledger 8 has no tagged-key
92
+ * concept — its keys are BIP-340 only and `SigningKey` is a bare hex `string` — so the platform
93
+ * key's `tag` is *dropped* rather than carried, and only its `value` survives. Dropping it is safe
94
+ * only because {@link era}'s allowlist has already rejected every scheme but `schnorr` by the time
95
+ * `Ledger.fromPlatformSigningKey` calls this; an ECDSA key has no representation here at all and
96
+ * must never reach this function.
97
+ *
98
+ * @category constructors
99
+ */
100
+ export const makeSigningKey = (signingKey) => signingKey.value;
101
+ //# sourceMappingURL=v8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v8.js","sourceRoot":"","sources":["../../../../../src/effect/internal/ledger/v8.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAyBH,OAAO,EACL,4BAA4B,IAAI,kCAAkC,EAClE,wBAAwB,EACxB,qCAAqC,EACrC,SAAS,IAAI,eAAe,EAG7B,MAAM,0BAA0B,C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M,CAAC,MAAM,4BAA4B,GAAG,GAA6B,EAAE,CACzE,IAAI,wBAAwB,CAAC,0BAA0B,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,WAAuB,EAAyC,EAAE,CACzG,IAAI,qCAAqC,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAC;AAErF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAA8B,EAAoB,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC"}
@@ -0,0 +1,91 @@
1
+ /*
2
+ * This file is part of midnight-sdk.
3
+ * Copyright (C) 2025 Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { ContractOperationVersion, ContractOperationVersionedVerifierKey, CostModel as LedgerCostModel } from '@midnightntwrk/ledger-v9';
16
+ // The proof/binding/signature markers are type-only, for declaration-emit hygiene: nothing here
17
+ // needs them at run time, and `runtime/conformance.ts` reaches this module with `import type`.
18
+ //
19
+ // `UnshieldedOffer` and `DustActions` must be *values*: a consumer constructs them to fund an
20
+ // intent, and fetching those classes from its own resolution is the second instantiation that
21
+ // `LedgerDualInstantiation.test.ts` shows `Intent.dustActions` silently discards.
22
+ //
23
+ // `CostModel` is not in this list — it is branded below.
24
+ export { ChargedState, communicationCommitmentRandomness, ContractCall, ContractCallPrototype, ContractDeploy, ContractMaintenanceAuthority, ContractState, DustActions, Intent, LedgerParameters, MaintenanceUpdate, partitionTranscripts, PreTranscript, QueryContext, ReplaceAuthority, signData, StateValue, Transaction, UnshieldedOffer, VerifierKeyInsert, VerifierKeyRemove, ZswapOffer } from '@midnightntwrk/ledger-v9';
25
+ const CostModel = LedgerCostModel;
26
+ export { CostModel };
27
+ /**
28
+ * The contract operation (verifier key) version this era's ledger expects. Defined once so an era
29
+ * bump is a one-line edit; both constructors below read it from here.
30
+ *
31
+ * `'v4'` is the slot for ZKIR v3 (`verifier-key[v7]`) keys, the only kind compactc 0.36 emits;
32
+ * `'v3'` holds ZKIR v2 (`verifier-key[v6]`) keys and rejects a 0.36 key on decode.
33
+ */
34
+ const CONTRACT_OPERATION_VERSION = 'v4';
35
+ /**
36
+ * The signature schemes verified end-to-end against the ledger 9 CMA path (`signData` and
37
+ * `signatureVerifyingKey`). Add a scheme here only once it has been verified end-to-end; an
38
+ * unlisted scheme is rejected loudly by the facade, never silently coerced. Module-local so the
39
+ * allowlist cannot be reached (or mutated) through the public `era` value.
40
+ */
41
+ const CMA_SIGNATURE_KINDS = new Set(['schnorr', 'ecdsa']);
42
+ /** The ledger 9 {@link Era} descriptor. @category era */
43
+ export const era = {
44
+ ledger: 9,
45
+ // Ledger 9 pairs with compact-runtime 0.21 (over onchain-runtime-v4). Stated here rather than
46
+ // read from the runtime seam so this binding stays the single description of the era, and so the
47
+ // two seams do not import each other; `CompactRuntime.test.ts` checks they agree.
48
+ runtime: '0.21',
49
+ supportsCmaSignatureKind: (kind) => CMA_SIGNATURE_KINDS.has(kind),
50
+ cmaSignatureKindsDescription: [...CMA_SIGNATURE_KINDS].join(', '),
51
+ defaultCmaSignatureKind: 'schnorr'
52
+ };
53
+ // A half-built binding must fail at import, not at first CMA signing: the default sampling scheme
54
+ // must be in its own verified allowlist (which therefore also cannot be empty).
55
+ if (!era.supportsCmaSignatureKind(era.defaultCmaSignatureKind)) {
56
+ throw new Error(`ledger ${era.ledger} era binding: default CMA signature kind '${era.defaultCmaSignatureKind}' is not in the era's allowlist`);
57
+ }
58
+ /**
59
+ * Creates the {@link ContractOperationVersion} for this era. The version literal lives here so it
60
+ * cannot leak into era-neutral code.
61
+ *
62
+ * @category constructors
63
+ */
64
+ export const makeContractOperationVersion = () => new ContractOperationVersion(CONTRACT_OPERATION_VERSION);
65
+ /**
66
+ * Creates a {@link ContractOperationVersionedVerifierKey} for `verifierKey` at this era's
67
+ * operation version.
68
+ *
69
+ * @category constructors
70
+ */
71
+ export const makeVersionedVerifierKey = (verifierKey) => new ContractOperationVersionedVerifierKey(CONTRACT_OPERATION_VERSION, verifierKey);
72
+ /**
73
+ * Adapts a platform-js signing key to ledger 9's `SigningKey`.
74
+ *
75
+ * @remarks
76
+ * Ledger 9 keys are tagged (`{ tag, value }`) and, as of platform-js@3.0.0, structurally identical
77
+ * to platform-js's — so this is a field copy rather than a conversion. It is still the binding's
78
+ * job: ledger 8 represents the same key as a bare hex string, so an era-neutral facade cannot know
79
+ * the shape. The caller-supplied `tag` is preserved so an ECDSA-tagged key is never silently
80
+ * treated as Schnorr.
81
+ *
82
+ * Scheme admissibility is *not* checked here — that is era-neutral policy and stays in
83
+ * `Ledger.fromPlatformSigningKey`, which consults {@link era}'s allowlist before calling this.
84
+ *
85
+ * @category constructors
86
+ */
87
+ export const makeSigningKey = (signingKey) => ({
88
+ tag: signingKey.tag,
89
+ value: signingKey.value
90
+ });
91
+ //# sourceMappingURL=v9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v9.js","sourceRoot":"","sources":["../../../../../src/effect/internal/ledger/v9.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAaH,OAAO,EACL,wBAAwB,EACxB,qCAAqC,EACrC,SAAS,IAAI,eAAe,EAE7B,MAAM,0BAA0B,CAAC;AAIlC,gGAAgG;AAChG,+FAA+F;AAC/F,EAAE;AACF,8FAA8F;AAC9F,8FAA8F;AAC9F,kFAAkF;AAClF,EAAE;AACF,yDAAyD;AACzD,OAAO,EAGL,YAAY,EACZ,iCAAiC,EAEjC,YAAY,EACZ,qBAAqB,EACrB,cA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,WAAuB,EAAyC,EAAE,CACzG,IAAI,qCAAqC,CAAC,0BAA0B,EAAE,WAAW,CAAC,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAA8B,EAAoB,EAAE,CAAC,CAAC;IACnF,GAAG,EAAE,UAAU,CAAC,GAAG;IACnB,KAAK,EAAE,UAAU,CAAC,KAAK;CACxB,CAAC,CAAC"}
@@ -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=binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../../../../src/effect/internal/runtime/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -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/runtime/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,25 @@
1
+ /*
2
+ * This file is part of midnight-sdk.
3
+ * Copyright (C) 2025 Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ /**
16
+ * The compact-runtime line currently bound to this build. Every entry — suffixed and unsuffixed —
17
+ * resolves the `CompactRuntime` facade through this one module, so changing the export below
18
+ * changes the runtime for ALL of them, `/v9` included. Giving each era-pinned entry its own
19
+ * binding is the outstanding work (midnight-sdk#388).
20
+ *
21
+ * Swap this together with `internal/ledger/current.ts`: the two are era-paired, and
22
+ * `test/effect/CompactRuntime.test.ts` fails if only one of them moves.
23
+ */
24
+ export * from './v0_21.js';
25
+ //# sourceMappingURL=current.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current.js","sourceRoot":"","sources":["../../../../../src/effect/internal/runtime/current.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AACH,cAAc,YAAY,CAAC"}
@@ -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=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../../../src/effect/internal/runtime/execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,178 @@
1
+ /*
2
+ * This file is part of midnight-sdk.
3
+ * Copyright (C) 2025 Midnight Foundation
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * You may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ import { ContractMaintenanceAuthority as RuntimeContractMaintenanceAuthority, createCircuitContext, sampleSigningKey } from 'compact-runtime-ledger8';
16
+ // `CallContext`, `Effects` and `CoinCommitment` are the types of the partition inputs
17
+ // `ContractCallPublic` exposes (midnight-sdk#400), and `EncodedStateValue` is listed for the
18
+ // separate reason given on the 0.21 twin. This line reaches all four the same way — an explicit
19
+ // re-export from onchain-runtime-v3 — but without the `CallContext` ambiguity: 0.16's
20
+ // circuit-context declares no `CallContext` of its own, so there is only one to resolve to.
21
+ export { CompactError, ContractState, createCircuitContext, createConstructorContext, decodeZswapLocalState, emptyZswapLocalState, encodeZswapLocalState, signatureVerifyingKey } from 'compact-runtime-ledger8';
22
+ /**
23
+ * This line's `ContractMaintenanceAuthority`, with `deserialize`'s return type repaired.
24
+ *
25
+ * @remarks
26
+ * onchain-runtime-v3 declares `static deserialize(raw: Uint8Array): ContractState` — an upstream
27
+ * mistake in the generated `.d.ts`, and the exact one `@midnightntwrk/ledger-v8@8.1.3` carries on
28
+ * the ledger side (see `internal/ledger/v8.ts`). The WASM really returns a
29
+ * `ContractMaintenanceAuthority`: verified against the shipped 3.1.1 build, where
30
+ * `deserialize(cma.serialize())` yields a value whose constructor is
31
+ * `ContractMaintenanceAuthority` and which fails `instanceof ContractState`.
32
+ *
33
+ * Repairing it at the seam matters more here than the label suggests. `makeConversions` derives
34
+ * `fromRuntimeMaintenanceAuthority`'s **parameter** from this return type, so unrepaired the
35
+ * published `/v8/effect` signature asks for a `ContractState`: the authority a caller actually
36
+ * holds is rejected at compile time, and the contract state that is accepted instead fails inside
37
+ * WASM. The ledger 9 line declares this correctly, so without the repair the two eras would also
38
+ * disagree on a signature that #388 requires to be identical.
39
+ *
40
+ * Re-check on each 3.x release — if upstream fixes the declaration, this cast becomes a no-op and
41
+ * can go. `RuntimeBinding.tst.ts` pins the relationship on both lines.
42
+ */
43
+ const ContractMaintenanceAuthority = RuntimeContractMaintenanceAuthority;
44
+ export { ContractMaintenanceAuthority };
45
+ /**
46
+ * The compact-runtime line this binding targets.
47
+ *
48
+ * @category era
49
+ */
50
+ export const line = '0.16';
51
+ /**
52
+ * Samples a fresh signing key in this line's native representation.
53
+ *
54
+ * @remarks
55
+ * `kind` is accepted and **ignored**: onchain-runtime-v3 has no scheme concept at all — its
56
+ * `SigningKey` is a bare hex string and `sampleSigningKey()` takes no argument — so BIP-340
57
+ * Schnorr is the only thing this line can produce. Callers must consult the *ledger* era's
58
+ * allowlist first (`internal/ledger/v8.ts` permits `schnorr` only), which is what makes ignoring
59
+ * the argument safe rather than silently wrong.
60
+ *
61
+ * The key is returned in this line's native representation — a bare hex string — so that it stays
62
+ * assignable to this line's own `signatureVerifyingKey`. {@link signingKeyHex} is what makes the
63
+ * hex readable era-neutrally.
64
+ *
65
+ * @category constructors
66
+ */
67
+ export const makeSampleSigningKey = (_kind) => sampleSigningKey();
68
+ /**
69
+ * Extracts the hex value of a ledger 8 era signing key.
70
+ *
71
+ * @remarks
72
+ * The identity: onchain-runtime-v3 has no tagged-key concept, so a `SigningKey` *is* its hex
73
+ * string. Present so era-neutral code can read a key's hex without branching — the ledger 9 era's
74
+ * counterpart reads `.value` off a tagged key.
75
+ *
76
+ * @category conversions
77
+ */
78
+ export const signingKeyHex = (key) => key;
79
+ /**
80
+ * Carries the facts `readExecution` needs but 0.16 does not record: the circuit id, the contract
81
+ * address, and the query context as it stood *before* execution.
82
+ *
83
+ * A `Symbol` key, not a string, so it cannot collide with anything the generated contract reads —
84
+ * and not a `WeakMap`, because the generated 0.16 circuit rebuilds the context
85
+ * (`const context = { ...contextOrig_0, gasCost: … }`), which would break identity-keyed lookup.
86
+ * Object spread copies own enumerable *symbol* properties as well as string ones, so this survives
87
+ * that hop.
88
+ */
89
+ const EXECUTION_META = Symbol('compact-js/runtime/0.16/executionMeta');
90
+ /**
91
+ * Builds a circuit-execution context for this line.
92
+ *
93
+ * @remarks
94
+ * Two adaptations. The positional order differs — 0.16 takes the contract address first and has no
95
+ * circuit-id parameter at all — and the circuit id, address and pre-execution query context are
96
+ * recorded on the context so {@link readExecution} can rebuild a trace entry the newer line
97
+ * supplies natively.
98
+ *
99
+ * The initial query context is snapshotted *here*, not read back later: the flat 0.16 context is
100
+ * mutated in place during execution, so reading it afterwards would report the final state as the
101
+ * initial one and silently corrupt transcript partitioning.
102
+ *
103
+ * @throws If `stateProvider`, `moduleProvider` or `parentBlockHash` is supplied. This line has no
104
+ * `crossContractCall`, `ContractStateProvider` or `ContractModuleProvider`, so honouring a
105
+ * cross-contract call is impossible; ignoring a provider would instead make such a call appear to
106
+ * succeed against stale state.
107
+ *
108
+ * @category execution
109
+ */
110
+ export const createExecutionContext = (params) => {
111
+ if (params.stateProvider !== undefined ||
112
+ params.moduleProvider !== undefined ||
113
+ params.parentBlockHash !== undefined) {
114
+ throw new Error(`compact-runtime ${line} (ledger 8 era) cannot execute cross-contract calls: ` +
115
+ 'this line has no crossContractCall, ContractStateProvider or ContractModuleProvider. ' +
116
+ 'Use a build pinned to a later era to call across contracts.');
117
+ }
118
+ // The gas limit is fifth and `time` seventh here; `costModel` sits between them and stays at
119
+ // the default, for the reason the 0.21 twin gives.
120
+ const context = createCircuitContext(params.address, params.zswapLocalState, params.contractState, params.privateState, params.queryGasLimit, undefined, params.time);
121
+ const meta = {
122
+ circuitId: params.circuitId,
123
+ contractAddress: params.address,
124
+ initialQueryContext: context.currentQueryContext
125
+ };
126
+ return Object.defineProperty(context, EXECUTION_META, {
127
+ value: meta,
128
+ enumerable: true,
129
+ writable: false,
130
+ configurable: false
131
+ });
132
+ };
133
+ /**
134
+ * Projects this line's circuit results into the era-neutral execution view.
135
+ *
136
+ * @remarks
137
+ * The trace is **synthesised** as a single entry. That is faithful rather than lossy: without
138
+ * `crossContractCall` this line can only ever produce one call, so a one-element trace is complete
139
+ * by construction. The proof data 0.21 hangs off each `CallProofData` lives on `results.proofData`
140
+ * here, and is moved across.
141
+ *
142
+ * `events` is always empty, and typed `never[]` — see {@link LogEvent}.
143
+ *
144
+ * @throws If the context was not built by {@link createExecutionContext}. Without the recorded
145
+ * metadata the circuit id, address and pre-execution state are unrecoverable, and guessing them
146
+ * would produce a trace that looks valid and proves the wrong call.
147
+ *
148
+ * @category execution
149
+ */
150
+ export const readExecution = (results) => {
151
+ const meta = results.context[EXECUTION_META];
152
+ if (meta === undefined) {
153
+ throw new Error(`compact-runtime ${line} (ledger 8 era): circuit results carry no execution metadata. ` +
154
+ 'Build the context with createExecutionContext rather than createCircuitContext.');
155
+ }
156
+ const entry = {
157
+ circuitId: meta.circuitId,
158
+ contractAddress: meta.contractAddress,
159
+ initialQueryContext: meta.initialQueryContext,
160
+ finalQueryContext: results.context.currentQueryContext,
161
+ publicTranscript: results.proofData.publicTranscript,
162
+ input: results.proofData.input,
163
+ output: results.proofData.output,
164
+ privateTranscriptOutputs: results.proofData.privateTranscriptOutputs,
165
+ zswapLocalState: results.context.currentZswapLocalState,
166
+ // Only ever set for a cross-contract sub-call, which this line cannot make.
167
+ commCommData: undefined
168
+ };
169
+ return {
170
+ result: results.result,
171
+ trace: [entry],
172
+ privateState: results.context.currentPrivateState,
173
+ zswapLocalState: results.context.currentZswapLocalState,
174
+ events: [],
175
+ gasCosts: undefined
176
+ };
177
+ };
178
+ //# sourceMappingURL=v0_16.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v0_16.js","sourceRoot":"","sources":["../../../../../src/effect/internal/runtime/v0_16.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA2CH,OAAO,EAIL,4BAA4B,IAAI,mCAAmC,EAEnE,oBAAoB,EAKpB,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAKjC,sFAAsF;AACtF,6FAA6F;AAC7F,gGAAgG;AAChG,sFAAsF;AACtF,4FAA4F;AAC5F,OAAO,EAML,YAAY,EAGZ,aAAa,EACb,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EAErB,oBAAoB,EAGpB,qBAAqB,EAIrB,qBAAqB,EAItB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,4BAA4B,GAAG,mCAGpC,CAAC;AAEF,OAAO,EAAE,4BAA4B,EAAE,CAAC;AAKxC;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAA4B,CAAC;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAoB,EAAc,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAE7F;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAe,EAAU,EAAE,CAAC,GAAG,CAAC;AAyC9D;;;;;;;;;GASG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;AAUvE;;;;;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