@openzeppelin/compact-deployer 0.2.0 → 0.3.1

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 (57) hide show
  1. package/CHANGELOG.md +30 -5
  2. package/README.md +116 -81
  3. package/dist/config/compact-config.d.ts +5 -0
  4. package/dist/config/compact-config.js +65 -19
  5. package/dist/config/compact-config.js.map +1 -1
  6. package/dist/config/patterns.d.ts +20 -0
  7. package/dist/config/patterns.js +68 -0
  8. package/dist/config/patterns.js.map +1 -0
  9. package/dist/config/schema.d.ts +314 -46
  10. package/dist/config/schema.js +44 -11
  11. package/dist/config/schema.js.map +1 -1
  12. package/dist/deployer.d.ts +11 -1
  13. package/dist/deployer.js +106 -29
  14. package/dist/deployer.js.map +1 -1
  15. package/dist/errors.d.ts +9 -1
  16. package/dist/errors.js +11 -3
  17. package/dist/errors.js.map +1 -1
  18. package/dist/loaders/artifact.d.ts +2 -0
  19. package/dist/loaders/artifact.js +4 -3
  20. package/dist/loaders/artifact.js.map +1 -1
  21. package/dist/loaders/contract-resolve.d.ts +3 -2
  22. package/dist/loaders/contract-resolve.js +8 -3
  23. package/dist/loaders/contract-resolve.js.map +1 -1
  24. package/dist/loaders/init-state.d.ts +7 -3
  25. package/dist/loaders/init-state.js +9 -3
  26. package/dist/loaders/init-state.js.map +1 -1
  27. package/dist/loaders/signing-key.d.ts +3 -0
  28. package/dist/loaders/signing-key.js +6 -0
  29. package/dist/loaders/signing-key.js.map +1 -1
  30. package/dist/runDeploy.d.ts +7 -1
  31. package/dist/runDeploy.js +7 -2
  32. package/dist/runDeploy.js.map +1 -1
  33. package/dist/services/chain-state.d.ts +7 -4
  34. package/dist/services/chain-state.js +14 -5
  35. package/dist/services/chain-state.js.map +1 -1
  36. package/dist/services/contract-state.d.ts +2 -2
  37. package/dist/services/contract-state.js +2 -2
  38. package/dist/services/contract-state.js.map +1 -1
  39. package/dist/services/deploy-tx.d.ts +16 -5
  40. package/dist/services/deploy-tx.js +17 -7
  41. package/dist/services/deploy-tx.js.map +1 -1
  42. package/dist/services/fragment-size.d.ts +8 -0
  43. package/dist/services/fragment-size.js +19 -0
  44. package/dist/services/fragment-size.js.map +1 -0
  45. package/dist/services/maintenance-tx.d.ts +17 -5
  46. package/dist/services/maintenance-tx.js +38 -5
  47. package/dist/services/maintenance-tx.js.map +1 -1
  48. package/dist/services/wallet-cache.d.ts +3 -3
  49. package/dist/services/wallet-cache.js +2 -2
  50. package/dist/services/wallet-cache.js.map +1 -1
  51. package/dist/services/wallet-sync.js +3 -3
  52. package/dist/services/wallet-sync.js.map +1 -1
  53. package/dist/wallet/handler.d.ts +1 -1
  54. package/dist/wallet/handler.js +5 -3
  55. package/dist/wallet/handler.js.map +1 -1
  56. package/package.json +19 -19
  57. package/proof-server.yml +1 -1
