wasmlock 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wasmlock contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,245 @@
1
1
  # wasmlock
2
2
 
3
- Dependency updater for on-chain Soroban contracts: it pins third-party contract code, detects upgrades, documents them and proposes a re-pin.
3
+ A dependency updater for on-chain Soroban contracts.
4
4
 
5
- This version only reserves the package name. The first release will be published from CI with provenance.
5
+ You depend on third-party contracts by address. Their code can change under you: an admin upgrades
6
+ the contract, or a CAP-85 external reference is repointed. `wasmlock` keeps a lockfile of each
7
+ contract, how it reaches its code, the code hash and a snapshot of its interface. It reads the live
8
+ ledger, tells you when a pin no longer holds, documents what changed, and proposes a re-pin for a
9
+ person to review.
10
+
11
+ ## The problem
12
+
13
+ A contract you call can be upgraded by whoever administers it, and your code keeps calling the
14
+ same address. Some upgrades are announced on the ledger before they apply. The Aquarius router
15
+ (`CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK`) upgraded in two steps:
16
+
17
+ - In ledger 65560332 (2026-11-19 11:28 UTC) the admin ran `commit_upgrade`, which wrote the new
18
+ code hash (`FutureWASM`) and a deadline three days later (`UpgradeDeadline`) to the contract's
19
+ instance storage.
20
+ - In ledger 65663788 (2026-11-25 11:09 UTC) the new code was applied.
21
+
22
+ For six days the new hash and the deadline were readable on the ledger. `wasmlock check` reads
23
+ them and reports `pending`, with the candidate hash and the time left, and `wasmlock diff
24
+ --pending` compares the interface of the candidate code with the one you pinned. The commit and
25
+ apply ledgers come from the recorded upgrade transactions; the state between them is rebuilt from
26
+ them, because it has left the public RPC's retention window. See
27
+ [test/fixtures/README.md](test/fixtures/README.md).
28
+
29
+ ## What it does and what it does not
30
+
31
+ It detects, documents and proposes:
32
+
33
+ - `check` compares every pin with the live ledger: `clean`, `drift`, `pending` or `incomplete`.
34
+ - `diff` compares the pinned interface with the live code, or with the candidate of a pending
35
+ upgrade, and classifies each change.
36
+ - `add` pins a live contract. `update` re-pins a drifted contract from values it read on the
37
+ ledger and writes a report to paste in a pull request.
38
+ - A GitHub Action runs `check`, and can open one pull request per drifted contract.
39
+
40
+ It does not decide for you:
41
+
42
+ - It never accepts a code hash on its own. A person merges every re-pin.
43
+ - It never signs or submits anything. It only reads, and holds no key.
44
+ - "No breaking interface change" is not "safe". The spec is self-declared, the tool does not
45
+ analyze behavior, and a report never says a change is safe.
46
+ - A pending-upgrade rule reads instance storage only. A contract that upgrades in one step gives
47
+ no notice, and `check` can only report the drift after it happened.
48
+
49
+ ## Install
50
+
51
+ The package is `wasmlock` and has no runtime dependencies: installing it adds exactly one package.
52
+ It needs Node 22 or newer.
53
+
54
+ ```sh
55
+ npm install --save-dev wasmlock
56
+ npx wasmlock --help
57
+ ```
58
+
59
+ It is not on npm until the first release (see [CHANGELOG.md](CHANGELOG.md)). Until then, build it
60
+ from a checkout with `bun install` and `bun run build`, and run `node dist/cli.js`.
61
+
62
+ ## Quick start
63
+
64
+ Pin a contract, then check it. Every command below is run by the test suite against the offline
65
+ fixtures of this repository, and the exit code in the comment is the one the test asserts. On the
66
+ live network the ledger numbers and the results differ. The commands that name `test/fixtures/`
67
+ run from a checkout of this repository.
68
+
69
+ Pin a live contract. `add` reads the contract and writes `wasmlock.json`:
70
+
71
+ <!-- quickstart: diff-upgrades.json, upgrade-events.json -->
72
+ ```sh
73
+ wasmlock add CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK --network mainnet --label aquarius-router --pending aquarius-timelock # exit 0
74
+ ```
75
+
76
+ ```text
77
+ added CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK (aquarius-router) in wasmlock.json
78
+ code hash 2f8e7d7f237eca17e188c4e5d08b73b0065584b3d39f9e1d801993a8510a3107
79
+ ```
80
+
81
+ Check the pins against the ledger. Run it in CI and on a schedule:
82
+
83
+ <!-- quickstart: diff-upgrades.json, upgrade-events.json -->
84
+ ```sh
85
+ wasmlock check # exit 0
86
+ ```
87
+
88
+ ```text
89
+ clean CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK (aquarius-router)
90
+ ```
91
+
92
+ Compare the pinned interface with the live code:
93
+
94
+ <!-- quickstart: diff-upgrades.json, upgrade-events.json -->
95
+ ```sh
96
+ wasmlock diff CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK # exit 0
97
+ ```
98
+
99
+ ```text
100
+ result: no change: the live code is the pinned code
101
+ ```
102
+
103
+ A pin whose code changed is `drift` and exits `1`. This lockfile pins the router at its previous
104
+ code hash:
105
+
106
+ <!-- quickstart: mainnet.json -->
107
+ ```sh
108
+ wasmlock check --lockfile test/fixtures/lockfile/live-pins-drifted.json # exit 1
109
+ ```
110
+
111
+ ```text
112
+ drift CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK (aquarius-router)
113
+ wasmHash: c99539b023df4a28d7857d33ca4c915c2e20fec04f12b125132b84fbdf94dad3 -> 2f8e7d7f237eca17e188c4e5d08b73b0065584b3d39f9e1d801993a8510a3107
114
+ ```
115
+
116
+ `diff` classifies what changed in the interface. A changed signature exits `1`:
117
+
118
+ <!-- quickstart: diff-upgrades.json -->
119
+ ```sh
120
+ wasmlock diff CARVQXFP4JF5ELLXUMQ6DALR346YVGBMQOHB4ENA7SSVXAYABXLBDDC4 --lockfile test/fixtures/lockfile/diff-soroswap.json # exit 1
121
+ ```
122
+
123
+ ```text
124
+ result: 1 potentially breaking interface change(s)
125
+ [potentially-breaking] function changed: argument routes type Vec<Route> -> Vec<RouteOut>; uses is not declared, so every function counts as used
126
+ ```
127
+
128
+ `update` re-pins the drifted contracts from the ledger and writes `report.md` for a pull request.
129
+ `--dry-run` shows what it would do and writes nothing:
130
+
131
+ <!-- quickstart: diff-upgrades.json, upgrade-events.json -->
132
+ ```sh
133
+ wasmlock update --dry-run --lockfile test/fixtures/lockfile/diff-soroswap.json # exit 0
134
+ ```
135
+
136
+ ```text
137
+ updated CARVQXFP4JF5ELLXUMQ6DALR346YVGBMQOHB4ENA7SSVXAYABXLBDDC4 (soroswap-aggregator)
138
+ code hash 437653282e9c93b0b4d736d8fde01bf002adefb61bfb75917e609f5336ee3190 -> 72138d720c2d89831906a5f6e88dcf832abda02125fa32e9f0ebf1714041901f
139
+ wasmlock proposes this change to the lockfile and a person decides whether to accept it. It does not say the new code is safe.
140
+ dry run: nothing was written
141
+ ```
142
+
143
+ A pending-upgrade rule (`--pending aquarius-timelock` above) turns an announced upgrade into
144
+ `pending`, which exits `2`. This lockfile pins the router while its upgrade is committed and not
145
+ applied (the state is rebuilt, see above):
146
+
147
+ <!-- quickstart: pending-aquarius.json -->
148
+ ```sh
149
+ wasmlock check --lockfile test/fixtures/lockfile/diff-aquarius-pending.json # exit 2
150
+ ```
151
+
152
+ ```text
153
+ pending CBQDHNBFBZYE4MKPWBSJOPIYLW4SFSXAXUTSXJN76GNKYVYPCKWC6QUK (aquarius-router)
154
+ rule aquarius-timelock: an upgrade is waiting to be applied
155
+ candidate code hash 2f8e7d7f237eca17e188c4e5d08b73b0065584b3d39f9e1d801993a8510a3107
156
+ deadline 1795346903 (2026-11-22T11:28:23Z), 2 days 23 hours left (latest ledger closed 2026-11-19T11:29:03Z)
157
+ ```
158
+
159
+ `diff --pending` compares the pinned interface with the candidate code, before it runs:
160
+
161
+ <!-- quickstart: pending-aquarius.json -->
162
+ ```sh
163
+ wasmlock diff --pending --lockfile test/fixtures/lockfile/diff-aquarius-pending.json # exit 0
164
+ ```
165
+
166
+ ```text
167
+ candidate 2f8e7d7f237eca17e188c4e5d08b73b0065584b3d39f9e1d801993a8510a3107 (pending upgrade: the pinned interface is compared with this code)
168
+ result: no breaking interface change found (read the scope statement before re-pinning)
169
+ ```
170
+
171
+ Every option and output format is in [docs/commands.md](docs/commands.md). Rules are in
172
+ [docs/rules.md](docs/rules.md).
173
+
174
+ ## Exit codes
175
+
176
+ | Code | Name | Meaning for `check` |
177
+ | --- | --- | --- |
178
+ | `0` | clean | Every pin holds. |
179
+ | `1` | drift | The code, or the way the contract reaches it, changed. |
180
+ | `2` | pending | An upgrade is announced and not applied yet. |
181
+ | `3` | incomplete | Something could not be read or verified. It is never reported as clean. |
182
+ | `4` | usage | A usage, lockfile or configuration error. |
183
+
184
+ When statuses are mixed, drift wins over pending, and pending wins over incomplete. The other
185
+ commands use the same codes; the table per command is in [docs/commands.md](docs/commands.md).
186
+
187
+ ## GitHub Action
188
+
189
+ The repository is a composite Action with two modes: `check` reports and fails by a policy you
190
+ choose, `propose` also opens one pull request per drifted contract. Pin it to a full commit SHA.
191
+
192
+ ```yaml
193
+ permissions:
194
+ contents: read
195
+ steps:
196
+ - uses: actions/checkout@<full commit SHA> # <version>
197
+ with:
198
+ persist-credentials: false
199
+ - uses: LumenWipe/wasmlock@<full commit SHA> # <release version>
200
+ with:
201
+ fail-on: drift
202
+ ```
203
+
204
+ Inputs, outputs, permissions and the behavior of `propose` are in [docs/action.md](docs/action.md).
205
+ Complete workflows are in [examples/check.yml](examples/check.yml) and
206
+ [examples/propose.yml](examples/propose.yml).
207
+
208
+ ## Security model
209
+
210
+ - The tool is read-only: it holds no key and submits nothing.
211
+ - The code of a pinned contract and what an RPC provider says are untrusted. Their text reaches a
212
+ terminal or a pull request only as escaped text or inside a code span.
213
+ - The endpoint is never read from the lockfile, so a pull request cannot redirect the tool.
214
+ - Limits: the spec is self-declared, signers and thresholds are read at check time, a public RPC
215
+ keeps about seven days of events, and there is no behavior analysis.
216
+ - Every mitigation with the test that proves it is in [docs/security-model.md](docs/security-model.md).
217
+ To report a vulnerability, see [SECURITY.md](SECURITY.md).
218
+
219
+ ## Supply chain
220
+
221
+ - The npm package has no runtime dependencies and no install scripts.
222
+ - The Stellar SDK is inlined at the versions `bun.lock` fixes, and `THIRD_PARTY_NOTICES.txt` lists
223
+ every inlined package with its license.
224
+ - The build is reproducible: building twice gives the same bytes.
225
+ - The release workflow publishes with npm provenance. Nothing is published yet.
226
+ - How to verify a published version is in [docs/supply-chain.md](docs/supply-chain.md).
227
+
228
+ ## Documentation
229
+
230
+ - [docs/commands.md](docs/commands.md): every command, option, variable, exit code and output.
231
+ - [docs/lockfile.md](docs/lockfile.md): the `wasmlock.json` format.
232
+ - [docs/rules.md](docs/rules.md): pending-upgrade rules.
233
+ - [docs/action.md](docs/action.md): the GitHub Action.
234
+ - [docs/security-model.md](docs/security-model.md): the threat model.
235
+ - [docs/supply-chain.md](docs/supply-chain.md): the published package.
236
+ - [CHANGELOG.md](CHANGELOG.md) and [RELEASING.md](RELEASING.md).
237
+
238
+ ## Contributing
239
+
240
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Development uses bun: `bun install`, then
241
+ `bun run verify`.
242
+
243
+ ## License
244
+
245
+ MIT, see [LICENSE](LICENSE).