@partylayer/sdk 0.7.0 → 0.9.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, 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, 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, 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';
3
+ export { AdapterConnectResult, AdapterContext, AdapterDetectResult, 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';
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,7 +136,7 @@ interface PartyLayerConfig {
136
136
  * });
137
137
  * ```
138
138
  */
139
- adapters?: (WalletAdapter | AdapterClass)[];
139
+ adapters?: (WalletAdapter | AdapterClass | OfficialProviderAdapter | OfficialAdapterFactory)[];
140
140
  /** Storage adapter (default: browser localStorage-based encrypted) */
141
141
  storage?: StorageAdapter;
142
142
  /** Crypto adapter (default: WebCrypto) */
@@ -316,6 +316,13 @@ type EventHandler<T extends PartyLayerEvent = PartyLayerEvent> = (event: T) => v
316
316
  declare class PartyLayerClient {
317
317
  private config;
318
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;
319
326
  private eventHandlers;
320
327
  private activeSession;
321
328
  readonly registryClient: RegistryClient;
@@ -355,6 +362,15 @@ declare class PartyLayerClient {
355
362
  * List available wallets
356
363
  */
357
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;
358
374
  /**
359
375
  * Whether announce discovery is active: explicit `discovery.announce`, else
360
376
  * ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
@@ -397,6 +413,44 @@ declare class PartyLayerClient {
397
413
  * Connect to a wallet
398
414
  */
399
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;
400
454
  /**
401
455
  * Disconnect from wallet
402
456
  */
@@ -554,6 +608,121 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
554
608
  submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
555
609
  }
556
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
+ /**
642
+ * Pre-constructed official adapter (explicit-host form, e.g.
643
+ * `new WalleyAdapter({ host })`). Its baked host is used as-is; `factory` /
644
+ * `networkHosts` are ignored. Mutually exclusive with `factory`.
645
+ */
646
+ official?: OfficialProviderAdapter;
647
+ /**
648
+ * Factory form: `create(host)` constructs the official adapter with a host
649
+ * resolved from `networkHosts[activeNetwork]` at connect time. Needed because
650
+ * official adapters seal `host` at construction (no re-hosting a pre-built
651
+ * instance). Mutually exclusive with `official`.
652
+ */
653
+ factory?: OfficialAdapterFactory;
654
+ /**
655
+ * Network→host map for the factory form (the registry entry's
656
+ * `adapter.networkHosts`). Injected by the SDK once the registry is loaded
657
+ * (see {@link GenericDiscoveryAdapter.setNetworkHosts}); resolved
658
+ * SYNCHRONOUSLY at connect so the popup-safe gesture path holds.
659
+ */
660
+ networkHosts?: NetworkHosts;
661
+ /**
662
+ * SDK walletId for this wallet. Defaults to `toWalletId(providerId)` so it
663
+ * aligns with the registry entry whose `id` equals the provider id (the
664
+ * convention for `transport: 'discovery-adapter'` entries). Pass explicitly
665
+ * to bind to a different registry id.
666
+ */
667
+ walletId?: WalletId;
668
+ /** Display name override (falls back to the official adapter's / factory's name). */
669
+ name?: string;
670
+ /** Icon override (falls back to the official adapter's / factory's icon). */
671
+ icon?: string;
672
+ }
673
+ declare class GenericDiscoveryAdapter implements WalletAdapter {
674
+ readonly walletId: WalletId;
675
+ readonly name: string;
676
+ readonly icon?: string;
677
+ /**
678
+ * Resolved official adapter. Set at construction for the instance form; for
679
+ * the factory form it stays null until {@link resolveOfficial} constructs it
680
+ * with the network-resolved host.
681
+ */
682
+ private official;
683
+ /** Factory form (null for the instance form). */
684
+ private readonly factory;
685
+ /** Network→host map for the factory form; injected by the SDK post-registry. */
686
+ private networkHosts;
687
+ /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
688
+ private providerInstance;
689
+ constructor(args: GenericDiscoveryAdapterArgs);
690
+ /** Whether this bridge resolves its host from `networkHosts` (factory form). */
691
+ usesFactory(): boolean;
692
+ /**
693
+ * Inject the registry's network→host map (factory form only). SYNCHRONOUS —
694
+ * the SDK calls this during the async warm phase once the registry entry is
695
+ * loaded, BEFORE the (possibly gesture-synchronous) connect.
696
+ */
697
+ setNetworkHosts(networkHosts: NetworkHosts): void;
698
+ /**
699
+ * Resolve + construct the official adapter for `network` — SYNCHRONOUS, so the
700
+ * popup-safe gesture path reaches `window.open` with NO awaits. Idempotent.
701
+ * The SDK pre-calls it during warm-up; `connect()` also calls it as its first
702
+ * statement so a cold (un-warmed) connect is still gesture-safe.
703
+ *
704
+ * Failure is CLEAR, never a silent wrong-network host: a factory wallet with
705
+ * no host for `network` in `networkHosts` throws, naming the network.
706
+ */
707
+ resolveOfficial(network: NetworkId): void;
708
+ /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
709
+ * `official.provider()` is typed `OfficialProvider` (loose `request` so real
710
+ * official adapters are assignable); it is call-compatible with CIP0103Provider
711
+ * (the bridge only ever calls `request({ method, params })`). */
712
+ private get provider();
713
+ /**
714
+ * Baseline CIP-0103 capabilities. NEVER includes `'events'`: popup/remote
715
+ * wallets expose the event surface but do not emit (truthfulness doctrine).
716
+ */
717
+ getCapabilities(): CapabilityKey[];
718
+ /** Install/availability probe — delegated to the official adapter (popup-free). */
719
+ detectInstalled(): Promise<AdapterDetectResult>;
720
+ connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
721
+ disconnect(): Promise<void>;
722
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
723
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
724
+ }
725
+
557
726
  /**
558
727
  * Built-in wallet adapters
559
728
  *
@@ -672,4 +841,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
672
841
  */
673
842
  declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
674
843
 
675
- 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, 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 };
844
+ 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, 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, 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, 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';
3
+ export { AdapterConnectResult, AdapterContext, AdapterDetectResult, 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';
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,7 +136,7 @@ interface PartyLayerConfig {
136
136
  * });
137
137
  * ```
