@partylayer/sdk 0.16.0 → 0.17.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/dist/index.d.mts +31 -6
- package/dist/index.d.ts +31 -6
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/dist/index.mjs
CHANGED
|
@@ -364,6 +364,46 @@ var GenericDiscoveryAdapter = class {
|
|
|
364
364
|
};
|
|
365
365
|
return { partyId, session, capabilities: this.getCapabilities() };
|
|
366
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Restore a persisted session by delegating to the official adapter's own `restore`.
|
|
369
|
+
*
|
|
370
|
+
* The official `ProviderAdapter` shape carries an optional `restore()` that reinstates a
|
|
371
|
+
* session (for example from the wallet's own storage) and returns a LIVE provider.
|
|
372
|
+
* Without this method the SDK revived the persisted record as-is and then built a fresh,
|
|
373
|
+
* SESSION-LESS provider from `provider()`, so a wallet that restores in `restore` looked
|
|
374
|
+
* connected after a reload but its first real request threw. This forwards to the
|
|
375
|
+
* official `restore` and, when it yields a provider, adopts it as the cached provider so
|
|
376
|
+
* the very next request uses the restored session.
|
|
377
|
+
*
|
|
378
|
+
* Popup-safe: this runs on the SDK's init/restore path, never inside a user gesture, so a
|
|
379
|
+
* popup could not open here even if an adapter tried (the browser would block it). Per
|
|
380
|
+
* the official contract `restore` is storage-based and gesture-free. If the official
|
|
381
|
+
* adapter has no `restore`, it returns null, or host resolution is not ready, this falls
|
|
382
|
+
* through to the previous behavior: the persisted session is returned and the provider is
|
|
383
|
+
* built lazily on first use, exactly as before.
|
|
384
|
+
*/
|
|
385
|
+
async restore(ctx, persisted) {
|
|
386
|
+
const asIs = { ...persisted, walletId: this.walletId };
|
|
387
|
+
try {
|
|
388
|
+
this.resolveOfficial(ctx.network);
|
|
389
|
+
} catch {
|
|
390
|
+
return asIs;
|
|
391
|
+
}
|
|
392
|
+
const restore = this.official?.restore;
|
|
393
|
+
if (this.official && restore) {
|
|
394
|
+
let restored = null;
|
|
395
|
+
try {
|
|
396
|
+
restored = await restore.call(this.official);
|
|
397
|
+
} catch {
|
|
398
|
+
restored = null;
|
|
399
|
+
}
|
|
400
|
+
if (restored) {
|
|
401
|
+
this.providerInstance = restored;
|
|
402
|
+
return asIs;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return asIs;
|
|
406
|
+
}
|
|
367
407
|
async disconnect() {
|
|
368
408
|
try {
|
|
369
409
|
await this.provider.request({ method: "disconnect" });
|