@partylayer/sdk 0.16.0 → 0.17.1
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/README.md +3 -3
- package/dist/index.d.mts +38 -11
- package/dist/index.d.ts +38 -11
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
### Features
|
|
20
20
|
|
|
21
|
-
- **Multi-Wallet Support**: Console, 5N Loop, Cantor8,
|
|
21
|
+
- **Multi-Wallet Support**: one integration for every wallet in the Canton registry (eight today, including Console, Send, 5N Loop, Cantor8, Nightly, Bron, Walley, and WalletConnect)
|
|
22
22
|
- **Zero Configuration**: Works out of the box with sensible defaults
|
|
23
23
|
- **Type-Safe**: Full TypeScript support with strict mode
|
|
24
24
|
- **Secure**: Encrypted session storage with origin binding
|
|
@@ -121,8 +121,8 @@ await client.disconnect();
|
|
|
121
121
|
| Wallet | Networks | Capabilities | Opt-in | Adapter |
|
|
122
122
|
|--------|----------|--------------|--------|---------|
|
|
123
123
|
| Console Wallet | devnet, testnet, mainnet | signMessage, signTransaction, submitTransaction, transactionStatus | No | `@partylayer/adapter-console` |
|
|
124
|
-
| 5N Loop | devnet,
|
|
125
|
-
| Cantor8 | devnet,
|
|
124
|
+
| 5N Loop | devnet, mainnet | signMessage, submitTransaction, transactionStatus | No | `@partylayer/adapter-loop` |
|
|
125
|
+
| Cantor8 | devnet, mainnet | submitTransaction, transactionStatus | No | `@partylayer/adapter-cantor8` |
|
|
126
126
|
| Bron | devnet, testnet, mainnet | signMessage, signTransaction | Yes | `@partylayer/adapter-bron` |
|
|
127
127
|
| Nightly | devnet, testnet, mainnet | signMessage, submitTransaction | No | `@partylayer/adapter-nightly` |
|
|
128
128
|
| Send | mainnet | signMessage, submitTransaction, transactionStatus | No | `@partylayer/adapter-send` |
|
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 */
|
|
@@ -100,22 +101,24 @@ interface PartyLayerConfig {
|
|
|
100
101
|
/**
|
|
101
102
|
* Wallet adapters to register (OPTIONAL)
|
|
102
103
|
*
|
|
103
|
-
* By default,
|
|
104
|
-
* - ConsoleAdapter (Console Wallet - browser extension)
|
|
104
|
+
* By default, the built-in adapters that need no configuration are registered:
|
|
105
105
|
* - LoopAdapter (5N Loop - QR code / popup)
|
|
106
106
|
* - Cantor8Adapter (Cantor8 - deep link transport)
|
|
107
|
+
* - NightlyAdapter (Nightly - injected extension)
|
|
107
108
|
*
|
|
108
|
-
*
|
|
109
|
+
* Console and Send are NOT in the defaults; they are CIP-0103 native and appear
|
|
110
|
+
* through the announce path. BronAdapter (hosted OAuth) and the WalletConnect
|
|
111
|
+
* adapter require configuration and are opt-in.
|
|
109
112
|
*
|
|
110
113
|
* Only provide this if you want to customize which adapters to use.
|
|
111
114
|
*
|
|
112
115
|
* @example
|
|
113
116
|
* ```typescript
|
|
114
|
-
* // Default:
|
|
117
|
+
* // Default: the no-config built-in adapters (recommended)
|
|
115
118
|
* const client = createPartyLayer({
|
|
116
119
|
* network: 'devnet',
|
|
117
120
|
* app: { name: 'My dApp' },
|
|
118
|
-
* // adapters not specified =
|
|
121
|
+
* // adapters not specified = getBuiltinAdapters() = Loop, Cantor8, Nightly
|
|
119
122
|
* });
|
|
120
123
|
*
|
|
121
124
|
* // Custom: only specific adapters
|
|
@@ -776,10 +779,15 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
776
779
|
* (e.g. `new WalleyAdapter({ host: 'https://dev.walley.cc' })`), so the bridge
|
|
777
780
|
* never sees or sets them.
|
|
778
781
|
*
|
|
782
|
+
* Session restore forwards to the official adapter's own `restore` (see {@link
|
|
783
|
+
* GenericDiscoveryAdapter.restore}): on reload the wallet reinstates its session, typically
|
|
784
|
+
* from its own storage, and the bridge adopts the returned live provider, so the first
|
|
785
|
+
* request after reload works. If the official adapter has no `restore`, the SDK revives the
|
|
786
|
+
* persisted record as-is.
|
|
787
|
+
*
|
|
779
788
|
* 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'`.
|
|
789
|
+
* but popup/remote wallets typically never emit, so `getCapabilities()` NEVER
|
|
790
|
+
* returns `'events'`.
|
|
783
791
|
*/
|
|
784
792
|
|
|
785
793
|
interface GenericDiscoveryAdapterArgs {
|
|
@@ -863,6 +871,25 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
863
871
|
/** Install/availability probe — delegated to the official adapter (popup-free). */
|
|
864
872
|
detectInstalled(): Promise<AdapterDetectResult>;
|
|
865
873
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
874
|
+
/**
|
|
875
|
+
* Restore a persisted session by delegating to the official adapter's own `restore`.
|
|
876
|
+
*
|
|
877
|
+
* The official `ProviderAdapter` shape carries an optional `restore()` that reinstates a
|
|
878
|
+
* session (for example from the wallet's own storage) and returns a LIVE provider.
|
|
879
|
+
* Without this method the SDK revived the persisted record as-is and then built a fresh,
|
|
880
|
+
* SESSION-LESS provider from `provider()`, so a wallet that restores in `restore` looked
|
|
881
|
+
* connected after a reload but its first real request threw. This forwards to the
|
|
882
|
+
* official `restore` and, when it yields a provider, adopts it as the cached provider so
|
|
883
|
+
* the very next request uses the restored session.
|
|
884
|
+
*
|
|
885
|
+
* Popup-safe: this runs on the SDK's init/restore path, never inside a user gesture, so a
|
|
886
|
+
* popup could not open here even if an adapter tried (the browser would block it). Per
|
|
887
|
+
* the official contract `restore` is storage-based and gesture-free. If the official
|
|
888
|
+
* adapter has no `restore`, it returns null, or host resolution is not ready, this falls
|
|
889
|
+
* through to the previous behavior: the persisted session is returned and the provider is
|
|
890
|
+
* built lazily on first use, exactly as before.
|
|
891
|
+
*/
|
|
892
|
+
restore(ctx: AdapterContext, persisted: PersistedSession): Promise<Session | null>;
|
|
866
893
|
disconnect(): Promise<void>;
|
|
867
894
|
signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
|
|
868
895
|
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 */
|
|
@@ -100,22 +101,24 @@ interface PartyLayerConfig {
|
|
|
100
101
|
/**
|
|
101
102
|
* Wallet adapters to register (OPTIONAL)
|
|
102
103
|
*
|
|
103
|
-
* By default,
|
|
104
|
-
* - ConsoleAdapter (Console Wallet - browser extension)
|
|
104
|
+
* By default, the built-in adapters that need no configuration are registered:
|
|
105
105
|
* - LoopAdapter (5N Loop - QR code / popup)
|
|
106
106
|
* - Cantor8Adapter (Cantor8 - deep link transport)
|
|
107
|
+
* - NightlyAdapter (Nightly - injected extension)
|
|
107
108
|
*
|
|
108
|
-
*
|
|
109
|
+
* Console and Send are NOT in the defaults; they are CIP-0103 native and appear
|
|
110
|
+
* through the announce path. BronAdapter (hosted OAuth) and the WalletConnect
|
|
111
|
+
* adapter require configuration and are opt-in.
|
|
109
112
|
*
|
|
110
113
|
* Only provide this if you want to customize which adapters to use.
|
|
111
114
|
*
|
|
112
115
|
* @example
|
|
113
116
|
* ```typescript
|
|
114
|
-
* // Default:
|
|
117
|
+
* // Default: the no-config built-in adapters (recommended)
|
|
115
118
|
* const client = createPartyLayer({
|
|
116
119
|
* network: 'devnet',
|
|
117
120
|
* app: { name: 'My dApp' },
|
|
118
|
-
* // adapters not specified =
|
|
121
|
+
* // adapters not specified = getBuiltinAdapters() = Loop, Cantor8, Nightly
|
|
119
122
|
* });
|
|
120
123
|
*
|
|
121
124
|
* // Custom: only specific adapters
|
|
@@ -776,10 +779,15 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
776
779
|
* (e.g. `new WalleyAdapter({ host: 'https://dev.walley.cc' })`), so the bridge
|
|
777
780
|
* never sees or sets them.
|
|
778
781
|
*
|
|
782
|
+
* Session restore forwards to the official adapter's own `restore` (see {@link
|
|
783
|
+
* GenericDiscoveryAdapter.restore}): on reload the wallet reinstates its session, typically
|
|
784
|
+
* from its own storage, and the bridge adopts the returned live provider, so the first
|
|
785
|
+
* request after reload works. If the official adapter has no `restore`, the SDK revives the
|
|
786
|
+
* persisted record as-is.
|
|
787
|
+
*
|
|
779
788
|
* 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'`.
|
|
789
|
+
* but popup/remote wallets typically never emit, so `getCapabilities()` NEVER
|
|
790
|
+
* returns `'events'`.
|
|
783
791
|
*/
|
|
784
792
|
|
|
785
793
|
interface GenericDiscoveryAdapterArgs {
|
|
@@ -863,6 +871,25 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
|
|
|
863
871
|
/** Install/availability probe — delegated to the official adapter (popup-free). */
|
|
864
872
|
detectInstalled(): Promise<AdapterDetectResult>;
|
|
865
873
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
874
|
+
/**
|
|
875
|
+
* Restore a persisted session by delegating to the official adapter's own `restore`.
|
|
876
|
+
*
|
|
877
|
+
* The official `ProviderAdapter` shape carries an optional `restore()` that reinstates a
|
|
878
|
+
* session (for example from the wallet's own storage) and returns a LIVE provider.
|
|
879
|
+
* Without this method the SDK revived the persisted record as-is and then built a fresh,
|
|
880
|
+
* SESSION-LESS provider from `provider()`, so a wallet that restores in `restore` looked
|
|
881
|
+
* connected after a reload but its first real request threw. This forwards to the
|
|
882
|
+
* official `restore` and, when it yields a provider, adopts it as the cached provider so
|
|
883
|
+
* the very next request uses the restored session.
|
|
884
|
+
*
|
|
885
|
+
* Popup-safe: this runs on the SDK's init/restore path, never inside a user gesture, so a
|
|
886
|
+
* popup could not open here even if an adapter tried (the browser would block it). Per
|
|
887
|
+
* the official contract `restore` is storage-based and gesture-free. If the official
|
|
888
|
+
* adapter has no `restore`, it returns null, or host resolution is not ready, this falls
|
|
889
|
+
* through to the previous behavior: the persisted session is returned and the provider is
|
|
890
|
+
* built lazily on first use, exactly as before.
|
|
891
|
+
*/
|
|
892
|
+
restore(ctx: AdapterContext, persisted: PersistedSession): Promise<Session | null>;
|
|
866
893
|
disconnect(): Promise<void>;
|
|
867
894
|
signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
|
|
868
895
|
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" });
|
|
@@ -1771,6 +1811,19 @@ var PartyLayerClient = class {
|
|
|
1771
1811
|
const adapter = this.adapters.get(session.walletId);
|
|
1772
1812
|
if (adapter?.restore) {
|
|
1773
1813
|
const ctx = this.createAdapterContext();
|
|
1814
|
+
if (adapter instanceof GenericDiscoveryAdapter && adapter.usesFactory()) {
|
|
1815
|
+
let networkHosts = {};
|
|
1816
|
+
try {
|
|
1817
|
+
const entry = await this.registryClient.getWalletEntry(String(session.walletId));
|
|
1818
|
+
networkHosts = entry.adapter?.networkHosts ?? {};
|
|
1819
|
+
} catch {
|
|
1820
|
+
}
|
|
1821
|
+
adapter.setNetworkHosts(networkHosts);
|
|
1822
|
+
try {
|
|
1823
|
+
adapter.resolveOfficial(session.network);
|
|
1824
|
+
} catch {
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1774
1827
|
const restored = await adapter.restore(ctx, {
|
|
1775
1828
|
...session,
|
|
1776
1829
|
encrypted
|