@miden-sdk/miden-wallet-adapter 0.13.1 → 0.13.3

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/README.md +98 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -165,6 +165,104 @@ function AssetsAndNotesComponent() {
165
165
  }
166
166
  ```
167
167
 
168
+ ## MidenFiSignerProvider
169
+
170
+ `MidenFiSignerProvider` is a higher-level alternative to `WalletProvider` that integrates the wallet adapter directly with `MidenProvider` from `@miden-sdk/react`. It automatically creates and manages a Miden signer account using the connected wallet's keys, and exposes it to the `@miden-sdk/react` hooks (`useSigner`, `useMiden`, etc.).
171
+
172
+ ### Basic setup
173
+
174
+ ```tsx
175
+ import { MidenFiSignerProvider } from '@miden-sdk/miden-wallet-adapter-react';
176
+ import { WalletAdapterNetwork } from '@miden-sdk/miden-wallet-adapter-base';
177
+ import { MidenProvider } from '@miden-sdk/react';
178
+
179
+ function App() {
180
+ return (
181
+ <MidenFiSignerProvider
182
+ appName="My Miden dApp"
183
+ network={WalletAdapterNetwork.Testnet}
184
+ >
185
+ <MidenProvider config={{ rpcUrl: 'testnet' }}>
186
+ <YourApp />
187
+ </MidenProvider>
188
+ </MidenFiSignerProvider>
189
+ );
190
+ }
191
+ ```
192
+
193
+ ### Account type and storage mode
194
+
195
+ ```tsx
196
+ <MidenFiSignerProvider
197
+ appName="My Miden dApp"
198
+ accountType="RegularAccountImmutableCode"
199
+ storageMode="public"
200
+ >
201
+ ...
202
+ </MidenFiSignerProvider>
203
+ ```
204
+
205
+ | Prop | Type | Default | Description |
206
+ |---|---|---|---|
207
+ | `accountType` | `SignerAccountType` | `'RegularAccountImmutableCode'` | The type of on-chain signer account to create |
208
+ | `storageMode` | `'private' \| 'public' \| 'network'` | `'public'` | Where the account state is stored |
209
+
210
+ ### Custom account components
211
+
212
+ Pass `customComponents` to attach custom on-chain logic — compiled from `.masp` (Miden Assembly Package) files — to the signer account at creation time.
213
+
214
+ ```tsx
215
+ import type { AccountComponent } from '@miden-sdk/miden-sdk';
216
+ import { myComponent } from '@myorg/my-masp-package'; // compiled AccountComponent
217
+
218
+ function App() {
219
+ return (
220
+ <MidenFiSignerProvider
221
+ appName="My Miden dApp"
222
+ accountType="RegularAccountImmutableCode"
223
+ storageMode="public"
224
+ customComponents={[myComponent]}
225
+ >
226
+ <MidenProvider config={{ rpcUrl: 'testnet' }}>
227
+ <YourApp />
228
+ </MidenProvider>
229
+ </MidenFiSignerProvider>
230
+ );
231
+ }
232
+ ```
233
+
234
+ `customComponents` is only applied during account creation. Changing the prop after the account exists has no effect on the deployed account. If the array is empty or omitted, the account is created with default components only.
235
+
236
+ ### Props reference
237
+
238
+ | Prop | Type | Default | Description |
239
+ |---|---|---|---|
240
+ | `appName` | `string` | — | App name passed to the default wallet adapter |
241
+ | `wallets` | `Adapter[]` | `[MidenWalletAdapter]` | Wallet adapters to use |
242
+ | `network` | `WalletAdapterNetwork` | — | Network to connect to |
243
+ | `autoConnect` | `boolean` | `true` | Auto-connect to previously selected wallet on mount |
244
+ | `accountType` | `SignerAccountType` | `'RegularAccountImmutableCode'` | Type of signer account to create |
245
+ | `storageMode` | `'private' \| 'public' \| 'network'` | `'public'` | Account storage mode |
246
+ | `customComponents` | `AccountComponent[]` | — | Custom components from a compiled `.masp` package |
247
+ | `onError` | `(error: WalletError) => void` | — | Error handler |
248
+ | `localStorageKey` | `string` | — | Key for persisting wallet selection |
249
+
250
+ ### Accessing signer and wallet state
251
+
252
+ ```tsx
253
+ import { useMidenFiWallet } from '@miden-sdk/miden-wallet-adapter-react';
254
+ import { useMiden, useSigner } from '@miden-sdk/react';
255
+
256
+ function WalletStatus() {
257
+ const { connected, address, connect, disconnect } = useMidenFiWallet();
258
+ const { isReady, signerAccountId } = useMiden();
259
+
260
+ return connected
261
+ ? <button onClick={disconnect}>Disconnect ({address})</button>
262
+ : <button onClick={connect}>Connect Wallet</button>;
263
+ }
264
+ ```
265
+
168
266
  ## UI Components
169
267
 
170
268
  The package includes several pre-built React components:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miden-sdk/miden-wallet-adapter",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
4
4
  "description": "Modular TypeScript wallet adapters and React components for Miden applications.",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",