From cdfb507e068297b40e930d6df7a4718dae9cfc1b Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Tue, 5 Dec 2023 00:46:12 +0700 Subject: [PATCH] feat: integrate Zerion --- src/assets/wallets-connect/zerion.svg | 11 +++++++++++ src/constants/connectors/index.ts | 1 + src/constants/connectors/utils.ts | 4 ++++ src/constants/wallets.ts | 17 +++++++++++++++++ src/react-app-env.d.ts | 1 + 5 files changed, 34 insertions(+) create mode 100644 src/assets/wallets-connect/zerion.svg diff --git a/src/assets/wallets-connect/zerion.svg b/src/assets/wallets-connect/zerion.svg new file mode 100644 index 0000000000..0850d091f3 --- /dev/null +++ b/src/assets/wallets-connect/zerion.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/constants/connectors/index.ts b/src/constants/connectors/index.ts index ab117f50de..2db3c025e8 100644 --- a/src/constants/connectors/index.ts +++ b/src/constants/connectors/index.ts @@ -20,6 +20,7 @@ import { export const [injected, injectedHooks] = initializeConnector(actions => new MetaMask({ actions })) export const [rabby, rabbyHooks] = initializeConnector(actions => new MetaMask({ actions })) +export const [zerion, zerionHooks] = initializeConnector(actions => new MetaMask({ actions })) export const [krystal, krystalHooks] = initializeConnector(actions => new MetaMask({ actions })) export const [metaMask, metamaskHooks] = initializeConnector(actions => new MetaMask({ actions })) export const [gnosisSafe, gnosisSafeHooks] = initializeConnector(actions => new GnosisSafe({ actions })) diff --git a/src/constants/connectors/utils.ts b/src/constants/connectors/utils.ts index 9a15423737..c484bc2b9c 100644 --- a/src/constants/connectors/utils.ts +++ b/src/constants/connectors/utils.ts @@ -47,6 +47,7 @@ const allNonMetamaskFlags = [ 'isKrystalWallet', 'isPhantom', 'isBlocto', + 'isZerion', ] as const export const getIsMetaMaskWallet = () => Boolean(window.ethereum?.isMetaMask && !allNonMetamaskFlags.some(flag => window.ethereum?.[flag])) @@ -67,6 +68,8 @@ export const getIsBloctoWallet = () => Boolean(window.ethereum?.isBlocto) export const getIsC98Wallet = () => Boolean(window.ethereum?.isCoin98 && window.coin98) +export const getIsZerionWallet = () => Boolean(window.ethereum?.isZerion) + export const getIsTrustWallet = () => Boolean((window.ethereum?.isTrustWallet || window.ethereum?.isTrust) && !getIsKrystalWallet()) @@ -79,6 +82,7 @@ export const getIsGenericInjector = () => !getIsRabbyWallet() && !getIsBloctoWallet() && !getIsKrystalWallet() && + !getIsZerionWallet() && !getIsTrustWallet() // https://eips.ethereum.org/EIPS/eip-1193#provider-errors diff --git a/src/constants/wallets.ts b/src/constants/wallets.ts index 1f414475ee..72cb991e76 100644 --- a/src/constants/wallets.ts +++ b/src/constants/wallets.ts @@ -13,6 +13,7 @@ import RABBY from 'assets/wallets-connect/rabby.svg' import SAFE from 'assets/wallets-connect/safe.svg' import TRUSTWALLET from 'assets/wallets-connect/trust-wallet.svg' import WALLETCONNECT from 'assets/wallets-connect/wallet-connect.svg' +import ZERION from 'assets/wallets-connect/zerion.svg' import INJECTED_DARK_ICON from 'assets/wallets/browser-wallet-dark.svg' import { blocto, @@ -41,6 +42,8 @@ import { trustHooks, walletConnectV2, walletConnectV2Hooks, + zerion, + zerionHooks, } from 'constants/connectors' import { getIsBloctoWallet, @@ -52,6 +55,7 @@ import { getIsMetaMaskWallet, getIsRabbyWallet, getIsTrustWallet, + getIsZerionWallet, } from 'constants/connectors/utils' export enum WalletReadyState { @@ -112,6 +116,11 @@ const detectRabbyInjected = (): WalletReadyState => { return WalletReadyState.NotDetected } +const detectZerionInjected = (): WalletReadyState => { + if (getIsZerionWallet()) return WalletReadyState.Installed + return WalletReadyState.NotDetected +} + const detectKrystalInjected = (): WalletReadyState => { if (getIsKrystalWallet()) return WalletReadyState.Installed return WalletReadyState.Unsupported @@ -191,6 +200,14 @@ export const SUPPORTED_WALLETS = { installLink: 'https://rabby.io', readyState: detectRabbyInjected, } as WalletInfo, + ZERION: { + connector: zerion, + hooks: zerionHooks, + name: 'Zerion', + icon: ZERION, + installLink: 'https://zerion.io', + readyState: detectZerionInjected, + } as WalletInfo, TRUST_WALLET: { connector: trust, hooks: trustHooks, diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index e08f52ae64..30154b5816 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -19,6 +19,7 @@ interface Window { isLedgerConnect?: boolean isKrystal?: boolean isKrystalWallet?: boolean + isZerion?: boolean on?: (...args: any[]) => void removeListener?: (...args: any[]) => void request: (params: { method: string; params?: any }) => Promise