Skip to content

Commit

Permalink
update wallet configs, new web3 provider, fix cbw id, update useWalle…
Browse files Browse the repository at this point in the history
…t hook, update uri methods
  • Loading branch information
lochie committed Jan 16, 2024
1 parent 6d065fa commit 7a9ef60
Show file tree
Hide file tree
Showing 22 changed files with 458 additions and 452 deletions.
2 changes: 1 addition & 1 deletion packages/connectkit/src/components/BalanceButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const Balance: React.FC<BalanceProps> = ({ hideIcon, hideSymbol }) => {
</PulseContainer>
</span>
</Container>
) : chains.some((x) => x.id === chain?.id) ? (
) : Boolean(chain && !chains.some((x) => x.id !== chain?.id)) ? (
<Container>
{!hideIcon && <Chain id={chain?.id} />}
<span style={{ minWidth: 32 }}>???</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ const ChainSelector: React.FC = () => {
<Tooltip message={locales.chainNetwork} xOffset={-6} delay={0.01}>
<Chain
id={chain?.id}
unsupported={chains.some((x) => x.id === chain?.id)}
unsupported={Boolean(
chain && !chains.some((x) => x.id !== chain?.id)
)}
/>
</Tooltip>
) : (
<Chain
id={chain?.id}
unsupported={chains.some((x) => x.id === chain?.id)}
unsupported={Boolean(
chain && !chains.some((x) => x.id !== chain?.id)
)}
/>
)}
{!disabled && <ChevronDown style={{ top: 1, left: -3 }} />}
Expand Down
14 changes: 10 additions & 4 deletions packages/connectkit/src/components/Common/ConnectorList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ import { useWallets } from '../../../hooks/useWallets';
import { useInjectedWallet } from '../../../hooks/connectors/useInjectedWallet';
import { isInjectedConnector, isWalletConnectConnector } from '../../../utils';

import { useWalletConnectUri } from '../../../hooks/connectors/useWalletConnectUri';
import { useLastConnector } from '../../../hooks/useLastConnector';
import useIsMobile from '../../../hooks/useIsMobile';

import { ScrollArea } from '../../Common/ScrollArea';
import Alert from '../Alert';
import { useWeb3 } from '../../contexts/web3';

const ConnectorList = () => {
const context = useContext();
const isMobile = useIsMobile();

const { uri } = useWalletConnectUri();
const {
connect: { getUri },
} = useWeb3();
const uri = getUri();

const { lastConnectorId } = useLastConnector();
const injectedWallet = useInjectedWallet();

Expand Down Expand Up @@ -66,10 +70,12 @@ const ConnectorList = () => {
icon,
iconConnector,
connector,
createUri,
getWalletConnectDeeplink,
} = wallet;

let deeplink = isMobile ? createUri?.(uri ?? '') : undefined;
let deeplink = isMobile
? getWalletConnectDeeplink?.(uri ?? '')
: undefined;

const redirectToMoreWallets =
isMobile && isWalletConnectConnector(id);
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/src/components/Common/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ const Modal: React.FC<ModalProps> = ({
function shouldUseQrcode() {
if (!wallet) return false; // Fail states are shown in the injector flow

const useInjector = !wallet.createUri || wallet.isInstalled;
const useInjector = !wallet.getWalletConnectDeeplink || wallet.isInstalled;
return !useInjector;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/connectkit/src/components/ConnectButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const ConnectButtonRenderer: React.FC<ConnectButtonRendererProps> = ({
show,
hide,
chain: chain,
unsupported: !!chains.some((x) => x.id === chain?.id),
unsupported: Boolean(chain && !chains.some((x) => x.id !== chain?.id)),
isConnected: !!address,
isConnecting: open, // Using `open` to determine if connecting as wagmi isConnecting only is set to true when an active connector is awaiting connection
address: address,
Expand Down Expand Up @@ -214,7 +214,7 @@ function ConnectKitButtonInner({
<AuthIcon />
</motion.div>
)}
{chains.some((x) => x.id === chain?.id) && (
{Boolean(chain && !chains.some((x) => x.id !== chain?.id)) && (
<UnsupportedNetworkContainer
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
Expand Down Expand Up @@ -347,7 +347,7 @@ export function ConnectKitButton({
if (!isMounted) return null;

const shouldShowBalance =
showBalance && !chains.some((x) => x.id === chain?.id);
showBalance && Boolean(chain && !chains.some((x) => x.id !== chain?.id));
const willShowBalance = address && shouldShowBalance;

return (
Expand Down
Loading

0 comments on commit 7a9ef60

Please sign in to comment.