You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replace signer.disconnect() with signer.closeChannel() (correct API per SDK docs)
- Fix local dev section: remove conflation with @dfinity/oisy-wallet-signer
- Add git clone step to working example deploy instructions
- Add requestPermissions() note before getAccounts()
- Add error code table to error handling section
- Add Principal import to session persistence code block
- Add forward-looking note about @dfinity/ledger-wallet-identity and @dfinity/icrc21-agent
If you skip this step, the signer handles permissions per-method — the user sees a permissions prompt the first time each method is called.
90
+
80
91
## Create a SignerAgent
81
92
82
93
`SignerAgent` wraps a `Signer` and acts as a drop-in replacement for `HttpAgent`. Any canister actor built with it routes calls through the wallet for approval.
Call `disconnect()` on the signer when the user logs out or closes the session:
147
+
Call `closeChannel()` on the signer when the user logs out or closes the session:
137
148
138
149
```javascript
139
-
awaitsigner.disconnect();
150
+
awaitsigner.closeChannel();
140
151
```
141
152
142
-
Disconnect closes the wallet popup and removes any cached session state.
153
+
`closeChannel()` closes the open communication channel with the wallet popup.
143
154
144
155
## Session persistence
145
156
146
157
The signer session is tied to the browser tab. After a page reload, the user's principal is no longer available from the signer. To avoid opening the popup again immediately, store the principal in `sessionStorage` and restore it on mount — then re-establish the signer session lazily when the user initiates a transfer:
147
158
148
159
```javascript
160
+
import { Principal } from'@icp-sdk/core/principal';
161
+
149
162
constSESSION_KEY='wallet-principal';
150
163
151
164
// On connect: store principal
@@ -172,17 +185,25 @@ try {
172
185
awaitsigner.getAccounts();
173
186
} catch (err) {
174
187
if (err instanceof SignerError) {
175
-
// err.code: numeric error code from the ICRC-25 standard
The `@dfinity/oisy-wallet-signer` repository includes a [pseudo wallet signer](https://github.com/dfinity/oisy-wallet-signer) you can run locally as a test signer. See its `demo/` directory for setup instructions.
220
+
For a test signer target, you can use any ICRC-25-compliant wallet running locally that exposes a `/sign` endpoint — for example, a local instance of [OISY](https://github.com/dfinity/oisy-wallet) or a custom signer built with `@icp-sdk/signer`.
200
221
201
222
On mainnet, omit `host` from `HttpAgent.create()` — it defaults to `https://icp0.io`.
202
223
@@ -211,13 +232,22 @@ The [oisy-signer-demo](https://github.com/dfinity/examples/tree/master/hosting/o
211
232
To run locally:
212
233
213
234
```bash
214
-
icp network start -d
235
+
git clone https://github.com/dfinity/examples
215
236
cd examples/hosting/oisy-signer-demo
237
+
icp network start -d
216
238
npm install
217
-
cd frontend && npm install
218
239
icp deploy
219
240
```
220
241
242
+
## Ecosystem libraries
243
+
244
+
Two additional libraries are available for more advanced wallet integration scenarios:
245
+
246
+
-[`@dfinity/ledger-wallet-identity`](https://www.npmjs.com/package/@dfinity/ledger-wallet-identity) — hardware wallet identity support
Both libraries are expected to move to the `@icp-sdk` namespace on npm and will likely be covered in the wallet-integration skill going forward. They are not documented in detail here.
0 commit comments