-
Notifications
You must be signed in to change notification settings - Fork 635
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 clear signing upgrades #5966
Changes from all commits
404a7ec
606f42b
7128272
01ca5a3
0bacbd6
ba68d52
85a7241
48fd4eb
534e3f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
'use strict'; | ||
|
||
import AppEth, { ledgerService } from '@ledgerhq/hw-app-eth'; | ||
import TransportBLE from '@ledgerhq/react-native-hw-transport-ble'; | ||
import { SignTypedDataVersion, TypedDataUtils } from '@metamask/eth-sig-util'; | ||
import { Signer } from '@ethersproject/abstract-signer'; | ||
import { Bytes, hexlify, joinSignature } from '@ethersproject/bytes'; | ||
|
@@ -14,6 +13,7 @@ import { logger, RainbowError } from '@/logger'; | |
import { Navigation } from '@/navigation'; | ||
import Routes from '@/navigation/routesNames'; | ||
import { getAddress } from '@ethersproject/address'; | ||
import { getEthApp } from '@/utils/ledger'; | ||
|
||
function waiter(duration: number): Promise<void> { | ||
return new Promise(resolve => { | ||
|
@@ -40,10 +40,9 @@ export class LedgerSigner extends Signer { | |
defineReadOnly( | ||
this, | ||
'_eth', | ||
TransportBLE.open(deviceId).then( | ||
transport => { | ||
const eth = new AppEth(transport); | ||
return eth; | ||
getEthApp(deviceId).then( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using .then vs await to keep it compatible with the Signer interface |
||
ethApp => { | ||
return ethApp; | ||
}, | ||
error => { | ||
return Promise.reject(error); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,7 @@ import { findWalletWithAccount } from '@/helpers/findWalletWithAccount'; | |
import { EthereumAddress } from '@/entities'; | ||
import { authenticateWithPIN, authenticateWithPINAndCreateIfNeeded } from '@/handlers/authentication'; | ||
import { saveAccountEmptyState } from '@/handlers/localstorage/accountLocal'; | ||
import { | ||
addHexPrefix, | ||
isHexString, | ||
isHexStringIgnorePrefix, | ||
isValidBluetoothDeviceId, | ||
isValidMnemonic, | ||
web3Provider, | ||
} from '@/handlers/web3'; | ||
import { addHexPrefix, isHexString, isHexStringIgnorePrefix, isValidBluetoothDeviceId, isValidMnemonic } from '@/handlers/web3'; | ||
import { createSignature } from '@/helpers/signingWallet'; | ||
import showWalletErrorAlert from '@/helpers/support'; | ||
import walletTypes, { EthereumWalletType } from '@/helpers/walletTypes'; | ||
|
@@ -300,11 +293,11 @@ export const loadWallet = async <S extends Screen>({ | |
if (isHardwareWalletKey(privateKey)) { | ||
const index = privateKey?.split('/')[1]; | ||
const deviceId = privateKey?.split('/')[0]; | ||
if (typeof index !== undefined && provider && deviceId) { | ||
if (typeof index !== undefined && deviceId && provider) { | ||
return new LedgerSigner(provider, getHdPath({ type: WalletLibraryType.ledger, index: Number(index) }), deviceId); | ||
} | ||
} else if (privateKey) { | ||
return new Wallet(privateKey, provider || web3Provider); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the line I mentioned before. Now the provider defaults to mainnet instead of being undefined. |
||
return new Wallet(privateKey, provider); | ||
} | ||
if (ios && showErrorIfNotLoaded) { | ||
showWalletErrorAlert(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,7 +170,7 @@ export default function SendSheet() { | |
const [debouncedRecipient] = useDebounce(recipient, 500); | ||
|
||
const [isValidAddress, setIsValidAddress] = useState(!!recipientOverride); | ||
const [currentProvider, setCurrentProvider] = useState<StaticJsonRpcProvider | undefined>(); | ||
const [currentProvider, setCurrentProvider] = useState<StaticJsonRpcProvider | undefined>(getProvider({ chainId: ChainId.mainnet })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provider now defaulting to mainnet. Before it was undefined (breaking ledger mainnet sends) |
||
const theme = useTheme(); | ||
const { colors, isDarkMode } = theme; | ||
|
||
|
@@ -403,7 +403,6 @@ export default function SendSheet() { | |
const onSubmit = useCallback( | ||
async ({ ens }: OnSubmitProps = {}) => { | ||
if (!selected) return; | ||
|
||
const wallet = await performanceTracking.getState().executeFn({ | ||
fn: loadWallet, | ||
operation: TimeToSignOperation.KeychainRead, | ||
|
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.
This is required to resolve ledger packages correctly otherwise it won't find them.