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

Support Onekey logo #326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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.
38 changes: 25 additions & 13 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,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);
},
},
{
Expand All @@ -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",
Expand All @@ -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) => {
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 @@ -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";
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