Skip to content

Commit

Permalink
feat: remove uniswap wallet and fix coinbase wallet (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfolch-redeemeum authored Jan 24, 2024
1 parent c324e61 commit df9bbaa
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 80 deletions.
102 changes: 51 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"dependencies": {
"@apollo/client": "^3.8.1",
"@bosonprotocol/chat-sdk": "^1.3.1-alpha.9",
"@bosonprotocol/react-kit": "^0.25.0-alpha.2",
"@bosonprotocol/react-kit": "^0.25.0-alpha.4",
"@davatar/react": "^1.10.4",
"@ethersproject/address": "^5.6.1",
"@ethersproject/units": "^5.6.1",
Expand Down
9 changes: 8 additions & 1 deletion src/components/header/accountDrawer/AuthenticatedHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const IconHoverText = styled.span`
const IconContainer = styled.div`
display: flex;
align-items: center;
justify-content: flex-end;
& > a,
& > button {
margin-right: 8px;
Expand Down Expand Up @@ -144,6 +145,12 @@ const PortfolioDrawerContainer = styled(Column)`
flex: 1;
`;

const StyledIconWithConfirmTextButton = styled(IconWithConfirmTextButton)`
* {
font-size: 0.7rem;
}
`;

export function PortfolioArrow({
change,
...rest
Expand Down Expand Up @@ -247,7 +254,7 @@ export default function AuthenticatedHeader({ account }: { account: string }) {
)}
</StatusWrapper>
<IconContainer>
<IconWithConfirmTextButton
<StyledIconWithConfirmTextButton
data-testid="wallet-disconnect"
onConfirm={() => disconnect({ isUserDisconnecting: true })}
Icon={SignOut}
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/web3Provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Updater() {
const [, addConnectedWallet] = useConnectedWallets();
useEffect(() => {
if (account && account !== previousAccount) {
const walletType = getConnection(connector).getName();
const walletType = getConnection(connector)?.getName() ?? "";

addConnectedWallet({ account, walletType });
}
Expand Down
1 change: 1 addition & 0 deletions src/components/header/web3Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const Web3StatusGeneric = styled.button`
const breakpointWhenConnectButtonOverflows = "1300px";
const Web3StatusConnected = styled(Web3StatusGeneric)<{ $color: string }>`
border: 2px solid transparent;
width: auto;
font-weight: 500;
color: ${({ $color }) => $color};
&:hover,
Expand Down
28 changes: 4 additions & 24 deletions src/lib/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Actions, Connector } from "@web3-react/types";
import GNOSIS_ICON from "assets/images/gnosis.png";
import UNISWAP_LOGO from "assets/svg/logo.svg";
import COINBASE_ICON from "assets/wallets/coinbase-icon.svg";
import UNIWALLET_ICON from "assets/wallets/uniswap-wallet-icon.png";
import WALLET_CONNECT_ICON from "assets/wallets/walletconnect-icon.svg";
import {
CONFIG,
Expand All @@ -18,18 +17,15 @@ import {
import { useSyncExternalStore } from "react";

import { RPC_PROVIDERS } from "../constants/providers";
import { isMobile, isNonIOSPhone } from "../utils/userAgent";
import { isMobile } from "../utils/userAgent";
import { Connection, ConnectionType } from "./types";
import {
getInjection,
getIsCoinbaseWallet,
getIsInjected,
getIsMetaMaskWallet
} from "./utils";
import {
UniwalletConnect as UniwalletWCV2Connect,
WalletConnectV2
} from "./WalletConnectV2";
import { WalletConnectV2 } from "./WalletConnectV2";
const RPC_URLS = CONFIG.rpcUrls;

function onError(error: Error) {
Expand Down Expand Up @@ -170,19 +166,6 @@ export const walletConnectV2Connection: Connection = new (class
}
})();

const [web3WCV2UniwalletConnect, web3WCV2UniwalletConnectHooks] =
initializeConnector<UniwalletWCV2Connect>(
(actions) => new UniwalletWCV2Connect({ actions, onError })
);
export const uniwalletWCV2ConnectConnection: Connection = {
getName: () => "Uniswap Wallet",
connector: web3WCV2UniwalletConnect,
hooks: web3WCV2UniwalletConnectHooks,
type: ConnectionType.UNISWAP_WALLET_V2,
getIcon: () => UNIWALLET_ICON,
shouldDisplay: () => Boolean(!getIsInjectedMobileBrowser() && !isNonIOSPhone)
};

const [web3CoinbaseWallet, web3CoinbaseWalletHooks] =
initializeConnector<CoinbaseWallet>(
(actions) =>
Expand All @@ -197,7 +180,7 @@ const [web3CoinbaseWallet, web3CoinbaseWalletHooks] =
onError
})
);
const coinbaseWalletConnection: Connection = {
export const coinbaseWalletConnection: Connection = {
getName: () => "Coinbase Wallet",
connector: web3CoinbaseWallet,
hooks: web3CoinbaseWalletHooks,
Expand All @@ -224,8 +207,7 @@ export const connections = [
gnosisSafeConnection,
walletConnectV2Connection,
coinbaseWalletConnection,
networkConnection,
uniwalletWCV2ConnectConnection
networkConnection
];

export function getConnection(c: Connector | ConnectionType) {
Expand All @@ -245,8 +227,6 @@ export function getConnection(c: Connector | ConnectionType) {
return coinbaseWalletConnection;
case ConnectionType.WALLET_CONNECT_V2:
return walletConnectV2Connection;
case ConnectionType.UNISWAP_WALLET_V2:
return uniwalletWCV2ConnectConnection;
case ConnectionType.NETWORK:
return networkConnection;
case ConnectionType.GNOSIS_SAFE:
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils/hooks/useSwitchChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { useAppDispatch } from "state/hooks";
import { endSwitchingChain, startSwitchingChain } from "state/wallets/reducer";

import {
coinbaseWalletConnection,
networkConnection,
uniwalletWCV2ConnectConnection,
walletConnectV2Connection
} from "../../connection";
import { getChainInfo } from "../../constants/chainInfo";
Expand Down Expand Up @@ -51,7 +51,7 @@ export function useSwitchChain(doConnect = true) {
if (
[
walletConnectV2Connection.connector,
uniwalletWCV2ConnectConnection.connector,
coinbaseWalletConnection.connector,
networkConnection.connector
].includes(connector)
) {
Expand Down

0 comments on commit df9bbaa

Please sign in to comment.