@partylayer/sdk 0.6.0 → 0.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _partylayer_core from '@partylayer/core';
2
- import { WalletAdapter, NetworkId, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult } from '@partylayer/core';
3
- export { AdapterConnectResult, AdapterContext, AdapterDetectResult, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkId, 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 } from '@partylayer/core';
2
+ import { WalletAdapter, NetworkId, OfficialProviderAdapter, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult } from '@partylayer/core';
3
+ export { AdapterConnectResult, AdapterContext, AdapterDetectResult, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkId, 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, 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';
6
6
  export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
@@ -136,13 +136,35 @@ interface PartyLayerConfig {
136
136
  * });
137
137
  * ```
138
138
  */
139
- adapters?: (WalletAdapter | AdapterClass)[];
139
+ adapters?: (WalletAdapter | AdapterClass | OfficialProviderAdapter)[];
140
140
  /** Storage adapter (default: browser localStorage-based encrypted) */
141
141
  storage?: StorageAdapter;
142
142
  /** Crypto adapter (default: WebCrypto) */
143
143
  crypto?: CryptoAdapter;
144
144
  /** Registry public keys for signature verification (ed25519) */
145
145
  registryPublicKeys?: string[];
146
+ /**
147
+ * EIP-6963-style announce discovery — the canonical Canton provider contract
148
+ * (`canton:requestProvider` → `canton:announceProvider`, see provider.md).
149
+ *
150
+ * When enabled, `listWallets()` aggregates announced CIP-0103 wallets with
151
+ * the `window.canton` namespace scan, the registry, and registered adapters:
152
+ * - an announced id matching a registered/registry wallet's
153
+ * `providerDetection` (provider.id) maps to that adapter — NO duplicate
154
+ * picker entry (e.g. Console's announce `lpnf…` → the Console adapter);
155
+ * - an UNKNOWN announced id surfaces as a dynamic entry routed to its own
156
+ * extension `target` (collision-proof; future announce-capable wallets
157
+ * appear with zero code changes).
158
+ *
159
+ * Default ON in the browser; ALWAYS skipped under SSR (`typeof window` guard).
160
+ * With zero announcers, `listWallets()` output is byte-identical to before.
161
+ */
162
+ discovery?: {
163
+ /** Aggregate `canton:announceProvider` wallets. @default true (in browser) */
164
+ announce?: boolean;
165
+ /** Announce-collection window in ms. @default 300 (canonical ~300ms) */
166
+ announceTimeoutMs?: number;
167
+ };
146
168
  /**
147
169
  * Telemetry configuration or adapter
148
170
  *
@@ -294,6 +316,13 @@ type EventHandler<T extends PartyLayerEvent = PartyLayerEvent> = (event: T) => v
294
316
  declare class PartyLayerClient {
295
317
  private config;
296
318
  private adapters;
319
+ /**
320
+ * Pre-resolved connect plans for popup/remote (GenericDiscoveryAdapter)
321
+ * wallets, warmed on `listWallets()` (which the modal calls on open) so a
322
+ * subsequent click can connect gesture-synchronously. Consumed (deleted) on
323
+ * use and cleared on disconnect; a cold miss falls back to the normal path.
324
+ */
325
+ private readonly warmPlans;
297
326
  private eventHandlers;
298
327
  private activeSession;
299
328
  readonly registryClient: RegistryClient;
@@ -301,6 +330,8 @@ declare class PartyLayerClient {
301
330
  private crypto;
302
331
  private storage;
303
332
  private telemetry?;
333
+ /** Cached announce-discovery picker entries (one-shot; cleared by refreshDiscovery). */
334
+ private announceEntriesCache;
304
335
  private origin;
305
336
  constructor(config: PartyLayerConfig);
306
337
  /**
@@ -331,6 +362,39 @@ declare class PartyLayerClient {
331
362
  * List available wallets
332
363
  */
333
364
  listWallets(filter?: WalletFilter): Promise<WalletInfo[]>;
365
+ /**
366
+ * Hide `transport: 'discovery-adapter'` registry entries whose matching
367
+ * adapter is NOT registered. A discovery-adapter wallet's provider is supplied
368
+ * by the app (an official ProviderAdapter the SDK bridges under
369
+ * `toWalletId(providerId)`); without it, clicking the entry can only fail. So
370
+ * the entry surfaces only when its adapter is present. No-op when the registry
371
+ * is unavailable (list is already adapters-only) or has no such entries.
372
+ */
373
+ private gateDiscoveryAdapterEntries;
374
+ /**
375
+ * Whether announce discovery is active: explicit `discovery.announce`, else
376
+ * ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
377
+ */
378
+ private get announceEnabled();
379
+ /**
380
+ * Clear the cached announce round-trip so the next `listWallets()` re-runs the
381
+ * `canton:requestProvider` handshake (e.g. after a wallet is installed).
382
+ */
383
+ refreshDiscovery(): void;
384
+ /**
385
+ * Aggregate `canton:announceProvider` wallets into the picker list (A2).
386
+ *
387
+ * One-shot cached per client (refresh via {@link refreshDiscovery}); SSR-skipped.
388
+ * For each discovered provider (announce ∪ `window.canton` scan, deduped):
389
+ * - if its id matches a known wallet's `providerDetection` (provider.id) it
390
+ * IS that wallet — no new entry (identity bridge: Console's `lpnf…` → the
391
+ * `console` entry, Send's `ldmo…` → the `send` entry);
392
+ * - otherwise it is surfaced as a dynamic `browser:ext:<id>` entry routed to
393
+ * its own extension `target`, with a {@link GenericAnnounceAdapter}
394
+ * registered so a click connects through that target ONLY (no shared slot).
395
+ * With zero announcers this returns `base` unchanged.
396
+ */
397
+ private aggregateAnnouncedWallets;
334
398
  /** Active network-enforcement policy (default 'guard'). */
335
399
  private get enforcement();
336
400
  /**
@@ -349,6 +413,44 @@ declare class PartyLayerClient {
349
413
  * Connect to a wallet
350
414
  */
351
415
  connect(options?: ConnectOptions): Promise<Session>;
416
+ /**
417
+ * Pre-resolve everything `adapter.connect()` needs WITHOUT calling it: wallet
418
+ * selection, origin-allowlist + capability + install guards, and the adapter
419
+ * context. `prefetchedWallets` (passed during warm-up from `listWallets`)
420
+ * avoids a recursive `listWallets()` call.
421
+ */
422
+ private resolveConnectPlan;
423
+ /**
424
+ * Invoke `adapter.connect()` (its FIRST statement — no await precedes it) and
425
+ * build / persist / emit the session. Separated from plan resolution so the
426
+ * popup-safe fast-path can call it gesture-synchronously.
427
+ */
428
+ private completeConnect;
429
+ /**
430
+ * PUBLIC popup-safe primitive: pre-resolve a connect plan ahead of the user
431
+ * gesture; the returned `connect()` invokes `adapter.connect()` as its first
432
+ * statement (no await precedes it) so a popup/remote wallet's `window.open`
433
+ * survives the gesture. For consumers driving such a wallet outside the modal
434
+ * (the modal gets this for free via the `listWallets` warm-up + `connect()`).
435
+ */
436
+ prepareConnect(options?: ConnectOptions): Promise<{
437
+ walletId: WalletId;
438
+ connect: (o?: ConnectOptions) => Promise<Session>;
439
+ }>;
440
+ /**
441
+ * Background warm-up of connect plans for popup/remote
442
+ * (`GenericDiscoveryAdapter`) wallets. Popup-free — `resolveConnectPlan` only
443
+ * runs read/guard probes. Skips already-warm entries; never throws.
444
+ */
445
+ private warmDiscoveryPlans;
446
+ /**
447
+ * SYNCHRONOUS fast-path: if a fresh warm plan exists for a popup/remote wallet
448
+ * — and `options` carries no plan-affecting guards — consume it and START
449
+ * `completeConnect` immediately, reaching `adapter.connect()` with no awaits.
450
+ * Returns the in-flight Session promise, or null to fall back to the normal
451
+ * path (e.g. cold cache, or a non-discovery wallet).
452
+ */
453
+ private tryFastConnect;
352
454
  /**
353
455
  * Disconnect from wallet
354
456
  */
@@ -453,6 +555,129 @@ declare class PartyLayerClient {
453
555
  */
454
556
  declare function createPartyLayer(config: PartyLayerConfig): PartyLayerClient;
455
557
 
558
+ /**
559
+ * Dynamic adapter for an announced CIP-0103 wallet that has no first-party
560
+ * PartyLayer adapter.
561
+ *
562
+ * Canonical contract (provider.md): after `canton:requestProvider`, wallets
563
+ * announce `{ id, name?, icon?, target? }`; "the SDK … registers one adapter
564
+ * per id with providerId `browser:ext:<id>`". This adapter is that registration
565
+ * for the UNKNOWN case — it delegates every call to a `CIP0103Provider` bound to
566
+ * the wallet's own extension `target` channel (built by
567
+ * `createExtensionChannelProvider({ target: announced.target ?? announced.id })`).
568
+ * Because the channel is target-scoped, a click on this entry can ONLY ever
569
+ * reach the wallet that announced it — never a shared `window.canton` slot or
570
+ * another wallet (the A2 collision guarantee), and future announce-capable
571
+ * Canton wallets light up with zero code changes.
572
+ *
573
+ * KNOWN wallets (Console, Send, …) never use this class — the SDK's identity
574
+ * bridge maps their announce id to their existing adapter via `providerDetection`.
575
+ */
576
+
577
+ /** Canonical providerId prefix for an announced extension (provider.md: `browser:ext:<id>`). */
578
+ declare const ANNOUNCED_WALLET_ID_PREFIX = "browser:ext:";
579
+ /** Build the canonical SDK walletId for an announced extension id. */
580
+ declare function announcedWalletId(announceId: string): WalletId;
581
+ interface GenericAnnounceAdapterArgs {
582
+ /** The announced extension id (== announce `detail.id`). */
583
+ announceId: string;
584
+ /** Display name from the announce detail (falls back to a derived label). */
585
+ name?: string;
586
+ /** Icon (data: URI or URL) from the announce detail. */
587
+ icon?: string;
588
+ /** Target-scoped CIP-0103 provider built from the announce (the discovery result). */
589
+ provider: CIP0103Provider;
590
+ }
591
+ declare class GenericAnnounceAdapter implements WalletAdapter {
592
+ readonly walletId: WalletId;
593
+ readonly name: string;
594
+ /** Icon surfaced to the picker (announce detail). */
595
+ readonly icon?: string;
596
+ private readonly provider;
597
+ constructor(args: GenericAnnounceAdapterArgs);
598
+ /** Baseline CIP-0103 capabilities every announced wallet must implement. */
599
+ getCapabilities(): CapabilityKey[];
600
+ /**
601
+ * The adapter is only ever constructed for a wallet that just announced, so
602
+ * its presence is established by the announce handshake itself.
603
+ */
604
+ detectInstalled(): Promise<AdapterDetectResult>;
605
+ connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
606
+ disconnect(): Promise<void>;
607
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
608
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
609
+ }
610
+
611
+ /**
612
+ * Generic bridge from an official `@canton-network/core-wallet-discovery`
613
+ * `ProviderAdapter` (matched structurally as `OfficialProviderAdapter`) to our
614
+ * `WalletAdapter` contract.
615
+ *
616
+ * This is the GENERIC host for popup/remote Canton wallets that neither inject
617
+ * `window.canton` nor announce via `canton:announceProvider` (e.g. Walley): the
618
+ * app supplies the wallet's OWN official adapter instance in `config.adapters`,
619
+ * and the SDK auto-wraps it here. There is NO wallet-specific package in our
620
+ * codebase — any standards-compliant wallet shipping the official ProviderAdapter
621
+ * shape inherits this path. We deliberately do NOT import `@canton-network/*`
622
+ * (mirroring `@partylayer/provider`'s extension-channel); the standard's SHAPE
623
+ * is the contract.
624
+ *
625
+ * Sibling to `GenericAnnounceAdapter`: both delegate every call to a
626
+ * `CIP0103Provider`. The difference is the source — here the provider comes from
627
+ * the official adapter's `provider()` (obtained LAZILY so SDK init stays
628
+ * SSR-safe; the wallet's `provider()` may touch `window`).
629
+ *
630
+ * Host/network are baked into the app-supplied official adapter at construction
631
+ * (e.g. `new WalleyAdapter({ host: 'https://dev.walley.cc' })`), so the bridge
632
+ * never sees or sets them.
633
+ *
634
+ * Eventless note: the official provider exposes `on`/`emit`/`removeListener`
635
+ * but popup/remote wallets typically never emit. The session layer restores via
636
+ * `status`/`listAccounts` polling + persists on fresh connect, so this is
637
+ * tolerated; `getCapabilities()` therefore NEVER returns `'events'`.
638
+ */
639
+
640
+ interface GenericDiscoveryAdapterArgs {
641
+ /** App-supplied official adapter (e.g. `new WalleyAdapter({ host })`). */
642
+ official: OfficialProviderAdapter;
643
+ /**
644
+ * SDK walletId for this wallet. Defaults to `toWalletId(official.providerId)`
645
+ * so it aligns with the registry entry whose `id` equals the provider id
646
+ * (the convention for `transport: 'discovery-adapter'` entries). Pass
647
+ * explicitly to bind to a different registry id.
648
+ */
649
+ walletId?: WalletId;
650
+ /** Display name override (falls back to the official adapter's name). */
651
+ name?: string;
652
+ /** Icon override (falls back to the official adapter's icon). */
653
+ icon?: string;
654
+ }
655
+ declare class GenericDiscoveryAdapter implements WalletAdapter {
656
+ readonly walletId: WalletId;
657
+ readonly name: string;
658
+ readonly icon?: string;
659
+ private readonly official;
660
+ /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
661
+ private providerInstance;
662
+ constructor(args: GenericDiscoveryAdapterArgs);
663
+ /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
664
+ * `official.provider()` is typed `OfficialProvider` (loose `request` so real
665
+ * official adapters are assignable); it is call-compatible with CIP0103Provider
666
+ * (the bridge only ever calls `request({ method, params })`). */
667
+ private get provider();
668
+ /**
669
+ * Baseline CIP-0103 capabilities. NEVER includes `'events'`: popup/remote
670
+ * wallets expose the event surface but do not emit (truthfulness doctrine).
671
+ */
672
+ getCapabilities(): CapabilityKey[];
673
+ /** Install/availability probe — delegated to the official adapter (popup-free). */
674
+ detectInstalled(): Promise<AdapterDetectResult>;
675
+ connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
676
+ disconnect(): Promise<void>;
677
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
678
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
679
+ }
680
+
456
681
  /**
457
682
  * Built-in wallet adapters
458
683
  *
@@ -571,4 +796,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
571
796
  */
