Skip to content

Commit

Permalink
Support Onekey logo
Browse files Browse the repository at this point in the history
  • Loading branch information
habibitcoin committed Dec 21, 2023
1 parent 679d112 commit f6c000d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Binary file added public/images/logo/onekey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions src/components/modals/connect-wallet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -13,10 +14,18 @@ const ConnectWallet = ({ callback }) => {
onHideConnectModal,
} = useWallet();

let metaMaskName = "MetaMask";
let metaMaskLogo = "/images/logo/metamask.png";

if (LocalStorage.get(LocalStorageKeys.ONEKEY_WALLET)) {
metaMaskName = "OneKey";
metaMaskLogo = "/images/logo/onekey.png";
}

const wallets = [
{
name: "MetaMask",
image: "/images/logo/metamask.png",
name: metaMaskName,
image: metaMaskLogo,
ethereum: true,

onClick: () => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/user-dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -21,6 +22,9 @@ const UserDropdown = () => {
const domain = SessionStorage.get(SessionsStorageKeys.DOMAIN);
switch (domain) {
case "nosft.xyz":
if (LocalStorage.get(LocalStorageKeys.ONEKEY_WALLET)) {
return "/images/logo/onekey.png";
}
return "/images/logo/metamask.png";
case "ordswap.io":
return "/images/logo/ordswap.svg";
Expand Down
7 changes: 6 additions & 1 deletion src/services/local-storage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const LocalStorageKeys = {
INSCRIPTIONS_OUTPOINT: "INSCRIPTION_OUTPOINT",
COLLECTION_INFO: "COLLECTION_INFO",
ONEKEY_WALLET: "onekey_wallet_info_local_key",
};

const LocalStorage = {
Expand Down Expand Up @@ -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);
}
});
},
};

Expand Down

0 comments on commit f6c000d

Please sign in to comment.