138
138
  */
139
- adapters?: (WalletAdapter | AdapterClass)[];
139
+ adapters?: (WalletAdapter | AdapterClass | OfficialProviderAdapter | OfficialAdapterFactory)[];
140
140
  /** Storage adapter (default: browser localStorage-based encrypted) */
141
141
  storage?: StorageAdapter;
142
142
  /** Crypto adapter (default: WebCrypto) */
@@ -316,6 +316,13 @@ type EventHandler<T extends PartyLayerEvent = PartyLayerEvent> = (event: T) => v
316
316
  declare class PartyLayerClient {
317
317
  private config;
318
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;
319
326
  private eventHandlers;
320
327
  private activeSession;
321
328
  readonly registryClient: RegistryClient;
@@ -355,6 +362,15 @@ declare class PartyLayerClient {
355
362
  * List available wallets
356
363
  */
357
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;
358
374
  /**
359
375
  * Whether announce discovery is active: explicit `discovery.announce`, else
360
376
  * ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
@@ -397,6 +413,44 @@ declare class PartyLayerClient {
397
413
  * Connect to a wallet
398
414
  */
399
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;
400
454
  /**
401
455
  * Disconnect from wallet
402
456
  */
@@ -554,6 +608,121 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
554
608
  submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
555
609
  }
556
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
+ /**
642
+ * Pre-constructed official adapter (explicit-host form, e.g.
643
+ * `new WalleyAdapter({ host })`). Its baked host is used as-is; `factory` /
644
+ * `networkHosts` are ignored. Mutually exclusive with `factory`.
645
+ */
646
+ official?: OfficialProviderAdapter;
647
+ /**
648
+ * Factory form: `create(host)` constructs the official adapter with a host
649
+ * resolved from `networkHosts[activeNetwork]` at connect time. Needed because
650
+ * official adapters seal `host` at construction (no re-hosting a pre-built
651
+ * instance). Mutually exclusive with `official`.
652
+ */
653
+ factory?: OfficialAdapterFactory;
654
+ /**
655
+ * Network→host map for the factory form (the registry entry's
656
+ * `adapter.networkHosts`). Injected by the SDK once the registry is loaded
657
+ * (see {@link GenericDiscoveryAdapter.setNetworkHosts}); resolved
658
+ * SYNCHRONOUSLY at connect so the popup-safe gesture path holds.
659
+ */
660
+ networkHosts?: NetworkHosts;
661
+ /**
662
+ * SDK walletId for this wallet. Defaults to `toWalletId(providerId)` so it
663
+ * aligns with the registry entry whose `id` equals the provider id (the
664
+ * convention for `transport: 'discovery-adapter'` entries). Pass explicitly
665
+ * to bind to a different registry id.
666
+ */
667
+ walletId?: WalletId;
668
+ /** Display name override (falls back to the official adapter's / factory's name). */
669
+ name?: string;
670
+ /** Icon override (falls back to the official adapter's / factory's icon). */
671
+ icon?: string;
672
+ }
673
+ declare class GenericDiscoveryAdapter implements WalletAdapter {
674
+ readonly walletId: WalletId;
675
+ readonly name: string;
676
+ readonly icon?: string;
677
+ /**
678
+ * Resolved official adapter. Set at construction for the instance form; for
679
+ * the factory form it stays null until {@link resolveOfficial} constructs it
680
+ * with the network-resolved host.
681
+ */
682
+ private official;
683
+ /** Factory form (null for the instance form). */
684
+ private readonly factory;
685
+ /** Network→host map for the factory form; injected by the SDK post-registry. */
686
+ private networkHosts;
687
+ /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
688
+ private providerInstance;
689
+ constructor(args: GenericDiscoveryAdapterArgs);
690
+ /** Whether this bridge resolves its host from `networkHosts` (factory form). */
691
+ usesFactory(): boolean;
692
+ /**
693
+ * Inject the registry's network→host map (factory form only). SYNCHRONOUS —
694
+ * the SDK calls this during the async warm phase once the registry entry is
695
+ * loaded, BEFORE the (possibly gesture-synchronous) connect.
696
+ */
697
+ setNetworkHosts(networkHosts: NetworkHosts): void;
698
+ /**
699
+ * Resolve + construct the official adapter for `network` — SYNCHRONOUS, so the
700
+ * popup-safe gesture path reaches `window.open` with NO awaits. Idempotent.
701
+ * The SDK pre-calls it during warm-up; `connect()` also calls it as its first
702
+ * statement so a cold (un-warmed) connect is still gesture-safe.
703
+ *
704
+ * Failure is CLEAR, never a silent wrong-network host: a factory wallet with
705
+ * no host for `network` in `networkHosts` throws, naming the network.
706
+ */
707
+ resolveOfficial(network: NetworkId): void;
708
+ /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
709
+ * `official.provider()` is typed `OfficialProvider` (loose `request` so real
710
+ * official adapters are assignable); it is call-compatible with CIP0103Provider
711
+ * (the bridge only ever calls `request({ method, params })`). */
712
+ private get provider();
713
+ /**
714
+ * Baseline CIP-0103 capabilities. NEVER includes `'events'`: popup/remote
715
+ * wallets expose the event surface but do not emit (truthfulness doctrine).
716
+ */
717
+ getCapabilities(): CapabilityKey[];
718
+ /** Install/availability probe — delegated to the official adapter (popup-free). */
719
+ detectInstalled(): Promise<AdapterDetectResult>;
720
+ connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
721
+ disconnect(): Promise<void>;
722
+ signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
723
+ submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
724
+ }
725
+
557
726
  /**
558
727
  * Built-in wallet adapters
559
728
  *
@@ -672,4 +841,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
672
841
  */
673
842
  declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
674
843
 
675
- 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, 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 };
844
+ 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 };