@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,167 @@
1
+ /**
2
+ * An in-process accumulator, and query surface, over the {@link ContractLog.ContractEvent}s
3
+ * produced by locally executed circuits (MIP-0002 Part 2).
4
+ *
5
+ * @remarks
6
+ * This is deliberately **indexer-agnostic**: the store is an in-memory accumulator over events
7
+ * from local circuit execution, not a chain index. Its {@link ContractEventFilter} and monotonic
8
+ * `id` cursor are shaped to align with the MIP's `ContractEventFilter` / `id` so a future
9
+ * indexer-backed implementation (in `midnight-js`) can reuse the same types.
10
+ *
11
+ * Typical usage — decode a circuit result's raw events and append them, then query:
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { ContractExecutable, ContractLog, ContractEventStore } from '@midnightntwrk/compact-js/effect';
16
+ * import { Effect } from 'effect';
17
+ *
18
+ * const program = Effect.gen(function* () {
19
+ * const store = yield* ContractEventStore.ContractEventStore;
20
+ * const result = yield* contract.circuit(circuitId, ctx, ...args);
21
+ * yield* store.append(ContractLog.decodeAll(result.events));
22
+ * return yield* store.query({ eventType: 'unshielded-mint' });
23
+ * }).pipe(Effect.provide(ContractEventStore.layer));
24
+ * ```
25
+ *
26
+ * @packageDocumentation
27
+ */
28
+ import type * as ContractAddress from '@midnight-ntwrk/platform-js/effect/ContractAddress';
29
+ import { Context, Effect, Layer, Stream } from 'effect';
30
+ import * as ContractLog from './ContractLog.js';
31
+ import * as MalformedHexPrefixError from './MalformedHexPrefixError.js';
32
+ /**
33
+ * A {@link ContractLog.ContractEvent} accumulated in a {@link ContractEventStore}, tagged with the
34
+ * monotonic `id` assigned on append (mirroring the indexer's `BIGSERIAL` cursor). The emitting
35
+ * contract's `address` is carried on the event itself.
36
+ *
37
+ * @category model
38
+ */
39
+ export type StoredEvent = ContractLog.ContractEvent & {
40
+ readonly id: bigint;
41
+ };
42
+ /**
43
+ * Matches a single indexed field's byte value against a hex `prefix`. When `fieldName` is omitted,
44
+ * the prefix matches if **any** of the event's indexed fields starts with it.
45
+ *
46
+ * @category model
47
+ */
48
+ export interface FieldPrefixFilter {
49
+ readonly fieldName?: string;
50
+ /**
51
+ * A hex string (with or without a leading `0x`), matched case-insensitively as a prefix of the
52
+ * field's bytes. Matching is nibble-granular: use an **even-length** prefix for byte-accurate
53
+ * matching (e.g. `'07'` matches only the byte `0x07`), since an odd-length prefix such as `'7'`
54
+ * matches any field whose first byte is `0x70`–`0x7f`. An empty prefix matches any present field.
55
+ * A prefix that is not valid hex fails the `query`/`subscribe` with a
56
+ * {@link MalformedHexPrefixError.MalformedHexPrefixError} rather than silently matching nothing.
57
+ */
58
+ readonly prefix: string;
59
+ }
60
+ /**
61
+ * A filter over accumulated events, aligned with the MIP-0002 `ContractEventFilter` shape. All
62
+ * present criteria must match (logical AND). Events whose type indexes nothing (e.g. `misc`,
63
+ * lifecycle) and degraded events never match a {@link FieldPrefixFilter}.
64
+ *
65
+ * @category model
66
+ */
67
+ export interface ContractEventFilter {
68
+ /** Restrict to events emitted by this contract. */
69
+ readonly contractAddress?: ContractAddress.ContractAddress;
70
+ /** Restrict to a single event type. */
71
+ readonly eventType?: ContractLog.LogEventType;
72
+ /** Restrict to events whose indexed fields match every given prefix. */
73
+ readonly fieldPrefixes?: readonly FieldPrefixFilter[];
74
+ /** Resume cursor — include only events with `id >= fromId`. */
75
+ readonly fromId?: bigint;
76
+ }
77
+ declare const ContractEventStore_base: Context.TagClass<ContractEventStore, "compact-js/ContractEventStore", ContractEventStore.Service>;
78
+ /**
79
+ * Provides an in-process store, query surface, and subscription feed for contract log events.
80
+ *
81
+ * @category services
82
+ */
83
+ export declare class ContractEventStore extends ContractEventStore_base {
84
+ }
85
+ export declare namespace ContractEventStore {
86
+ /**
87
+ * Provides an in-process store, query surface, and subscription feed for contract log events.
88
+ */
89
+ interface Service {
90
+ /**
91
+ * Appends events to the store, assigning each a monotonic `id`, and returns them as
92
+ * {@link StoredEvent}s in append order.
93
+ *
94
+ * @param events The decoded events to append (e.g. `ContractLog.decodeAll(result.events)`).
95
+ * @returns An `Effect` yielding the stored events, each tagged with its assigned `id`.
96
+ */
97
+ readonly append: (events: readonly ContractLog.ContractEvent[]) => Effect.Effect<readonly StoredEvent[]>;
98
+ /**
99
+ * Returns the accumulated events matching `filter`, in ascending `id` order.
100
+ *
101
+ * @param filter The criteria to match; when omitted, all events are returned.
102
+ * @returns An `Effect` yielding the matching events, or failing with a
103
+ * {@link MalformedHexPrefixError.MalformedHexPrefixError} if any `fieldPrefixes` prefix is not
104
+ * valid hex.
105
+ */
106
+ readonly query: (filter?: ContractEventFilter) => Effect.Effect<readonly StoredEvent[], MalformedHexPrefixError.MalformedHexPrefixError>;
107
+ /**
108
+ * Subscribes to a live, filtered, resumable feed of events in ascending `id` order.
109
+ *
110
+ * The stream first **replays** matching history (from `filter.fromId`, if given), then **tails**
111
+ * newly appended events — with no gap or duplicate at the boundary. The same `filter` is applied
112
+ * to both phases. The subscription is scope-managed: it is torn down automatically when the
113
+ * enclosing `Scope` closes.
114
+ *
115
+ * To resume after a disconnect, pass **`lastSeenId + 1n`** as `filter.fromId`: the cursor is
116
+ * **inclusive** (`id >= fromId`), so passing the last-seen id itself would redeliver that event.
117
+ *
118
+ * Under sustained backpressure the live feed may drop the oldest un-consumed events (see
119
+ * {@link makeLayer}). There is **no programmatic drop signal** — a filter-induced `id` skip and
120
+ * a drop-induced one are indistinguishable on the stream — so a subscriber that must not miss
121
+ * events should periodically reconcile via `query`, and after falling behind reconnect with an
122
+ * updated `fromId` to backfill the missed events from the retained history.
123
+ *
124
+ * @param filter The criteria to match; when omitted, every event is delivered. A `fieldPrefixes`
125
+ * prefix that is not valid hex fails the stream with a
126
+ * {@link MalformedHexPrefixError.MalformedHexPrefixError}.
127
+ * @returns A `Stream` of matching events.
128
+ */
129
+ readonly subscribe: (filter?: ContractEventFilter) => Stream.Stream<StoredEvent, MalformedHexPrefixError.MalformedHexPrefixError>;
130
+ }
131
+ }
132
+ /** Determine whether a stored event satisfies every present criterion of a filter. */
133
+ export declare const matches: (event: StoredEvent, filter?: ContractEventFilter) => boolean;
134
+ /** Default `PubSub` capacity for the live subscription feed. */
135
+ export declare const DEFAULT_CAPACITY = 1024;
136
+ /**
137
+ * Builds an in-memory {@link ContractEventStore} layer backed by a `Ref` (full history) and a
138
+ * **sliding** `PubSub` (live feed). Events accumulate for the lifetime of the provided scope; ids
139
+ * are monotonic starting at `1`.
140
+ *
141
+ * @remarks
142
+ * The live feed uses a **sliding** buffer rather than a back-pressuring one, and this is a
143
+ * deliberate liveness choice: `append` publishes to the feed while holding the append lock, so a
144
+ * back-pressuring buffer would let a single slow or non-draining subscriber fill the buffer, wedge
145
+ * the suspended publish under the lock, and block **every** subsequent append — including those
146
+ * driven by circuit execution — indefinitely. A sliding buffer never suspends the publisher, so
147
+ * appends can never be wedged by a stalled consumer. The trade-off is that a subscriber that cannot
148
+ * keep up loses the **oldest** un-consumed live events once more than `capacity` accumulate (a gap
149
+ * in its live tail). Because the full history is always retained in the backing `Ref`, such a
150
+ * subscriber can recover any missed events by re-`query`-ing or resubscribing with a `fromId`
151
+ * cursor.
152
+ *
153
+ * @param capacity The live-feed buffer size; once more than this many events are buffered for a
154
+ * subscriber, the oldest are dropped for that subscriber. Defaults to {@link DEFAULT_CAPACITY}.
155
+ *
156
+ * @category layers
157
+ */
158
+ export declare const makeLayer: (capacity?: number) => Layer.Layer<ContractEventStore>;
159
+ /**
160
+ * An in-memory {@link ContractEventStore} layer with the default live-feed capacity
161
+ * ({@link DEFAULT_CAPACITY}). See {@link makeLayer} to configure the capacity.
162
+ *
163
+ * @category layers
164
+ */
165
+ export declare const layer: Layer.Layer<ContractEventStore>;
166
+ export {};
167
+ //# sourceMappingURL=ContractEventStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractEventStore.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractEventStore.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,KAAK,eAAe,MAAM,oDAAoD,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,uBAAuB,MAAM,8BAA8B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,aAAa,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC;IAC3D,uCAAuC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC;IAC9C,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtD,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,uBAGrC;CAAG;AAEN,MAAM,CAAC,OAAO,WAAW,kBAAkB,CAAC;IAC1C;;OAEG;IACH,UAAiB,OAAO;QACtB;;;;;;WAMG;QACH,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,WAAW,CAAC,aAAa,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC;QAEzG;;;;;;;WAOG;QACH,QAAQ,CAAC,KAAK,EAAE,CACd,MAAM,CAAC,EAAE,mBAAmB,KACzB,MAAM,CAAC,MAAM,CAAC,SAAS,WAAW,EAAE,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;QAE5F;;;;;;;;;;;;;;;;;;;;;WAqBG;QACH,QAAQ,CAAC,SAAS,EAAE,CAClB,MAAM,CAAC,EAAE,mBAAmB,KACzB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,uBAAuB,CAAC,uBAAuB,CAAC,CAAC;KAClF;CACF;AAgED,sFAAsF;AACtF,eAAO,MAAM,OAAO,GAAI,OAAO,WAAW,EAAE,SAAS,mBAAmB,KAAG,OAQ1E,CAAC;AASF,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS,GAAI,WAAU,MAAyB,KAAG,KAAK,CAAC,KAAK,CAAC,kBAAkB,CA2D3F,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAAe,CAAC"}
@@ -0,0 +1,34 @@
1
+ declare const TypeId: unique symbol;
2
+ type TypeId = typeof TypeId;
3
+ declare const ContractEventValidationError_base: new <A extends Record<string, any>>(args: import("effect/Types").Simplify<A>) => import("effect/Cause").YieldableError & Record<typeof TypeId, typeof TypeId> & {
4
+ readonly _tag: "ContractEventValidationError";
5
+ } & Readonly<A>;
6
+ /**
7
+ * An error that occurred while validating that contract events comply with system constraints.
8
+ *
9
+ * @category errors
10
+ */
11
+ export declare class ContractEventValidationError extends ContractEventValidationError_base<{
12
+ /** A displayable message. */
13
+ readonly message: string;
14
+ /** Indicates a more specific cause of the error. */
15
+ readonly cause?: unknown;
16
+ }> {
17
+ }
18
+ /**
19
+ * Determines if a value is a contract event validation error.
20
+ *
21
+ * @param u The value to check.
22
+ * @returns `true` if `u` is a {@link ContractEventValidationError}; `false` otherwise.
23
+ *
24
+ * @category guards
25
+ */
26
+ export declare const isValidationError: (u: unknown) => u is ContractEventValidationError;
27
+ /**
28
+ * Creates a new {@link ContractEventValidationError}.
29
+ *
30
+ * @category constructors
31
+ */
32
+ export declare const make: (message: string, cause?: unknown) => ContractEventValidationError;
33
+ export {};
34
+ //# sourceMappingURL=ContractEventValidationError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractEventValidationError.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractEventValidationError.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,MAAM,EAAE,OAAO,MAAqE,CAAC;AAC3F,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;;;;AAE5B;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,kCAA0D;IAC1G,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;CAAI;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,4BAAsD,CAAC;AAE3G;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,4BACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Effect } from 'effect';
2
+ import * as ContractEventValidationError from './ContractEventValidationError.js';
3
+ /**
4
+ * Validates that `events` is a well-formed array of contract log events.
5
+ *
6
+ * Events reach this boundary as untrusted input, so they are decoded from `unknown` with a
7
+ * {@link Schema} — yielding both the structural validation and a typed failure, rather than
8
+ * hand-rolled `in`/`instanceof` checks.
9
+ *
10
+ * @param events The value to validate.
11
+ * @returns An {@link Effect} that fails with a
12
+ * {@link ContractEventValidationError.ContractEventValidationError} if `events` is not a valid
13
+ * array of log events.
14
+ *
15
+ * @category validation
16
+ */
17
+ export declare const validateEvents: (events: unknown) => Effect.Effect<void, ContractEventValidationError.ContractEventValidationError>;
18
+ //# sourceMappingURL=ContractEventValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractEventValidator.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractEventValidator.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,KAAK,4BAA4B,MAAM,mCAAmC,CAAC;AAmBlF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,OAAO,KACd,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,4BAA4B,CAAC,4BAA4B,CAS7E,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Contract execution for the era this build binds.
3
+ *
4
+ * @remarks
5
+ * The bodies live in `internal/executable.ts`, which takes an era pair as arguments; this module is
6
+ * that factory applied to the {@link Ledger} and {@link CompactRuntime} facades — so it follows
7
+ * each seam's `current.ts`, exactly as it did when it held the implementation itself. Consumers
8
+ * see no difference: the type and function names, their parameters and their results are unchanged.
9
+ *
10
+ * What changed is that this is no longer the *only* application. `internal/era/v8Executable.ts` and
11
+ * `internal/era/v9Executable.ts` apply the same factory to a pinned era pair, which is what lets
12
+ * `/v8/effect` and `/v9/effect` export an executable that genuinely belongs to the era its path
13
+ * names rather than to whichever era the build bound (midnight-sdk#387/#388).
14
+ *
15
+ * @module
16
+ */
17
+ import * as CompactRuntime from './CompactRuntime.js';
18
+ import type * as Contract from './Contract.js';
19
+ import * as Internal from './internal/executable.js';
20
+ import * as Ledger from './Ledger.js';
21
+ /** The era pair this entry executes against: whichever the build binds. */
22
+ type BoundLedger = typeof Ledger;
23
+ type BoundRuntime = typeof CompactRuntime;
24
+ /**
25
+ * An executable form of a Compact compiled contract.
26
+ */
27
+ export interface ContractExecutable<in out C extends Contract.Contract<PS>, PS, out E = never, out R = never> extends Internal.ContractExecutable<BoundLedger, BoundRuntime, C, PS, E, R> {
28
+ }
29
+ export declare namespace ContractExecutable {
30
+ /**
31
+ * The services required as context for executing contracts.
32
+ */
33
+ type Context = Internal.Context;
34
+ type ContractContext = Internal.ContractContext<BoundLedger, BoundRuntime>;
35
+ type CircuitContext<PS> = Internal.CircuitContext<BoundLedger, BoundRuntime, PS>;
36
+ type GasCost = Internal.GasCost;
37
+ type DeployResultPublic = Internal.DeployResultPublic<BoundLedger, BoundRuntime>;
38
+ type DeployResultPrivate<PS> = Internal.DeployResultPrivate<BoundLedger, BoundRuntime, PS>;
39
+ type DeployResult<PS> = Internal.DeployResult<BoundLedger, BoundRuntime, PS>;
40
+ type PartitionedTranscript = Internal.PartitionedTranscript<BoundLedger, BoundRuntime>;
41
+ type CallPartitionInputs = Internal.CallPartitionInputs<BoundLedger, BoundRuntime>;
42
+ type ContractCallPublic = Internal.ContractCallPublic<BoundLedger, BoundRuntime>;
43
+ type ContractCallPrivate = Internal.ContractCallPrivate<BoundLedger, BoundRuntime>;
44
+ /**
45
+ * Proof data for a single contract call. One {@link ContractCall} is produced for every call
46
+ * made while executing a circuit — the root call plus one per cross-contract call —
47
+ * corresponding to the entries of the runtime's `callProofDataTrace`.
48
+ */
49
+ type ContractCall = Internal.ContractCall<BoundLedger, BoundRuntime>;
50
+ /**
51
+ * The result of invoking a circuit.
52
+ *
53
+ * `calls` holds the proof data for every contract call made during execution, in
54
+ * `callProofDataTrace` order — callees first, the root call last. The application-facing
55
+ * `result`, `privateState`, and `zswapLocalState` belong to the root contract and are
56
+ * statically typed for it; sub-calls expose only proof data (other contracts' types are not
57
+ * known here, and only the root holds private state). Each call carries its own Zswap local
58
+ * state on `calls[i].private.zswapLocalState` — the root's is repeated here for convenience.
59
+ *
60
+ * `events` is the single execution-wide log-event list across the whole call tree, in emission
61
+ * order; each event is tagged with its emitting contract's address, so a per-contract view is a
62
+ * filter over that tag. Events are NOT consensus state and are handled by the indexer; size and
63
+ * well-formedness are enforced on-chain by the ledger/VM (degraded, not failed) per MIP-0002.
64
+ *
65
+ * The events are kept **raw** here to avoid paying decode cost when unused. To obtain typed,
66
+ * per-event payloads, decode on demand with `ContractLog.decodeAll(result.events)` (which
67
+ * degrades gracefully and never throws); feed them to a `ContractEventStore` to query/subscribe.
68
+ */
69
+ type CallResult<C extends Contract.Contract<PS>, PS, K extends Contract.ProvableCircuitId<C>> = Internal.CallResult<BoundLedger, BoundRuntime, C, PS, K>;
70
+ type MaintenanceResultPublic = Internal.MaintenanceResultPublic<BoundLedger, BoundRuntime>;
71
+ type MaintenanceResultPrivate = Internal.MaintenanceResultPrivate;
72
+ type MaintenanceResult = Internal.MaintenanceResult<BoundLedger, BoundRuntime>;
73
+ }
74
+ /**
75
+ * An error occurred while executing a constructor, or a circuit, of an executable contract.
76
+ *
77
+ * @category errors
78
+ */
79
+ export type ContractExecutionError = Internal.ContractExecutionError;
80
+ /**
81
+ * Takes a Compact compiled contract, and makes it executable.
82
+ *
83
+ * @param compiledContract A {@link CompiledContract}
84
+ * @returns A {@link ContractExecutable} for `compiledContract`.
85
+ *
86
+ * @category constructors
87
+ */
88
+ export declare const make: <C extends Contract.Contract<PS, Contract.Witnesses<PS>>, PS>(compiledContract: import("./CompiledContract.js").CompiledContract<C, PS, never>) => Internal.ContractExecutable<typeof Ledger, typeof CompactRuntime, C, PS, Internal.ContractExecutionError, Internal.Context>;
89
+ /**
90
+ * Provides a layer to the executable contract.
91
+ *
92
+ * @category combinators
93
+ */
94
+ export declare const provide: {
95
+ <LA, LE, LR>(layer: import("effect/Layer").Layer<LA, LE, LR>): <C extends Contract.Contract<PS, Contract.Witnesses<PS>>, PS, E, Rq>(self: Internal.ContractExecutable<typeof Ledger, typeof CompactRuntime, C, PS, E, Rq>) => Internal.ContractExecutable<typeof Ledger, typeof CompactRuntime, C, PS, LE | E, LR | Exclude<Rq, LA>>;
96
+ <C extends Contract.Contract<PS, Contract.Witnesses<PS>>, PS, E, Rq, LA, LE, LR>(self: Internal.ContractExecutable<typeof Ledger, typeof CompactRuntime, C, PS, E, Rq>, layer: import("effect/Layer").Layer<LA, LE, LR>): Internal.ContractExecutable<typeof Ledger, typeof CompactRuntime, C, PS, E | LE, LR | Exclude<Rq, LA>>;
97
+ };
98
+ export {};
99
+ //# sourceMappingURL=ContractExecutable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractExecutable.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractExecutable.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,2EAA2E;AAC3E,KAAK,WAAW,GAAG,OAAO,MAAM,CAAC;AACjC,KAAK,YAAY,GAAG,OAAO,cAAc,CAAC;AAI1C;;GAEG;AAEH,MAAM,WAAW,kBAAkB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,CAC1G,SAAQ,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;CAAG;AAEhF,MAAM,CAAC,OAAO,WAAW,kBAAkB,CAAC;IAC1C;;OAEG;IACH,KAAY,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAEvC,KAAY,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAElF,KAAY,cAAc,CAAC,EAAE,IAAI,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAExF,KAAY,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAEvC,KAAY,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACxF,KAAY,mBAAmB,CAAC,EAAE,IAAI,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAClG,KAAY,YAAY,CAAC,EAAE,IAAI,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAEpF,KAAY,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAC9F,KAAY,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAC1F,KAAY,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACxF,KAAY,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAE1F;;;;OAIG;IACH,KAAY,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAE5E;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAY,UAAU,CACpB,CAAC,SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAC/B,EAAE,EACF,CAAC,SAAS,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,IACrC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAE7D,KAAY,uBAAuB,GAAG,QAAQ,CAAC,uBAAuB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClG,KAAY,wBAAwB,GAAG,QAAQ,CAAC,wBAAwB,CAAC;IACzE,KAAY,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;CACvF;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,gRAAkB,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;CAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type Layer, ManagedRuntime } from 'effect';
2
+ import { type ContractExecutable } from './ContractExecutable.js';
3
+ export declare const make: <E>(layer: Layer.Layer<ContractExecutable.Context, E>) => ManagedRuntime.ManagedRuntime<import("./internal/executable.js").Context, E>;
4
+ //# sourceMappingURL=ContractExecutableRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractExecutableRuntime.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractExecutableRuntime.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,OAAO,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC,CAAC,iFAA+B,CAAA"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The canonical key-location grammar for contract calls.
3
+ *
4
+ * A transaction carries one proof per contract call, and each call prototype carries a
5
+ * `key_location` string that routes the call to the proving material (prover key, verifier key,
6
+ * ZKIR) for its circuit. The ledger treats `key_location` as opaque prover-routing metadata: it is
7
+ * written by the transaction assembler, round-tripped verbatim to the proving provider, and never
8
+ * enters consensus. Historically the bare circuit name was used, which collides when two contracts
9
+ * in the same transaction deploy identically named circuits.
10
+ *
11
+ * The canonical grammar is:
12
+ *
13
+ * ```
14
+ * contract:<contract-address-hex>/<circuitId>?vk=<sha-256 of the deployed raw verifier key, hex>
15
+ * ```
16
+ *
17
+ * - `<contract-address-hex>` is the 64-character hex encoding of the contract's address;
18
+ * - `<circuitId>` is the circuit's identifier, restricted to `[A-Za-z0-9_]+` so that locations
19
+ * can never traverse paths when a prover maps them onto a file system;
20
+ * - `vk` is the lowercase hex SHA-256 digest of the raw verifier key bytes deployed for the
21
+ * circuit, allowing provers to resolve key material by verifier-key content (a vk-join) rather
22
+ * than trusting a name.
23
+ *
24
+ * The `midnight/` prefix is reserved for protocol builtins (e.g. `midnight/zswap/spend`) and is
25
+ * never produced or parsed by this codec.
26
+ */
27
+ export interface ContractKeyLocation {
28
+ /** The hex-encoded address of the contract being called. */
29
+ readonly contractAddress: string;
30
+ /** The identifier of the circuit being invoked. */
31
+ readonly circuitId: string;
32
+ /** The lowercase hex SHA-256 digest of the circuit's deployed raw verifier key. */
33
+ readonly verifierKeyHash: string;
34
+ }
35
+ /**
36
+ * Computes the lowercase hex SHA-256 digest of a raw verifier key.
37
+ *
38
+ * @param verifierKey The raw verifier key bytes, exactly as deployed in the contract's operation.
39
+ */
40
+ export declare const hashVerifierKey: (verifierKey: Uint8Array) => string;
41
+ /**
42
+ * Encodes a {@link ContractKeyLocation} into the canonical grammar.
43
+ *
44
+ * @throws Error If any component fails validation; an invalid component can never be a key
45
+ * location, and silently encoding one would produce a location no prover can resolve.
46
+ */
47
+ export declare const encodeContractKeyLocation: (location: ContractKeyLocation) => string;
48
+ /**
49
+ * Parses a canonical key location, returning `undefined` when the input is not in the canonical
50
+ * grammar (e.g. a bare circuit name, or a `midnight/` protocol builtin). Parsing is strict:
51
+ * a string that begins with `contract:` but deviates from the grammar is rejected rather than
52
+ * repaired, so that assembler and prover can never disagree about a location's meaning.
53
+ */
54
+ export declare const parseContractKeyLocation: (keyLocation: string) => ContractKeyLocation | undefined;
55
+ //# sourceMappingURL=ContractKeyLocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractKeyLocation.d.ts","sourceRoot":"","sources":["../../../src/effect/ContractKeyLocation.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAQD;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,aAAa,UAAU,KAAG,MAAyC,CAAC;AAEpG;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,mBAAmB,KAAG,MAiBzE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,aAAa,MAAM,KAAG,mBAAmB,GAAG,SAcpF,CAAC"}