package/CHANGELOG.md CHANGED
@@ -8,16 +8,41 @@ and this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ### Fixed
12
+
13
+ - A fragmented deploy of a contract compiled with `--feature-zkir-v3` no longer fails its verifier-key insert with `expected header tag 'midnight:verifier-key[v6]:'`. Each key is inserted under the version the ledger accepts for it (#200)
14
+
15
+ ## 0.3.0 (2026-09-24)
16
+
17
+ ### Added
18
+
19
+ - `[contracts]` pattern keys, so one entry covers many contracts: a name pattern (`"Mock*"`) or a directory pattern (`"**/test/mocks/*"`) matched under the new `[profile].src_dir`. `{name}` expands to the contract name and `artifact` defaults to it. See the README's "Patterns" section (#193)
20
+ - `initialPrivateState` on `DeployerOptions` and `RunDeployOptions` sets the initial private state in code and overrides `[contracts.X].init_private_state`. A `private_state_id` with no initial private state from either source fails with exit 2, and so does an in-code state with no `private_state_id` (#193)
21
+ - `witnesses` on `DeployerOptions` and `RunDeployOptions` sets the witness implementations in code and overrides `[contracts.X].witnesses` (#193)
22
+ - `record` on `DeployerOptions` and `RunDeployOptions`, default `true`. With `false` a deploy reads and writes no deployments ledger, so it never resumes and `deploymentsFile` is `''` (#193)
23
+ - With no fragment budget, a later deploy of the same artifact on the same network starts at the size an earlier halving in the process settled on, instead of every circuit (#193)
24
+
25
+ ### Changed
26
+
27
+ - **Breaking:** the deploy stack moves to Ledger v9. Compile artifacts with `compact compile +0.34.0`; an older one fails at submit with `Version mismatch`. Versions in the README's "Supported stack" (#192)
28
+ - **Breaking:** signing and verifying keys are tagged `{ tag, value }`, not hex. `SigningKey.ledgerKey` gives that form and `ChainSnapshot.committee` is `SignatureVerifyingKey[]`. `signing_key_file` on disk is unchanged (#192)
29
+ - yarn and pnpm need one resolution, `@midnightntwrk/ledger-v9`, down from six (#192)
30
+ - `proof_server = "auto"` boots `midnightntwrk/proof-server:9.0.0-rc.6` (#192)
31
+ - `@midnightntwrk/ledger-v9` moves from 1.0.0-rc.3 to 1.0.0-rc.5. npm now needs the pin too, as `overrides`. Update the yarn / pnpm resolution to match (#193)
32
+ - **Breaking:** `CompactConfigData.contracts` holds partial entries, which `CompactConfig.contract(name)` merges and validates. `listContracts()` returns exact keys only; `listPatterns()` returns the pattern keys (#193)
33
+
34
+ ## 0.2.0 (2026-09-15)
35
+
11
36
  ### Added
12
37
 
13
- - Fragmented deploy for contracts too large for one block, driven by `--circuits-per-tx` / `[contracts.X].circuits_per_tx`, with resume from chain state and a strict verify before `confirmed`. See the README's "Large contracts" section
14
- - `DeployResult` gains `fragments` and `circuits`; both appear in `--json`, alongside a failed fragmented deploy's `address`, `circuitsOnChain`, `circuitsPending`, and `txId`
15
- - Exit codes `7` (`BlockLimitError`: the deploy tx was refused as too large at the configured or minimum fragment size) and `8` (`FragmentDeployError`: fragmented deploy incomplete and resumable)
38
+ - Fragmented deploy for contracts too large for one block, driven by `--circuits-per-tx` / `[contracts.X].circuits_per_tx`, with resume from chain state and a strict verify before `confirmed`. See the README's "Large contracts" section (#174)
39
+ - `DeployResult` gains `fragments` and `circuits`; both appear in `--json`, alongside a failed fragmented deploy's `address`, `circuitsOnChain`, `circuitsPending`, and `txId` (#174)
40
+ - Exit codes `7` (`BlockLimitError`: the deploy tx was refused as too large at the configured or minimum fragment size) and `8` (`FragmentDeployError`: fragmented deploy incomplete and resumable) (#174)
16
41
 
17
42
  ### Changed
18
43
 
19
- - `DeploymentRecord` gains a `partial` member. A single-tx deploy still writes only `pending` then `confirmed`, so an exhaustive `switch` on `status` needs a new arm only if it reads records from a split deploy
20
- - A deploy that fits one transaction is unchanged: same transaction, same `pending` then `confirmed` records, no chain read and no maintenance transaction
44
+ - `DeploymentRecord` gains a `partial` member. A single-tx deploy still writes only `pending` then `confirmed`, so an exhaustive `switch` on `status` needs a new arm only if it reads records from a split deploy (#174)
45
+ - A deploy that fits one transaction is unchanged: same transaction, same `pending` then `confirmed` records, no chain read and no maintenance transaction (#174)
21
46
 
22
47
  ## 0.1.0 (2026-09-09)
23
48
 
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
  compact-deploy Token --network local
5
5
  ```
6
6
 
7
- > **Status: developer-preview, testnet only.** Verified on local devnet and on preprod (dry run to chain tip, 2026-09-04); the preview endpoints are null-routed ([Known issues](#known-issues-may-2026)). Mainnet unsupported: unaudited, no hardware signer, no multisig, no tx retry, no upgrade tooling. See [Roadmap](#roadmap--todo).
7
+ > **Status: developer-preview, local standalone only.** No public network runs the Ledger v9 stack yet. Mainnet unsupported: unaudited, no hardware signer, no multisig, no tx retry, no upgrade tooling.
8
8
 
9
9
  ## Requirements
10
10
 
11
- - Node.js >= 24 — the deployer uses explicit resource management (`await using` / `AsyncDisposableStack`), global only from Node 24.
11
+ - Node.js >= 24. The deployer uses `await using` / `AsyncDisposableStack`.
12
12
 
13
13
  ## Quick start
14
14
 
@@ -24,16 +24,14 @@ The deploy result lands in `deployments/compact/<network>.json`.
24
24
 
25
25
  ## Install & run
26
26
 
27
- The `compact-deploy` bin ships in `@openzeppelin/compact-cli`. Install it as a dev dependency of the project that holds your compiled artifacts, then run it with `npx`:
27
+ The `compact-deploy` bin ships in `@openzeppelin/compact-cli`. Install it as a dev dependency of the project that holds your compiled artifacts:
28
28
 
29
29
  ```bash
30
30
  npm i -D @openzeppelin/compact-cli # or pnpm/yarn
31
31
  npx compact-deploy Token --network local # resolves the local install
32
32
  ```
33
33
 
34
- `npx` prefers the local `node_modules/.bin`, so the deployer and your compiled contracts share **one** `@midnight-ntwrk/compact-runtime` copy. A real deploy requires this: the deploy-tx builder creates a `ContractMaintenanceAuthority` from the runtime and hands it to your contract, and the WASM check rejects it unless both sides are the same physical copy.
35
-
36
- > **Ephemeral `npx @openzeppelin/compact-cli compact-deploy …` (no local install)** is fine for `--help`, `--version`, and `--dry-run` / validation, but **not reliable for a real deploy**: npx fetches the CLI into its own cache tree, so its `compact-runtime` differs from your project's and the submit fails with `expected instance of ContractMaintenanceAuthority`. Install it locally for real deploys.
34
+ Install it locally for any real deploy. The deployer and your artifacts must share one physical `@midnight-ntwrk/compact-runtime` copy, and an ephemeral `npx @openzeppelin/compact-cli …` fetches its own, failing the submit with `expected instance of ContractMaintenanceAuthority`. Ephemeral is fine for `--help`, `--version` and `--dry-run`.
37
35
 
38
36
  ## Supported stack
39
37
 
@@ -41,32 +39,27 @@ The deployer pins one Midnight stack, and artifacts have to be compiled against
41
39
 
42
40
  | Component | Version |
43
41
  |---|---|
44
- | `@midnight-ntwrk/compact-runtime` | 0.16.0 |
45
- | `@midnight-ntwrk/ledger-v8` | 8.1.0 |
46
- | `@midnight-ntwrk/midnight-js-*` | 4.1.1 |
47
- | `@midnight-ntwrk/testkit-js` | 4.1.1 |
48
- | `@midnight-ntwrk/wallet-sdk-facade` | 4.0.1 |
49
- | Compact compiler | 0.31.1 |
42
+ | `@midnight-ntwrk/compact-runtime` | 0.19.0 |
43
+ | `@midnightntwrk/ledger-v9` | 1.0.0-rc.5 |
44
+ | `@midnight-ntwrk/compact-js` | 2.5.5-rc.8 |
45
+ | `@midnight-ntwrk/midnight-js-*` | 5.0.0-beta.7 |
46
+ | `@midnight-ntwrk/testkit-js` | 5.0.0-beta.7 |
47
+ | `@midnightntwrk/wallet-sdk-facade` | 5.0.0-beta.2 |
48
+ | Compact compiler | 0.34.0 |
49
+
50
+ Compile with `compact compile +0.34.0`. An older artifact fails at submit with `Version mismatch`.
50
51
 
51
- `ledger-v8` is pinned to 8.1.0 because `midnight-js-protocol` 4.1.1 requires exactly that version. A second copy of the ledger WASM in the tree fails a deploy with `expected instance of DustParameters`. npm dedupes to the single pinned copy on its own. yarn and pnpm resolve each range to the newest version, so a project using them adds the same pins as this repo's root `package.json`:
52
+ The ledger and the wallet SDK sit under the `@midnightntwrk` scope, no hyphen. Everything else keeps `@midnight-ntwrk`.
53
+
54
+ Every package manager needs one pin, because the stack's packages ask for different ledger versions and a second ledger copy breaks every deploy. With npm:
52
55
 
53
56
  ```json
54
- "resolutions": {
55
- "@midnight-ntwrk/ledger-v8": "8.1.0",
56
- "@midnight-ntwrk/wallet-sdk-address-format": "3.1.2",
57
- "@midnight-ntwrk/wallet-sdk-dust-wallet": "4.1.0",
58
- "@midnight-ntwrk/wallet-sdk-facade": "4.0.1",
59
- "@midnight-ntwrk/wallet-sdk-shielded": "3.0.1",
60
- "@midnight-ntwrk/wallet-sdk-unshielded-wallet": "3.1.0"
57
+ "overrides": {
58
+ "@midnightntwrk/ledger-v9": "1.0.0-rc.5"
61
59
  }
62
60
  ```
63
61
 
64
- (`pnpm.overrides` for pnpm.)
65
-
66
- Compile with the pinned compiler: `compact compile +0.31.1`. The current default compactc (0.34.x) emits code for compact-runtime 0.19.0, and the deploy then fails with a `Version mismatch` runtime error.
67
-
68
- - As of 2026-09, `OpenZeppelin/compact-contracts` `main` is on compact-runtime 0.19.0 / ledger-v9 1.0.0-rc.3, so contracts built there are not deployable with this tool today.
69
- - Moving the deployer to the v9 stack is pending a published `@midnight-ntwrk/ledger-v9`: `@midnight-ntwrk/compact-js` 2.5.3 depends on an unpublished ledger-v9 alpha, which yarn rejects with `YN0082`.
62
+ yarn takes the same entry under `resolutions`, and pnpm under `pnpm.overrides`. Nothing else in the stack floats.
70
63
 
71
64
  ## CLI
72
65
 
@@ -93,62 +86,63 @@ compact-deploy <Contract>
93
86
 
94
87
  Exit codes: `0` ok · `2` config error (includes a pending or partial deploy record without `--force`) · `3` wallet error · `5` deploy tx failed or not confirmed · `6` deployments ledger unreadable or unwritable · `7` the deploy tx was refused as too large at the configured or minimum fragment size · `8` fragmented deploy incomplete · `1` unexpected.
95
88
 
96
- A deploy writes a `status: "pending"` record (address, txId) to `deployments/<network>.json` as soon as the node accepts the tx, then promotes it to `status: "confirmed"` (txHash, blockHeight) on finalization. A dropped connection or `--tx-timeout` leaves the pending record in place and names the address and txId in the error; the next deploy of that contract refuses until you check the tx on chain and pass `--force`.
89
+ A deploy writes `status: "pending"` (address, txId) as soon as the node accepts the tx, then `status: "confirmed"` (txHash, blockHeight) on finalization. A dropped connection or `--tx-timeout` leaves the pending record in place; the next deploy of that contract refuses until you check the tx on chain and pass `--force`.
97
90
 
98
91
  ## Large contracts
99
92
 
100
- The node rejects a deploy tx above the per-block extrinsic limit with `1010: Invalid Transaction: Transaction would exhaust the block limits`. Weight grows with circuit count, so past roughly 15 circuits a single-tx deploy stops landing on the local stack.
93
+ The node rejects a deploy tx above the per-block extrinsic limit with `1010: Invalid Transaction: Transaction would exhaust the block limits`. Weight grows with circuit count, so past roughly 15 circuits a single-tx deploy stops landing.
94
+
95
+ `--circuits-per-tx <n>` (or `[contracts.X].circuits_per_tx`) splits it: fragment 0's verifier keys ride the deploy tx, each further fragment is one `MaintenanceUpdate` batching `VerifierKeyInsert`s.
101
96
 
102
- - `--circuits-per-tx <n>` (or `[contracts.X].circuits_per_tx`) splits the deploy: fragment 0's verifier keys ride the deploy tx, each further fragment is one `MaintenanceUpdate` batching `VerifierKeyInsert`s.
103
97
  - Left unset, the deployer submits the largest batch it can and halves on a refusal, down to a single circuit. There is no pre-flight weight check.
104
- - Set at or above the circuit count, it pins a single-tx deploy and disables halving: a refusal is exit 7, never a split. Use it as the never-fragment switch.
105
- - One `deploy()` call does the deploy, every insert, and a byte-for-byte check of every on-chain verifier key against the artifact. Only that check writes `confirmed`.
98
+ - Set at or above the circuit count, it pins a single-tx deploy and disables halving: a refusal is exit 7, never a split.
99
+ - A size found by halving is remembered in memory: later deploys of the same artifact on the same network, in the same process, start there. A set budget and a resume ignore it.
106
100
  - Fragments are ordered by sorted circuit name, so a rerun rebuilds the same plan.
107
- - Between fragment 0 landing and the last insert the contract is live with a subset of its circuits, chosen by sorted name rather than by dependency. Keep every circuit safe to call on its own, or hold traffic until the deploy confirms.
108
- - Each fragment waits for the wallet to apply the previous spend before the next tx is balanced.
101
+ - One `deploy()` call does the deploy, every insert, and a byte-for-byte check of every on-chain key against the artifact. Only that check writes `confirmed`.
102
+ - Between fragment 0 landing and the last insert the contract is live with a subset of its circuits, ordered by name rather than by dependency. Keep every circuit safe to call alone, or hold traffic until the deploy confirms.
109
103
  - A constructor that creates or spends a Zswap coin cannot be split: exit 2.
110
- - A maintenance committee with a threshold above 1 is refused: the deployer holds one key. Exit 2.
111
-
112
- A split deploy writes `status: "partial"` (address, txId, `circuitsOnChain`, `circuitsPending`) instead of `pending`. Re-running the same deploy command resumes it: the remaining circuits come from chain state, not from the record. Resume is refused with exit 2 unless the recorded address exists, its maintenance committee holds this signing key, and every on-chain key matches the artifact. If the deploy tx is not seen within `--tx-timeout` and no state is readable yet, the run exits 8 instead: the tx may still be landing, so check the address on an explorer before reaching for `--force`. `--force` on a `partial` head abandons it (rotated into history) and deploys a new contract at a new address.
104
+ - A committee with a threshold above 1 is refused, since the deployer holds one key: exit 2.
113
105
 
114
- A resume confirms only once it knows the deploy tx's `txHash` and `blockHeight`, read from the indexer or carried in the `partial` record. If every circuit is on chain but the indexer never serves the deploy tx, each re-run exits 8 with the same message; the exit is to copy the two fields from an explorer into the record and re-run, which confirms without a new transaction. `--force` is not the answer there, since it abandons a fully landed contract.
106
+ ### Resuming
115
107
 
116
- A resume stores the signing key for the address if the private-state store lacks it. It does not restore `initialPrivateState`: that value only exists inside the constructor run the original deploy did, so a dApp that needs it must seed the store itself.
108
+ A split deploy writes `status: "partial"` (address, txId, `circuitsOnChain`, `circuitsPending`). Re-running the same command resumes it from chain state, not from the record.
117
109
 
118
- Results carry `fragments` (transactions the address has taken, counting an interrupted run's inserts; `0` on a dry-run) and `circuits` (keys verified on chain), printed by the CLI and included in `--json`. A `--json` failure of a fragmented deploy also carries `address`, `circuitsOnChain`, `circuitsPending`, and the failed insert's `txId`.
110
+ - Resume is refused with exit 2 unless the recorded address exists, its committee holds this signing key, and every on-chain key matches the artifact.
111
+ - Exit 8 means the deploy tx was not seen within `--tx-timeout`. It may still be landing, so check the address on an explorer before reaching for `--force`.
112
+ - If every circuit is on chain but the indexer never serves the deploy tx, copy `txHash` and `blockHeight` from an explorer into the record and re-run. That confirms without a new transaction.
113
+ - `--force` on a `partial` head abandons it and deploys a new contract at a new address.
114
+ - A resume stores the signing key if the private-state store lacks it. It never restores `initialPrivateState`, which exists only inside the original constructor run.
115
+ - The guard cannot tell two deploys of the same artifact with the same key apart. Do not hand-edit a `partial` record's `address`, or a sibling deploy will receive this run's remaining keys.
119
116
 
120
- **Resume guard limit.** The guard proves the recorded address holds a contract this signing key maintains whose on-chain keys match this artifact; it cannot tell two deploys of the same artifact with the same key apart. Do not hand-edit a `partial` record's `address`, or a sibling deploy will receive this run's remaining keys.
121
-
122
- The properties this path has to hold are listed in [docs/invariants.md](./docs/invariants.md).
117
+ Results carry `fragments` (transactions the address has taken; `0` on a dry-run) and `circuits` (keys verified on chain). A `--json` failure adds `address`, `circuitsOnChain`, `circuitsPending`, and the failed insert's `txId`.
123
118
 
124
119
  ## Deploying to real networks (preprod, preview, testnet)
125
120
 
126
- > Preview is down (null-routed DNS); preprod is reachable. A first cold preprod sync takes ~37 min, so raise `--sync-timeout`. Local standalone (`make env-up`) is still the fastest target. See [Known issues](#known-issues-may-2026).
121
+ > Nothing public is deployable today: preprod is still on the v8 ledger and preview is null-routed. Local standalone (`make env-up`) is the only working target. The rules below apply once a public network moves to v9.
127
122
 
128
- - **First sync is slow** (~3 min on preview, ~37 min on preprod from genesis, measured 2026-09-04). Cache makes reruns near-instant.
129
- - **Bump sync timeout**: `--sync-timeout 3600` (default 10 min).
130
- - **Bump Node heap** for long-history chains: `NODE_OPTIONS="--max-old-space-size=8192"`.
131
- - **Tune the sync batch size**: `--sync-batch-size <n>` (default 5000). Larger replays a long dust history faster but uses more memory per batch; lower it on a memory-constrained host.
132
- - **Persist the sync knobs in TOML**: set `sync_timeout` (seconds) and/or `sync_batch_size` under `[networks.X]` so you don't pass the flags every run. The matching CLI flag overrides the TOML value when both are present (CLI > TOML > default).
133
- - **Tip gate is tolerant**: sync completes once every sub-wallet is within 50 events of the tip, not at an exact gap of 0. On a live network the global dust stream advances continuously, so an exact-match gate would never fire.
123
+ - **First sync is slow** on a long-history chain, tens of minutes from genesis. Cache makes reruns near-instant, but raise `--sync-timeout` for the first run.
124
+ - **Bump the Node heap** for long-history chains: `NODE_OPTIONS="--max-old-space-size=8192"`.
125
+ - **Lower `--sync-batch-size`** on a memory-constrained host. Larger replays a long dust history faster but costs memory per batch.
126
+ - **Persist the sync knobs**: `sync_timeout` and `sync_batch_size` under `[networks.X]`. Precedence is CLI > TOML > default.
127
+ - **The tip gate is tolerant**: sync completes within 50 events of the tip. On a live network the dust stream advances continuously, so an exact gate would never fire.
134
128
  - **Seed source**: `--seed-file`, `MN_DEPLOYER_SEED`, or `[wallet].keystore`. The `wallet = { source = "local" }` shorthand is dev-preset only.
135
129
 
136
130
  ## Wallet cache
137
131
 
138
- After each successful sync the deployer writes `<compact.toml dir>/.states/<network>-<seed-hash>-<kind>.gz` (one file per shielded / dust / unshielded sub-wallet). Next run restores from it instead of re-syncing from genesis.
132
+ After each successful sync the deployer writes `<compact.toml dir>/.states/<network>-<seed-hash>-<kind>.gz`, one file per shielded / dust / unshielded sub-wallet. The next run restores from it instead of re-syncing from genesis.
139
133
 
140
- - Contents: gzipped sub-wallet state (UTXOs, checkpoint). No private keys (re-derived from seed each run).
141
- - Keyed by SHA-256(seed) + network ID, so `local` vs `preprod` keep separate caches.
142
- - Bust it: `--no-cache` (force fresh) or `rm -rf .states/`. Auto-falls-back on corrupt or version-mismatched files.
143
- - Best-effort writes; never block a deploy. Concurrent runs against the same seed race. Don't.
144
- - Resolved against the `compact.toml` directory, not the shell CWD, so running from a subdirectory reuses the same cache. Same for the LevelDB private-state store (`<compact.toml dir>/midnight-level-db/`).
145
- - Both live under the `compact.toml` directory, which makes the project the unit of deployer state. Run one `compact-deploy` at a time per project: a second concurrent run fails on the LevelDB lock.
146
- - Library callers that run several deploys in one process must pass `privateStateProvider` (e.g. the SDK's in-memory provider) alongside `walletProvider`. The default LevelDB store holds its lock until the process exits.
134
+ - Contents: gzipped sub-wallet state (UTXOs, checkpoint). No private keys; those are re-derived from the seed each run.
135
+ - Keyed by SHA-256(seed) + network ID, so `local` and `preprod` keep separate caches.
136
+ - Bust it with `--no-cache` or `rm -rf .states/`. Corrupt or version-mismatched files fall back to a fresh sync.
137
+ - Writes are best-effort and never block a deploy.
138
+ - Resolved against the `compact.toml` directory, not the shell CWD. Same for the LevelDB private-state store (`<compact.toml dir>/midnight-level-db/`).
139
+ - Run one `compact-deploy` at a time per project. A second concurrent run fails on the LevelDB lock, and two runs on one seed race the cache.
140
+ - Library callers running several deploys in one process must pass their own `privateStateProvider`. The default LevelDB store holds its lock until the process exits.
147
141
  - `.states/` is gitignored.
148
142
 
149
143
  ### Importing a pre-warmed state file
150
144
 
151
- If cold sync OOMs on preprod (the known upstream bug) and you already have a `wallet.serializeState()` snapshot from a prior session, drop it in with:
145
+ Drop in a `wallet.serializeState()` snapshot from a prior session:
152
146
 
153
147
  ```
154
148
  compact-deploy <Contract> --network preprod \
@@ -157,13 +151,12 @@ compact-deploy <Contract> --network preprod \
157
151
  --seed-cache-from-unshielded /path/to/unshielded.json
158
152
  ```
159
153
 
160
- - The dust file is the one that matters on preprod; the shielded and unshielded imports are optional.
161
- - Accepts either raw JSON (the direct `serializeState()` output) or its gzipped copy. Gzip is detected by magic bytes.
162
- - The file is renamed to the seed-derived cache name and dropped into `.states/`.
163
- - **The previous cache (if any) is preserved at `<target>.gz.bak`** — never deleted, never overwritten by the import. To roll back from a bad import, `mv .states/<target>.gz.bak .states/<target>.gz`.
164
- - The write itself is atomic: payload lands in `<target>.gz.tmp` first, then is renamed over `<target>.gz`. A mid-write crash can never leave the live cache half-overwritten.
165
- - Restore failure (e.g. schema mismatch) falls through to the normal "fresh sync from genesis" path with a `warn` log — so the deploy still completes if the import doesn't take.
166
- - Ignored under `--no-cache` (with a warning), since load is disabled in that mode.
154
+ - The dust file is the one that matters on a long-history chain. The other two are optional.
155
+ - Raw JSON or gzipped, detected by magic bytes.
156
+ - The previous cache is kept at `<target>.gz.bak`, never deleted. Roll back with `mv .states/<target>.gz.bak .states/<target>.gz`.
157
+ - The write is atomic: `<target>.gz.tmp` first, then renamed over `<target>.gz`.
158
+ - A restore failure warns and falls through to a fresh sync, so the deploy still completes.
159
+ - Ignored under `--no-cache`.
167
160
 
168
161
  ## Wallet seed resolution
169
162
 
@@ -232,34 +225,55 @@ signing_key_file = "./deploy/Vault.signingkey"
232
225
  circuits_per_tx = 8
233
226
  ```
234
227
 
235
- `proof_server`: a URL pins the server; `"auto"` spawns a `testcontainers`-managed proof-server container for the duration of the deploy; omitting it falls back to the env var `PROOF_SERVER_PORT` then to `http://127.0.0.1:6300`.
228
+ `proof_server`: a URL pins the server; `"auto"` spawns a `testcontainers`-managed proof-server container for the deploy; omitting it falls back to `PROOF_SERVER_PORT`, then to `http://127.0.0.1:6300`.
229
+
230
+ `"auto"` needs Docker and boots the `proof-server.yml` shipped in this package, pinning `midnightntwrk/proof-server:9.0.0-rc.6`. To boot a different image, put your own `proof-server.yml` in the directory you run `compact-deploy` from; it wins over the packaged one.
231
+
232
+ ### Patterns
233
+
234
+ One `[contracts]` entry can cover many contracts. A key is one of:
235
+
236
+ - `Token`: exact, that contract only.
237
+ - `"Mock*"`: a name pattern (holds `*`, `?`, `[` or `{`), matched against the contract name.
238
+ - `"**/test/mocks/*"`: a directory pattern (holds `/`), matched against the contract's source path under `[profile].src_dir`, `.compact` included. The source of `<name>` is the unique `<src_dir>/**/<name>.compact`, skipping `node_modules` and dot-directories. A second match is an error.
239
+
240
+ Every matching pattern applies in file order, a later one overriding an earlier one field by field. The exact entry applies last. `{name}` in any string value expands to the contract name, and `artifact` defaults to it. `runDeploy(Contract)` searches exact keys only.
236
241
 
237
- `"auto"` needs Docker and boots the `proof-server.yml` shipped in this package, which pins `midnightntwrk/proof-server:8.0.3` and publishes port 6300 on a free host port. To boot a different image, put your own `proof-server.yml` in the directory you run `compact-deploy` from; a compose file there wins over the packaged one.
242
+ ```toml
243
+ [profile]
244
+ src_dir = "contracts/src"
245
+
246
+ [contracts."**/test/mocks/*"]
247
+ signing_key_file = "./deploy/{name}.signingkey"
248
+
249
+ # Inherits signing_key_file from the pattern above.
250
+ [contracts.MockToken]
251
+ args = ["MyToken", "MTK", 18]
252
+ ```
238
253
 
239
254
  ## Keystore format
240
255
 
241
- `compact-deploy` reads/writes a JSON keystore with the Ethereum V3 shape (scrypt + AES-128-CTR) but with `version: "midnight-1"` so other tooling does not silently mis-read it as an Ethereum key. The encrypted secret is a 32-byte Midnight wallet seed (hex).
256
+ An Ethereum V3 JSON keystore (scrypt + AES-128-CTR) tagged `version: "midnight-1"`, so other tooling does not mis-read it as an Ethereum key. The encrypted secret is a 32-byte Midnight wallet seed (hex).
242
257
 
243
- ## Known issues (May 2026)
258
+ ## Known issues
244
259
 
245
- 1. **Preview endpoints null-routed.** `rpc.preview.midnight.network` and `indexer.preview.midnight.network` resolve to `0.0.0.0` on the authoritative AWS Route 53 nameservers for `midnight.network` (verified against Google, Cloudflare, and Quad9). Preview was alive on 2026-05-22, broken on 2026-05-24. Blocks every consumer of testkit-js's `PreviewTestEnvironment`. File at [midnightntwrk/servicedesk](https://github.com/midnightntwrk/servicedesk/issues/new?template=bug-report.yml). **Workaround:** none on public testnet. `make env-up` (local standalone) is the only working target until Midnight restores the endpoints.
260
+ 1. **Preprod runs the v8 ledger.** Its transactions carry the `midnight:transaction[v9]` header tag, which `@midnightntwrk/ledger-v9` rejects on deserialize. **Workaround:** none until preprod upgrades; use local standalone.
246
261
 
247
- 2. **Preprod blocked: `Wallet.Sync: Could not deserialize Ledger Event` on `DustSpendProcessed`.** Dust sync aborts mid-stream on a `DustSpendProcessed` event whose `midnight:event[v9]:`-prefixed `raw` bytes fail `effect/Schema` parsing. The thrown `Wallet.Sync` corrupts `DustLocalState`. The next `walletBalance()` call hits `RuntimeError: unreachable` in the ledger WASM. Two independent runs, two different event IDs: 2026-05-22 id **565,975** (confirmed in Midnight dev Discord by `Knife`); 2026-05-24 id **571,224** with `maxId` 676,018. Affected stack: `wallet-sdk-dust-wallet@4.0.0`, `ledger-v8@8.0.3`, `testkit-js@4.1.0`. File at [midnightntwrk/midnight-wallet](https://github.com/midnightntwrk/midnight-wallet/issues/new). Distinct from [#361 `InvalidDustSpendProof`](https://github.com/midnightntwrk/midnight-wallet/issues/361), which is a chain-side tx rejection (this bug is client-side event ingest). **Workaround:** none. Preview is also down (see #1). Local standalone is the only working target today.
262
+ 2. **Preview endpoints are null-routed.** `rpc.preview` and `indexer.preview` resolve to `0.0.0.0`, which blocks every consumer of testkit-js's `PreviewTestEnvironment`. **Workaround:** none on public testnet; use local standalone.
248
263
 
249
- **2026-09-04, stack `wallet-sdk-dust-wallet@4.1.0` / `ledger-v8@8.1.2` / `testkit-js@4.1.1`:** not reproduced.
250
- A cold preprod dry run reached chain tip on all three sub-wallets (~37 min) and ended at the expected `UnfundedWalletError`.
264
+ 3. **The faucet is manual.** Fund the wallet's `unshielded` address, logged at startup, before running.
251
265
 
252
- 3. **Faucet is manual.** The deployer never hits a faucet. Fund the wallet's `unshielded` address (logged at startup) via the official Midnight faucet site or Discord bot before running.
266
+ 4. **Dust fee overhead breaks faucet wallets.** testkit-js defaults `additionalFeeOverhead` to `5e20` against a faucet wallet's `~3e15` dust, giving `Insufficient Funds: could not balance dust`. The deployer overrides to `5e14`; library users building their own provider must mirror that.
253
267
 
254
- 4. **Dust fee overhead default breaks faucet wallets.** testkit-js default `additionalFeeOverhead` is `5e20` vs a faucet wallet's `~3e15` dust → `Insufficient Funds: could not balance dust`. Deployer overrides to `5e14` for non-mainnet. Library users constructing their own provider must mirror this.
268
+ 5. **Long-history dust sync exhausts the default Node heap.** The deployer raises the sync batch size to 5000 ([midnight-wallet#425](https://github.com/midnightntwrk/midnight-wallet/issues/425)), but a first sync on a long-history chain can still pass V8's ~2 GB default old-space. Set `NODE_OPTIONS="--max-old-space-size=8192"` for that run; cache fixes the rest.
255
269
 
256
- 5. **Long-history dust sync exhausts default Node heap.** The deployer now raises the dust/shielded sync batch size (`batchUpdates = { size: 5000, … }`) so the replay no longer OOMs mid-stream ([midnightntwrk/midnight-wallet#425](https://github.com/midnightntwrk/midnight-wallet/issues/425)). First hit on `wallet-sdk-dust-wallet@4.0.0`; the override is kept on the shipped 4.1.0 and has not been re-tested without it. The restored dust tree plus shielded trial-decryption can still spike past V8's ~2 GB default old-space on a first preprod sync, so set `NODE_OPTIONS="--max-old-space-size=8192"` for that run. Cache fixes subsequent runs.
270
+ 6. **The root `@midnightntwrk/ledger-v9` resolution is load-bearing.** `compact-js` declares it as a range, so without the pin yarn nests a second ledger copy and deploys fail. Do not drop it on a bump.
257
271
 
258
- 6. **Root `resolutions` pin the wallet-SDK packages; do not drop them on a bump.** `testkit-js@4.1.1` pulls `@midnight-ntwrk/wallet-sdk@1.1.0`, which declares `wallet-sdk-facade ^4.0.1` and so resolves to 4.1.0 — a version that imports a nonexistent `Clock` export and fails to load. Without the pins the tree also duplicates `wallet-sdk-dust-wallet` (4.2.0) and `wallet-sdk-shielded` (3.0.2). The root `package.json` therefore pins `wallet-sdk-address-format 3.1.2`, `wallet-sdk-dust-wallet 4.1.0`, `wallet-sdk-facade 4.0.1`, `wallet-sdk-shielded 3.0.1`, `wallet-sdk-unshielded-wallet 3.1.0`.
272
+ 7. **`@midnight-ntwrk/compact-runtime` resolves to two copies**, `0.19.0-rc.0` under `compact-js` and `midnight-js-protocol` against `0.19.0` everywhere else. The integration suite deploys on that tree, including the pruned constructor path through `compact-js`. Forcing one `0.19.0` copy with a resolution also deploys, the split path included.
259
273
 
260
274
  ## Programmatic API
261
275
 
262
- The package has no barrel entrypoint: each module is its own subpath export, so an import names the module it comes from and pulls in only that module.
276
+ The package has no barrel entrypoint. Each module is its own subpath export, so an import names the module it comes from and pulls in only that module.
263
277
 
264
278
  | Subpath | Exports |
265
279
  |---|---|
@@ -273,7 +287,7 @@ The package has no barrel entrypoint: each module is its own subpath export, so
273
287
  | `/providers/proof-server` | `ProofServer` |
274
288
  | `/wallet/handler` · `/wallet/keystore` · `/wallet/seeds` | `WalletHandler`, `Keystore`, `classifySeed`, `localPrefundedSeed` |
275
289
 
276
- Curried form — pass the compiled `Contract` class and the constructor args are typed function parameters:
290
+ Curried form. Pass the compiled `Contract` class and the constructor args become typed parameters:
277
291
 
278
292
  ```ts
279
293
  import { runDeploy } from "@openzeppelin/compact-deployer/run-deploy";
@@ -287,7 +301,7 @@ const result = await runDeploy(Contract, { network: "local" })(
287
301
  console.log(result.address);
288
302
  ```
289
303
 
290
- Options-object form — name the contract as it appears in `compact.toml`, with args from the TOML or passed inline:
304
+ Options-object form. Name the contract as it appears in `compact.toml`, with args from the TOML or inline:
291
305
 
292
306
  ```ts
293
307
  import { runDeploy } from "@openzeppelin/compact-deployer/run-deploy";
@@ -301,4 +315,25 @@ const result = await runDeploy({
301
315
  console.log(result.address);
302
316
  ```
303
317
 
304
- Every option has a `process.argv` default (`--network`, `--config`, `--dry-run`, …), so the same script works with flags at the call site. On failure `runDeploy` sets `process.exitCode` and rethrows the original error; it never calls `process.exit`, so catch it if you want that exit code to reach the shell.
318
+ Every option has a `process.argv` default (`--network`, `--config`, `--dry-run`, …), so the same script works with flags at the call site. On failure `runDeploy` sets `process.exitCode` and rethrows; it never calls `process.exit`, so catch it if you want that code to reach the shell.
319
+
320
+ Three options suit a caller that deploys many contracts from code, such as a test harness. `Deployer.prepare` and `runDeploy` both take them, with no argv flag:
321
+
322
+ - `initialPrivateState` and `witnesses` override `[contracts.X].init_private_state` and `[contracts.X].witnesses`. A `private_state_id` and an initial private state come together: `prepare` throws `ConfigError` when one lacks the other.
323
+ - `record: false` skips the deployments ledger. Nothing is read or written, so every deploy is fresh and `deploymentsFile` is `''`.
324
+
325
+ ```ts
326
+ import { Deployer } from "@openzeppelin/compact-deployer/deployer";
327
+
328
+ await using deployer = await Deployer.prepare({
329
+ contract: "MockToken",
330
+ network: "local",
331
+ logger,
332
+ walletProvider, // one wallet shared across deploys
333
+ privateStateProvider, // e.g. testkit-js inMemoryPrivateStateProvider()
334
+ initialPrivateState: { secretKey },
335
+ witnesses,
336
+ record: false,
337
+ });
338
+ const { address } = await deployer.deploy();
339
+ ```
@@ -23,9 +23,14 @@ export declare class CompactConfig {
23
23
  get deploymentsDir(): string;
24
24
  get wallet(): WalletConfig | undefined;
25
25
  hasNetwork(name: string): boolean;
26
+ /** Whether any `[contracts]` key, exact or pattern, applies to `name`. */
26
27
  hasContract(name: string): boolean;
27
28
  listNetworks(): string[];
29
+ /** Names with an exact `[contracts.X]` key. */
28
30
  listContracts(): string[];
31
+ /** Name and directory pattern keys, in file order. */
32
+ listPatterns(): string[];
29
33
  network(name: string): NetworkConfig;
34
+ /** Merges every `[contracts]` key that applies to `name`, then validates the result. */
30
35
  contract(name: string): ContractConfig;
31
36
  }
@@ -3,7 +3,8 @@ import { readFile } from 'node:fs/promises';
3
3
  import { dirname, isAbsolute, resolve } from 'node:path';
4
4
  import { parse as parseToml } from 'smol-toml';
5
5
  import { ConfigError } from "../errors.js";
6
- import { configSchema, } from "./schema.js";
6
+ import { indexSources, keyKind, resolveEntry, sourceOf, } from "./patterns.js";
7
+ import { configSchema, contractSchema, } from "./schema.js";
7
8
  /**
8
9
  * Parsed + validated `compact.toml` with the resolved project root.
9
10
  * Single source of truth for the pipeline; `network` / `contract`
@@ -20,10 +21,14 @@ export class CompactConfig {
20
21
  */
21
22
  rootDir;
22
23
  #data;
23
- constructor(data, configPath) {
24
+ /** Set when a directory pattern exists. */
25
+ #sources;
26
+ #resolved = new Map();
27
+ constructor(data, configPath, sources) {
24
28
  this.#data = data;
25
29
  this.configPath = configPath;
26
30
  this.rootDir = dirname(configPath);
31
+ this.#sources = sources;
27
32
  }
28
33
  /** Walks up from `cwd` Foundry-style when `explicitPath` is omitted. */
29
34
  static async load(explicitPath, cwd = process.cwd()) {
@@ -49,18 +54,21 @@ export class CompactConfig {
49
54
  }
50
55
  const result = configSchema.safeParse(parsed);
51
56
  if (!result.success) {
52
- const issues = result.error.issues
53
- .map((i) => {
54
- // A TOML document always parses to a table, so an issue can
55
- // never land at the empty root path.
56
- /* v8 ignore next */
57
- const at = i.path.join('.') || '(root)';
58
- return ` - ${at}: ${i.message}`;
59
- })
60
- .join('\n');
61
- throw new ConfigError(`compact.toml validation failed:\n${issues}`);
57
+ throw new ConfigError(`compact.toml validation failed:\n${formatIssues(result.error.issues)}`);
62
58
  }
63
- return new CompactConfig(result.data, configPath);
59
+ const { contracts, profile } = result.data;
60
+ const sources = profile.src_dir !== undefined &&
61
+ Object.keys(contracts).some((key) => keyKind(key) === 'directory')
62
+ ? await indexSources(resolve(dirname(configPath), profile.src_dir))
63
+ : undefined;
64
+ const config = new CompactConfig(result.data, configPath, sources);
65
+ // With a directory pattern, `configSchema` cannot check exact entries:
66
+ // whether the pattern applies needs the source index.
67
+ if (sources) {
68
+ for (const name of config.listContracts())
69
+ config.contract(name);
70
+ }
71
+ return config;
64
72
  }
65
73
  get defaultNetwork() {
66
74
  return this.#data.profile.default_network;
@@ -77,14 +85,20 @@ export class CompactConfig {
77
85
  hasNetwork(name) {
78
86
  return Object.hasOwn(this.#data.networks, name);
79
87
  }
88
+ /** Whether any `[contracts]` key, exact or pattern, applies to `name`. */
80
89
  hasContract(name) {
81
- return Object.hasOwn(this.#data.contracts, name);
90
+ return this.#resolve(name) !== undefined;
82
91
  }
83
92
  listNetworks() {
84
93
  return Object.keys(this.#data.networks);
85
94
  }
95
+ /** Names with an exact `[contracts.X]` key. */
86
96
  listContracts() {
87
- return Object.keys(this.#data.contracts);
97
+ return Object.keys(this.#data.contracts).filter((key) => keyKind(key) === 'exact');
98
+ }
99
+ /** Name and directory pattern keys, in file order. */
100
+ listPatterns() {
101
+ return Object.keys(this.#data.contracts).filter((key) => keyKind(key) !== 'exact');
88
102
  }
89
103
  network(name) {
90
104
  const n = this.#data.networks[name];
@@ -93,14 +107,46 @@ export class CompactConfig {
93
107
  }
94
108
  return n;
95
109
  }
110
+ /** Merges every `[contracts]` key that applies to `name`, then validates the result. */
96
111
  contract(name) {
97
- const c = this.#data.contracts[name];
98
- if (!c) {
99
- throw new ConfigError(`Contract "${name}" not defined. Available: ${this.listContracts().join(', ')}`);
112
+ const cached = this.#resolved.get(name);
113
+ if (cached)
114
+ return cached;
115
+ const resolved = this.#resolve(name);
116
+ if (!resolved) {
117
+ const available = [
118
+ ...this.listContracts(),
119
+ ...this.listPatterns().map((key) => `"${key}"`),
120
+ ].join(', ');
121
+ const noSource = this.#sources && !this.#sources.byName.has(name)
122
+ ? ` (no ${name}.compact under ${this.#sources.dir})`
123
+ : '';
124
+ throw new ConfigError(`Contract "${name}" not defined. Available: ${available}${noSource}`);
125
+ }
126
+ const result = contractSchema.safeParse(resolved.entry);
127
+ if (!result.success) {
128
+ const keys = resolved.keys.map((key) => `"${key}"`).join(', ');
129
+ throw new ConfigError(`compact.toml validation failed for contract "${name}" (from ${keys}):\n${formatIssues(result.error.issues, ['contracts', name])}`);
100
130
  }
101
- return c;
131
+ this.#resolved.set(name, result.data);
132
+ return result.data;
133
+ }
134
+ #resolve(name) {
135
+ const source = this.#sources && sourceOf(name, this.#sources);
136
+ return resolveEntry(name, this.#data.contracts, source);
102
137
  }
103
138
  }
139
+ function formatIssues(issues, prefix = []) {
140
+ return issues
141
+ .map((i) => {
142
+ // A TOML document always parses to a table, so an issue can
143
+ // never land at the empty root path.
144
+ /* v8 ignore next */
145
+ const at = [...prefix, ...i.path].join('.') || '(root)';
146
+ return ` - ${at}: ${i.message}`;
147
+ })
148
+ .join('\n');
149
+ }
104
150
  function resolveExplicit(p, cwd) {
105
151
  const abs = isAbsolute(p) ? p : resolve(cwd, p);
106
152
  if (!existsSync(abs)) {
@@ -1 +1 @@
1
- {"version":3,"file":"compact-config.js","sourceRoot":"","sources":["../../src/config/compact-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAGL,YAAY,GAGb,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACf,UAAU,CAAS;IAC5B;;;;;;OAMG;IACM,OAAO,CAAS;IAChB,KAAK,CAAoB;IAElC,YAAoB,IAAuB,EAAE,UAAkB;QAC7D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,wEAAwE;IACxE,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,YAAqB,EACrB,MAAc,OAAO,CAAC,GAAG,EAAE;QAE3B,MAAM,UAAU,GAAG,YAAY;YAC7B,CAAC,CAAC,eAAe,CAAC,YAAY,EAAE,GAAG,CAAC;YACpC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,EAA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KAAa;IAC/B,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC/C,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,SAAS,CAAC;QACrC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ContractEntry } from './schema.ts';
2
+ export type KeyKind = 'exact' | 'name' | 'directory';
3
+ /** Every `[contracts]` key that applies to a contract, and their merged entry. */
4
+ export interface ResolvedEntry {
5
+ keys: string[];
6
+ entry: ContractEntry;
7
+ }
8
+ /** `.compact` source paths under `dir`, relative and `/`-separated, by contract name. */
9
+ export interface SourceIndex {
10
+ dir: string;
11
+ byName: ReadonlyMap<string, readonly string[]>;
12
+ }
13
+ /** A key holding `/` is a directory pattern, one holding `*`, `?`, `[` or `{` a name pattern. */
14
+ export declare function keyKind(key: string): KeyKind;
15
+ /** Merges matching patterns in file order, then the exact key; a later key wins field by field. */
16
+ export declare function resolveEntry(name: string, contracts: Readonly<Record<string, ContractEntry>>, source: string | undefined): ResolvedEntry | undefined;
17
+ /** Indexes the `.compact` sources under `dir`, skipping `node_modules` and dot-directories. */
18
+ export declare function indexSources(dir: string): Promise<SourceIndex>;
19
+ /** The unique source of `name`, if any; several throw a {@link ConfigError}. */
20
+ export declare function sourceOf(name: string, index: SourceIndex): string | undefined;