-
Notifications
You must be signed in to change notification settings - Fork 5.4k
refactor: wallet specific Option components #4065
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5922d59
refactor: wallet specific Option components
vm e5cd322
fix
vm fc7723b
fix
vm 4abc571
fix coinbase wallet logic
vm e46a00c
injected logic
vm db4faa1
remove wallet.ts
vm 73c53e0
install metamask
vm 02bd035
move all into InjectedOption
vm 95f5b0f
fix mobile metamask
vm 4575457
wip
vm e812c13
more mocking
vm 8f9ed2e
more test fixes
vm f640291
refactor
vm 380179a
more special casing
vm fe81a1d
Merge branch 'main' into specific-option
vm ab0ee79
isMetaMask
vm 410eef4
simplify components
vm 1ace663
fix imports
vm 309605d
fix coinbase wallet
vm 8f9f4a9
test fix
vm 2acfe64
fix connectors changing
vm e0a9ea0
Merge branch 'main' into specific-option
vm 12678c4
Revert "fix connectors changing"
vm 443302b
more to typescript logic instead of jsx
vm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { Connector } from '@web3-react/types' | ||
| import COINBASE_ICON_URL from 'assets/images/coinbaseWalletIcon.svg' | ||
| import { coinbaseWalletConnection, ConnectionType } from 'connection' | ||
| import { getConnectionName } from 'connection/utils' | ||
|
|
||
| import Option from './Option' | ||
|
|
||
| const BASE_PROPS = { | ||
| color: '#315CF5', | ||
| icon: COINBASE_ICON_URL, | ||
| id: 'coinbase-wallet', | ||
| } | ||
|
|
||
| export function OpenCoinbaseWalletOption() { | ||
| const isActive = coinbaseWalletConnection.hooks.useIsActive() | ||
| return ( | ||
| <Option | ||
| {...BASE_PROPS} | ||
| isActive={isActive} | ||
| link="https://go.cb-w.com/mtUDhEZPy1" | ||
| header="Open in Coinbase Wallet" | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export function CoinbaseWalletOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { | ||
| const isActive = coinbaseWalletConnection.hooks.useIsActive() | ||
| return ( | ||
| <Option | ||
| {...BASE_PROPS} | ||
| isActive={isActive} | ||
| onClick={() => tryActivation(coinbaseWalletConnection.connector)} | ||
| header={getConnectionName(ConnectionType.COINBASE_WALLET)} | ||
| /> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Connector } from '@web3-react/types' | ||
| import FORTMATIC_ICON_URL from 'assets/images/fortmaticIcon.png' | ||
| import { ConnectionType, fortmaticConnection } from 'connection' | ||
| import { getConnectionName } from 'connection/utils' | ||
|
|
||
| import Option from './Option' | ||
|
|
||
| const BASE_PROPS = { | ||
| color: '#6748FF', | ||
| icon: FORTMATIC_ICON_URL, | ||
| id: 'fortmatic', | ||
| } | ||
|
|
||
| export function FortmaticOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { | ||
| const isActive = fortmaticConnection.hooks.useIsActive() | ||
| return ( | ||
| <Option | ||
| {...BASE_PROPS} | ||
| isActive={isActive} | ||
| onClick={() => tryActivation(fortmaticConnection.connector)} | ||
| header={getConnectionName(ConnectionType.FORTMATIC)} | ||
| /> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { Trans } from '@lingui/macro' | ||
| import { Connector } from '@web3-react/types' | ||
| import INJECTED_ICON_URL from 'assets/images/arrow-right.svg' | ||
| import METAMASK_ICON_URL from 'assets/images/metamask.png' | ||
| import { ConnectionType, injectedConnection } from 'connection' | ||
| import { getConnectionName } from 'connection/utils' | ||
|
|
||
| import Option from './Option' | ||
|
|
||
| const INJECTED_PROPS = { | ||
| color: '#010101', | ||
| icon: INJECTED_ICON_URL, | ||
| id: 'injected', | ||
| } | ||
|
|
||
| const METAMASK_PROPS = { | ||
| color: '#E8831D', | ||
| icon: METAMASK_ICON_URL, | ||
| id: 'metamask', | ||
| } | ||
|
|
||
| export function InstallMetaMaskOption() { | ||
| return <Option {...METAMASK_PROPS} header={<Trans>Install MetaMask</Trans>} link={'https://metamask.io/'} /> | ||
| } | ||
|
|
||
| export function MetaMaskOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { | ||
| const isActive = injectedConnection.hooks.useIsActive() | ||
| return ( | ||
| <Option | ||
| {...METAMASK_PROPS} | ||
| isActive={isActive} | ||
| header={getConnectionName(ConnectionType.INJECTED, true)} | ||
| onClick={() => tryActivation(injectedConnection.connector)} | ||
| /> | ||
| ) | ||
| } | ||
|
|
||
| export function InjectedOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { | ||
| const isActive = injectedConnection.hooks.useIsActive() | ||
| return ( | ||
| <Option | ||
| {...INJECTED_PROPS} | ||
| isActive={isActive} | ||
| header={getConnectionName(ConnectionType.INJECTED, false)} | ||
| onClick={() => tryActivation(injectedConnection.connector)} | ||
| /> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Connector } from '@web3-react/types' | ||
| import WALLET_CONNECT_ICON_URL from 'assets/images/walletConnectIcon.svg' | ||
| import { ConnectionType, walletConnectConnection } from 'connection' | ||
| import { getConnectionName } from 'connection/utils' | ||
|
|
||
| import Option from './Option' | ||
|
|
||
| const BASE_PROPS = { | ||
| color: '#4196FC', | ||
| icon: WALLET_CONNECT_ICON_URL, | ||
| id: 'wallet-connect', | ||
| } | ||
|
|
||
| export function WalletConnectOption({ tryActivation }: { tryActivation: (connector: Connector) => void }) { | ||
| const isActive = walletConnectConnection.hooks.useIsActive() | ||
| return ( | ||
| <Option | ||
| {...BASE_PROPS} | ||
| isActive={isActive} | ||
| onClick={() => tryActivation(walletConnectConnection.connector)} | ||
| header={getConnectionName(ConnectionType.WALLET_CONNECT)} | ||
| /> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventually i wanna make tryActivation a hook