@solana/connector 0.2.2 → 0.2.3

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.
@@ -704,6 +704,28 @@ var logger3 = chunkBF67LVVM_js.createLogger("WalletDetector");
704
704
  function isSolanaWallet(wallet) {
705
705
  return Array.isArray(wallet.chains) && wallet.chains.some((chain) => typeof chain == "string" && chain.startsWith("solana:"));
706
706
  }
707
+ function normalizeWalletName(value) {
708
+ return value.trim().toLowerCase();
709
+ }
710
+ function applyWalletDisplayConfig(wallets, config) {
711
+ if (!config) return [...wallets];
712
+ let allowList = (config.allowList ?? []).map(normalizeWalletName).filter(Boolean), denyList = (config.denyList ?? []).map(normalizeWalletName).filter(Boolean), featured = (config.featured ?? []).map(normalizeWalletName).filter(Boolean), allowSet = new Set(allowList), denySet = new Set(denyList), filtered = wallets.filter((wallet) => {
713
+ let name = normalizeWalletName(wallet.name);
714
+ return !(denySet.has(name) || allowSet.size > 0 && !allowSet.has(name));
715
+ });
716
+ if (featured.length === 0) return filtered;
717
+ let byName = /* @__PURE__ */ new Map();
718
+ for (let wallet of filtered)
719
+ byName.set(normalizeWalletName(wallet.name), wallet);
720
+ let featuredWallets = [], featuredNames = /* @__PURE__ */ new Set();
721
+ for (let name of featured) {
722
+ if (featuredNames.has(name)) continue;
723
+ let wallet = byName.get(name);
724
+ wallet && (featuredNames.add(name), featuredWallets.push(wallet));
725
+ }
726
+ let remaining = filtered.filter((wallet) => !featuredNames.has(normalizeWalletName(wallet.name)));
727
+ return [...featuredWallets, ...remaining];
728
+ }
707
729
  function hasFeature(wallet, featureName) {
708
730
  return wallet.features != null && wallet.features[featureName] !== void 0;
709
731
  }
@@ -727,6 +749,7 @@ var WalletDetector = class extends BaseCollaborator {
727
749
  super({ stateManager, eventEmitter, debug }, "WalletDetector");
728
750
  chunkL5FWMNWO_js.__publicField(this, "unsubscribers", []);
729
751
  chunkL5FWMNWO_js.__publicField(this, "additionalWallets", []);
752
+ chunkL5FWMNWO_js.__publicField(this, "walletDisplayConfig");
730
753
  /** Map from stable connector ID to Wallet reference (not stored in state) */
731
754
  chunkL5FWMNWO_js.__publicField(this, "connectorRegistry", /* @__PURE__ */ new Map());
732
755
  }
@@ -745,20 +768,27 @@ var WalletDetector = class extends BaseCollaborator {
745
768
  getAdditionalWallets() {
746
769
  return this.additionalWallets;
747
770
  }
771
+ /**
772
+ * Set wallet display controls for Wallet Standard auto-discovery.
773
+ * This affects which detected wallets are exposed as connectors (and therefore selectable / autoConnect-able).
774
+ */
775
+ setWalletDisplayConfig(config) {
776
+ this.walletDisplayConfig = config, this.unsubscribers.length > 0 && this.refreshWallets();
777
+ }
748
778
  /**
749
779
  * Refresh wallet list (re-detect and merge)
750
780
  */
751
781
  refreshWallets() {
752
782
  if (!(typeof window > "u"))
753
783
  try {
754
- let registryWallets = getWalletsRegistry().get().filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]);
755
- this.updateConnectorRegistry(unique), this.stateManager.updateState({
756
- wallets: unique.map((w) => this.mapToWalletInfo(w)),
757
- connectors: unique.map((w) => this.mapToConnectorMetadata(w))
784
+ let registryWallets = getWalletsRegistry().get().filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]), filtered = applyWalletDisplayConfig(unique, this.walletDisplayConfig);
785
+ this.updateConnectorRegistry(filtered), this.stateManager.updateState({
786
+ wallets: filtered.map((w) => this.mapToWalletInfo(w)),
787
+ connectors: filtered.map((w) => this.mapToConnectorMetadata(w))
758
788
  }), this.log("\u{1F50D} WalletDetector: refreshed wallets", {
759
789
  registry: registryWallets.length,
760
790
  additional: additionalWallets.length,
761
- total: unique.length
791
+ total: filtered.length
762
792
  });
763
793
  } catch {
764
794
  }
