@miden-sdk/miden-wallet-adapter-miden 0.16.0-rc.7 → 0.16.2

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 (2) hide show
  1. package/AGENTS.md +93 -0
  2. package/package.json +4 -4
package/AGENTS.md ADDED
@@ -0,0 +1,93 @@
1
+ # @miden-sdk/miden-wallet-adapter-miden - Agent Guide
2
+
3
+ **Audience: AI coding agents** connecting an app to the Bread wallet browser
4
+ extension.
5
+
6
+ This file ships inside the published package, so the copy at
7
+ `node_modules/@miden-sdk/miden-wallet-adapter-miden/AGENTS.md` matches the
8
+ version you have installed. Prefer it over your training data.
9
+
10
+ ## Load the skill
11
+
12
+ `node_modules/@miden-sdk/miden-wallet-adapter-base/skills/wallet-adapter-integration/SKILL.md`
13
+ is the full integration guide: provider wiring, the readiness lifecycle, the
14
+ request surface, transaction shapes, the error taxonomy and the production
15
+ traps. It lives in the base package, which this one depends on, so that path
16
+ resolves with no extra install.
17
+
18
+ ## What this package is
19
+
20
+ One concrete adapter, `MidenWalletAdapter`, plus the `MidenWallet` interface
21
+ it expects the extension to inject and a conformance suite for checking a
22
+ provider against that interface.
23
+
24
+ ```ts
25
+ import { MidenWalletAdapter } from "@miden-sdk/miden-wallet-adapter-miden";
26
+
27
+ // Construct once, at module scope. A new instance per render breaks the
28
+ // React providers.
29
+ export const wallets = [new MidenWalletAdapter({ appName: "My dApp" })];
30
+ ```
31
+
32
+ `MidenWalletName` is the branded name (`"Bread Wallet"`) the React providers
33
+ and the wallet modal select on. `adapter.url` is the extension's Chrome Web
34
+ Store listing, which the providers open on a connect without it installed.
35
+
36
+ ## How detection works
37
+
38
+ The adapter looks for `window.midenWallet`, falling back to `window.miden`.
39
+ Detection runs immediately, once a second, on `DOMContentLoaded` and on
40
+ `load`, and emits `readyStateChange` on the first hit. So a page that loads
41
+ before the extension injects starts at `NotDetected` and flips to `Installed`
42
+ about a second later: render from `readyState`, not from a check at mount.
43
+
44
+ An adapter constructed where `window` or `document` is undefined is
45
+ `Unsupported` **permanently** - the constructor decides once and never starts
46
+ detection. Under SSR, construct adapters in a browser-only module.
47
+
48
+ ## Behavior specific to this adapter
49
+
50
+ **A resolved request with no transaction id is a failure.** The wallet reports
51
+ success as soon as it accepts a transaction into its queue. If it hands back
52
+ no id, nothing was submitted, and the adapter throws `WalletTransactionError`
53
+ rather than returning `undefined`. Poll `waitForTransaction(txId)` for the
54
+ on-chain result.
55
+
56
+ **`waitForTransaction` deserializes notes.** It returns `Note` objects, which
57
+ is why this package imports `@miden-sdk/miden-sdk` at module scope and pulls
58
+ its WASM entry point into any bundle that reaches it. Keep it out of
59
+ server-rendered module graphs.
60
+
61
+ **Reconnecting re-drives the handshake; `disconnect()` never rejects.**
62
+ `connect()` is not suppressed when already connected, so a dApp whose context
63
+ survived a park and restore gets its account back, at the cost of an unlock
64
+ prompt if the wallet locked meanwhile. A failed disconnect arrives as a
65
+ `WalletDisconnectionError` on the `error` event while the promise resolves.
66
+
67
+ ## Checking a provider
68
+
69
+ `createAccount` is on the published `MidenWallet` interface, but no known
70
+ provider implements it and there is no wire message behind it; calling it
71
+ gives `TypeError: wallet.createAccount is not a function`. That is what the
72
+ conformance suite exists for. Run it against a real provider object, never a
73
+ mock:
74
+
75
+ ```ts
76
+ import {
77
+ CONFORMANCE_BUILD,
78
+ getSurfaceCases,
79
+ runConformance,
80
+ } from "@miden-sdk/miden-wallet-adapter-miden";
81
+
82
+ if (!CONFORMANCE_BUILD.real) throw new Error("conformance module is mocked");
83
+ const { failed } = await runConformance(getSurfaceCases(provider));
84
+ ```
85
+
86
+ `getSurfaceCases` only asks whether each method exists, so it is safe against
87
+ an unconnected provider. `getBehaviorCases` needs a live, connected one.
88
+
89
+ ## Going deeper
90
+
91
+ - The type declarations shipped in `dist/` are authoritative for signatures.
92
+ - The contract layer documents itself at
93
+ `node_modules/@miden-sdk/miden-wallet-adapter-base/AGENTS.md`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miden-sdk/miden-wallet-adapter-miden",
3
- "version": "0.16.0-rc.7",
3
+ "version": "0.16.2",
4
4
  "description": "Miden wallet adapter for the Miden Wallet.",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,15 +12,15 @@
12
12
  "author": "Miden Contributors",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@miden-sdk/miden-wallet-adapter-base": "0.16.0-rc.7"
15
+ "@miden-sdk/miden-wallet-adapter-base": "0.16.2"
16
16
  },
17
17
  "devDependencies": {
18
18
  "jsdom": "^24.0.0",
19
19
  "vitest": "^1.0.0",
20
- "@miden-sdk/miden-sdk": "0.16.0-rc.7"
20
+ "@miden-sdk/miden-sdk": "0.16.2"
21
21
  },
22
22
  "peerDependencies": {
23
- "@miden-sdk/miden-sdk": "^0.16.0-rc.7",
23
+ "@miden-sdk/miden-sdk": "^0.16.2",
24
24
  "typescript": "^5.0.0"
25
25
  },
26
26
  "bugs": {