-
Notifications
You must be signed in to change notification settings - Fork 26
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
Ledger live implementation #515
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
37d51a7
Add Ledger Live connector
michalsmiarowski 4da9032
Add LedgerLive button to SelectWallet modal
michalsmiarowski 42d139b
Create ConnectLedgerLive component
michalsmiarowski 27053bc
Fix typings in ledger_live connector
michalsmiarowski 9b1eff2
Add `@ledgerhq/connect-kit-loader` package
michalsmiarowski d2a1af9
Add `LEDGER_LIVE` to `WalletType` enum
michalsmiarowski f7be6fa
Add proper Ledger Live icon
michalsmiarowski 131ab84
Add listeners to the provider
michalsmiarowski 740de82
Fix error then disconnectin the Ledger wallet.
michalsmiarowski d7ed01b
Change console.log to console.error
michalsmiarowski 869f9ac
Add empty line
michalsmiarowski f936566
Remove duplicated code
michalsmiarowski c235c98
Use correct Ledger Live icon
michalsmiarowski 1149fa5
Rename ledger_live connector
michalsmiarowski f1fac17
Remove unnecessary undefined.
michalsmiarowski 36b0767
Create `ConnectorNotAcivatedError` error
michalsmiarowski 6ccab86
Close walletconnection modal for LedgerLive
michalsmiarowski 225800e
Pass rpc to contructor of ledger Live
michalsmiarowski 6f909fc
Use `useColorModeValue` hook
michalsmiarowski bc69060
Merge branch 'main' into ledger-live-implementation
michalsmiarowski f6ff7f5
Add alert for unsupported network
michalsmiarowski eaaa1b6
Merge branch 'main' into ledger-live-implementation
michalsmiarowski df848ca
Update @ledgerhq/connect-kit-loader lib
michalsmiarowski 66224b1
Adjust `checkSupport` method for new lib version
michalsmiarowski aaacbe7
Make code more readable
michalsmiarowski ab114c9
Simplify wallet connection aler useEffect
michalsmiarowski 3bf7da1
Add `shouldForceCloseModal` property
michalsmiarowski 98a6086
Add `shouldForceCloseModal` to dependency array
michalsmiarowski e3f46f9
Add feature flag for ledger live
michalsmiarowski 0853ce8
Pass project id through a constructor
michalsmiarowski 1f996cd
Update `@ledgerhq/connect-kit-loader`
michalsmiarowski 6cfe182
Fix "Cannot convert undefined or null to object"
michalsmiarowski 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 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 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 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
43 changes: 43 additions & 0 deletions
43
src/components/Modal/SelectWalletModal/ConnectLedgerLive.tsx
This file contains 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,43 @@ | ||
import { FC } from "react" | ||
import { useWeb3React } from "@web3-react/core" | ||
import { ledgerLive } from "../../../web3/connectors" | ||
import { WalletConnectionModalBase } from "./components" | ||
import { ConnectionError, WalletType } from "../../../enums" | ||
import doesErrorInclude from "../../../web3/utils/doesErrorInclude" | ||
import { LedgerLight } from "../../../static/icons/LedgerLight" | ||
import { LedgerDark } from "../../../static/icons/LedgerDark" | ||
import { useColorModeValue } from "@threshold-network/components" | ||
|
||
const ConnectLedgerLive: FC<{ goBack: () => void; closeModal: () => void }> = ({ | ||
goBack, | ||
closeModal, | ||
}) => { | ||
const { activate, error } = useWeb3React() | ||
|
||
const connectionRejected = doesErrorInclude( | ||
error, | ||
ConnectionError.RejectedMetamaskConnection | ||
) | ||
|
||
const walletIcon = useColorModeValue(LedgerLight, LedgerDark) | ||
|
||
return ( | ||
<WalletConnectionModalBase | ||
connector={ledgerLive} | ||
goBack={goBack} | ||
closeModal={closeModal} | ||
WalletIcon={walletIcon} | ||
title="Ledger Live" | ||
subTitle={ | ||
!error | ||
? "The Ledger Live extension will open in an external window." | ||
: "" | ||
} | ||
tryAgain={connectionRejected ? () => activate(ledgerLive) : undefined} | ||
walletType={WalletType.LedgerLive} | ||
shouldForceCloseModal | ||
/> | ||
) | ||
} | ||
|
||
export default ConnectLedgerLive |
This file contains 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 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 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 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 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 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 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 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 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,21 @@ | ||
import { createIcon } from "@chakra-ui/icons" | ||
|
||
export const LedgerDark = createIcon({ | ||
displayName: "Ledger", | ||
viewBox: "0 0 160 160", | ||
path: ( | ||
<svg | ||
width="160" | ||
height="160" | ||
viewBox="0 0 160 160" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<rect width="160" height="160" rx="16" fill="#00000D" /> | ||
<path | ||
d="M93.1482 119.207V125H135V98.8769H128.902V119.207H93.1482ZM93.1482 33V38.792H128.902V59.1231H135V33H93.1482ZM74.0104 59.1231H67.9125V98.8769H95.4153V93.6539H74.0104V59.1231ZM26 98.8769V125H67.8518V119.207H32.0979V98.8769H26ZM26 33V59.1231H32.0979V38.792H67.8518V33H26Z" | ||
fill="white" | ||
/> | ||
</svg> | ||
), | ||
}) |
This file contains 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,21 @@ | ||
import { createIcon } from "@chakra-ui/icons" | ||
|
||
export const LedgerLight = createIcon({ | ||
displayName: "Ledger", | ||
viewBox: "0 0 160 160", | ||
path: ( | ||
<svg | ||
width="160" | ||
height="160" | ||
viewBox="0 0 160 160" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<rect width="160" height="160" rx="16" fill="white" /> | ||
<path | ||
d="M93.1482 119.207V125H135V98.8769H128.902V119.207H93.1482ZM93.1482 33V38.792H128.902V59.1231H135V33H93.1482ZM74.0104 59.1231H67.9125V98.8769H95.4153V93.6539H74.0104V59.1231ZM26 98.8769V125H67.8518V119.207H32.0979V98.8769H26ZM26 33V59.1231H32.0979V38.792H67.8518V33H26Z" | ||
fill="#00000D" | ||
/> | ||
</svg> | ||
), | ||
}) | ||
This file contains 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 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.
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.
Looks like the svg is the same we only swap colors in
<rect fill={}
and<path fill={} />
. So we can create one fileLedgerLive.tsx
and create an custom icon using Icon component see https://chakra-ui.com/docs/components/icon#using-the-icon-component: