Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add XDEFI Wallet option #1998

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/icons/wallets/xdefi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/components/WalletConnection/WalletSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ const WalletRow = ({ walletName, walletType }: WalletRowProps) => {
alt={`browser wallet icon`}
/>
);
case WalletType.XDEFI:
return (
<img
src={`/icons/wallets/xdefi.svg`}
width="24px"
height="24px"
alt={`xdefi wallet icon`}
/>
);
// case WalletType.FRAME:
// return (
// <img
Expand Down Expand Up @@ -219,6 +228,12 @@ export const WalletSelector = () => {
walletName="Coinbase Wallet"
walletType={WalletType.WALLET_LINK}
/>
{
// @ts-expect-error ethereum doesn't necessarily exist
window.ethereum._XDEFI && (
<WalletRow key="xdefi_wallet" walletName="XDEFI Wallet" walletType={WalletType.XDEFI} />
)
}
<WalletRow key="torus_wallet" walletName="Torus" walletType={WalletType.TORUS} />
{/* <WalletRow key="frame_wallet" walletName="Frame" walletType={WalletType.FRAME} /> */}
<Box sx={{ display: 'flex', alignItems: 'center', mb: 1, padding: '10px 0' }}>
Expand Down
2 changes: 2 additions & 0 deletions src/libs/web3-data-provider/WalletOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum WalletType {
GNOSIS = 'gnosis',
LEDGER = 'ledger',
READ_ONLY_MODE = 'read_only_mode',
XDEFI = 'xdefi_wallet',
}

const APP_NAME = 'Aave';
Expand Down Expand Up @@ -83,6 +84,7 @@ export const getWallet = (
// case WalletType.LEDGER:
// return new LedgerHQFrameConnector({});
case WalletType.INJECTED:
case WalletType.XDEFI:
return new InjectedConnector({});
case WalletType.WALLET_LINK:
const networkConfig = getNetworkConfig(chainId);
Expand Down
6 changes: 5 additions & 1 deletion src/libs/web3-data-provider/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
await activateFn(connector, 1);
};

const activateInjectedProvider = (providerName: string | 'MetaMask' | 'CoinBase') => {
const activateInjectedProvider = (providerName: string | 'MetaMask' | 'CoinBase' | 'XDEFI') => {
// @ts-expect-error ethereum doesn't necessarily exist
const { ethereum } = window;

Expand All @@ -232,6 +232,10 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil
//@ts-expect-error no type
provider = ethereum.providers.find(({ isMetaMask }) => isMetaMask);
break;
case 'XDEFI':
//@ts-expect-error no type
provider = ethereum.providers.find(({ _XDEFI }) => _XDEFI);
break;
default:
return false;
}
Expand Down