@volr/react-ui 0.1.21 → 0.1.22
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.cjs +0 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -15
- package/dist/index.d.ts +11 -15
- package/dist/index.js +1 -48
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3090,53 +3090,6 @@ function useSwitchNetwork() {
|
|
|
3090
3090
|
[client]
|
|
3091
3091
|
);
|
|
3092
3092
|
}
|
|
3093
|
-
async function switchNetwork(chainId, client) {
|
|
3094
|
-
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
3095
|
-
if (typeof window === "undefined" || !window.ethereum) {
|
|
3096
|
-
throw new Error("No wallet found");
|
|
3097
|
-
}
|
|
3098
|
-
const ethereum = window.ethereum;
|
|
3099
|
-
try {
|
|
3100
|
-
await ethereum.request({
|
|
3101
|
-
method: "wallet_switchEthereumChain",
|
|
3102
|
-
params: [{ chainId: chainIdHex }]
|
|
3103
|
-
});
|
|
3104
|
-
} catch (switchError) {
|
|
3105
|
-
if (switchError.code === 4902) {
|
|
3106
|
-
try {
|
|
3107
|
-
const response = await client.get(
|
|
3108
|
-
`/networks/${chainId}?includeWalletConfig=true&includeRpcUrl=true`
|
|
3109
|
-
);
|
|
3110
|
-
if (!response.rpcUrl) {
|
|
3111
|
-
throw new Error(`RPC URL not available for chainId ${chainId}`);
|
|
3112
|
-
}
|
|
3113
|
-
if (!response.nativeCurrency) {
|
|
3114
|
-
throw new Error(`Native currency configuration not available for chainId ${chainId}`);
|
|
3115
|
-
}
|
|
3116
|
-
await ethereum.request({
|
|
3117
|
-
method: "wallet_addEthereumChain",
|
|
3118
|
-
params: [
|
|
3119
|
-
{
|
|
3120
|
-
chainId: chainIdHex,
|
|
3121
|
-
chainName: response.name,
|
|
3122
|
-
nativeCurrency: response.nativeCurrency,
|
|
3123
|
-
rpcUrls: [response.rpcUrl],
|
|
3124
|
-
blockExplorerUrls: response.blockExplorerUrl ? [response.blockExplorerUrl] : void 0
|
|
3125
|
-
}
|
|
3126
|
-
]
|
|
3127
|
-
});
|
|
3128
|
-
} catch (addError) {
|
|
3129
|
-
throw new Error(
|
|
3130
|
-
`Failed to add network: ${addError instanceof Error ? addError.message : "Unknown error"}`
|
|
3131
|
-
);
|
|
3132
|
-
}
|
|
3133
|
-
} else {
|
|
3134
|
-
throw new Error(
|
|
3135
|
-
`Failed to switch network: ${switchError.message || "Unknown error"}`
|
|
3136
|
-
);
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
3093
|
async function getCurrentChainId() {
|
|
3141
3094
|
if (typeof window === "undefined" || !window.ethereum) {
|
|
3142
3095
|
throw new Error("No wallet found");
|
|
@@ -3177,7 +3130,6 @@ exports.MpcConnectView = MpcConnectView;
|
|
|
3177
3130
|
exports.PasskeyEnrollView = PasskeyEnrollView;
|
|
3178
3131
|
exports.VolrUIProvider = VolrUIProvider;
|
|
3179
3132
|
exports.getCurrentChainId = getCurrentChainId;
|
|
3180
|
-
exports.switchNetwork = switchNetwork;
|
|
3181
3133
|
exports.useI18n = useI18n;
|
|
3182
3134
|
exports.useSwitchNetwork = useSwitchNetwork;
|
|
3183
3135
|
exports.useTranslation = useTranslation;
|