@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.
- package/README.md +17 -0
- package/dist/{chunk-VVLY6QPI.js → chunk-B6YBZB6H.js} +18 -18
- package/dist/{chunk-VVLY6QPI.js.map → chunk-B6YBZB6H.js.map} +1 -1
- package/dist/{chunk-SQ2JEA2M.mjs → chunk-DFKGCW7K.mjs} +53 -14
- package/dist/chunk-DFKGCW7K.mjs.map +1 -0
- package/dist/{chunk-TRSJSU33.js → chunk-ULEPN4NL.js} +53 -14
- package/dist/chunk-ULEPN4NL.js.map +1 -0
- package/dist/{chunk-3623Z2QL.mjs → chunk-UOML5ULB.mjs} +3 -3
- package/dist/{chunk-3623Z2QL.mjs.map → chunk-UOML5ULB.mjs.map} +1 -1
- package/dist/{chunk-DFHJYZKZ.mjs → chunk-WPDCSFX2.mjs} +3 -3
- package/dist/{chunk-DFHJYZKZ.mjs.map → chunk-WPDCSFX2.mjs.map} +1 -1
- package/dist/{chunk-I2XX5FUG.js → chunk-X2X5TFXS.js} +4 -4
- package/dist/{chunk-I2XX5FUG.js.map → chunk-X2X5TFXS.js.map} +1 -1
- package/dist/headless.d.mts +7 -2
- package/dist/headless.d.ts +7 -2
- package/dist/headless.js +107 -107
- package/dist/headless.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +148 -148
- package/dist/index.mjs +3 -3
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +49 -49
- package/dist/react.mjs +2 -2
- package/dist/{standard-shim-Cg6fmjK_.d.ts → standard-shim-BB0Lkg_C.d.ts} +34 -1
- package/dist/{standard-shim-Cz4UNS7t.d.mts → standard-shim-n5phZB1d.d.mts} +34 -1
- package/package.json +1 -1
- package/dist/chunk-SQ2JEA2M.mjs.map +0 -1
- package/dist/chunk-TRSJSU33.js.map +0 -1
|
@@ -702,6 +702,28 @@ var logger3 = createLogger("WalletDetector");
|
|
|
702
702
|
function isSolanaWallet(wallet) {
|
|
703
703
|
return Array.isArray(wallet.chains) && wallet.chains.some((chain) => typeof chain == "string" && chain.startsWith("solana:"));
|
|
704
704
|
}
|
|
705
|
+
function normalizeWalletName(value) {
|
|
706
|
+
return value.trim().toLowerCase();
|
|
707
|
+
}
|
|
708
|
+
function applyWalletDisplayConfig(wallets, config) {
|
|
709
|
+
if (!config) return [...wallets];
|
|
710
|
+
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) => {
|
|
711
|
+
let name = normalizeWalletName(wallet.name);
|
|
712
|
+
return !(denySet.has(name) || allowSet.size > 0 && !allowSet.has(name));
|
|
713
|
+
});
|
|
714
|
+
if (featured.length === 0) return filtered;
|
|
715
|
+
let byName = /* @__PURE__ */ new Map();
|
|
716
|
+
for (let wallet of filtered)
|
|
717
|
+
byName.set(normalizeWalletName(wallet.name), wallet);
|
|
718
|
+
let featuredWallets = [], featuredNames = /* @__PURE__ */ new Set();
|
|
719
|
+
for (let name of featured) {
|
|
720
|
+
if (featuredNames.has(name)) continue;
|
|
721
|
+
let wallet = byName.get(name);
|
|
722
|
+
wallet && (featuredNames.add(name), featuredWallets.push(wallet));
|
|
723
|
+
}
|
|
724
|
+
let remaining = filtered.filter((wallet) => !featuredNames.has(normalizeWalletName(wallet.name)));
|
|
725
|
+
return [...featuredWallets, ...remaining];
|
|
726
|
+
}
|
|
705
727
|
function hasFeature(wallet, featureName) {
|
|
706
728
|
return wallet.features != null && wallet.features[featureName] !== void 0;
|
|
707
729
|
}
|
|
@@ -725,6 +747,7 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
725
747
|
super({ stateManager, eventEmitter, debug }, "WalletDetector");
|
|
726
748
|
__publicField(this, "unsubscribers", []);
|
|
727
749
|
__publicField(this, "additionalWallets", []);
|
|
750
|
+
__publicField(this, "walletDisplayConfig");
|
|
728
751
|
/** Map from stable connector ID to Wallet reference (not stored in state) */
|
|
729
752
|
__publicField(this, "connectorRegistry", /* @__PURE__ */ new Map());
|
|
730
753
|
}
|
|
@@ -743,20 +766,27 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
743
766
|
getAdditionalWallets() {
|
|
744
767
|
return this.additionalWallets;
|
|
745
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* Set wallet display controls for Wallet Standard auto-discovery.
|
|
771
|
+
* This affects which detected wallets are exposed as connectors (and therefore selectable / autoConnect-able).
|
|
772
|
+
*/
|
|
773
|
+
setWalletDisplayConfig(config) {
|
|
774
|
+
this.walletDisplayConfig = config, this.unsubscribers.length > 0 && this.refreshWallets();
|
|
775
|
+
}
|
|
746
776
|
/**
|
|
747
777
|
* Refresh wallet list (re-detect and merge)
|
|
748
778
|
*/
|
|
749
779
|
refreshWallets() {
|
|
750
780
|
if (!(typeof window > "u"))
|
|
751
781
|
try {
|
|
752
|
-
let registryWallets = getWalletsRegistry().get().filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]);
|
|
753
|
-
this.updateConnectorRegistry(
|
|
754
|
-
wallets:
|
|
755
|
-
connectors:
|
|
782
|
+
let registryWallets = getWalletsRegistry().get().filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]), filtered = applyWalletDisplayConfig(unique, this.walletDisplayConfig);
|
|
783
|
+
this.updateConnectorRegistry(filtered), this.stateManager.updateState({
|
|
784
|
+
wallets: filtered.map((w) => this.mapToWalletInfo(w)),
|
|
785
|
+
connectors: filtered.map((w) => this.mapToConnectorMetadata(w))
|
|
756
786
|
}), this.log("\u{1F50D} WalletDetector: refreshed wallets", {
|
|
757
787
|
registry: registryWallets.length,
|
|
758
788
|
additional: additionalWallets.length,
|
|
759
|
-
total:
|
|
789
|
+
total: filtered.length
|
|
760
790
|
});
|
|
761
791
|
} catch {
|
|
762
792
|
}
|
|
@@ -775,14 +805,14 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
775
805
|
if (!(typeof window > "u"))
|
|
776
806
|
try {
|
|
777
807
|
let walletsApi = getWalletsRegistry(), update = () => {
|
|
778
|
-
let ws = walletsApi.get(), previousCount = this.getState().wallets.length, registryWallets = ws.filter(isSolanaWallet), additionalWallets = this.additionalWallets.filter(isSolanaWallet), unique = this.deduplicateWallets([...registryWallets, ...additionalWallets]),
|
|
808
|
+
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;
|
|
779
809
|
newCount !== previousCount && this.log("\u{1F50D} WalletDetector: found wallets:", {
|
|
780
810
|
registry: registryWallets.length,
|
|
781
811
|
additional: additionalWallets.length,
|
|
782
812
|
total: newCount
|
|
783
|
-
}), this.updateConnectorRegistry(
|
|
784
|
-
wallets:
|
|
785
|
-
connectors:
|
|
813
|
+
}), this.updateConnectorRegistry(filtered), this.stateManager.updateState({
|
|
814
|
+
wallets: filtered.map((w) => this.mapToWalletInfo(w)),
|
|
815
|
+
connectors: filtered.map((w) => this.mapToConnectorMetadata(w))
|
|
786
816
|
}), newCount !== previousCount && newCount > 0 && this.eventEmitter.emit({
|
|
787
817
|
type: "wallets:detected",
|
|
788
818
|
count: newCount,
|
|
@@ -1808,7 +1838,7 @@ var logger5 = createLogger("ConnectorClient"), ConnectorClient = class {
|
|
|
1808
1838
|
initialize() {
|
|
1809
1839
|
if (typeof window > "u" || this.initialized) return;
|
|
1810
1840
|
let { error } = tryCatchSync(() => {
|
|
1811
|
-
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) => {
|
|
1841
|
+
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) => {
|
|
1812
1842
|
this.config.debug && logger5.error("WalletConnect initialization failed", { error: err });
|
|
1813
1843
|
}), this.config.autoConnect && setTimeout(() => {
|
|
1814
1844
|
this.autoConnector.attemptAutoConnect().catch((err) => {
|
|
@@ -2201,7 +2231,8 @@ function getDefaultConfig(options) {
|
|
|
2201
2231
|
programLabels,
|
|
2202
2232
|
coingecko,
|
|
2203
2233
|
walletConnect,
|
|
2204
|
-
additionalWallets
|
|
2234
|
+
additionalWallets,
|
|
2235
|
+
wallets
|
|
2205
2236
|
} = options, defaultClusters = clusters ?? [
|
|
2206
2237
|
createSolanaMainnet(),
|
|
2207
2238
|
createSolanaDevnet(),
|
|
@@ -2248,6 +2279,7 @@ function getDefaultConfig(options) {
|
|
|
2248
2279
|
appUrl,
|
|
2249
2280
|
enableMobile,
|
|
2250
2281
|
network,
|
|
2282
|
+
wallets,
|
|
2251
2283
|
cluster: {
|
|
2252
2284
|
clusters: defaultClusters,
|
|
2253
2285
|
persistSelection: persistClusterSelection,
|
|
@@ -2359,7 +2391,11 @@ var solanaNetworkSchema = z.enum(["mainnet", "mainnet-beta", "devnet", "testnet"
|
|
|
2359
2391
|
}).optional(), walletSchema = z.custom(
|
|
2360
2392
|
(val) => typeof val == "object" && val !== null && "name" in val && "version" in val && "features" in val && "chains" in val,
|
|
2361
2393
|
{ message: "Invalid Wallet Standard wallet object" }
|
|
2362
|
-
),
|
|
2394
|
+
), nonEmptyTrimmedStringSchema = z.string().transform((s) => s.trim()).refine((s) => s.length > 0, { message: "Wallet name cannot be empty or whitespace-only" }), walletDisplayConfigSchema = z.object({
|
|
2395
|
+
allowList: z.array(nonEmptyTrimmedStringSchema).optional(),
|
|
2396
|
+
denyList: z.array(nonEmptyTrimmedStringSchema).optional(),
|
|
2397
|
+
featured: z.array(nonEmptyTrimmedStringSchema).optional()
|
|
2398
|
+
}).optional(), defaultConfigOptionsSchema = z.object({
|
|
2363
2399
|
// Required
|
|
2364
2400
|
appName: z.string().min(1, "Application name is required"),
|
|
2365
2401
|
// Optional strings
|
|
@@ -2385,11 +2421,14 @@ var solanaNetworkSchema = z.enum(["mainnet", "mainnet-beta", "devnet", "testnet"
|
|
|
2385
2421
|
walletConnect: walletConnectConfigSchema,
|
|
2386
2422
|
// Additional wallets (remote signers, etc.)
|
|
2387
2423
|
additionalWallets: z.array(walletSchema).optional(),
|
|
2424
|
+
// Wallet display controls
|
|
2425
|
+
wallets: walletDisplayConfigSchema,
|
|
2388
2426
|
// Functions (can't validate implementation, just existence)
|
|
2389
2427
|
onError: z.custom((val) => typeof val == "function").optional()
|
|
2390
2428
|
}); z.strictObject({
|
|
2391
2429
|
autoConnect: z.boolean().optional(),
|
|
2392
2430
|
debug: z.boolean().optional(),
|
|
2431
|
+
wallets: walletDisplayConfigSchema,
|
|
2393
2432
|
storage: storageConfigSchema,
|
|
2394
2433
|
cluster: clusterConfigSchema,
|
|
2395
2434
|
imageProxy: z.string().optional(),
|
|
@@ -3134,5 +3173,5 @@ function createKitTransactionSigner(connectorSigner) {
|
|
|
3134
3173
|
var createGillTransactionSigner = createKitTransactionSigner;
|
|
3135
3174
|
|
|
3136
3175
|
export { ClipboardErrorType, ConnectorClient, EnhancedStorage, EnhancedStorageAdapter, INITIAL_WALLET_STATUS, PUBLIC_RPC_ENDPOINTS, TransactionSignerError, WALLET_STATE_VERSION, clearWalletState, copyAddressToClipboard, copySignatureToClipboard, copyToClipboard, createConnectorId, createEnhancedStorageAccount, createEnhancedStorageCluster, createEnhancedStorageWallet, createEnhancedStorageWalletState, createGillTransactionSigner, createKitTransactionSigner, createTransactionSigner, formatAddress, formatBigIntBalance, formatBigIntUsd, formatLamportsToSolSafe, formatNumber, formatSOL, formatTokenAmount, formatTokenBalanceSafe, getAddressUrl, getBlockUrl, getChainIdForWalletStandard, getClusterChainId, getClusterExplorerUrl, getClusterName, getClusterRpcUrl, getClusterType, getDefaultConfig, getDefaultMobileConfig, getDefaultRpcUrl, getNetworkDisplayName, getPolyfillStatus, getTokenUrl, getTransactionUrl, getWalletNameFromConnectorId, getWalletsRegistry, installPolyfills, isClipboardAvailable, isConnected, isConnecting, isCryptoAvailable, isDevnet, isDevnetCluster, isDisconnected, isLocalCluster, isLocalnet, isMainnet, isMainnetCluster, isPolyfillInstalled, isStatusError, isTestnet, isTestnetCluster, isTransactionSignerError, isWalletConnectorId, isWalletStatusError, normalizeNetwork, parseConfigOptions, ready, saveWalletState, toClusterId, toLegacyWalletState, truncate, validateConfigOptions };
|
|
3137
|
-
//# sourceMappingURL=chunk-
|
|
3138
|
-
//# sourceMappingURL=chunk-
|
|
3176
|
+
//# sourceMappingURL=chunk-DFKGCW7K.mjs.map
|
|
3177
|
+
//# sourceMappingURL=chunk-DFKGCW7K.mjs.map
|