diff --git a/public/images/logo/onekey.png b/public/images/logo/onekey.png new file mode 100644 index 00000000..55c86d95 Binary files /dev/null and b/public/images/logo/onekey.png differ diff --git a/src/components/modals/connect-wallet/index.js b/src/components/modals/connect-wallet/index.js index 501c5a20..8652e9a9 100644 --- a/src/components/modals/connect-wallet/index.js +++ b/src/components/modals/connect-wallet/index.js @@ -3,6 +3,7 @@ import PropTypes from "prop-types"; import Modal from "react-bootstrap/Modal"; import Image from "next/image"; import { useWallet } from "@context/wallet-context"; +import LocalStorage, { LocalStorageKeys } from "@services/local-storage"; // Gets the callback function from the parent component to notify when the wallet get's connecteds const ConnectWallet = ({ callback }) => { @@ -13,14 +14,22 @@ const ConnectWallet = ({ callback }) => { onHideConnectModal, } = useWallet(); + let uniSatName = "UniSat"; + let uniSatLogo = "/images/logo/unisat.png"; + const oneKeyWalletExists = LocalStorage.get(LocalStorageKeys.ONEKEY_WALLET); + + if (oneKeyWalletExists) { + uniSatName = "OneKey"; + uniSatLogo = "/images/logo/onekey.png"; + } + const wallets = [ { - name: "MetaMask", - image: "/images/logo/metamask.png", - ethereum: true, - + name: uniSatName, + image: uniSatLogo, + provider: "unisat", onClick: () => { - onConnect("nosft.xyz", callback); + onConnect("unisat.io", callback); }, }, { @@ -41,14 +50,6 @@ const ConnectWallet = ({ callback }) => { onConnect("generative.xyz", callback); }, }, - { - name: "UniSat", - image: "/images/logo/unisat.png", - provider: "unisat", - onClick: () => { - onConnect("unisat.io", callback); - }, - }, { name: "Alby", image: "/images/logo/alby.svg", @@ -67,6 +68,17 @@ const ConnectWallet = ({ callback }) => { }, ]; + if (!oneKeyWalletExists) { + wallets.unshift({ + name: "MetaMask", + image: "/images/logo/metamask.png", + ethereum: true, + onClick: () => { + onConnect("nosft.xyz", callback); + }, + }); + } + const getWallets = () => { const activeWallets = []; wallets.forEach((wallet) => { diff --git a/src/components/user-dropdown/index.js b/src/components/user-dropdown/index.js index c12bd275..a9221a3c 100644 --- a/src/components/user-dropdown/index.js +++ b/src/components/user-dropdown/index.js @@ -3,6 +3,7 @@ import Anchor from "@ui/anchor"; import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import SessionStorage, { SessionsStorageKeys } from "@services/session-storage"; +import LocalStorage, { LocalStorageKeys } from "@services/local-storage"; import { useMemo } from "react"; import { useWallet } from "@context/wallet-context"; import { useRouter } from "next/router"; @@ -27,6 +28,9 @@ const UserDropdown = () => { case "generative.xyz": return "/images/logo/generative.png"; case "unisat.io": + if (LocalStorage.get(LocalStorageKeys.ONEKEY_WALLET)) { + return "/images/logo/onekey.png"; + } return "/images/logo/unisat.png"; default: return "/images/logo/alby.png"; diff --git a/src/services/local-storage.js b/src/services/local-storage.js index 01dbdaf6..606e6da9 100644 --- a/src/services/local-storage.js +++ b/src/services/local-storage.js @@ -1,6 +1,7 @@ const LocalStorageKeys = { INSCRIPTIONS_OUTPOINT: "INSCRIPTION_OUTPOINT", COLLECTION_INFO: "COLLECTION_INFO", + ONEKEY_WALLET: "onekey_wallet_info_local_key", }; const LocalStorage = { @@ -37,7 +38,11 @@ const LocalStorage = { return undefined; } - return window.localStorage.clear(); + return Object.keys(window.localStorage).forEach(key => { + if (key !== "onekey_wallet_info_local_key") { + window.localStorage.removeItem(key); + } + }); }, };