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

wallets order #2200

Merged
merged 4 commits into from
Aug 30, 2023
Merged
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
17 changes: 11 additions & 6 deletions src/components/Header/web3/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,17 @@ export default function WalletModal() {
}
})

const sortWallets = (walletA: WalletInfoExtended, walletB: WalletInfoExtended): -1 | 0 | 1 => {
if (!walletA.installLink && !walletA.isOverridden && !walletB.installLink && !walletB.isOverridden) {
return walletA.name < walletB.name ? -1 : 1
}
if (walletA.installLink || walletA.isOverridden) return 1
return -1
const sortPoint: { [readyState in WalletReadyState]: number } = {
[WalletReadyState.Installed]: 1000,
[WalletReadyState.Loadable]: 100,
[WalletReadyState.NotDetected]: 10,
[WalletReadyState.Unsupported]: 1,
}
const sortWallets = (walletA: WalletInfoExtended, walletB: WalletInfoExtended): number => {
return (
sortPoint[walletB.readyState || WalletReadyState.Unsupported] -
sortPoint[walletA.readyState || WalletReadyState.Unsupported]
)
}
return (
parsedWalletList
Expand Down
87 changes: 42 additions & 45 deletions src/constants/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export const SUPPORTED_WALLETS = {
name: 'Browser Wallet',
icon: INJECTED_DARK_ICON,
iconLight: INJECTED_LIGHT_ICON,
installLink: 'https://metamask.io/download',
readyState: detectInjected,
} as EVMWalletInfo,
METAMASK: {
Expand All @@ -179,32 +178,14 @@ export const SUPPORTED_WALLETS = {
installLink: 'https://metamask.io/download',
readyState: detectMetamask,
} as EVMWalletInfo,
BLOCTO: {
connector: blocto,
hooks: bloctoHooks,
name: 'Blocto',
icon: BLOCTO,
iconLight: BLOCTO,
installLink: 'https://www.blocto.io/download',
readyState: detectBlocto,
} as EVMWalletInfo,
BLOCTO_INJECTED: {
connector: bloctoInject,
hooks: bloctoInjectHooks,
name: 'Blocto',
icon: BLOCTO,
iconLight: BLOCTO,
installLink: 'https://www.blocto.io/download',
readyState: detectBloctoInjected,
} as EVMWalletInfo,
SAFE: {
connector: gnosisSafe,
hooks: gnosisSafeHooks,
name: 'Safe',
icon: SAFE,
iconLight: SAFE,
installLink: 'https://safe.global/wallet',
readyState: detectSafe,
KRYSTAL: {
connector: krystal,
hooks: krystalHooks,
name: 'Krystal',
icon: KRYSTAL,
iconLight: KRYSTAL,
installLink: 'https://wallet.krystal.app',
readyState: detectKrystal,
} as EVMWalletInfo,
RABBY: {
connector: rabby,
Expand All @@ -215,14 +196,14 @@ export const SUPPORTED_WALLETS = {
installLink: 'https://rabby.io',
readyState: detectRabby,
} as EVMWalletInfo,
KRYSTAL: {
connector: krystal,
hooks: krystalHooks,
name: 'Krystal',
icon: KRYSTAL,
iconLight: KRYSTAL,
installLink: 'https://wallet.krystal.app',
readyState: detectKrystal,
TRUST_WALLET: {
connector: trust,
hooks: trustHooks,
name: 'Trust Wallet',
icon: TRUSTWALLET,
iconLight: TRUSTWALLET,
installLink: 'https://trustwallet.com/vi/deeplink',
readyState: detectTrustWallet,
} as EVMWalletInfo,
BRAVE: {
connector: brave,
Expand Down Expand Up @@ -264,9 +245,34 @@ export const SUPPORTED_WALLETS = {
name: 'WalletConnect',
icon: WALLETCONNECT,
iconLight: WALLETCONNECT,
installLink: 'https://walletconnect.com/',
readyState: () => WalletReadyState.Installed,
} as EVMWalletInfo,
SAFE: {
connector: gnosisSafe,
hooks: gnosisSafeHooks,
name: 'Safe',
icon: SAFE,
iconLight: SAFE,
installLink: 'https://safe.global/wallet',
readyState: detectSafe,
} as EVMWalletInfo,
BLOCTO: {
connector: blocto,
hooks: bloctoHooks,
name: 'Blocto',
icon: BLOCTO,
iconLight: BLOCTO,
installLink: 'https://www.blocto.io/download',
readyState: detectBlocto,
} as EVMWalletInfo,
BLOCTO_INJECTED: {
connector: bloctoInject,
hooks: bloctoInjectHooks,
name: 'Blocto',
icon: BLOCTO,
iconLight: BLOCTO,
readyState: detectBloctoInjected,
} as EVMWalletInfo,
SOLFLARE: {
adapter: solflareAdapter,
name: 'Solflare',
Expand All @@ -291,15 +297,6 @@ export const SUPPORTED_WALLETS = {
installLink: slopeAdapter.url,
readyStateSolana: () => (isMobile ? WalletReadyState.Unsupported : slopeAdapter.readyState),
} as SolanaWalletInfo,
TRUST_WALLET: {
connector: trust,
hooks: trustHooks,
name: 'Trust Wallet',
icon: TRUSTWALLET,
iconLight: TRUSTWALLET,
installLink: 'https://trustwallet.com/vi/deeplink',
readyState: detectTrustWallet,
} as EVMWalletInfo,
} as const
export type SUPPORTED_WALLET = keyof typeof SUPPORTED_WALLETS

Expand Down
Loading