572
797
  declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
573
798
 
574
- export { type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, PartyLayerClient as _PartyLayerClientInternal, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
799
+ export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _partylayer_core from '@partylayer/core';
2
- import { WalletAdapter, NetworkId, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult } from '@partylayer/core';
3
- export { AdapterConnectResult, AdapterContext, AdapterDetectResult, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkId, 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 } from '@partylayer/core';
2
+ import { WalletAdapter, NetworkId, OfficialProviderAdapter, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult } from '@partylayer/core';
3
+ export { AdapterConnectResult, AdapterContext, AdapterDetectResult, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkId, 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, 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';
6
6
  export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
@@ -136,13 +136,35 @@ interface PartyLayerConfig {
136
136
  * });
137
137
  * ```
138
138
  */
139
- adapters?: (WalletAdapter | AdapterClass)[];
139
+ adapters?: (WalletAdapter | AdapterClass | OfficialProviderAdapter)[];
140
140
  /** Storage adapter (default: browser localStorage-based encrypted) */
141
141
  storage?: StorageAdapter;
142
142
  /** Crypto adapter (default: WebCrypto) */
143
143
  crypto?: CryptoAdapter;
144
144
  /** Registry public keys for signature verification (ed25519) */
145
145
  registryPublicKeys?: string[];
146
+ /**
147
+ * EIP-6963-style announce discovery — the canonical Canton provider contract
148
+ * (`canton:requestProvider` → `canton:announceProvider`, see provider.md).
149
+ *
150
+ * When enabled, `listWallets()` aggregates announced CIP-0103 wallets with
151
+ * the `window.canton` namespace scan, the registry, and registered adapters:
152
+ * - an announced id matching a registered/registry wallet's
153
+ * `providerDetection` (provider.id) maps to that adapter — NO duplicate
154
+ * picker entry (e.g. Console's announce `lpnf…` → the Console adapter);
155
+ * - an UNKNOWN announced id surfaces as a dynamic entry routed to its own
156
+ * extension `target` (collision-proof; future announce-capable wallets
157
+ * appear with zero code changes).
158
+ *
159
+ * Default ON in the browser; ALWAYS skipped under SSR (`typeof window` guard).
160
+ * With zero announcers, `listWallets()` output is byte-identical to before.
161
+ */
162
+ discovery?: {
163
+ /** Aggregate `canton:announceProvider` wallets. @default true (in browser) */
164
+ announce?: boolean;
165
+ /** Announce-collection window in ms. @default 300 (canonical ~300ms) */
166
+ announceTimeoutMs?: number;
167
+ };
146
168
  /**
147
169
  * Telemetry configuration or adapter
148
170
  *
@@ -294,6 +316,13 @@ type EventHandler<T extends PartyLayerEvent = PartyLayerEvent> = (event: T) => v
294
316
  declare class PartyLayerClient {
295
317
  private config;
296
318
  private adapters;
319
+ /**
320
+ * Pre-resolved connect plans for popup/remote (GenericDiscoveryAdapter)
321
+ * wallets, warmed on `listWallets()` (which the modal calls on open) so a
322
+ * subsequent click can connect gesture-synchronously. Consumed (deleted) on
323
+ * use and cleared on disconnect; a cold miss falls back to the normal path.
324
+ */
325
+ private readonly warmPlans;
297
326
  private eventHandlers;
298
327
  private activeSession;
299
328
  readonly registryClient: RegistryClient;
@@ -301,6 +330,8 @@ declare class PartyLayerClient {
301
330
  private crypto;
302
331
  private storage;
303
332
  private telemetry?;
333
+ /** Cached announce-discovery picker entries (one-shot; cleared by refreshDiscovery). */
334
+ private announceEntriesCache;
304
335
  private origin;
305
336
  constructor(config: PartyLayerConfig);
306
337
  /**
@@ -331,6 +362,39 @@ declare class PartyLayerClient {
331
362
  * List available wallets
332
363
  */
333
364
  listWallets(filter?: WalletFilter): Promise<WalletInfo[]>;
365
+ /**
366
+ * Hide `transport: 'discovery-adapter'` registry entries whose matching
367
+ * adapter is NOT registered. A discovery-adapter wallet's provider is supplied
368
+ * by the app (an official ProviderAdapter the SDK bridges under
369
+ * `toWalletId(providerId)`); without it, clicking the entry can only fail. So
370
+ * the entry surfaces only when its adapter is present. No-op when the registry
371
+ * is unavailable (list is already adapters-only) or has no such entries.
372
+ */
373
+ private gateDiscoveryAdapterEntries;
374
+ /**
375
+ * Whether announce discovery is active: explicit `discovery.announce`, else
376
+ * ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
377
+ */
378
+ private get announceEnabled();
379
+ /**
380
+ * Clear the cached announce round-trip so the next `listWallets()` re-runs the
381
+ * `canton:requestProvider` handshake (e.g. after a wallet is installed).
382
+ */
383
+ refreshDiscovery(): void;
384
+ /**
385
+ * Aggregate `canton:announceProvider` wallets into the picker list (A2).
386
+ *
387
+ * One-shot cached per client (refresh via {@link refreshDiscovery}); SSR-skipped.
388
+ * For each discovered provider (announce ∪ `window.canton` scan, deduped):
389
+ * - if its id matches a known wallet's `providerDetection` (provider.id) it
390
+ * IS that wallet — no new entry (identity bridge: Console's `lpnf…` → the
391
+ * `console` entry, Send's `ldmo…` → the `send` entry);
392
+ * - otherwise it is surfaced as a dynamic `browser:ext:<id>` entry routed to
393
+ * its own extension `target`, with a {@link GenericAnnounceAdapter}
394
+ * registered so a click connects through that target ONLY (no shared slot).
395
+ * With zero announcers this returns `base` unchanged.
396
+ */
397
+ private aggregateAnnouncedWallets;
334
398
  /** Active network-enforcement policy (default 'guard'). */
335
399
  private get enforcement();
336
400
  /**
@@ -349,6 +413,44 @@ declare class PartyLayerClient {
349
413
  * Connect to a wallet
350
414
  */
351
415
  connect(options?: ConnectOptions): Promise<Session>;
416
+ /**
417
+ * Pre-resolve everything `adapter.connect()` needs WITHOUT calling it: wallet
418
+ * selection, origin-allowlist + capability + install guards, and the adapter
419
+ * context. `prefetchedWallets` (passed during warm-up from `listWallets`)
420
+ * avoids a recursive `listWallets()` call.
421
+ */
422
+ private resolveConnectPlan;
423
+ /**
424
+ * Invoke `adapter.connect()` (its FIRST statement — no await precedes it) and
425
+ * build / persist / emit the session. Separated from plan resolution so the
426
+ * popup-safe fast-path can call it gesture-synchronously.
427
+ */
428
+ private completeConnect;
429
+ /**
430
+ * PUBLIC popup-safe primitive: pre-resolve a connect plan ahead of the user
431
+ * gesture; the returned `connect()` invokes `adapter.connect()` as its first
432
+ * statement (no await precedes it) so a popup/remote wallet's `window.open`
433
+ * survives the gesture. For consumers driving such a wallet outside the modal
434
+ * (the modal gets this for free via the `listWallets` warm-up + `connect()`).
435
+ */
436
+ prepareConnect(options?: ConnectOptions): Promise<{
437
+ walletId: WalletId;
438
+ connect: (o?: ConnectOptions) => Promise<Session>;
439
+ }>;
440
+ /**
441
+ * Background warm-up of connect plans for popup/remote
442
+ * (`GenericDiscoveryAdapter`) wallets. Popup-free — `resolveConnectPlan` only
443
+ * runs read/guard probes. Skips already-warm entries; never throws.
444
+ */
445
+ private warmDiscoveryPlans;
446
+ /**
447
+ * SYNCHRONOUS fast-path: if a fresh warm plan exists for a popup/remote wallet
448
+ * — and `options` carries no plan-affecting guards — consume it and START
449
+ * `completeConnect` immediately, reaching `adapter.connect()` with no awaits.
450
+ * Returns the in-flight Session promise, or null to fall back to the normal
451
+ * path (e.g. cold cache, or a non-discovery wallet).
452
+ */
453
+ private tryFastConnect;
352
454
  /**
353
455
  * Disconnect from wallet
354
456
  */
@@ -453,6 +555,129 @@ declare class PartyLayerClient {
453
555
  */
454
556
  declare function createPartyLayer(config: PartyLayerConfig): PartyLayerClient;
455
557
 
558
+ /**
559
+ * Dynamic adapter for an announced CIP-0103 wallet that has no first-party
560
+ * PartyLayer adapter.
561
+ *
562
+ * Canonical contract (provider.md): after `canton:requestProvider`, wallets
563
+ * announce `{ id, name?, icon?, target? }`; "the SDK … registers one adapter
564
+ * per id with providerId `browser:ext:<id>`". This adapter is that registration
565
+ * for the UNKNOWN case — it delegates every call to a `CIP0103Provider` bound to
566
+ * the wallet's own extension `target` channel (built by
567
+ * `createExtensionChannelProvider({ target: announced.target ?? announced.id })`).
568
+ * Because the channel is target-scoped, a click on this entry can ONLY ever
569
+ * reach the wallet that announced it — never a shared `window.canton` slot or
570
+ * another wallet (the A2 collision guarantee), and future announce-capable
571
+ * Canton wallets light up with zero code changes.
572
+ *
573
+ * KNOWN wallets (Console, Send, …) never use this class — the SDK's identity
574
+ * bridge maps their announce id to their existing adapter via `providerDetection`.
575
+ */
576
+
577
+ /** Canonical providerId prefix for an announced extension (provider.md: `browser:ext:<id>`). */
578
+ declare const ANNOUNCED_WALLET_ID_PREFIX = "browser:ext:";
579
+ /** Build the canonical SDK walletId for an announced extension id. */
580
+ declare function announcedWalletId(announceId: string): WalletId;
581
+ interface GenericAnnounceAdapterArgs {
582
+ /** The announced extension id (== announce `detail.id`). */
583
+ announceId: string;
584
+ /** Display name from the announce detail (falls back to a derived label). */
585
+ name?: string;
586
+ /** Icon (data: URI or URL) from the announce detail. */
587
+ icon?: string;
588
+ /** Target-scoped CIP-0103 provider built from the announce (the discovery result). */
589
+ provider: CIP0103Provider;
590
+ }
591
+ declare class GenericAnnounceAdapter implements WalletAdapter {
592
+ readonly walletId: WalletId;
593
+ readonly name: string;
594
+ /** Icon surfaced to the picker (announce detail). */
595
+ readonly icon?: string;
596
+ private readonly provider;
597
+ constructor(args: GenericAnnounceAdapterArgs);
598
+ /** Baseline CIP-0103 capabilities every announced wallet must implement. */
599
+ getCapabilities(): CapabilityKey[];
600
+ /**
601
+ * The adapter is only ever constructed for a wallet that just announced, so
602
+ * its presence is established by the announce handshake itself.
603
+ */
604
+ detectInstalled(): Promise<AdapterDetectResult>;
605
+ connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
606
+ disconnect(): Promise<void>;
607
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
608
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
609
+ }
610
+
611
+ /**
612
+ * Generic bridge from an official `@canton-network/core-wallet-discovery`
613
+ * `ProviderAdapter` (matched structurally as `OfficialProviderAdapter`) to our
614
+ * `WalletAdapter` contract.
615
+ *
616
+ * This is the GENERIC host for popup/remote Canton wallets that neither inject
617
+ * `window.canton` nor announce via `canton:announceProvider` (e.g. Walley): the
618
+ * app supplies the wallet's OWN official adapter instance in `config.adapters`,
619
+ * and the SDK auto-wraps it here. There is NO wallet-specific package in our
620
+ * codebase — any standards-compliant wallet shipping the official ProviderAdapter
621
+ * shape inherits this path. We deliberately do NOT import `@canton-network/*`
622
+ * (mirroring `@partylayer/provider`'s extension-channel); the standard's SHAPE
623
+ * is the contract.
624
+ *
625
+ * Sibling to `GenericAnnounceAdapter`: both delegate every call to a
626
+ * `CIP0103Provider`. The difference is the source — here the provider comes from
627
+ * the official adapter's `provider()` (obtained LAZILY so SDK init stays
628
+ * SSR-safe; the wallet's `provider()` may touch `window`).
629
+ *
630
+ * Host/network are baked into the app-supplied official adapter at construction
631
+ * (e.g. `new WalleyAdapter({ host: 'https://dev.walley.cc' })`), so the bridge
632
+ * never sees or sets them.
633
+ *
634
+ * Eventless note: the official provider exposes `on`/`emit`/`removeListener`
635
+ * but popup/remote wallets typically never emit. The session layer restores via
636
+ * `status`/`listAccounts` polling + persists on fresh connect, so this is
637
+ * tolerated; `getCapabilities()` therefore NEVER returns `'events'`.
638
+ */
639
+
640
+ interface GenericDiscoveryAdapterArgs {
641
+ /** App-supplied official adapter (e.g. `new WalleyAdapter({ host })`). */
642
+ official: OfficialProviderAdapter;
643
+ /**
644
+ * SDK walletId for this wallet. Defaults to `toWalletId(official.providerId)`
645
+ * so it aligns with the registry entry whose `id` equals the provider id
646
+ * (the convention for `transport: 'discovery-adapter'` entries). Pass
647
+ * explicitly to bind to a different registry id.
648
+ */
649
+ walletId?: WalletId;
650
+ /** Display name override (falls back to the official adapter's name). */
651
+ name?: string;
652
+ /** Icon override (falls back to the official adapter's icon). */
653
+ icon?: string;
654
+ }
655
+ declare class GenericDiscoveryAdapter implements WalletAdapter {
656
+ readonly walletId: WalletId;
657
+ readonly name: string;
658
+ readonly icon?: string;
659
+ private readonly official;
660
+ /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
661
+ private providerInstance;
662
+ constructor(args: GenericDiscoveryAdapterArgs);
663
+ /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
664
+ * `official.provider()` is typed `OfficialProvider` (loose `request` so real
665
+ * official adapters are assignable); it is call-compatible with CIP0103Provider
666
+ * (the bridge only ever calls `request({ method, params })`). */
667
+ private get provider();
668
+ /**
669
+ * Baseline CIP-0103 capabilities. NEVER includes `'events'`: popup/remote
670
+ * wallets expose the event surface but do not emit (truthfulness doctrine).
671
+ */
672
+ getCapabilities(): CapabilityKey[];
673
+ /** Install/availability probe — delegated to the official adapter (popup-free). */
674
+ detectInstalled(): Promise<AdapterDetectResult>;
675
+ connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
676
+ disconnect(): Promise<void>;
677
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
678
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
679
+ }
680
+
456
681
  /**
457
682
  * Built-in wallet adapters
458
683
  *
@@ -571,4 +796,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
571
796
  */
572
797
  declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
573
798
 
574
- export { type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, PartyLayerClient as _PartyLayerClientInternal, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };
799
+ export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, isTelemetryConfig };