diff --git a/public/images/logos/fordefi-logo.svg b/public/images/logos/fordefi-logo.svg new file mode 100644 index 00000000..0b9e22af --- /dev/null +++ b/public/images/logos/fordefi-logo.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/app/components/modals/select-bitcoin-wallet-modal/select-bitcoin-wallet-modal.tsx b/src/app/components/modals/select-bitcoin-wallet-modal/select-bitcoin-wallet-modal.tsx index 7af33fc0..48991ca2 100644 --- a/src/app/components/modals/select-bitcoin-wallet-modal/select-bitcoin-wallet-modal.tsx +++ b/src/app/components/modals/select-bitcoin-wallet-modal/select-bitcoin-wallet-modal.tsx @@ -47,6 +47,19 @@ export function SelectBitcoinWalletModal({ }); } break; + case BitcoinWalletType.Fordefi: + try { + await connectUnisatWallet(true); + } catch (error: any) { + toast({ + title: 'Failed to connect to Unisat Wallet', + description: error.message, + status: 'error', + duration: 9000, + isClosable: true, + }); + } + break; case BitcoinWalletType.Ledger: dispatch(modalActions.toggleLedgerModalVisibility()); break; diff --git a/src/app/hooks/use-psbt.ts b/src/app/hooks/use-psbt.ts index 745aa1bd..e7cfd4bd 100644 --- a/src/app/hooks/use-psbt.ts +++ b/src/app/hooks/use-psbt.ts @@ -232,6 +232,7 @@ export function usePSBT(): UsePSBTReturnType { [BitcoinWalletType.Ledger]: isLedgerLoading, [BitcoinWalletType.Leather]: isLeatherLoading, [BitcoinWalletType.Unisat]: isUnisatLoading, + [BitcoinWalletType.Fordefi]: isUnisatLoading, }; return { diff --git a/src/app/hooks/use-unisat.ts b/src/app/hooks/use-unisat.ts index 1b1a17fc..3cf6c13f 100644 --- a/src/app/hooks/use-unisat.ts +++ b/src/app/hooks/use-unisat.ts @@ -21,7 +21,7 @@ import { shiftValue } from 'dlc-btc-lib/utilities'; import { BITCOIN_NETWORK_MAP } from '@shared/constants/bitcoin.constants'; interface UseUnisatReturnType { - connectUnisatWallet: () => Promise; + connectUnisatWallet: (isFordefi?: boolean) => Promise; handleFundingTransaction: ( dlcHandler: SoftwareWalletDLCHandler, vault: RawVault, @@ -131,10 +131,16 @@ export function useUnisat(): UseUnisatReturnType { * * @returns A promise that resolves to the user's taproot address. */ - async function getBitcoinAddresses(): Promise { + async function getBitcoinAddresses(isFordefi: boolean = false): Promise { try { if (!window.unisat) { - throw new UnisatError('Unisat Wallet is not installed'); + throw new UnisatError( + isFordefi ? 'Fordefi Wallet is Not Installed' : 'Unisat Wallet is Not Installed' + ); + } else if (isFordefi && !window?.unisat?.is_fordefi) { + throw new UnisatError('Please disable Unisat Wallet and enable Fordefi Wallet'); + } else if (!isFordefi && window?.unisat?.is_fordefi) { + throw new UnisatError('Please disable Fordefi Wallet and enable Unisat Wallet'); } const userAddresses: string[] = await window.unisat.requestAccounts(); @@ -159,11 +165,11 @@ export function useUnisat(): UseUnisatReturnType { * * @returns A promise that resolves to the User's Taproot Address. */ - async function connectUnisatWallet(): Promise { + async function connectUnisatWallet(isFordefi: boolean = false): Promise { try { setIsLoading([true, 'Connecting To Unisat Wallet']); - const taprootAccount = await getBitcoinAddresses(); + const taprootAccount = await getBitcoinAddresses(isFordefi); const unisatDLCHandler = new SoftwareWalletDLCHandler( taprootAccount.publicKey, diff --git a/src/shared/models/wallet.ts b/src/shared/models/wallet.ts index 31189491..2b7fbb1f 100644 --- a/src/shared/models/wallet.ts +++ b/src/shared/models/wallet.ts @@ -2,6 +2,7 @@ export enum BitcoinWalletType { Leather = 'Leather', Ledger = 'Ledger', Unisat = 'Unisat', + Fordefi = 'Fordefi', } export interface BitcoinWallet { @@ -28,4 +29,10 @@ const unisat: BitcoinWallet = { logo: '/images/logos/unisat-logo.svg', }; -export const bitcoinWallets: BitcoinWallet[] = [leather, ledger, unisat]; +const fordefi: BitcoinWallet = { + id: BitcoinWalletType.Fordefi, + name: 'Fordefi', + logo: '/images/logos/fordefi-logo.svg', +}; + +export const bitcoinWallets: BitcoinWallet[] = [leather, ledger, unisat, fordefi];