Skip to content

FEAT: show mobile wallet connect button on mobile & add foxwalletApp … #15

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

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
71 changes: 70 additions & 1 deletion src/components/layouts/HeaderDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ import util from '../../util/util'
import { isBraveBrowser } from '../../util/browserUtils'
import walletDispatchers from '../../util/walletsDispatchers'
import { onCopySuccess, onCopyError, isMobileEnv } from '../../util'
import {
COINBASE,
METAMASK,
BRAVE,
BLOCKWALLET,
TALLYHO,
IM_TOKEN_APP,
METAMASK_APP,
BIT_KEEP_APP,
COINBASE_APP,
FOXWALLET_APP,
} from '../../util/walletsDispatchers/constants'

const { walletDispatchersOnInit, walletDispatchersOnDisconnect } =
walletDispatchers
Expand Down Expand Up @@ -167,36 +179,93 @@ export default {
return walletIsLogin.value
},
loginData() {
if (this.isMobile) {
if (check.checkIsFoxWallet()) {
return [
{
isConnect: false,
icon: "foxwalletapp",
title: "FoxWallet",
type: FOXWALLET_APP,
}
]
}
if (check.checkIsImToken()) {
return [
{
isConnect: false,
icon: "imtokenapp",
title: "imToken",
type: IM_TOKEN_APP,
}
]
}
if (check.checkIsBitKeep()) {
return [
{
isConnect: false,
icon: "bitkeepapp",
title: "BitKeep",
type: BIT_KEEP_APP,
}
]
}
if (check.checkIsCoinBaseApp()) {
return [
{
isConnect: false,
icon: "coinbase",
title: "Coinbase",
type: COINBASE_APP,
}
]
}
return [
{
isConnect: false,
icon: 'metamask',
title: 'MetaMask',
type: METAMASK_APP,
}
]
}

const wallets = [
{
isConnect: walletIsLogin.value && check.checkIsMetaMask(),
icon: 'metamask',
title: 'MetaMask',
type: METAMASK,
},
{
isConnect: false,
icon: 'tallyho',
title: 'TallyHo',
type: TALLYHO,
},
{
isConnect: false,
icon: 'blockwallet',
title: 'BlockWallet',
type: BLOCKWALLET,
},
{
isConnect: false,
icon: 'walletConnect',
title: 'WalletConnect',
type: WALLETCONNECT,
},
{
isConnect: false,
icon: 'coinbase',
title: 'Coinbase',
type: COINBASE,
},
{
isConnect: false,
icon: 'brave',
title: 'Brave',
type: BRAVE,
},
]
// the brave wallet is exclusive to the brave browser
Expand Down Expand Up @@ -278,7 +347,7 @@ export default {
},
connectWallet(walletConf) {
this.closeSelectWalletDialog()
walletDispatchersOnInit[walletConf.title]()
walletDispatchersOnInit[walletConf.type]()
},
checkIsMobileEnv() {
return isMobileEnv()
Expand Down
4 changes: 4 additions & 0 deletions src/icons/svg/bitkeepapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions src/icons/svg/foxwalletapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/icons/svg/imtokenapp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/util/check/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export default {
}
return false
},
checkIsFoxWallet: function () {
if (compatibleGlobalWalletConf.value.walletPayload.provider) {
if (compatibleGlobalWalletConf.value.walletPayload.provider.isFoxWallet) {
return true
}
}
return false
},
checkIsMetaMask: function () {
if (compatibleGlobalWalletConf.value.walletPayload.provider) {
if (compatibleGlobalWalletConf.value.walletPayload.provider.isMetaMask) {
Expand All @@ -59,4 +67,16 @@ export default {
}
return false
},
checkIsCoinBaseApp: function () {
if (compatibleGlobalWalletConf.value.walletPayload.provider) {
if (
compatibleGlobalWalletConf.value.walletPayload.provider
.isCoinbaseBrowser &&
compatibleGlobalWalletConf.value.walletPayload.provider.isCoinbaseWallet
) {
return true
}
}
return false
},
}
1 change: 1 addition & 0 deletions src/util/walletsDispatchers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export const IM_TOKEN_APP = 'imTokenApp' // imToken app name
export const BIT_KEEP_APP = 'bitKeepApp' // bitKeep app name
export const COINBASE_APP = 'coinbaseApp' // coinbase app name
export const METAMASK_APP = 'metamaskApp' // metamask app name
export const FOXWALLET_APP = 'foxWalletApp' // fox wallet app name
export const TOKEN_POCKET_APP = 'tokenPocketApp' // token pocket app name
export const LOCALLOGINDATA = 'localLoginData' // mainly used in localStorage for store the information if any wallets have been logged in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IM_TOKEN_APP,
BIT_KEEP_APP,
COINBASE_APP,
FOXWALLET_APP,
} from '../constants'

// open ./pcBrowser/standardPCBrowserWalletConf to get the meaning of each prop member
Expand All @@ -15,6 +16,11 @@ const standardMobileAppConf = [
walletIsInstalledInvestigator: (provider) => provider.isImToken,
chainIdTransfer: defaultChainIdTransfer,
},
{
walletType: FOXWALLET_APP,
walletIsInstalledInvestigator: (provider) => provider.isFoxWallet,
chainIdTransfer: defaultChainIdTransfer,
},
{
walletType: METAMASK_APP,
walletIsInstalledInvestigator: (provider) =>
Expand Down
3 changes: 3 additions & 0 deletions src/util/walletsDispatchers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TOKEN_POCKET_APP,
BIT_KEEP_APP,
COINBASE_APP,
FOXWALLET_APP,
} from './constants'
import {
updateGlobalSelectWalletConf,
Expand Down Expand Up @@ -55,6 +56,7 @@ export const ethereumWalletTypeFitChecker = (walletType, ethereum) => {
if (walletType === TALLYHO) return ethereum.isTally
if (walletType === COINBASE) return ethereum.isCoinbaseWallet
if (walletType === BRAVE) return ethereum.isBraveWallet
if (walletType === FOXWALLET_APP) return ethereum.isFoxWallet
if (walletType === IM_TOKEN_APP) return ethereum.isImToken
if (walletType === METAMASK_APP) return ethereum.isMetaMask
if (walletType === TOKEN_POCKET_APP) return ethereum.isTokenPocket
Expand Down Expand Up @@ -115,6 +117,7 @@ export const fetchTargetWalletLoginStatus = ({ walletType }) => {
export const getMobileAppTypeByProvider = () => {
const provider = window.ethereum
if (provider.isImToken) return IM_TOKEN_APP
if (provider.isFoxWallet) return FOXWALLET_APP
if (provider.isTokenPocket) return TOKEN_POCKET_APP
if (provider.isMetaMask && !provider.isTokenPocket) return METAMASK_APP
if ('isBitKeepChrome' in provider) return BIT_KEEP_APP
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4701,16 +4701,11 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001358:
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001358, caniuse-lite@^1.0.30001458:
version "1.0.30001458"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz"
integrity sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==

caniuse-lite@^1.0.30001458:
version "1.0.30001458"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz#871e35866b4654a7d25eccca86864f411825540c"
integrity sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==

case-sensitive-paths-webpack-plugin@^2.3.0:
version "2.4.0"
resolved "https://registry.npmmirror.com/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.4.0.tgz#db64066c6422eed2e08cc14b986ca43796dbc6d4"
Expand Down