@partylayer/sdk 0.8.0 → 0.10.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, 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';
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 | OfficialProviderAdapter)[];
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) */
@@ -638,28 +638,73 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
638
638
  */
639
639
 
640
640
  interface GenericDiscoveryAdapterArgs {
641
- /** App-supplied official adapter (e.g. `new WalleyAdapter({ host })`). */
642
- official: OfficialProviderAdapter;
643
641
  /**
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.
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.
648
666
  */
649
667
  walletId?: WalletId;
650
- /** Display name override (falls back to the official adapter's name). */
668
+ /** Display name override (falls back to the official adapter's / factory's name). */
651
669
  name?: string;
652
- /** Icon override (falls back to the official adapter's icon). */
670
+ /** Icon override (falls back to the official adapter's / factory's icon). */
653
671
  icon?: string;
654
672
  }
655
673
  declare class GenericDiscoveryAdapter implements WalletAdapter {
656
674
  readonly walletId: WalletId;
657
675
  readonly name: string;
658
676
  readonly icon?: string;
659
- private readonly official;
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;
660
687
  /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
661
688
  private providerInstance;
662
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;
663
708
  /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
664
709
  * `official.provider()` is typed `OfficialProvider` (loose `request` so real
665
710
  * official adapters are assignable); it is call-compatible with CIP0103Provider
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _partylayer_core 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';
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 | OfficialProviderAdapter)[];
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) */
@@ -638,28 +638,73 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
638
638
  */
639
639
 
640
640
  interface GenericDiscoveryAdapterArgs {
641
- /** App-supplied official adapter (e.g. `new WalleyAdapter({ host })`). */
642
- official: OfficialProviderAdapter;
643
641
  /**
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.
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.
648
666
  */
649
667
  walletId?: WalletId;
650
- /** Display name override (falls back to the official adapter's name). */
668
+ /** Display name override (falls back to the official adapter's / factory's name). */
651
669
  name?: string;
652
- /** Icon override (falls back to the official adapter's icon). */
670
+ /** Icon override (falls back to the official adapter's / factory's icon). */
653
671
  icon?: string;
654
672
  }
