@volr/react-ui 0.1.21 → 0.1.23

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.cts CHANGED
@@ -198,19 +198,22 @@ interface VolrModalContextValue {
198
198
  declare const useVolrModal: () => VolrModalContextValue;
199
199
 
200
200
  /**
201
- * @deprecated Use NetworkWalletConfig instead
202
- * Legacy interface for wallet_addEthereumChain (converted from API response)
201
+ * Network switching utilities for external wallets
203
202
  */
204
- interface NetworkConfig {
203
+ /**
204
+ * Network wallet configuration from backend API
205
+ * (when includeWalletConfig=true)
206
+ */
207
+ interface NetworkWalletConfig {
205
208
  chainId: number;
206
- chainName: string;
207
- nativeCurrency: {
209
+ name: string;
210
+ nativeCurrency?: {
208
211
  name: string;
209
212
  symbol: string;
210
213
  decimals: number;
211
214
  };
212
- rpcUrls: string[];
213
- blockExplorerUrls?: string[];
215
+ rpcUrl?: string;
216
+ blockExplorerUrl?: string | null;
214
217
  }
215
218
  /**
216
219
  * Hook to switch to a different network
@@ -218,16 +221,9 @@ interface NetworkConfig {
218
221
  * Fetches network configuration from backend DB
219
222
  */
220
223
  declare function useSwitchNetwork(): (chainId: number) => Promise<void>;
221
- /**
222
- * @deprecated Use useSwitchNetwork hook instead
223
- * Switch to a different network (legacy function, requires client parameter)
224
- */
225
- declare function switchNetwork(chainId: number, client: {
226
- get: <T>(url: string) => Promise<T>;
227
- }): Promise<void>;
228
224
  /**
229
225
  * Get current chain ID from wallet
230
226
  */
231
227
  declare function getCurrentChainId(): Promise<number>;
232
228
 
233
- export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type Translations, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, switchNetwork, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrUI };
229
+ export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkWalletConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type Translations, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrUI };
package/dist/index.d.ts CHANGED
@@ -198,19 +198,22 @@ interface VolrModalContextValue {
198
198
  declare const useVolrModal: () => VolrModalContextValue;
199
199
 
200
200
  /**
201
- * @deprecated Use NetworkWalletConfig instead
202
- * Legacy interface for wallet_addEthereumChain (converted from API response)
201
+ * Network switching utilities for external wallets
203
202
  */
204
- interface NetworkConfig {
203
+ /**
204
+ * Network wallet configuration from backend API
205
+ * (when includeWalletConfig=true)
206
+ */
207
+ interface NetworkWalletConfig {
205
208
  chainId: number;
206
- chainName: string;
207
- nativeCurrency: {
209
+ name: string;
210
+ nativeCurrency?: {
208
211
  name: string;
209
212
  symbol: string;
210
213
  decimals: number;
211
214
  };
212
- rpcUrls: string[];
213
- blockExplorerUrls?: string[];
215
+ rpcUrl?: string;
216
+ blockExplorerUrl?: string | null;
214
217
  }
215
218
  /**
216
219
  * Hook to switch to a different network
@@ -218,16 +221,9 @@ interface NetworkConfig {
218
221
  * Fetches network configuration from backend DB
219
222
  */
220
223
  declare function useSwitchNetwork(): (chainId: number) => Promise<void>;
221
- /**
222
- * @deprecated Use useSwitchNetwork hook instead
223
- * Switch to a different network (legacy function, requires client parameter)
224
- */
225
- declare function switchNetwork(chainId: number, client: {
226
- get: <T>(url: string) => Promise<T>;
227
- }): Promise<void>;
228
224
  /**
229
225
  * Get current chain ID from wallet
230
226
  */
231
227
  declare function getCurrentChainId(): Promise<number>;
232
228
 
233
- export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type Translations, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, switchNetwork, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrUI };
229
+ export { I18nContext, type I18nContextValue, I18nProvider, type I18nProviderProps, type Locale, MpcConnectView, type MpcConnectViewProps, type NetworkWalletConfig, PasskeyEnrollView, type PasskeyEnrollViewProps, type Translations, type VolrUIConfig, VolrUIProvider, type VolrUIProviderProps, getCurrentChainId, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrUI };
package/dist/index.js CHANGED
@@ -3085,53 +3085,6 @@ function useSwitchNetwork() {
3085
3085
  [client]
3086
3086
  );
3087
3087
  }
3088
- async function switchNetwork(chainId, client) {
3089
- const chainIdHex = `0x${chainId.toString(16)}`;
3090
- if (typeof window === "undefined" || !window.ethereum) {
3091
- throw new Error("No wallet found");
3092
- }
3093
- const ethereum = window.ethereum;
3094
- try {
3095
- await ethereum.request({
3096
- method: "wallet_switchEthereumChain",
3097
- params: [{ chainId: chainIdHex }]
3098
- });
3099
- } catch (switchError) {
3100
- if (switchError.code === 4902) {
3101
- try {
3102
- const response = await client.get(
3103
- `/networks/${chainId}?includeWalletConfig=true&includeRpcUrl=true`
3104
- );
3105
- if (!response.rpcUrl) {
3106
- throw new Error(`RPC URL not available for chainId ${chainId}`);
3107
- }
3108
- if (!response.nativeCurrency) {
3109
- throw new Error(`Native currency configuration not available for chainId ${chainId}`);
3110
- }
3111
- await ethereum.request({
3112
- method: "wallet_addEthereumChain",
3113
- params: [
3114
- {
3115
- chainId: chainIdHex,
3116
- chainName: response.name,
3117
- nativeCurrency: response.nativeCurrency,
3118
- rpcUrls: [response.rpcUrl],
3119
- blockExplorerUrls: response.blockExplorerUrl ? [response.blockExplorerUrl] : void 0
3120
- }
3121
- ]
3122
- });
3123
- } catch (addError) {
3124
- throw new Error(
3125
- `Failed to add network: ${addError instanceof Error ? addError.message : "Unknown error"}`
3126
- );
3127
- }
3128
- } else {
3129
- throw new Error(
3130
- `Failed to switch network: ${switchError.message || "Unknown error"}`
3131
- );
3132
- }
3133
- }
3134
- }
3135
3088
  async function getCurrentChainId() {
3136
3089
  if (typeof window === "undefined" || !window.ethereum) {
3137
3090
  throw new Error("No wallet found");
@@ -3142,6 +3095,6 @@ async function getCurrentChainId() {
3142
3095
  return parseInt(chainIdHex, 16);
3143
3096
  }
3144
3097
 
3145
- export { I18nContext, I18nProvider, MpcConnectView, PasskeyEnrollView, VolrUIProvider, getCurrentChainId, switchNetwork, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrUI };
3098
+ export { I18nContext, I18nProvider, MpcConnectView, PasskeyEnrollView, VolrUIProvider, getCurrentChainId, useI18n, useSwitchNetwork, useTranslation, useVolrModal, useVolrUI };
3146
3099
  //# sourceMappingURL=index.js.map
3147
3100
  //# sourceMappingURL=index.js.map