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

feat: enable ledger hardware wallet implementation. #7757

Merged
merged 114 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
b41b55b
feat: add account type tag label
stanleyyconsensys Oct 30, 2023
62af34e
fix: revert update
stanleyyconsensys Oct 30, 2023
85ab4b3
fix: update account overview
stanleyyconsensys Oct 30, 2023
123a581
fix: style
stanleyyconsensys Oct 30, 2023
dfb16dd
fix: style
stanleyyconsensys Oct 30, 2023
2fab4cc
feat: add error message to retry modal
stanleyyconsensys Oct 30, 2023
fbb6719
feat: add bluetooth library support
stanleyyconsensys Oct 30, 2023
e35a43d
fix: lint style
stanleyyconsensys Oct 30, 2023
717172f
fix: unit test
stanleyyconsensys Oct 30, 2023
ea3ee67
remove not using package
stanleyyconsensys Oct 30, 2023
cdf8dc9
fix: add unit test for address list and account info
stanleyyconsensys Oct 31, 2023
470d351
fix: unit test on component
stanleyyconsensys Oct 31, 2023
9c69e38
fix: lint style
stanleyyconsensys Oct 31, 2023
eae04e9
Merge branch 'main' into feat/add-account-type-tag
dawnseeker8 Oct 31, 2023
7f0a52e
feat: fix all unit tests with more valid address.
dawnseeker8 Oct 31, 2023
0a162b2
feat: make test more valid with real eth address.
dawnseeker8 Oct 31, 2023
4a5169b
feat: unit tests, remove address util mock
dawnseeker8 Oct 31, 2023
4f96842
Merge branch 'main' into feat/add-bluetooth-permission
dawnseeker8 Oct 31, 2023
e4a41a7
Merge branch 'main' into feat/add-bluetooth-permission
dawnseeker8 Nov 1, 2023
871e03c
Merge branch 'main' into feat/add-error-msg-to-retry-modal
dawnseeker8 Nov 1, 2023
973c806
Merge branch 'main' into feat/add-account-type-tag
dawnseeker8 Nov 1, 2023
d50530f
fix: action view btn not able translate
dawnseeker8 Nov 1, 2023
8ed8a22
Merge remote-tracking branch 'origin/feat/add-account-type-tag' into …
dawnseeker8 Nov 1, 2023
351ec14
Merge remote-tracking branch 'origin/feat/add-error-msg-to-retry-moda…
dawnseeker8 Nov 1, 2023
7618f8b
Merge remote-tracking branch 'origin/feat/add-bluetooth-permission' i…
dawnseeker8 Nov 1, 2023
c855635
feat: Working version with ledger enable
dawnseeker8 Nov 2, 2023
6cef3df
feat: Fix some missing changed files
dawnseeker8 Nov 2, 2023
cd32d1a
feat: fix all unit tests and lint errors
dawnseeker8 Nov 2, 2023
56ab5da
feat: add `account_type` in some metric metric,
dawnseeker8 Nov 6, 2023
8d45c82
feat: add missing constant
dawnseeker8 Nov 8, 2023
8f114fc
feat: move to use ExtendedKeyringTypes
dawnseeker8 Nov 9, 2023
85cb892
feat: use varient attribute to use theme variable
dawnseeker8 Nov 9, 2023
3f94a7c
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 9, 2023
ded0618
feat: fix some conflict files.
dawnseeker8 Nov 9, 2023
b84af5f
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 10, 2023
09fb42e
feat: commit to missing format of file
dawnseeker8 Nov 10, 2023
a8aa132
feat: ios Podfile.lock commit
dawnseeker8 Nov 10, 2023
5176dab
feat: Make all account label style consistance
dawnseeker8 Nov 10, 2023
5d8471c
feat: Fix the unit test failure
dawnseeker8 Nov 10, 2023
6b82de2
feat: fix lint error
dawnseeker8 Nov 10, 2023
161d5af
feat: refactory to reduce the change log in git.
dawnseeker8 Nov 10, 2023
3aba6c4
feat: fix lint issue and revert change
dawnseeker8 Nov 10, 2023
dc4b8c8
feat: Revert two android setting to main version
dawnseeker8 Nov 10, 2023
e7faf55
fix: reorder import sequence
stanleyyconsensys Nov 10, 2023
0f7f32b
fix: remove un necessary change
stanleyyconsensys Nov 10, 2023
6772762
feat: revert .project to main version.
dawnseeker8 Nov 10, 2023
ed04e63
update address utils method sequence
stanleyyconsensys Nov 10, 2023
ce5dd85
Merge branch 'feat/ledger-enable' of https://github.com/MetaMask/meta…
stanleyyconsensys Nov 10, 2023
beab782
feat: Fix dedupe pipeline failure
dawnseeker8 Nov 10, 2023
e1067dd
Merge branch 'main' into feat/ledger-enable
dawnseeker8 Nov 10, 2023
10a095f
feat: fix ltsc issue due to enum use another value
dawnseeker8 Nov 10, 2023
75accb9
Revert "feat: fix ltsc issue due to enum use another value"
dawnseeker8 Nov 10, 2023
f914a8d
feat: fix lint:tsc issue
dawnseeker8 Nov 10, 2023
fba40a5
Merge branch 'main' into feat/ledger-enable
dawnseeker8 Nov 13, 2023
5760ebf
feat: Fix dedupe error and one unit test.
dawnseeker8 Nov 13, 2023
83a4e32
feat: Fix dedupe ci broken.
dawnseeker8 Nov 13, 2023
f9f5722
feat: upgrade react-native-ble-plx library
dawnseeker8 Nov 14, 2023
421a2bd
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 14, 2023
914d0df
feat: change code based on Brian's comments,
dawnseeker8 Nov 14, 2023
eb74574
feat:update podfile.lock with react-native-ble-plx
dawnseeker8 Nov 14, 2023
938ffc1
feat: Fix `ledger` tag label, `g` has been cut off
dawnseeker8 Nov 14, 2023
ac33031
feat: make account tag label bold
dawnseeker8 Nov 14, 2023
b6ef0ed
feat: revert the tag style to `main` version.
dawnseeker8 Nov 15, 2023
906d3ea
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 15, 2023
2f42b34
feat: fix lint issue from rebase.
dawnseeker8 Nov 15, 2023
0540212
feat: remove unused images.
dawnseeker8 Nov 15, 2023
9f95dc6
feat: fix the ios build issue in britise
dawnseeker8 Nov 15, 2023
7c1bf89
feat: Manually remove the source map diff in patch
dawnseeker8 Nov 15, 2023
f325463
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 16, 2023
70439d0
feat: Revert javascriptEnabled to true in webview
dawnseeker8 Nov 16, 2023
c61fbe2
feat: revert cocapods version to `main` version.
dawnseeker8 Nov 16, 2023
4dbc4b2
feat: fix lint issue from rebase code.
dawnseeker8 Nov 16, 2023
50dff1a
feat:add comment description into patch file
dawnseeker8 Nov 16, 2023
ec13b8d
feat: Fix the syntax error in Podfile.lock
dawnseeker8 Nov 16, 2023
3c3ae68
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 17, 2023
f3b2717
feat: commit the missing file from last commit
dawnseeker8 Nov 17, 2023
6e71408
fix: update ledger.ts
stanleyyconsensys Nov 20, 2023
a1c79ad
Apply suggestions from code review
dawnseeker8 Nov 20, 2023
5896c37
feat: refactory code based on Custova's comment
dawnseeker8 Nov 20, 2023
c3e1e8e
feat: revert remove line.
dawnseeker8 Nov 20, 2023
85932df
feat: Revert the files was commited by mistaken.
dawnseeker8 Nov 20, 2023
8778e77
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 20, 2023
9d2bff4
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 21, 2023
e3e53db
feat: change based on Mike comments
dawnseeker8 Nov 21, 2023
1d2ef0f
feat: Revert all javascript disabled code
dawnseeker8 Nov 21, 2023
bbdee57
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 22, 2023
8543fbd
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 22, 2023
8eb3d9e
feat: change QR connect to account drawdown list screen
dawnseeker8 Nov 22, 2023
0885747
Merge branch 'main' into feat/ledger-enable
dawnseeker8 Nov 23, 2023
d0feb9e
feat: remove duplicate permission.
dawnseeker8 Nov 23, 2023
d97bf07
feat: fix the typo error in text attribute.
dawnseeker8 Nov 23, 2023
58af547
feat: Try to fix the ios e2e tests
dawnseeker8 Nov 23, 2023
10ade1f
feat: After few testing, confirm AccountView is fine.
dawnseeker8 Nov 23, 2023
0cc0f72
feat: refactory to remove unuse outdating code.
dawnseeker8 Nov 24, 2023
3359f74
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 24, 2023
7463abb
feat: add retry to prevent user immediately see error screen with eth…
dawnseeker8 Nov 24, 2023
c884b94
feat: Commit based on Stanley feedback.
dawnseeker8 Nov 27, 2023
98aeb9b
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 27, 2023
3c91fa6
feat: Dont store rpcEvents and accounts state in localStorage.
dawnseeker8 Nov 27, 2023
078da45
feat: try to fix regression e2e tests signing model not popup.
dawnseeker8 Nov 27, 2023
002bb3b
feat: check whether fix ios gem install error in ios e2e tests.
dawnseeker8 Nov 28, 2023
df8a91d
feat: Check whether e2e ios build can pass in bitrise or not.
dawnseeker8 Nov 28, 2023
a53517c
feat: Revert previous two ios change to `main` version.
dawnseeker8 Nov 28, 2023
43936e3
feat: Revert the suspect line which may break ios e2e build.
dawnseeker8 Nov 28, 2023
e5229f4
feat: revert the change to match main
dawnseeker8 Nov 28, 2023
c11b1fa
fea: hide ledger (#7940)
gantunesr Nov 28, 2023
417907a
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 28, 2023
fb5d4e0
feat: to test e2e test pass or not.
dawnseeker8 Nov 29, 2023
311f2d6
feat: Implement option 1 to turn off ledger feature..
dawnseeker8 Nov 29, 2023
9662cfc
Merge remote-tracking branch 'origin/main' into feat/ledger-enable
dawnseeker8 Nov 29, 2023
446a113
feat: revert the code to disable the ledger feature.
dawnseeker8 Nov 29, 2023
bfb34ab
feat: revert file to main version
dawnseeker8 Nov 29, 2023
7d2a071
feat: revert again to remove the change from main
dawnseeker8 Nov 29, 2023
2807dfc
feat: Remove the duplicate lines in `Podfile.lock` after rebase which…
dawnseeker8 Nov 29, 2023
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
4 changes: 2 additions & 2 deletions .detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
},
retries: 2,
},

