-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ordering wallet & move functions to utils
- Loading branch information
Showing
4 changed files
with
57 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useEffect, useState } from "react"; | ||
import { WalletProvider } from "get-starknet-core"; | ||
import { getBrowser } from "../utils/browserService"; | ||
|
||
export default function useGetDiscoveryWallets( | ||
getDiscoveryWallets: Promise<WalletProvider[]> | ||
) { | ||
const [argentX, setArgentX] = useState<string>(""); | ||
const [braavos, setBraavos] = useState<string>(""); | ||
|
||
useEffect(() => { | ||
if (typeof navigator !== "undefined") { | ||
getDiscoveryWallets.then((wallets) => { | ||
const browser = getBrowser(navigator.userAgent); | ||
|
||
wallets.map((wallet) => { | ||
if (wallet.id === "argentX") { | ||
setArgentX( | ||
browser | ||
? wallet.downloads[browser as keyof typeof wallet.downloads] | ||
: "https://www.argent.xyz/argent-x/" | ||
); | ||
} else if (wallet.id === "braavos") { | ||
setBraavos( | ||
browser | ||
? wallet.downloads[browser as keyof typeof wallet.downloads] | ||
: "https://braavos.app/download-braavos-wallet/" | ||
); | ||
} | ||
}); | ||
}); | ||
} | ||
}, [getDiscoveryWallets]); | ||
|
||
return { argentX, braavos }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function getBrowser(userAgent: string): string | undefined { | ||
if (userAgent.includes("Chrome")) { | ||
return "chrome"; | ||
} else if (userAgent.includes("Firefox")) { | ||
return "firefox"; | ||
} else { | ||
return undefined; | ||
} | ||
} |