@@ -777,14 +807,14 @@ var WalletDetector = class extends BaseCollaborator {
777
807
  if (!(typeof window > "u"))
778
808
  try {
779
809
  let walletsApi = getWalletsRegistry(), update = () => {
780
- let ws = walletsApi.get(), previousCount = this.getState().wallets.length, registryWallets = ws.filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]), newCount = unique.length;
810
+ let ws = walletsApi.get(), previousCount = this.getState().wallets.length, registryWallets = ws.filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]), filtered = applyWalletDisplayConfig(unique, this.walletDisplayConfig), newCount = filtered.length;
781
811
  newCount !== previousCount && this.log("\u{1F50D} WalletDetector: found wallets:", {
782
812
  registry: registryWallets.length,
783
813
  additional: additionalWallets.length,
784
814
  total: newCount
785
- }), this.updateConnectorRegistry(unique), this.stateManager.updateState({
786
- wallets: unique.map((w) => this.mapToWalletInfo(w)),
787
- connectors: unique.map((w) => this.mapToConnectorMetadata(w))
815
+ }), this.updateConnectorRegistry(filtered), this.stateManager.updateState({
816
+ wallets: filtered.map((w) => this.mapToWalletInfo(w)),
817
+ connectors: filtered.map((w) => this.mapToConnectorMetadata(w))
788
818
  }), newCount !== previousCount && newCount > 0 && this.eventEmitter.emit({
789
819
  type: "wallets:detected",
790
820
  count: newCount,
@@ -1810,7 +1840,7 @@ var logger5 = chunkBF67LVVM_js.createLogger("ConnectorClient"), ConnectorClient
1810
1840
  initialize() {
1811
1841
  if (typeof window > "u" || this.initialized) return;
1812
1842
  let { error } = chunk4KD6HQQG_js.tryCatchSync(() => {
1813
- this.config.additionalWallets && this.config.additionalWallets.length > 0 && this.walletDetector.setAdditionalWallets(this.config.additionalWallets), this.walletDetector.initialize(), this.config.walletConnect?.enabled && this.initializeWalletConnect().catch((err) => {
1843
+ this.config.additionalWallets && this.config.additionalWallets.length > 0 && this.walletDetector.setAdditionalWallets(this.config.additionalWallets), this.walletDetector.setWalletDisplayConfig(this.config.wallets), this.walletDetector.initialize(), this.config.walletConnect?.enabled && this.initializeWalletConnect().catch((err) => {
1814
1844
  this.config.debug && logger5.error("WalletConnect initialization failed", { error: err });
1815
1845
  }), this.config.autoConnect && setTimeout(() => {
1816
1846
  this.autoConnector.attemptAutoConnect().catch((err) => {
@@ -2203,7 +2233,8 @@ function getDefaultConfig(options) {
2203
2233
  programLabels,
2204
2234
  coingecko,
2205
2235
  walletConnect,
2206
- additionalWallets
2236
+ additionalWallets,
2237
+ wallets
2207
2238
  } = options, defaultClusters = clusters ?? [
2208
2239
  core.createSolanaMainnet(),
2209
2240
  core.createSolanaDevnet(),
@@ -2250,6 +2281,7 @@ function getDefaultConfig(options) {
2250
2281
  appUrl,
2251
2282
  enableMobile,
2252
2283
  network,
2284
+ wallets,
2253
2285
  cluster: {
2254
2286
  clusters: defaultClusters,
2255
2287
  persistSelection: persistClusterSelection,
@@ -2361,7 +2393,11 @@ var solanaNetworkSchema = v4.z.enum(["mainnet", "mainnet-beta", "devnet", "testn
2361
2393
  }).optional(), walletSchema = v4.z.custom(
2362
2394
  (val) => typeof val == "object" && val !== null && "name" in val && "version" in val && "features" in val && "chains" in val,
2363
2395
  { message: "Invalid Wallet Standard wallet object" }
2364
- ), defaultConfigOptionsSchema = v4.z.object({
2396
+ ), nonEmptyTrimmedStringSchema = v4.z.string().transform((s) => s.trim()).refine((s) => s.length > 0, { message: "Wallet name cannot be empty or whitespace-only" }), walletDisplayConfigSchema = v4.z.object({
2397
+ allowList: v4.z.array(nonEmptyTrimmedStringSchema).optional(),
2398
+ denyList: v4.z.array(nonEmptyTrimmedStringSchema).optional(),
2399
+ featured: v4.z.array(nonEmptyTrimmedStringSchema).optional()
2400
+ }).optional(), defaultConfigOptionsSchema = v4.z.object({
2365
2401
  // Required
2366
2402
  appName: v4.z.string().min(1, "Application name is required"),
2367
2403
  // Optional strings
@@ -2387,11 +2423,14 @@ var solanaNetworkSchema = v4.z.enum(["mainnet", "mainnet-beta", "devnet", "testn
2387
2423
  walletConnect: walletConnectConfigSchema,
2388
2424
  // Additional wallets (remote signers, etc.)
2389
2425
  additionalWallets: v4.z.array(walletSchema).optional(),
2426
+ // Wallet display controls
2427
+ wallets: walletDisplayConfigSchema,
2390
2428
  // Functions (can't validate implementation, just existence)
2391
2429
  onError: v4.z.custom((val) => typeof val == "function").optional()
2392
2430
  }); v4.z.strictObject({
2393
2431
  autoConnect: v4.z.boolean().optional(),
2394
2432
  debug: v4.z.boolean().optional(),
2433
+ wallets: walletDisplayConfigSchema,
2395
2434
  storage: storageConfigSchema,
2396
2435
  cluster: clusterConfigSchema,
2397
2436
  imageProxy: v4.z.string().optional(),
@@ -3207,5 +3246,5 @@ exports.toClusterId = toClusterId;
3207
3246
  exports.toLegacyWalletState = toLegacyWalletState;
3208
3247
  exports.truncate = truncate;
3209
3248
  exports.validateConfigOptions = validateConfigOptions;
3210
- //# sourceMappingURL=chunk-TRSJSU33.js.map
3211
- //# sourceMappingURL=chunk-TRSJSU33.js.map
3249
+ //# sourceMappingURL=chunk-ULEPN4NL.js.map
3250
+ //# sourceMappingURL=chunk-ULEPN4NL.js.map