dawnseeker8 marked this conversation as resolved.
Show resolved Hide resolved
artifacts: {
rootDir: "./artifacts/screenshots",
plugins: {
Expand All @@ -23,7 +23,7 @@ module.exports = {
}
},
},
},
},
dawnseeker8 marked this conversation as resolved.
Show resolved Hide resolved
configurations: {
'ios.sim.debug': {
device: 'ios.simulator',
Expand Down
7 changes: 7 additions & 0 deletions app/actions/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ export function setUseBlockieIcon(useBlockieIcon) {
useBlockieIcon,
};
}

export function setLedgerBetaEnabled(ledgerBetaEnabled) {
return {
type: 'SET_LEDGER_BETA_ENABLED',
ledgerBetaEnabled,
};
}
69 changes: 58 additions & 11 deletions app/components/Views/ConnectHardware/SelectHardware/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/* eslint @typescript-eslint/no-var-requires: "off" */
/* eslint @typescript-eslint/no-require-imports: "off" */

import React, { useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import {
View,
SafeAreaView,
Text,
StyleSheet,
TouchableOpacity,
Image,
Alert,
} from 'react-native';
import { useSelector, useDispatch } from 'react-redux';
import { useNavigation } from '@react-navigation/native';
import { setLedgerBetaEnabled } from '../../../../actions/settings';
import {
mockTheme,
useAppThemeFromContext,
Expand All @@ -23,9 +25,13 @@ import Routes from '../../../../constants/navigation/Routes';
import { getLedgerKeyring } from '../../../../core/Ledger/Ledger';
import { MetaMetricsEvents } from '../../../../core/Analytics';
import AnalyticsV2 from '../../../../util/analyticsV2';
import Text, {
TextVariant,
} from '../../../../component-library/components/Texts/Text';

const createStyle = (colors: any) =>
StyleSheet.create({
screen: { justifyContent: 'center' },
container: {
flex: 1,
marginHorizontal: '5%',
Expand Down Expand Up @@ -84,6 +90,13 @@ const SelectHardwareWallet = () => {
const navigation = useNavigation();
const { colors } = useAppThemeFromContext() || mockTheme;
const styles = createStyle(colors);
const [ledgerTaps, setLedgerTaps] = useState<number>(1);

const ledgerBetaEnabled = useSelector(
(state: any) => state.settings.ledgerBetaEnabled,
);

const dispatch = useDispatch();

useEffect(() => {
navigation.setOptions(
Expand All @@ -96,6 +109,30 @@ const SelectHardwareWallet = () => {
);
}, [navigation, colors]);

const showLedgerBetaAlert = () =>
Alert.alert(
strings('ledger.ledger_beta_alert'),
strings('ledger.ledger_beta_alert_description'),
[
{
text: strings('ledger.ledger_beta_cta'),
onPress: () => dispatch(setLedgerBetaEnabled(true)),
},
],
);

const updateLedgerBetaTaps = () => {
if (ledgerBetaEnabled) {
return;
}

if (ledgerTaps === 7) {
showLedgerBetaAlert();
} else {
setLedgerTaps(ledgerTaps + 1);
}
};

const navigateToConnectQRWallet = () => {
navigation.navigate(Routes.HW.CONNECT_QR_DEVICE);
};
Expand Down Expand Up @@ -126,22 +163,32 @@ const SelectHardwareWallet = () => {
</TouchableOpacity>
);

const LedgerButton = () => {
const ledgerLogo = useAssetFromTheme(ledgerLogoLight, ledgerLogoDark);
return (
ledgerBetaEnabled &&
renderHardwareButton(ledgerLogo, navigateToConnectLedger)
);
};

const QRButton = () => {
const qrHardwareLogo = useAssetFromTheme(
qrHardwareLogoLight,
qrHardwareLogoDark,
);
return renderHardwareButton(qrHardwareLogo, navigateToConnectQRWallet);
};

return (
<SafeAreaView style={styles.container}>
<View style={styles.textContainer}>
<Text style={styles.text}>
<Text variant={TextVariant.BodyMD} onPress={updateLedgerBetaTaps}>
{strings('connect_hardware.select_hardware')}
</Text>
</View>
<View style={styles.buttonsContainer}>
{renderHardwareButton(
useAssetFromTheme(ledgerLogoLight, ledgerLogoDark),
navigateToConnectLedger,
)}
{renderHardwareButton(
useAssetFromTheme(qrHardwareLogoLight, qrHardwareLogoDark),
navigateToConnectQRWallet,
)}
<LedgerButton />
<QRButton />
</View>
</SafeAreaView>
);
Expand Down
6 changes: 6 additions & 0 deletions app/reducers/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const initialState = {
lockTime: -1, // Disabled by default
useBlockieIcon: true,
hideZeroBalanceTokens: false,
ledgerBetaEnabled: false,
};

const settingsReducer = (state = initialState, action) => {
Expand Down Expand Up @@ -45,6 +46,11 @@ const settingsReducer = (state = initialState, action) => {
...state,
primaryCurrency: action.primaryCurrency,
};
case 'SET_LEDGER_BETA_ENABLED':
return {
...state,
ledgerBetaEnabled: action.ledgerBetaEnabled,
};
default:
return state;
}
Expand Down
4 changes: 4 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ DEPENDENCIES:
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- react-native-aes (from `../node_modules/react-native-aes-crypto`)
- react-native-background-timer (from `../node_modules/react-native-background-timer`)
- react-native-ble-plx (from `../node_modules/react-native-ble-plx`)
- "react-native-blur (from `../node_modules/@react-native-community/blur`)"
- react-native-branch (from `../node_modules/react-native-branch`)
- react-native-camera (from `../node_modules/react-native-camera`)
Expand Down Expand Up @@ -670,6 +671,7 @@ SPEC REPOS:
- FlipperKit
- fmt
- libevent
- MultiplatformBleAdapter
- OpenSSL-Universal
- Sentry
- SentryPrivate
Expand Down Expand Up @@ -729,6 +731,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-aes-crypto"
react-native-background-timer:
:path: "../node_modules/react-native-background-timer"
react-native-ble-plx:
:path: "../node_modules/react-native-ble-plx"
react-native-blur:
:path: "../node_modules/@react-native-community/blur"
react-native-branch:
Expand Down
5 changes: 4 additions & 1 deletion locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2649,7 +2649,10 @@
"error_during_connection_message": "There's been a slight problem connecting your Ledger Nano X, tap 'Retry' below to give this another go. Sometimes this occurs due to the ETH app on your Ledger Nano X being open at the start of the pairing process with MetaMask Mobile.",
"how_to_install_eth_webview_title": "How to install the Ethereum App",
"nonce_too_low": "Nonce too low",
"nonce_too_low_error": "The set nonce is too low"
"nonce_too_low_error": "The set nonce is too low",
"ledger_beta_alert": "Enabling Ledger integration",
"ledger_beta_alert_description": "You've found an experimental feature! By continuing you accept you're using this experimental feature at your own risk.",
"ledger_beta_cta": "Continue"
},
"account_actions": {
"edit_name": "Edit account name",
Expand Down
Loading