@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.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _partylayer_core from '@partylayer/core';
|
|
2
|
-
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts } from '@partylayer/core';
|
|
2
|
+
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
|
|
3
3
|
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
4
4
|
import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
|
|
5
5
|
export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
@@ -76,8 +76,9 @@ type AdapterClass = new () => WalletAdapter;
|
|
|
76
76
|
*/
|
|
77
77
|
interface PartyLayerConfig {
|
|
78
78
|
/**
|
|
79
|
-
* Registry URL (optional)
|
|
80
|
-
*
|
|
79
|
+
* Registry base URL (optional). The client appends `/v1/{channel}/registry.json`,
|
|
80
|
+
* so the default fetch is `https://registry.partylayer.xyz/v1/stable/registry.json`.
|
|
81
|
+
* @default 'https://registry.partylayer.xyz'
|
|
81
82
|
*/
|
|
82
83
|
registryUrl?: string;
|
|
83
84
|
/** Registry channel */
|
|
@@ -776,10 +777,15 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
776
777
|
* (e.g. `new WalleyAdapter({ host: 'https://dev.walley.cc' })`), so the bridge
|
|
777
778
|
* never sees or sets them.
|
|
778
779
|
*
|
|
780
|
+
* Session restore forwards to the official adapter's own `restore` (see {@link
|
|
781
|
+
* GenericDiscoveryAdapter.restore}): on reload the wallet reinstates its session, typically
|
|
782
|
+
* from its own storage, and the bridge adopts the returned live provider, so the first
|
|
783
|
+
* request after reload works. If the official adapter has no `restore`, the SDK revives the
|
|
784
|
+
* persisted record as-is.
|
|
785
|
+
*
|
|
779
786
|
* Eventless note: the official provider exposes `on`/`emit`/`removeListener`
|
|
780
|
-
* but popup/remote wallets typically never emit
|
|
781
|
-
* `
|
|
782
|
-
* tolerated; `getCapabilities()` therefore NEVER returns `'events'`.
|
|
787
|
+
* but popup/remote wallets typically never emit, so `getCapabilities()` NEVER
|
|
788
|
+
* returns `'events'`.
|
|
783
789
|
*/
|
|
784
790
|
|
|
785
791
|
interface GenericDiscoveryAdapterArgs {
|
|
@@ -863,6 +869,25 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
863
869
|
/** Install/availability probe — delegated to the official adapter (popup-free). */
|
|
864
870
|
detectInstalled(): Promise<AdapterDetectResult>;
|
|
865
871
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
872
|
+
/**
|
|
873
|
+
* Restore a persisted session by delegating to the official adapter's own `restore`.
|
|
874
|
+
*
|
|
875
|
+
* The official `ProviderAdapter` shape carries an optional `restore()` that reinstates a
|
|
876
|
+
* session (for example from the wallet's own storage) and returns a LIVE provider.
|
|
877
|
+
* Without this method the SDK revived the persisted record as-is and then built a fresh,
|
|
878
|
+
* SESSION-LESS provider from `provider()`, so a wallet that restores in `restore` looked
|
|
879
|
+
* connected after a reload but its first real request threw. This forwards to the
|
|
880
|
+
* official `restore` and, when it yields a provider, adopts it as the cached provider so
|
|
881
|
+
* the very next request uses the restored session.
|
|
882
|
+
*
|
|
883
|
+
* Popup-safe: this runs on the SDK's init/restore path, never inside a user gesture, so a
|
|
884
|
+
* popup could not open here even if an adapter tried (the browser would block it). Per
|
|
885
|
+
* the official contract `restore` is storage-based and gesture-free. If the official
|
|
886
|
+
* adapter has no `restore`, it returns null, or host resolution is not ready, this falls
|
|
887
|
+
* through to the previous behavior: the persisted session is returned and the provider is
|
|
888
|
+
* built lazily on first use, exactly as before.
|
|
889
|
+
*/
|
|
890
|
+
restore(ctx: AdapterContext, persisted: PersistedSession): Promise<Session | null>;
|
|
866
891
|
disconnect(): Promise<void>;
|
|
867
892
|
signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
|
|
868
893
|
submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _partylayer_core from '@partylayer/core';
|
|
2
|
-
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts } from '@partylayer/core';
|
|
2
|
+
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
|
|
3
3
|
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
4
4
|
import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
|
|
5
5
|
export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
@@ -76,8 +76,9 @@ type AdapterClass = new () => WalletAdapter;
|
|
|
76
76
|
*/
|
|
77
77
|
interface PartyLayerConfig {
|
|
78
78
|
/**
|
|
79
|
-
* Registry URL (optional)
|
|
80
|
-
*
|
|
79
|
+
* Registry base URL (optional). The client appends `/v1/{channel}/registry.json`,
|
|
80
|
+
* so the default fetch is `https://registry.partylayer.xyz/v1/stable/registry.json`.
|
|
81
|
+
* @default 'https://registry.partylayer.xyz'
|
|
81
82
|
*/
|
|
82
83
|
registryUrl?: string;
|
|
83
84
|
/** Registry channel */
|
|
@@ -776,10 +777,15 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
776
777
|
* (e.g. `new WalleyAdapter({ host: 'https://dev.walley.cc' })`), so the bridge
|
|
777
778
|
* never sees or sets them.
|
|
778
779
|
*
|
|
780
|
+
* Session restore forwards to the official adapter's own `restore` (see {@link
|
|
781
|
+
* GenericDiscoveryAdapter.restore}): on reload the wallet reinstates its session, typically
|
|
782
|
+
* from its own storage, and the bridge adopts the returned live provider, so the first
|
|
783
|
+
* request after reload works. If the official adapter has no `restore`, the SDK revives the
|
|
784
|
+
* persisted record as-is.
|
|
785
|
+
*
|
|
779
786
|
* Eventless note: the official provider exposes `on`/`emit`/`removeListener`
|
|
780
|
-
* but popup/remote wallets typically never emit
|
|
781
|
-
* `
|
|
782
|
-
* tolerated; `getCapabilities()` therefore NEVER returns `'events'`.
|
|
787
|
+
* but popup/remote wallets typically never emit, so `getCapabilities()` NEVER
|
|
788
|
+
* returns `'events'`.
|
|
783
789
|
*/
|
|
784
790
|
|
|
785
791
|
interface GenericDiscoveryAdapterArgs {
|
|
@@ -863,6 +869,25 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
863
869
|
/** Install/availability probe — delegated to the official adapter (popup-free). */
|
|
864
870
|
detectInstalled(): Promise<AdapterDetectResult>;
|
|
865
871
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
872
|
+
/**
|
|
873
|
+
* Restore a persisted session by delegating to the official adapter's own `restore`.
|
|
874
|
+
*
|
|
875
|
+
* The official `ProviderAdapter` shape carries an optional `restore()` that reinstates a
|
|
876
|
+
* session (for example from the wallet's own storage) and returns a LIVE provider.
|
|
877
|
+
* Without this method the SDK revived the persisted record as-is and then built a fresh,
|
|
878
|
+
* SESSION-LESS provider from `provider()`, so a wallet that restores in `restore` looked
|
|
879
|
+
* connected after a reload but its first real request threw. This forwards to the
|
|
880
|
+
* official `restore` and, when it yields a provider, adopts it as the cached provider so
|
|
881
|
+
* the very next request uses the restored session.
|
|
882
|
+
*
|
|
883
|
+
* Popup-safe: this runs on the SDK's init/restore path, never inside a user gesture, so a
|
|
884
|
+
* popup could not open here even if an adapter tried (the browser would block it). Per
|
|
885
|
+
* the official contract `restore` is storage-based and gesture-free. If the official
|
|
886
|
+
* adapter has no `restore`, it returns null, or host resolution is not ready, this falls
|
|
887
|
+
* through to the previous behavior: the persisted session is returned and the provider is
|
|
888
|
+
* built lazily on first use, exactly as before.
|
|
889
|
+
*/
|
|
890
|
+
restore(ctx: AdapterContext, persisted: PersistedSession): Promise<Session | null>;
|
|
866
891
|
disconnect(): Promise<void>;
|
|
867
892
|
signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
|
|
868
893
|
submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
package/dist/index.js
CHANGED
|
@@ -360,6 +360,46 @@ var GenericDiscoveryAdapter = class {
|
|
|
360
360
|
};
|
|
361
361
|
return { partyId, session, capabilities: this.getCapabilities() };
|
|
362
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Restore a persisted session by delegating to the official adapter's own `restore`.
|
|
365
|
+
*
|
|
366
|
+
* The official `ProviderAdapter` shape carries an optional `restore()` that reinstates a
|
|
367
|
+
* session (for example from the wallet's own storage) and returns a LIVE provider.
|
|
368
|
+
* Without this method the SDK revived the persisted record as-is and then built a fresh,
|
|
369
|
+
* SESSION-LESS provider from `provider()`, so a wallet that restores in `restore` looked
|
|
370
|
+
* connected after a reload but its first real request threw. This forwards to the
|
|
371
|
+
* official `restore` and, when it yields a provider, adopts it as the cached provider so
|
|
372
|
+
* the very next request uses the restored session.
|
|
373
|
+
*
|
|
374
|
+
* Popup-safe: this runs on the SDK's init/restore path, never inside a user gesture, so a
|
|
375
|
+
* popup could not open here even if an adapter tried (the browser would block it). Per
|
|
376
|
+
* the official contract `restore` is storage-based and gesture-free. If the official
|
|
377
|
+
* adapter has no `restore`, it returns null, or host resolution is not ready, this falls
|
|
378
|
+
* through to the previous behavior: the persisted session is returned and the provider is
|
|
379
|
+
* built lazily on first use, exactly as before.
|
|
380
|
+
*/
|
|
381
|
+
async restore(ctx, persisted) {
|
|
382
|
+
const asIs = { ...persisted, walletId: this.walletId };
|
|
383
|
+
try {
|
|
384
|
+
this.resolveOfficial(ctx.network);
|
|
385
|
+
} catch {
|
|
386
|
+
return asIs;
|
|
387
|
+
}
|
|
388
|
+
const restore = this.official?.restore;
|
|
389
|
+
if (this.official && restore) {
|
|
390
|
+
let restored = null;
|
|
391
|
+
try {
|
|
392
|
+
restored = await restore.call(this.official);
|
|
393
|
+
} catch {
|
|
394
|
+
restored = null;
|
|
395
|
+
}
|
|
396
|
+
if (restored) {
|
|
397
|
+
this.providerInstance = restored;
|
|
398
|
+
return asIs;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return asIs;
|
|
402
|
+
}
|
|
363
403
|
async disconnect() {
|
|
364
404
|
try {
|
|
365
405
|
await this.provider.request({ method: "disconnect" });
|