solariskit 1.2.0 → 1.3.0

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.
@@ -2608,7 +2608,7 @@ function setRainbowKitVersion({ version }) {
2608
2608
  }
2609
2609
  function useFingerprint() {
2610
2610
  const fingerprint = useCallback(() => {
2611
- setRainbowKitVersion({ version: "1.2.0" });
2611
+ setRainbowKitVersion({ version: "1.3.0" });
2612
2612
  }, []);
2613
2613
  useEffect(() => {
2614
2614
  fingerprint();
@@ -2683,6 +2683,7 @@ function useWalletConnectors(mergeEIP6963WithRkConnectors = false) {
2683
2683
  const initialChainId = useInitialChainId();
2684
2684
  const selectedChainId = useChainId();
2685
2685
  const { mutateAsync: connect } = useConnect();
2686
+ const { mutateAsync: switchChain } = useSwitchChain();
2686
2687
  const defaultCreatedConnectors = useConnectors();
2687
2688
  const { setIsWalletConnectModalOpen } = useWalletConnectOpenState();
2688
2689
  const defaultConnectors = defaultCreatedConnectors.map((connector) => ({
@@ -2691,11 +2692,24 @@ function useWalletConnectors(mergeEIP6963WithRkConnectors = false) {
2691
2692
  }));
2692
2693
  async function connectWallet(connector, parameters) {
2693
2694
  const walletChainId = await connector.getChainId();
2694
- const result = await connect({
2695
+ const targetChainId = parameters?.chainId ?? selectedChainId ?? initialChainId ?? (isChainIdSupported(rainbowKitChains, walletChainId) ? walletChainId : void 0) ?? rainbowKitChains[0]?.id;
2696
+ let result = await connect({
2695
2697
  ...parameters,
2696
- chainId: parameters?.chainId ?? selectedChainId ?? initialChainId ?? (isChainIdSupported(rainbowKitChains, walletChainId) ? walletChainId : void 0) ?? rainbowKitChains[0]?.id,
2698
+ chainId: targetChainId,
2697
2699
  connector
2698
2700
  });
2701
+ if (targetChainId && connector.switchChain) {
2702
+ if (await connector.getChainId() !== targetChainId) {
2703
+ const chain = await switchChain({
2704
+ chainId: targetChainId,
2705
+ connector
2706
+ });
2707
+ result = {
2708
+ ...result,
2709
+ chainId: chain.id
2710
+ };
2711
+ }
2712
+ }
2699
2713
  if (result) addRecentWalletId(connector.id);
2700
2714
  return result;
2701
2715
  }
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { b as EmojiAvatar, c as ChainModal, f as RainbowKitProvider, l as AccountModal, n as ConnectButton, t as WalletButton, y as Avatar } from "../WalletButton-CsbqNc5l.js";
2
+ import { b as EmojiAvatar, c as ChainModal, f as RainbowKitProvider, l as AccountModal, n as ConnectButton, t as WalletButton, y as Avatar } from "../WalletButton-DpDL4qfh.js";
3
3
 
4
4
  //#region src/components/Avatar/emojiAvatarForAddress.ts
5
5
  const colors = [
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { S as createAuthenticationAdapter, _ as useTransactionStore, a as useConnectModal, d as dialogContentMobile, f as RainbowKitProvider, g as cssObjectFromTheme, h as cssStringFromTheme, i as useChainModal, m as baseTheme, n as ConnectButton, o as MobileOptions, p as lightTheme, r as useAccountModal, s as DesktopOptions, t as WalletButton, u as dialogContent, v as useChainId$1, x as RainbowKitAuthenticationProvider } from "./WalletButton-CsbqNc5l.js";
2
+ import { S as createAuthenticationAdapter, _ as useTransactionStore, a as useConnectModal, d as dialogContentMobile, f as RainbowKitProvider, g as cssObjectFromTheme, h as cssStringFromTheme, i as useChainModal, m as baseTheme, n as ConnectButton, o as MobileOptions, p as lightTheme, r as useAccountModal, s as DesktopOptions, t as WalletButton, u as dialogContent, v as useChainId$1, x as RainbowKitAuthenticationProvider } from "./WalletButton-DpDL4qfh.js";
3
3
  import { a as injectedWallet, i as getWalletConnectConnector, n as safeWallet, o as base, r as metaMaskWallet, t as walletConnectWallet } from "./walletConnectors-C02JPPxf.js";
4
4
  import { useCallback } from "react";
5
5
  import { createConfig, http, useConnection } from "wagmi";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solariskit",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "The best way to connect a wallet",
5
5
  "keywords": [
6
6
  "blockchain",