655
673
  declare class GenericDiscoveryAdapter implements WalletAdapter {
656
674
  readonly walletId: WalletId;
657
675
  readonly name: string;
658
676
  readonly icon?: string;
659
- private readonly official;
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;
660
687
  /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
661
688
  private providerInstance;
662
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;
663
708
  /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
664
709
  * `official.provider()` is typed `OfficialProvider` (loose `request` so real
665
710
  * official adapters are assignable); it is call-compatible with CIP0103Provider
package/dist/index.js CHANGED
@@ -82,14 +82,70 @@ var GenericDiscoveryAdapter = class {
82
82
  walletId;
83
83
  name;
84
84
  icon;
85
+ /**
86
+ * Resolved official adapter. Set at construction for the instance form; for
87
+ * the factory form it stays null until {@link resolveOfficial} constructs it
88
+ * with the network-resolved host.
89
+ */
85
90
  official;
91
+ /** Factory form (null for the instance form). */
92
+ factory;
93
+ /** Network→host map for the factory form; injected by the SDK post-registry. */
94
+ networkHosts;
86
95
  /** Lazily resolved from `official.provider()` — NOT at construction (SSR-safe). */
87
96
  providerInstance = null;
88
97
  constructor(args) {
89
- this.official = args.official;
90
- this.walletId = args.walletId ?? core.toWalletId(args.official.providerId);
91
- this.name = args.name && args.name.length > 0 ? args.name : args.official.name;
92
- this.icon = args.icon ?? args.official.icon;
98
+ if (args.official) {
99
+ this.official = args.official;
100
+ this.factory = null;
101
+ this.networkHosts = {};
102
+ this.walletId = args.walletId ?? core.toWalletId(args.official.providerId);
103
+ this.name = args.name && args.name.length > 0 ? args.name : args.official.name;
104
+ this.icon = args.icon ?? args.official.icon;
105
+ } else if (args.factory) {
106
+ this.official = null;
107
+ this.factory = args.factory;
108
+ this.networkHosts = args.networkHosts ?? {};
109
+ this.walletId = args.walletId ?? core.toWalletId(args.factory.providerId);
110
+ this.name = args.name && args.name.length > 0 ? args.name : args.factory.name ?? args.factory.providerId;
111
+ this.icon = args.icon ?? args.factory.icon;
112
+ } else {
113
+ throw new Error(
114
+ "GenericDiscoveryAdapter requires either `official` (instance) or `factory`."
115
+ );
116
+ }
117
+ }
118
+ /** Whether this bridge resolves its host from `networkHosts` (factory form). */
119
+ usesFactory() {
120
+ return this.factory !== null;
121
+ }
122
+ /**
123
+ * Inject the registry's network→host map (factory form only). SYNCHRONOUS —
124
+ * the SDK calls this during the async warm phase once the registry entry is
125
+ * loaded, BEFORE the (possibly gesture-synchronous) connect.
126
+ */
127
+ setNetworkHosts(networkHosts) {
128
+ if (this.factory) this.networkHosts = networkHosts ?? {};
129
+ }
130
+ /**
131
+ * Resolve + construct the official adapter for `network` — SYNCHRONOUS, so the
132
+ * popup-safe gesture path reaches `window.open` with NO awaits. Idempotent.
133
+ * The SDK pre-calls it during warm-up; `connect()` also calls it as its first
134
+ * statement so a cold (un-warmed) connect is still gesture-safe.
135
+ *
136
+ * Failure is CLEAR, never a silent wrong-network host: a factory wallet with
137
+ * no host for `network` in `networkHosts` throws, naming the network.
138
+ */
139
+ resolveOfficial(network) {
140
+ if (this.official) return;
141
+ if (!this.factory) return;
142
+ const host = this.networkHosts[network];
143
+ if (!host) {
144
+ throw new Error(
145
+ `Wallet "${String(this.walletId)}" has no host for network "${network}". Add it to the registry entry's adapter.networkHosts, or supply a pre-constructed official adapter with an explicit host.`
146
+ );
147
+ }
148
+ this.official = this.factory.create(host);
93
149
  }
94
150
  /** Lazily obtain (and cache) the official provider — deferred off the init/SSR path.
95
151
  * `official.provider()` is typed `OfficialProvider` (loose `request` so real
@@ -97,6 +153,11 @@ var GenericDiscoveryAdapter = class {
97
153
  * (the bridge only ever calls `request({ method, params })`). */
98
154
  get provider() {
99
155
  if (this.providerInstance === null) {
156
+ if (!this.official) {
157
+ throw new Error(
158
+ `Wallet "${String(this.walletId)}" provider requested before host resolution \u2014 call resolveOfficial(network) first.`
159
+ );
160
+ }
100
161
  this.providerInstance = this.official.provider();
101
162
  }
102
163
  return this.providerInstance;
@@ -110,6 +171,9 @@ var GenericDiscoveryAdapter = class {
110
171
  }
111
172
  /** Install/availability probe — delegated to the official adapter (popup-free). */
112
173
  async detectInstalled() {
174
+ if (!this.official) {
175
+ return { installed: true, reason: "Popup/remote wallet (resolved at connect)" };
176
+ }
113
177
  try {
114
178
  const installed = await this.official.detect();
115
179
  return {
@@ -121,6 +185,7 @@ var GenericDiscoveryAdapter = class {
121
185
  }
122
186
  }
123
187
  async connect(ctx) {
188
+ this.resolveOfficial(ctx.network);
124
189
  await this.provider.request({ method: "connect" });
125
190
  const account = await this.provider.request({
126
191
  method: "getPrimaryAccount"
@@ -134,10 +199,13 @@ var GenericDiscoveryAdapter = class {
134
199
  } catch {
135
200
  }
136
201
  const partyId = core.toPartyId(account.partyId);
202
+ const network = [reportedNetwork, account.networkId, ctx.network].find(
203
+ (n) => typeof n === "string" && core.isRecognizedNetwork(n)
204
+ ) ?? ctx.network;
137
205
  const session = {
138
206
  walletId: this.walletId,
139
207
  partyId,
140
- network: reportedNetwork ?? account.networkId ?? ctx.network
208
+ network
141
209
  };
142
210
  return { partyId, session, capabilities: this.getCapabilities() };
143
211
  }
@@ -551,6 +619,8 @@ var PartyLayerClient = class {
551
619
  let adapter;
552
620
  if (typeof adapterOrClass === "function") {
553
621
  adapter = new adapterOrClass();
622
+ } else if (core.isOfficialAdapterFactory(adapterOrClass)) {
623
+ adapter = new GenericDiscoveryAdapter({ factory: adapterOrClass });
554
624
  } else if (core.isOfficialProviderAdapter(adapterOrClass)) {
555
625
  adapter = new GenericDiscoveryAdapter({ official: adapterOrClass });
556
626
  } else {
@@ -875,6 +945,18 @@ var PartyLayerClient = class {
875
945
  }
876
946
  await core.installGuard(adapter);
877
947
  const ctx = this.createAdapterContext();
948
+ if (adapter instanceof GenericDiscoveryAdapter && adapter.usesFactory()) {
949
+ let networkHosts = {};
950
+ try {
951
+ const entry = await this.registryClient.getWalletEntry(
952
+ String(selectedWallet.walletId)
953
+ );
954
+ networkHosts = entry.adapter?.networkHosts ?? {};
955
+ } catch {
956
+ }
957
+ adapter.setNetworkHosts(networkHosts);
958
+ adapter.resolveOfficial(ctx.network);
959
+ }
878
960
  return { selectedWallet, adapter, ctx, isNativeWallet };
879
961
  }
880
962
  /**
@@ -1279,6 +1361,29 @@ var PartyLayerClient = class {
1279
1361
  if (session.origin !== this.origin) {
1280
1362
  return null;
1281
1363
  }
1364
+ const mismatch = this.networkMismatch(session);
1365
+ if (mismatch) {
1366
+ this.emit("session:networkMismatch", {
1367
+ type: "session:networkMismatch",
1368
+ sessionId: session.sessionId,
1369
+ expected: mismatch.expected,
1370
+ actual: mismatch.actual,
1371
+ enforced: this.enforcement !== "off"
1372
+ });
1373
+ if (this.enforcement !== "off") {
1374
+ this.logger.warn("Refused session restore \u2014 network mismatch", {
1375
+ expected: mismatch.expected,
1376
+ actual: mismatch.actual
1377
+ });
1378
+ await this.removeSession(session.sessionId);
1379
+ this.emit("session:expired", {
1380
+ type: "session:expired",
1381
+ sessionId: session.sessionId
1382
+ });
1383
+ return null;
1384
+ }
1385
+ session.networkMismatch = mismatch;
1386
+ }
1282
1387
  const adapter = this.adapters.get(session.walletId);
1283
1388
  if (adapter?.restore) {
1284
1389
  const ctx = this.createAdapterContext();
@@ -1449,6 +1554,10 @@ Object.defineProperty(exports, "errorMetricName", {
1449
1554
  enumerable: true,
1450
1555
  get: function () { return core.errorMetricName; }
1451
1556
  });
1557
+ Object.defineProperty(exports, "isOfficialAdapterFactory", {
1558
+ enumerable: true,
1559
+ get: function () { return core.isOfficialAdapterFactory; }
1560
+ });
1452
1561
  Object.defineProperty(exports, "isOfficialProviderAdapter", {
1453
1562
  enumerable: true,
1454
1563
  get: function () { return core.isOfficialProviderAdapter; }