Skip to content

Commit

Permalink
feat: integrate Zerion
Browse files Browse the repository at this point in the history
  • Loading branch information
namgold committed Dec 4, 2023
1 parent 46da6d6 commit cdfb507
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/assets/wallets-connect/zerion.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/constants/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {

export const [injected, injectedHooks] = initializeConnector<MetaMask>(actions => new MetaMask({ actions }))
export const [rabby, rabbyHooks] = initializeConnector<MetaMask>(actions => new MetaMask({ actions }))
export const [zerion, zerionHooks] = initializeConnector<MetaMask>(actions => new MetaMask({ actions }))
export const [krystal, krystalHooks] = initializeConnector<MetaMask>(actions => new MetaMask({ actions }))
export const [metaMask, metamaskHooks] = initializeConnector<MetaMask>(actions => new MetaMask({ actions }))
export const [gnosisSafe, gnosisSafeHooks] = initializeConnector<GnosisSafe>(actions => new GnosisSafe({ actions }))
Expand Down
4 changes: 4 additions & 0 deletions src/constants/connectors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand All @@ -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())

Expand All @@ -79,6 +82,7 @@ export const getIsGenericInjector = () =>
!getIsRabbyWallet() &&
!getIsBloctoWallet() &&
!getIsKrystalWallet() &&
!getIsZerionWallet() &&
!getIsTrustWallet()

// https://eips.ethereum.org/EIPS/eip-1193#provider-errors
Expand Down
17 changes: 17 additions & 0 deletions src/constants/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -41,6 +42,8 @@ import {
trustHooks,
walletConnectV2,
walletConnectV2Hooks,
zerion,
zerionHooks,
} from 'constants/connectors'
import {
getIsBloctoWallet,
Expand All @@ -52,6 +55,7 @@ import {
getIsMetaMaskWallet,
getIsRabbyWallet,
getIsTrustWallet,
getIsZerionWallet,
} from 'constants/connectors/utils'

export enum WalletReadyState {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>
Expand Down

0 comments on commit cdfb507

Please sign in to comment.