@glacislabs/stablegenie-zerodelta 4.13.0 → 4.14.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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Glacis Labs
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Glacis Labs
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,223 +1,223 @@
1
- # @glacislabs/stablegenie-zerodelta
2
-
3
- A lightweight, embeddable **ZeroDelta payment, exchange + swap widget**. Every surface shares one
4
- dependency-free engine:
5
-
6
- - **`<StableGenieExchange>`** — the full exchange card (li.fi-style), in `compact`, `wide` or `pill`.
7
- - **`<StableGenieRwaExchange>`** — the same card over real-world assets, one leg on each side.
8
- - **`<StableGeniePay>`** — *exact-receive*. A merchant/dApp needs exactly `X` USDC on chain `Y` at
9
- address `Z`; the user pays in any supported asset/chain and ZeroDelta routes to the exact receive.
10
- - **`<StableGenieSwap>`** — *exact-in* swap between supported assets/chains.
11
- - **`<PaymentIsland>`** — ZeroDelta Link: a collapsed express-checkout pill that expands to a
12
- one-click card. `variant="pill"` on any of the above renders it.
13
-
14
- The user's own wallet always owns the final signature — the widget never holds keys and never
15
- submits silently. Every ZeroDelta quote is re-validated (`assertQuoteMatchesSelection`), every
16
- planned transaction is re-decoded before signing (`validatePlannedTransaction`), and the settling
17
- transaction is confirmed on-chain in a trusted realm (`verifySubmittedTx`).
18
-
19
- Supported **source** chains: Ethereum, Optimism, Arbitrum, Base, Ink, Unichain, Plasma, Sonic, Plume.
20
- Destinations are not limited to that set — receiving needs no escrow on the far chain, only a
21
- published route.
22
-
23
- Supported assets — three nested allowlists (`src/core/constants.ts`), 26 symbols in total:
24
-
25
- | List | Members |
26
- |---|---|
27
- | Executable stables (stable ⇄ stable) | USDC, USDT, USDE, USDTB, AUSD, PYUSD, USDG |
28
- | Additional RWA-side stables | USD1, wM, USDS, DAI, RLUSD |
29
- | Tradeable RWA | XAUT, nALPHA, nTBILL, nBASIS, nCREDIT, nOPAL, nWISDOM, nACRDX, nLCRD, nAXI, nCLOA, nFALCON, deJAAA, deSPXA |
30
-
31
- ⚠️ These **bound** what can be named; they are not the catalogue. What is selectable is derived per
32
- load from `/chains` + `/tokens` + `/routes` + `/route-health` (`engine.fetchCatalogue()`).
33
-
34
- Fiat on/off-ramp and bank settlement are roadmap, not shipped — those modes render an honest
35
- coming-soon panel rather than a quote the engine cannot perform.
36
-
37
- The engine targets the **production** ZeroDelta escrow (`0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40` on
38
- every supported chain, pinned offline and re-verified against `GET /api/v1/chains`).
39
-
40
- ## Documentation
41
-
42
- Integration docs are published at
43
- **[docs.glacislabs.com/zero-delta/widget](https://docs.glacislabs.com/zero-delta/widget)** — install
44
- and embed, configuration, theming, the keyless proxy you must deploy, and the API reference.
45
-
46
- ## Playground
47
-
48
- **[playground.glacislabs.com](https://playground.glacislabs.com/)** — configure every
49
- widget, preview it live against the production gateway, and copy the embed. It lives in this repo
50
- under [`playground/`](playground/) and deploys to Vercel from the same repository that publishes the
51
- package.
52
-
53
- ```sh
54
- cp .env.example .env # STABLEGENIE_API_KEY=<a ZeroDelta viewer key>
55
- npm run dev:playground # http://localhost:5173
56
- npm run test:e2e # offline Playwright suite against the production build
57
- ```
58
-
59
- - [`playground/src/components/WidgetPreview.tsx`](playground/src/components/WidgetPreview.tsx) is the
60
- reference integration: it imports the widgets by package name and passes plain props — exactly what
61
- the playground's "React" snippet prints.
62
- - [`api/`](api/) is the same-origin **keyless proxy** the widget's default `apiBase` (`/api/widget/v1`)
63
- expects: it forwards only `chains`, `tokens`, `routes`, `route-health`, `quote` and
64
- `screen/wallet` to the gateway and injects the viewer key server-side. Copy it into your own
65
- deployment (Vercel function or any Node handler — `api/_proxy.ts` is framework-free).
66
- ⚠️ Omitting `screen/wallet` (added in 4.0.0) fails **closed**: the engine cannot screen the
67
- direct-settlement path, so direct settlement disappears from the picker.
68
- - `vercel.json`, `.env.example` and `.github/workflows/ci.yml` document the deploy: Vercel project
69
- at the repo root, `npm run build:playground`, output `playground/dist`, env
70
- `STABLEGENIE_API_KEY` (+ optional `ZD_API_UPSTREAM`, `WIDGET_ALLOWED_ORIGINS`; the aliases
71
- `ZERODELTA_API_KEY` / `ZERODELTA_API_URL` are accepted too).
72
-
73
- ## Install (React host)
74
-
75
- ```sh
76
- npm i @glacislabs/stablegenie-zerodelta
77
- ```
78
-
79
- No registry configuration and no auth token are needed — the package is published publicly to
80
- npmjs.com.
81
-
82
- > [npm provenance](https://docs.npmjs.com/generating-provenance-statements) is **currently off**: it
83
- > requires a public source repository and this one is still private, so the tarball carries no
84
- > sigstore attestation. `id-token: write` stays on the release job, so restoring it is a one-line
85
- > change to `publishConfig` once the repo goes public — see [PUBLISHING.md](PUBLISHING.md).
86
-
87
- `react` and `react-dom` are **required peerDependencies** for the main entry (they are kept external
88
- in the ESM/CJS builds, so the host's React is reused — no double bundle). CSS is auto-injected; there
89
- is no stylesheet to import.
90
-
91
- ### Entry points
92
-
93
- | Import | Contains | React required |
94
- |---|---|---|
95
- | `@glacislabs/stablegenie-zerodelta` | the React components (`StableGeniePay`, `StableGenieSwap`, `StableGenieExchange`, `StableGenieRwaExchange`, `PaymentIsland`, `StableGenieProvider`) | **yes** |
96
- | `…/core` | the framework-agnostic engine — quoting, routing, encoding, the pre-sign validator and the on-chain verifier | **no** |
97
- | `…/mount` | imperative `mount(el, config)` for non-React hosts | yes (bundled by the host build) |
98
- | `…/standalone` | the prebuilt IIFE with React bundled in, for plain `<script>` embeds | no |
99
-
100
- Use `…/core` if you want the routing/validation engine without pulling in React — it is verifiably
101
- React-free (zero references in the emitted ESM, CJS and `.d.ts`).
102
-
103
- ```tsx
104
- import { StableGeniePay } from "@glacislabs/stablegenie-zerodelta";
105
-
106
- <StableGeniePay
107
- recipient="0x…" // merchant deposit address
108
- toChainId={42161} // Arbitrum
109
- toAsset="USDC"
110
- amount="250.00" // recipient receives exactly this
111
- apiBase="/api/widget/v1" // same-origin keyless proxy (default)
112
- provider={eip1193} // optional: inject the host wallet (e.g. wagmi connector)
113
- onSuccess={({ hash }) => console.log("paid", hash)}
114
- />
115
- ```
116
-
117
- ```tsx
118
- import { StableGenieSwap } from "@glacislabs/stablegenie-zerodelta";
119
-
120
- <StableGenieSwap defaultFromAsset="USDT" defaultFromChainId={42161} defaultToAsset="USDC" defaultToChainId={8453} />
121
- ```
122
-
123
- ## Embed (plain `<script>`, no React on the host)
124
-
125
- ```html
126
- <div id="sg"></div>
127
- <script src="/vendor/standalone.global.js"></script>
128
- <script>
129
- StableGenieWidget.mountPay(document.getElementById("sg"), {
130
- recipient: "0x…", toChainId: 42161, toAsset: "USDC", amount: "250.00",
131
- });
132
- </script>
133
- ```
134
-
135
- The `standalone.global.js` build bundles React; the ESM/CJS builds keep it external. The global
136
- exposes `mountPay`, `mountSwap`, `mountExchange`, `mountRwaExchange` and `mountExpress`, each taking
137
- the same props as the React component (including the display `variant`) and returning an unmount
138
- function. The playground's "Script tag" tab prints the exact call for any configuration.
139
-
140
- **Getting the file.** It ships in the package at `dist/standalone.global.js`, reachable as the
141
- `./standalone` export. Copy it into your own static assets as part of your build, e.g.
142
-
143
- ```jsonc
144
- // package.json
145
- "scripts": {
146
- "vendor:widget": "cp node_modules/@glacislabs/stablegenie-zerodelta/dist/standalone.global.js public/vendor/"
147
- }
148
- ```
149
-
150
- **Or load it from a CDN.** The `unpkg` and `jsdelivr` fields point at the standalone build:
151
-
152
- ```html
153
- <script src="https://unpkg.com/@glacislabs/stablegenie-zerodelta@4.0.0/dist/standalone.global.js"></script>
154
- <!-- or -->
155
- <script src="https://cdn.jsdelivr.net/npm/@glacislabs/stablegenie-zerodelta@4.0.0/dist/standalone.global.js"></script>
156
- ```
157
-
158
- ★ For production, pin an exact version (`…/stablegenie-zerodelta@4.0.0`) rather than tracking
159
- `latest`, and prefer self-hosting if your CSP disallows third-party script origins — this widget
160
- sits in a payment path.
161
-
162
- ## Configuration
163
-
164
- | Prop | Default | Notes |
165
- |---|---|---|
166
- | `apiBase` | `/api/widget/v1` | Same-origin keyless proxy (server injects the ZeroDelta key). |
167
- | `apiKey` | — | Not needed against the keyless proxy. Attached **only** to a same-origin (relative) `apiBase`, or to an absolute one matching `trustedApiOrigin`. |
168
- | `trustedApiOrigin` | — | The single absolute origin permitted to receive `apiKey`, e.g. `https://pay.example.com`. Omit and no absolute origin is trusted — same-origin only. |
169
- | `provider` | EIP-6963 / `window.ethereum` | Inject the host's EIP-1193 provider to reuse an existing connection. |
170
- | `theme` | light/dark | `{ accent, bg, surface, text, border, radius, font, mode }` — mirrors the ZeroDelta palette. |
171
- | `rpcOverrides` | registry / bundled | Per-chain RPC for on-chain settlement verification. |
172
-
173
- `StableGenieProvider` can supply these once for multiple widgets.
174
-
175
- > **On `trustedApiOrigin`.** The widget deliberately ships **no** default trusted origin. The
176
- > ZeroDelta API is reached through a server-side proxy that injects the key, so the browser normally
177
- > holds no credential at all — and the proxy origin differs per integrator deployment, so there is no
178
- > single correct value to bake in. Set this only to an origin you control: it is the one destination
179
- > permitted to receive your key.
180
-
181
- ## Security model
182
-
183
- The wallet always owns the final signature. In addition:
184
-
185
- - **The escrow address is pinned offline** per chain (`CANONICAL_ESCROW`) and cross-checked against
186
- the quote and the chain registry. Because both of those come from the same API, the offline pin is
187
- what makes the check meaningful — the widget fails closed on a mismatch.
188
- - **Every quote is re-validated** against your selection (`assertQuoteMatchesSelection`): owner,
189
- receiver, both tokens, both chains, both amounts, and a bounded deadline. Min-received is enforced
190
- on the encoded calldata, not trusted from the response.
191
- - **Every planned transaction is re-decoded before signing** (`validatePlannedTransaction`) and its
192
- `value` bound to the plan. Approvals are exact-amount — never unbounded.
193
- - **Settlement is confirmed by receipt.** `verifySubmittedTx` requires an
194
- `eth_getTransactionReceipt` with status `0x1` over a bundled public RPC before reporting success.
195
- A broadcast-but-unmined or reverted transaction surfaces as `pending`/`reverted`, and **`onSuccess`
196
- does not fire** for either — treat that callback as "the money moved", because that is what it means.
197
- - **No telemetry.** The only network calls are to your `apiBase`, to the RPC used for verification,
198
- and image loads for token artwork: the registry's https `logoUrl` when it ships one, otherwise the
199
- same CoinGecko images the ZeroDelta dapp draws (`BUNDLED_TOKEN_LOGO`, `coin-images.coingecko.com`).
200
- Chain marks are embedded in the bundle and load nothing. A blocked or failed image falls back to
201
- the letters glyph — add the host to your `img-src` or accept the letters; nothing else changes.
202
-
203
- ## Develop
204
-
205
- ```sh
206
- npm i
207
- npm run lint # biome — also runs in CI ahead of typecheck
208
- npm run typecheck # tsc --noEmit
209
- npm test # vitest — engine (node) + DOM behaviour (happy-dom)
210
- npm run build # tsup → dist/ (ESM + CJS + d.ts + standalone.global.js)
211
- npm run dev # tsup --watch
212
- ```
213
-
214
- Requires Node ≥ 20 (`engines`); CI verifies on 22.x.
215
-
216
- The vitest suite encodes the engine's security invariants (encoders, exact-out/in solvers,
217
- `assertQuoteMatchesSelection`, `buildRoute` native-value bounds, `validatePlannedTransaction`,
218
- `verifySubmittedTx`, and the API-key destination gate). Treat it as the release gate: a change that
219
- relaxes one of those checks should fail here first.
220
-
221
- Tests run in **node** by default. Files under `test/dom/` opt into a DOM with
222
- `// @vitest-environment happy-dom`; that is where the React behaviour lives, notably the
223
- verdict→UI mapping that decides whether a payment is reported as settled.
1
+ # @glacislabs/stablegenie-zerodelta
2
+
3
+ A lightweight, embeddable **ZeroDelta payment, exchange + swap widget**. Every surface shares one
4
+ dependency-free engine:
5
+
6
+ - **`<StableGenieExchange>`** — the full exchange card (li.fi-style), in `compact`, `wide` or `pill`.
7
+ - **`<StableGenieRwaExchange>`** — the same card over real-world assets, one leg on each side.
8
+ - **`<StableGeniePay>`** — *exact-receive*. A merchant/dApp needs exactly `X` USDC on chain `Y` at
9
+ address `Z`; the user pays in any supported asset/chain and ZeroDelta routes to the exact receive.
10
+ - **`<StableGenieSwap>`** — *exact-in* swap between supported assets/chains.
11
+ - **`<PaymentIsland>`** — ZeroDelta Link: a collapsed express-checkout pill that expands to a
12
+ one-click card. `variant="pill"` on any of the above renders it.
13
+
14
+ The user's own wallet always owns the final signature — the widget never holds keys and never
15
+ submits silently. Every ZeroDelta quote is re-validated (`assertQuoteMatchesSelection`), every
16
+ planned transaction is re-decoded before signing (`validatePlannedTransaction`), and the settling
17
+ transaction is confirmed on-chain in a trusted realm (`verifySubmittedTx`).
18
+
19
+ Supported **source** chains: Ethereum, Optimism, Arbitrum, Base, Ink, Unichain, Plasma, Sonic, Plume.
20
+ Destinations are not limited to that set — receiving needs no escrow on the far chain, only a
21
+ published route.
22
+
23
+ Supported assets — three nested allowlists (`src/core/constants.ts`), 26 symbols in total:
24
+
25
+ | List | Members |
26
+ |---|---|
27
+ | Executable stables (stable ⇄ stable) | USDC, USDT, USDE, USDTB, AUSD, PYUSD, USDG |
28
+ | Additional RWA-side stables | USD1, wM, USDS, DAI, RLUSD |
29
+ | Tradeable RWA | XAUT, nALPHA, nTBILL, nBASIS, nCREDIT, nOPAL, nWISDOM, nACRDX, nLCRD, nAXI, nCLOA, nFALCON, deJAAA, deSPXA |
30
+
31
+ ⚠️ These **bound** what can be named; they are not the catalogue. What is selectable is derived per
32
+ load from `/chains` + `/tokens` + `/routes` + `/route-health` (`engine.fetchCatalogue()`).
33
+
34
+ Fiat on/off-ramp and bank settlement are roadmap, not shipped — those modes render an honest
35
+ coming-soon panel rather than a quote the engine cannot perform.
36
+
37
+ The engine targets the **production** ZeroDelta escrow (`0x5e25c8ABc19b88d6A7Ab0D805C77A34987a68b40` on
38
+ every supported chain, pinned offline and re-verified against `GET /api/v1/chains`).
39
+
40
+ ## Documentation
41
+
42
+ Integration docs are published at
43
+ **[docs.glacislabs.com/zero-delta/widget](https://docs.glacislabs.com/zero-delta/widget)** — install
44
+ and embed, configuration, theming, the keyless proxy you must deploy, and the API reference.
45
+
46
+ ## Playground
47
+
48
+ **[playground.glacislabs.com](https://playground.glacislabs.com/)** — configure every
49
+ widget, preview it live against the production gateway, and copy the embed. It lives in this repo
50
+ under [`playground/`](playground/) and deploys to Vercel from the same repository that publishes the
51
+ package.
52
+
53
+ ```sh
54
+ cp .env.example .env # STABLEGENIE_API_KEY=<a ZeroDelta viewer key>
55
+ npm run dev:playground # http://localhost:5173
56
+ npm run test:e2e # offline Playwright suite against the production build
57
+ ```
58
+
59
+ - [`playground/src/components/WidgetPreview.tsx`](playground/src/components/WidgetPreview.tsx) is the
60
+ reference integration: it imports the widgets by package name and passes plain props — exactly what
61
+ the playground's "React" snippet prints.
62
+ - [`api/`](api/) is the same-origin **keyless proxy** the widget's default `apiBase` (`/api/widget/v1`)
63
+ expects: it forwards only `chains`, `tokens`, `routes`, `route-health`, `quote` and
64
+ `screen/wallet` to the gateway and injects the viewer key server-side. Copy it into your own
65
+ deployment (Vercel function or any Node handler — `api/_proxy.ts` is framework-free).
66
+ ⚠️ Omitting `screen/wallet` (added in 4.0.0) fails **closed**: the engine cannot screen the
67
+ direct-settlement path, so direct settlement disappears from the picker.
68
+ - `vercel.json`, `.env.example` and `.github/workflows/ci.yml` document the deploy: Vercel project
69
+ at the repo root, `npm run build:playground`, output `playground/dist`, env
70
+ `STABLEGENIE_API_KEY` (+ optional `ZD_API_UPSTREAM`, `WIDGET_ALLOWED_ORIGINS`; the aliases
71
+ `ZERODELTA_API_KEY` / `ZERODELTA_API_URL` are accepted too).
72
+
73
+ ## Install (React host)
74
+
75
+ ```sh
76
+ npm i @glacislabs/stablegenie-zerodelta
77
+ ```
78
+
79
+ No registry configuration and no auth token are needed — the package is published publicly to
80
+ npmjs.com.
81
+
82
+ > [npm provenance](https://docs.npmjs.com/generating-provenance-statements) is **currently off**: it
83
+ > requires a public source repository and this one is still private, so the tarball carries no
84
+ > sigstore attestation. `id-token: write` stays on the release job, so restoring it is a one-line
85
+ > change to `publishConfig` once the repo goes public — see [PUBLISHING.md](PUBLISHING.md).
86
+
87
+ `react` and `react-dom` are **required peerDependencies** for the main entry (they are kept external
88
+ in the ESM/CJS builds, so the host's React is reused — no double bundle). CSS is auto-injected; there
89
+ is no stylesheet to import.
90
+
91
+ ### Entry points
92
+
93
+ | Import | Contains | React required |
94
+ |---|---|---|
95
+ | `@glacislabs/stablegenie-zerodelta` | the React components (`StableGeniePay`, `StableGenieSwap`, `StableGenieExchange`, `StableGenieRwaExchange`, `PaymentIsland`, `StableGenieProvider`) | **yes** |
96
+ | `…/core` | the framework-agnostic engine — quoting, routing, encoding, the pre-sign validator and the on-chain verifier | **no** |
97
+ | `…/mount` | imperative `mount(el, config)` for non-React hosts | yes (bundled by the host build) |
98
+ | `…/standalone` | the prebuilt IIFE with React bundled in, for plain `<script>` embeds | no |
99
+
100
+ Use `…/core` if you want the routing/validation engine without pulling in React — it is verifiably
101
+ React-free (zero references in the emitted ESM, CJS and `.d.ts`).
102
+
103
+ ```tsx
104
+ import { StableGeniePay } from "@glacislabs/stablegenie-zerodelta";
105
+
106
+ <StableGeniePay
107
+ recipient="0x…" // merchant deposit address
108
+ toChainId={42161} // Arbitrum
109
+ toAsset="USDC"
110
+ amount="250.00" // recipient receives exactly this
111
+ apiBase="/api/widget/v1" // same-origin keyless proxy (default)
112
+ provider={eip1193} // optional: inject the host wallet (e.g. wagmi connector)
113
+ onSuccess={({ hash }) => console.log("paid", hash)}
114
+ />
115
+ ```
116
+
117
+ ```tsx
118
+ import { StableGenieSwap } from "@glacislabs/stablegenie-zerodelta";
119
+
120
+ <StableGenieSwap defaultFromAsset="USDT" defaultFromChainId={42161} defaultToAsset="USDC" defaultToChainId={8453} />
121
+ ```
122
+
123
+ ## Embed (plain `<script>`, no React on the host)
124
+
125
+ ```html
126
+ <div id="sg"></div>
127
+ <script src="/vendor/standalone.global.js"></script>
128
+ <script>
129
+ StableGenieWidget.mountPay(document.getElementById("sg"), {
130
+ recipient: "0x…", toChainId: 42161, toAsset: "USDC", amount: "250.00",
131
+ });
132
+ </script>
133
+ ```
134
+
135
+ The `standalone.global.js` build bundles React; the ESM/CJS builds keep it external. The global
136
+ exposes `mountPay`, `mountSwap`, `mountExchange`, `mountRwaExchange` and `mountExpress`, each taking
137
+ the same props as the React component (including the display `variant`) and returning an unmount
138
+ function. The playground's "Script tag" tab prints the exact call for any configuration.
139
+
140
+ **Getting the file.** It ships in the package at `dist/standalone.global.js`, reachable as the
141
+ `./standalone` export. Copy it into your own static assets as part of your build, e.g.
142
+
143
+ ```jsonc
144
+ // package.json
145
+ "scripts": {
146
+ "vendor:widget": "cp node_modules/@glacislabs/stablegenie-zerodelta/dist/standalone.global.js public/vendor/"
147
+ }
148
+ ```
149
+
150
+ **Or load it from a CDN.** The `unpkg` and `jsdelivr` fields point at the standalone build:
151
+
152
+ ```html
153
+ <script src="https://unpkg.com/@glacislabs/stablegenie-zerodelta@4.0.0/dist/standalone.global.js"></script>
154
+ <!-- or -->
155
+ <script src="https://cdn.jsdelivr.net/npm/@glacislabs/stablegenie-zerodelta@4.0.0/dist/standalone.global.js"></script>
156
+ ```
157
+
158
+ ★ For production, pin an exact version (`…/stablegenie-zerodelta@4.0.0`) rather than tracking
159
+ `latest`, and prefer self-hosting if your CSP disallows third-party script origins — this widget
160
+ sits in a payment path.
161
+
162
+ ## Configuration
163
+
164
+ | Prop | Default | Notes |
165
+ |---|---|---|
166
+ | `apiBase` | `/api/widget/v1` | Same-origin keyless proxy (server injects the ZeroDelta key). |
167
+ | `apiKey` | — | Not needed against the keyless proxy. Attached **only** to a same-origin (relative) `apiBase`, or to an absolute one matching `trustedApiOrigin`. |
168
+ | `trustedApiOrigin` | — | The single absolute origin permitted to receive `apiKey`, e.g. `https://pay.example.com`. Omit and no absolute origin is trusted — same-origin only. |
169
+ | `provider` | EIP-6963 / `window.ethereum` | Inject the host's EIP-1193 provider to reuse an existing connection. |
170
+ | `theme` | light/dark | `{ accent, bg, surface, text, border, radius, font, mode }` — mirrors the ZeroDelta palette. |
171
+ | `rpcOverrides` | registry / bundled | Per-chain RPC for on-chain settlement verification. |
172
+
173
+ `StableGenieProvider` can supply these once for multiple widgets.
174
+
175
+ > **On `trustedApiOrigin`.** The widget deliberately ships **no** default trusted origin. The
176
+ > ZeroDelta API is reached through a server-side proxy that injects the key, so the browser normally
177
+ > holds no credential at all — and the proxy origin differs per integrator deployment, so there is no
178
+ > single correct value to bake in. Set this only to an origin you control: it is the one destination
179
+ > permitted to receive your key.
180
+
181
+ ## Security model
182
+
183
+ The wallet always owns the final signature. In addition:
184
+
185
+ - **The escrow address is pinned offline** per chain (`CANONICAL_ESCROW`) and cross-checked against
186
+ the quote and the chain registry. Because both of those come from the same API, the offline pin is
187
+ what makes the check meaningful — the widget fails closed on a mismatch.
188
+ - **Every quote is re-validated** against your selection (`assertQuoteMatchesSelection`): owner,
189
+ receiver, both tokens, both chains, both amounts, and a bounded deadline. Min-received is enforced
190
+ on the encoded calldata, not trusted from the response.
191
+ - **Every planned transaction is re-decoded before signing** (`validatePlannedTransaction`) and its
192
+ `value` bound to the plan. Approvals are exact-amount — never unbounded.
193
+ - **Settlement is confirmed by receipt.** `verifySubmittedTx` requires an
194
+ `eth_getTransactionReceipt` with status `0x1` over a bundled public RPC before reporting success.
195
+ A broadcast-but-unmined or reverted transaction surfaces as `pending`/`reverted`, and **`onSuccess`
196
+ does not fire** for either — treat that callback as "the money moved", because that is what it means.
197
+ - **No telemetry.** The only network calls are to your `apiBase`, to the RPC used for verification,
198
+ and image loads for token artwork: the registry's https `logoUrl` when it ships one, otherwise the
199
+ same CoinGecko images the ZeroDelta dapp draws (`BUNDLED_TOKEN_LOGO`, `coin-images.coingecko.com`).
200
+ Chain marks are embedded in the bundle and load nothing. A blocked or failed image falls back to
201
+ the letters glyph — add the host to your `img-src` or accept the letters; nothing else changes.
202
+
203
+ ## Develop
204
+
205
+ ```sh
206
+ npm i
207
+ npm run lint # biome — also runs in CI ahead of typecheck
208
+ npm run typecheck # tsc --noEmit
209
+ npm test # vitest — engine (node) + DOM behaviour (happy-dom)
210
+ npm run build # tsup → dist/ (ESM + CJS + d.ts + standalone.global.js)
211
+ npm run dev # tsup --watch
212
+ ```
213
+
214
+ Requires Node ≥ 20 (`engines`); CI verifies on 22.x.
215
+
216
+ The vitest suite encodes the engine's security invariants (encoders, exact-out/in solvers,
217
+ `assertQuoteMatchesSelection`, `buildRoute` native-value bounds, `validatePlannedTransaction`,
218
+ `verifySubmittedTx`, and the API-key destination gate). Treat it as the release gate: a change that
219
+ relaxes one of those checks should fail here first.
220
+
221
+ Tests run in **node** by default. Files under `test/dom/` opt into a DOM with
222
+ `// @vitest-environment happy-dom`; that is where the React behaviour lives, notably the
223
+ verdict→UI mapping that decides whether a payment is reported as settled.