@partylayer/sdk 0.17.0 → 0.18.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/README.md +3 -3
- package/dist/index.d.mts +26 -12
- package/dist/index.d.ts +26 -12
- package/dist/index.js +34 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
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
|
@@ -101,22 +101,24 @@ interface PartyLayerConfig {
|
|
|
101
101
|
/**
|
|
102
102
|
* Wallet adapters to register (OPTIONAL)
|
|
103
103
|
*
|
|
104
|
-
* By default,
|
|
105
|
-
* - ConsoleAdapter (Console Wallet - browser extension)
|
|
104
|
+
* By default, the built-in adapters that need no configuration are registered:
|
|
106
105
|
* - LoopAdapter (5N Loop - QR code / popup)
|
|
107
106
|
* - Cantor8Adapter (Cantor8 - deep link transport)
|
|
107
|
+
* - NightlyAdapter (Nightly - injected extension)
|
|
108
108
|
*
|
|
109
|
-
*
|
|
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.
|
|
110
112
|
*
|
|
111
113
|
* Only provide this if you want to customize which adapters to use.
|
|
112
114
|
*
|
|
113
115
|
* @example
|
|
114
116
|
* ```typescript
|
|
115
|
-
* // Default:
|
|
117
|
+
* // Default: the no-config built-in adapters (recommended)
|
|
116
118
|
* const client = createPartyLayer({
|
|
117
119
|
* network: 'devnet',
|
|
118
120
|
* app: { name: 'My dApp' },
|
|
119
|
-
* // adapters not specified =
|
|
121
|
+
* // adapters not specified = getBuiltinAdapters() = Loop, Cantor8, Nightly
|
|
120
122
|
* });
|
|
121
123
|
*
|
|
122
124
|
* // Custom: only specific adapters
|
|
@@ -399,14 +401,26 @@ declare class PartyLayerClient {
|
|
|
399
401
|
*/
|
|
400
402
|
listWallets(filter?: WalletFilter): Promise<WalletInfo[]>;
|
|
401
403
|
/**
|
|
402
|
-
* Hide
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
404
|
+
* Hide registry entries whose wallet needs an app-registered adapter that is
|
|
405
|
+
* NOT registered. This is the library default (RainbowKit-style): never show a
|
|
406
|
+
* wallet the app cannot actually connect.
|
|
407
|
+
*
|
|
408
|
+
* A wallet is connectable with NO app adapter only when it is driven by the
|
|
409
|
+
* generic announce path (`adapter.transport: 'announce'`, e.g. Console, Send):
|
|
410
|
+
* there the SDK builds a generic announce adapter from the registry entry on
|
|
411
|
+
* demand, so installing the extension is enough and the entry stays visible.
|
|
412
|
+
* Every other transport can only connect through an adapter the app registered:
|
|
413
|
+
* a `discovery-adapter` popup/remote wallet whose official ProviderAdapter
|
|
414
|
+
* the app supplies (bridged under `toWalletId(providerId)`), or a wallet that
|
|
415
|
+
* ships a PartyLayer adapter package (Loop, Cantor8, Nightly, Bron,
|
|
416
|
+
* WalletConnect). Without that adapter, clicking the entry can only fail
|
|
417
|
+
* (connect throws), so it surfaces only when the adapter is present.
|
|
418
|
+
*
|
|
419
|
+
* The decision reads each entry's DECLARED transport, never a hardcoded wallet
|
|
420
|
+
* list. No-op when the registry is unavailable (the list is already
|
|
421
|
+
* adapters-only) or every non-announce entry is registered.
|
|
408
422
|
*/
|
|
409
|
-
private
|
|
423
|
+
private gateUnconnectableEntries;
|
|
410
424
|
/**
|
|
411
425
|
* If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
|
|
412
426
|
* return the bits to build an actionable "register its adapter" error; else
|
package/dist/index.d.ts
CHANGED
|
@@ -101,22 +101,24 @@ interface PartyLayerConfig {
|
|
|
101
101
|
/**
|
|
102
102
|
* Wallet adapters to register (OPTIONAL)
|
|
103
103
|
*
|
|
104
|
-
* By default,
|
|
105
|
-
* - ConsoleAdapter (Console Wallet - browser extension)
|
|
104
|
+
* By default, the built-in adapters that need no configuration are registered:
|
|
106
105
|
* - LoopAdapter (5N Loop - QR code / popup)
|
|
107
106
|
* - Cantor8Adapter (Cantor8 - deep link transport)
|
|
107
|
+
* - NightlyAdapter (Nightly - injected extension)
|
|
108
108
|
*
|
|
109
|
-
*
|
|
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.
|
|
110
112
|
*
|
|
111
113
|
* Only provide this if you want to customize which adapters to use.
|
|
112
114
|
*
|
|
113
115
|
* @example
|
|
114
116
|
* ```typescript
|
|
115
|
-
* // Default:
|
|
117
|
+
* // Default: the no-config built-in adapters (recommended)
|
|
116
118
|
* const client = createPartyLayer({
|
|
117
119
|
* network: 'devnet',
|
|
118
120
|
* app: { name: 'My dApp' },
|
|
119
|
-
* // adapters not specified =
|
|
121
|
+
* // adapters not specified = getBuiltinAdapters() = Loop, Cantor8, Nightly
|
|
120
122
|
* });
|
|
121
123
|
*
|
|
122
124
|
* // Custom: only specific adapters
|
|
@@ -399,14 +401,26 @@ declare class PartyLayerClient {
|
|
|
399
401
|
*/
|
|
400
402
|
listWallets(filter?: WalletFilter): Promise<WalletInfo[]>;
|
|
401
403
|
/**
|
|
402
|
-
* Hide
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
404
|
+
* Hide registry entries whose wallet needs an app-registered adapter that is
|
|
405
|
+
* NOT registered. This is the library default (RainbowKit-style): never show a
|
|
406
|
+
* wallet the app cannot actually connect.
|
|
407
|
+
*
|
|
408
|
+
* A wallet is connectable with NO app adapter only when it is driven by the
|
|
409
|
+
* generic announce path (`adapter.transport: 'announce'`, e.g. Console, Send):
|
|
410
|
+
* there the SDK builds a generic announce adapter from the registry entry on
|
|
411
|
+
* demand, so installing the extension is enough and the entry stays visible.
|
|
412
|
+
* Every other transport can only connect through an adapter the app registered:
|
|
413
|
+
* a `discovery-adapter` popup/remote wallet whose official ProviderAdapter
|
|
414
|
+
* the app supplies (bridged under `toWalletId(providerId)`), or a wallet that
|
|
415
|
+
* ships a PartyLayer adapter package (Loop, Cantor8, Nightly, Bron,
|
|
416
|
+
* WalletConnect). Without that adapter, clicking the entry can only fail
|
|
417
|
+
* (connect throws), so it surfaces only when the adapter is present.
|
|
418
|
+
*
|
|
419
|
+
* The decision reads each entry's DECLARED transport, never a hardcoded wallet
|
|
420
|
+
* list. No-op when the registry is unavailable (the list is already
|
|
421
|
+
* adapters-only) or every non-announce entry is registered.
|
|
408
422
|
*/
|
|
409
|
-
private
|
|
423
|
+
private gateUnconnectableEntries;
|
|
410
424
|
/**
|
|
411
425
|
* If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
|
|
412
426
|
* return the bits to build an actionable "register its adapter" error; else
|
package/dist/index.js
CHANGED
|
@@ -1011,7 +1011,7 @@ var PartyLayerClient = class {
|
|
|
1011
1011
|
channel: "stable"
|
|
1012
1012
|
});
|
|
1013
1013
|
}
|
|
1014
|
-
registryWallets = await this.
|
|
1014
|
+
registryWallets = await this.gateUnconnectableEntries(registryWallets);
|
|
1015
1015
|
registryWallets = await this.aggregateAnnouncedWallets(registryWallets);
|
|
1016
1016
|
void this.warmDiscoveryPlans(registryWallets);
|
|
1017
1017
|
if (filter?.requiredCapabilities) {
|
|
@@ -1027,19 +1027,31 @@ var PartyLayerClient = class {
|
|
|
1027
1027
|
return registryWallets;
|
|
1028
1028
|
}
|
|
1029
1029
|
/**
|
|
1030
|
-
* Hide
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1030
|
+
* Hide registry entries whose wallet needs an app-registered adapter that is
|
|
1031
|
+
* NOT registered. This is the library default (RainbowKit-style): never show a
|
|
1032
|
+
* wallet the app cannot actually connect.
|
|
1033
|
+
*
|
|
1034
|
+
* A wallet is connectable with NO app adapter only when it is driven by the
|
|
1035
|
+
* generic announce path (`adapter.transport: 'announce'`, e.g. Console, Send):
|
|
1036
|
+
* there the SDK builds a generic announce adapter from the registry entry on
|
|
1037
|
+
* demand, so installing the extension is enough and the entry stays visible.
|
|
1038
|
+
* Every other transport can only connect through an adapter the app registered:
|
|
1039
|
+
* a `discovery-adapter` popup/remote wallet whose official ProviderAdapter
|
|
1040
|
+
* the app supplies (bridged under `toWalletId(providerId)`), or a wallet that
|
|
1041
|
+
* ships a PartyLayer adapter package (Loop, Cantor8, Nightly, Bron,
|
|
1042
|
+
* WalletConnect). Without that adapter, clicking the entry can only fail
|
|
1043
|
+
* (connect throws), so it surfaces only when the adapter is present.
|
|
1044
|
+
*
|
|
1045
|
+
* The decision reads each entry's DECLARED transport, never a hardcoded wallet
|
|
1046
|
+
* list. No-op when the registry is unavailable (the list is already
|
|
1047
|
+
* adapters-only) or every non-announce entry is registered.
|
|
1036
1048
|
*/
|
|
1037
|
-
async
|
|
1049
|
+
async gateUnconnectableEntries(wallets) {
|
|
1038
1050
|
let hidden = null;
|
|
1039
1051
|
try {
|
|
1040
1052
|
const registry = await this.registryClient.getRegistry();
|
|
1041
1053
|
for (const entry of registry.wallets) {
|
|
1042
|
-
if (entry.adapter?.transport
|
|
1054
|
+
if (entry.adapter?.transport === "announce") continue;
|
|
1043
1055
|
const walletId = core.toWalletId(entry.id);
|
|
1044
1056
|
if (!this.adapters.has(walletId)) {
|
|
1045
1057
|
(hidden ??= /* @__PURE__ */ new Set()).add(String(walletId));
|
|
@@ -1811,6 +1823,19 @@ var PartyLayerClient = class {
|
|
|
1811
1823
|
const adapter = this.adapters.get(session.walletId);
|
|
1812
1824
|
if (adapter?.restore) {
|
|
1813
1825
|
const ctx = this.createAdapterContext();
|
|
1826
|
+
if (adapter instanceof GenericDiscoveryAdapter && adapter.usesFactory()) {
|
|
1827
|
+
let networkHosts = {};
|
|
1828
|
+
try {
|
|
1829
|
+
const entry = await this.registryClient.getWalletEntry(String(session.walletId));
|
|
1830
|
+
networkHosts = entry.adapter?.networkHosts ?? {};
|
|
1831
|
+
} catch {
|
|
1832
|
+
}
|
|
1833
|
+
adapter.setNetworkHosts(networkHosts);
|
|
1834
|
+
try {
|
|
1835
|
+
adapter.resolveOfficial(session.network);
|
|
1836
|
+
} catch {
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1814
1839
|
const restored = await adapter.restore(ctx, {
|
|
1815
1840
|
...session,
|
|
1816
1841
|
encrypted
|