@partylayer/sdk 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { toWalletId, toPartyId, hashForPrivacy, createMetricsPayload, isOfficialAdapterFactory, isOfficialProviderAdapter, mapUnknownErrorToPartyLayerError, findMatchingWalletInfo, detectNetworkMismatch, NetworkMismatchError, METRICS, WalletNotFoundError, capabilityGuard, installGuard, toSessionId, CapabilityNotSupportedError, errorMetricName } from '@partylayer/core';
2
- export { PartyLayerError as CantonConnectError, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, InternalError, METRICS, OriginNotAllowedError, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, SessionExpiredError, TimeoutError, TransportError, UserRejectedError, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
1
+ import { toWalletId, toPartyId, isRecognizedNetwork, hashForPrivacy, createMetricsPayload, isOfficialAdapterFactory, isOfficialProviderAdapter, mapUnknownErrorToPartyLayerError, findMatchingWalletInfo, detectNetworkMismatch, NetworkMismatchError, METRICS, AdapterNotRegisteredError, WalletNotFoundError, capabilityGuard, installGuard, toSessionId, CapabilityNotSupportedError, errorMetricName } from '@partylayer/core';
2
+ export { AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, InternalError, METRICS, OriginNotAllowedError, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, SessionExpiredError, TimeoutError, TransportError, UserRejectedError, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
3
3
  import { RegistryClient } from '@partylayer/registry-client';
4
4
  export { deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
5
5
  import { discoverProviders, createExtensionChannelProvider, createProviderBridge } from '@partylayer/provider';
@@ -205,10 +205,13 @@ var GenericDiscoveryAdapter = class {
205
205
  } catch {
206
206
  }
207
207
  const partyId = toPartyId(account.partyId);
208
+ const network = [reportedNetwork, account.networkId, ctx.network].find(
209
+ (n) => typeof n === "string" && isRecognizedNetwork(n)
210
+ ) ?? ctx.network;
208
211
  const session = {
209
212
  walletId: this.walletId,
210
213
  partyId,
211
- network: reportedNetwork ?? account.networkId ?? ctx.network
214
+ network
212
215
  };
213
216
  return { partyId, session, capabilities: this.getCapabilities() };
214
217
  }
@@ -750,6 +753,27 @@ var PartyLayerClient = class {
750
753
  if (!hidden || hidden.size === 0) return wallets;
751
754
  return wallets.filter((w) => !hidden.has(String(w.walletId)));
752
755
  }
756
+ /**
757
+ * If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
758
+ * return the bits to build an actionable "register its adapter" error; else
759
+ * null (truly-unknown or non-discovery → plain WalletNotFoundError). Reads the
760
+ * UNGATED registry (SWR-cached); registry-unavailable → null (safe fallback).
761
+ */
762
+ async unregisteredDiscoveryInfo(walletId) {
763
+ try {
764
+ const registry = await this.registryClient.getRegistry();
765
+ const entry = registry.wallets.find((w) => toWalletId(w.id) === walletId);
766
+ if (entry?.adapter?.transport !== "discovery-adapter") return null;
767
+ const pid = entry.adapter?.config?.providerId;
768
+ return {
769
+ name: entry.name,
770
+ providerId: typeof pid === "string" ? pid : entry.id,
771
+ adapterPackage: typeof entry.adapter?.type === "string" ? entry.adapter.type : void 0
772
+ };
773
+ } catch {
774
+ return null;
775
+ }
776
+ }
753
777
  /**
754
778
  * Whether announce discovery is active: explicit `discovery.announce`, else
755
779
  * ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
@@ -913,6 +937,10 @@ var PartyLayerClient = class {
913
937
  metadata: { source: "native-cip0103" }
914
938
  };
915
939
  } else {
940
+ const info = await this.unregisteredDiscoveryInfo(options.walletId);
941
+ if (info) {
942
+ throw new AdapterNotRegisteredError(String(options.walletId), info);
943
+ }
916
944
  throw new WalletNotFoundError(String(options.walletId));
917
945
  }
918
946
  }