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] Keystone integration #3915

Merged
merged 211 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
ad1ef6e
Upgrade controllers 22.0.0 -> 25.1.0
Jan 25, 2022
c9fbd52
Merge branch 'develop' into depend/controllers-25.1.0
Jan 25, 2022
5ab4e1f
Merge branch 'develop' into depend/controllers-25.1.0
Jan 26, 2022
8eab789
Update acceptance criteria with metrics line
Cal-L Jan 31, 2022
b2fcf0c
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile
Cal-L Feb 1, 2022
5b92f05
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile
Cal-L Feb 5, 2022
4b7f203
Remove hardcoded theme on iOS
Cal-L Feb 7, 2022
b9f6322
Set up theme foundation
Cal-L Feb 7, 2022
6eee989
Add theme toggle to react native dev menu
Cal-L Feb 7, 2022
e4949a1
Add theme toggle to react native dev menu
Cal-L Feb 7, 2022
cc56429
Fix inital theme toggle
Cal-L Feb 7, 2022
f3be3dd
Begin hooking up onboarding with dark mode
Cal-L Feb 8, 2022
0f65795
Change default theme mode
Cal-L Feb 8, 2022
5219ac2
Change default theme mode
Cal-L Feb 8, 2022
3c3b028
Begin introducing dark mode to settings
Cal-L Feb 8, 2022
b0b7ba8
Merge branch 'feature/3705-dark-mode-onboarding' of https://github.co…
Cal-L Feb 8, 2022
5236988
Merge branch 'feature/3707-dark-mode-settings' of https://github.com/…
Cal-L Feb 8, 2022
3a50876
Add context type to login screen
Cal-L Feb 8, 2022
b094145
Merge branch 'feature/3705-dark-mode-onboarding' of https://github.co…
Cal-L Feb 8, 2022
7bcab3b
Begin introducing dark theme to send flow
Cal-L Feb 9, 2022
a15f80c
Merge branch 'feature/3709-dark-mode-send' of https://github.com/Meta…
Cal-L Feb 9, 2022
1bb3bbf
Introduce dark mode to swaps
Cal-L Feb 9, 2022
c78a425
Merge branch 'feature/3708-dark-mode-swaps' of https://github.com/Met…
Cal-L Feb 9, 2022
e89be7a
Introduce dark mode to buy and receive screens
Cal-L Feb 9, 2022
0212956
Merge branch 'feature/3716-dark-mode-buy-and-receive' of https://gith…
Cal-L Feb 9, 2022
0cf88d9
Introduce dark mode to asset screens
Cal-L Feb 9, 2022
37c15c6
Merge branch 'feature/3710-dark-mode-import-assets' of https://github…
Cal-L Feb 9, 2022
c60e981
Introduce dark mode to drawer and related screens
Cal-L Feb 9, 2022
6d801a8
Merge branch 'feature/3719-dark-mode-drawer' of https://github.com/Me…
Cal-L Feb 9, 2022
d3c73e2
Import design tokens library
Cal-L Feb 10, 2022
d1c2452
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
6e410ae
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
0adc633
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
67f2046
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
347e568
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
441ae7a
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
728a003
Update carousel with theme colors
Cal-L Feb 10, 2022
ee55a65
Use theme colors in onboarding flow
Cal-L Feb 10, 2022
258863e
Merge branch 'feature/3698-theme-foundation' of https://github.com/Me…
Cal-L Feb 10, 2022
4c8237f
Merge branch 'feature/3705-dark-mode-onboarding' of https://github.co…
Cal-L Feb 10, 2022
b54c9aa
Update general with theme colors
Cal-L Feb 10, 2022
68db651
Update privacy with theme colors
Cal-L Feb 10, 2022
a41e20a
Update advanced with theme colors
Cal-L Feb 10, 2022
ae8baca
Add dark mode to contacts
Cal-L Feb 10, 2022
d449a88
Add dark mode to networks
Cal-L Feb 10, 2022
1c7010d
Add dark mode to experimental
Cal-L Feb 10, 2022
f5b4a9f
Add dark mode to about
Cal-L Feb 10, 2022
6463ec8
Merge branch 'feature/3707-dark-mode-settings' of https://github.com/…
Cal-L Feb 10, 2022
c4f894e
Merge branch 'feature/3708-dark-mode-swaps' of https://github.com/Met…
Cal-L Feb 11, 2022
b2f0475
Update swap elements with theme colors
Cal-L Feb 11, 2022
531185a
Merge branch 'feature/3708-dark-mode-swaps' of https://github.com/Met…
Cal-L Feb 11, 2022
ad4d457
Replacing jpg with pngs (#3734)
georgewrmarshall Feb 11, 2022
9375f0c
Merge branch 'feature/3705-dark-mode-onboarding' of https://github.co…
Cal-L Feb 11, 2022
5a95cab
Update send flow with dark theme colors
Cal-L Feb 11, 2022
8582396
Merge from dark mode send flow
Cal-L Feb 11, 2022
5fb50f0
Add dark theme colors to send and receive flows
Cal-L Feb 11, 2022
06adb55
Merge branch 'feature/3716-dark-mode-buy-and-receive' of https://gith…
Cal-L Feb 11, 2022
aaa7619
Add dark colors to settings
Cal-L Feb 12, 2022
17edf0f
Merge branch 'feature/3707-dark-mode-settings' of https://github.com/…
Cal-L Feb 12, 2022
150f0e2
Update onboarding flow with dark colors
Cal-L Feb 12, 2022
616f9ea
Merge branch 'feature/3705-dark-mode-onboarding' of https://github.co…
Cal-L Feb 12, 2022
0951a6a
Add dark colors to import assets screens
Cal-L Feb 12, 2022
b0db358
Merge from import assets
Cal-L Feb 12, 2022
44c8557
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Feb 13, 2022
ee5cc64
Update miscellaneous screens with dark mode
Cal-L Feb 15, 2022
48d2737
Continue updating colors
Cal-L Feb 15, 2022
43ce3cc
Merge branch 'main' into depend/controllers-25.1.0
Feb 16, 2022
ea0e666
Reintroduce animated fox
Cal-L Feb 16, 2022
cf78535
Update controlers patch
Feb 16, 2022
3937ff4
Tag places where icon colors are needed
Cal-L Feb 16, 2022
bbeb290
Use overlay and icon colors from design system
Cal-L Feb 16, 2022
51e1475
Continue flushing dark mode colors
Cal-L Feb 16, 2022
53d8a27
Merge branch 'main' into depend/controllers-25.1.0
Feb 16, 2022
acea0a1
Update few colors
Cal-L Feb 16, 2022
64d6c14
Add light and dark assets
Cal-L Feb 16, 2022
ad87f65
Update modal overlays
Cal-L Feb 17, 2022
24e758b
Replace slippage slider with SVG
Cal-L Feb 17, 2022
5a13248
Hook up theme settings in general settings
Cal-L Feb 17, 2022
58d03a6
Finalize removing unneccessary colors
Cal-L Feb 17, 2022
f87e53f
Finalize removing unneccessary colors
Cal-L Feb 17, 2022
bede32a
Integrate Keystone - connect Keystone Wallet (#3647)
soralit Feb 17, 2022
432cad3
Complete dark theme conversion
Cal-L Feb 17, 2022
23b9d02
Fix unit tests
Cal-L Feb 18, 2022
39a6b79
Merge from main
Cal-L Feb 18, 2022
f931248
Replace hardcoded white colors
Cal-L Feb 18, 2022
a215c7b
Increment build numbers
Cal-L Feb 18, 2022
e302a7f
Standardize on nav bar border
Cal-L Feb 18, 2022
8c6741f
Update build numbers
Cal-L Feb 18, 2022
26ec1a0
Update build number
Cal-L Feb 18, 2022
e52ce37
Update refresh loader colors
Cal-L Feb 18, 2022
6b5fd0f
Update unit test
Cal-L Feb 18, 2022
7fc9200
Merge branch 'main' into depend/controllers-25.1.0
Feb 18, 2022
79d528a
Add missing colors. Fix navigating to settings flow.
Cal-L Feb 20, 2022
f310315
Fix approval screen crash
Cal-L Feb 20, 2022
5030d79
Update build numbers
Cal-L Feb 20, 2022
032d641
Integrate Keystone - Support Sign flow and in-browser dApp (#3772)
soralit Feb 21, 2022
a15c6ea
Fix text input color
Cal-L Feb 21, 2022
42fe840
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Feb 23, 2022
10a37dd
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Feb 23, 2022
d75b3ba
Merge branch 'depend/controllers-25.1.0' of https://github.com/MetaMa…
Feb 23, 2022
b89e6e5
Add controllers and bump build number
Feb 23, 2022
02b583b
Integrate Keystone - Fix QA and UX issues (#3793)
soralit Mar 1, 2022
0213d3d
solve conflicts
Mar 3, 2022
ab37e05
update yarn lock
Mar 3, 2022
b30c67d
re-add ngraveio
Mar 3, 2022
8f1e9de
Integrate Keystone - Fix issues, add events tracking (#3827)
soralit Mar 3, 2022
e2ddfc9
update controller
Mar 4, 2022
811961a
Merge branch 'feat/keystone-integration' of https://github.com/MetaMa…
Mar 4, 2022
07fb9a3
Update dependencies
Mar 4, 2022
0486b19
Bump build and version number
Mar 4, 2022
fe63704
Update version and build number
Mar 7, 2022
cf52719
Merge conflicts from main
Cal-L Mar 8, 2022
62aea77
Introduce analytics event to track theme. Update design token library.
Cal-L Mar 8, 2022
cb98bc8
Explicitly pass app theme style to analytics
Cal-L Mar 9, 2022
a7659fc
solve conflicts
Mar 9, 2022
0dca09d
Merge from main
Cal-L Mar 9, 2022
2a105b0
Up build numbers
Cal-L Mar 10, 2022
876fbde
Update inputs to use dark mode keyboard for iOS
Cal-L Mar 11, 2022
2caf6ad
Pull from main
Cal-L Mar 11, 2022
2274fcb
Patch action sheet to support dark theme
Cal-L Mar 11, 2022
af89184
Fix WC deep link crasher. Attempt to fix Android dialog dark theme.
Cal-L Mar 11, 2022
1e8a87b
Integrate Keystone: fix UI issues. (#3872)
soralit Mar 11, 2022
e356009
Update controllers
Mar 11, 2022
cab72c1
solve conflicts
Mar 11, 2022
a621975
Update yarn.lock
Mar 11, 2022
0f74dcf
Update version
Mar 11, 2022
fcf12d1
Update version and build for android
Mar 11, 2022
417abc9
Fix color artifacts
Cal-L Mar 12, 2022
a172e97
Update build numbers + versions
Cal-L Mar 12, 2022
69805d4
Merge in from main
Cal-L Mar 12, 2022
b293ec7
Fix Android build. Fix toast background.
Cal-L Mar 12, 2022
708d8dc
Update build and version number
Mar 13, 2022
ca53d34
Remove toast background color
Cal-L Mar 13, 2022
a01c38a
Android build
Mar 13, 2022
169bf9a
Ypdate build version
Cal-L Mar 14, 2022
166d7e0
solve conflicts
Mar 14, 2022
b504a53
Pull dark mode
Mar 15, 2022
b2e98ff
Fix lint issues
Mar 15, 2022
d92a848
Update info.plist
Mar 15, 2022
7b6176e
Solve merge conflicts
Mar 17, 2022
cf2fcb3
Update yarn.lock
Mar 17, 2022
13627ce
Keystone integration: fix ui issues and fit dark mode (#3901)
soralit Mar 18, 2022
9388003
Solve main merge conflicts
Mar 18, 2022
639113c
Add new controllers
Mar 18, 2022
af1e2e0
Bump version + build number
Mar 18, 2022
cf5aa86
Bump version + build number for iOS
Mar 18, 2022
3c97acc
Merge branch 'main' into feat/keystone-integration
Mar 19, 2022
f409abd
Keystone Integration - fix ui issues with iOS (#3921)
soralit Mar 21, 2022
dfbf254
Update android version and build number
Mar 21, 2022
78cfce5
Update ios version and build number
Mar 21, 2022
3aecc08
Update metrics
Mar 22, 2022
0e27b57
Merge branch 'main' of https://github.com/MetaMask/metamask-mobile in…
Mar 22, 2022
d25f646
Keystone Integration: fix android crash. (#3938)
soralit Mar 23, 2022
3c92429
Merge main
Mar 23, 2022
ef01e2c
Update android numbers
Mar 23, 2022
de98e61
Update ios numbers
Mar 23, 2022
305cdd5
fix app crash issue and fix ios cannot show speedup modal (#3950)
soralit Mar 24, 2022
722785f
Update snapshot
Mar 24, 2022
9307fca
Merge branch 'main' into feat/keystone-integration
Mar 24, 2022
000f998
Update android numbers
Mar 24, 2022
ed801e0
Merge branch 'feat/keystone-integration' of https://github.com/MetaMa…
Mar 24, 2022
2c16b14
update ios numbers
Mar 24, 2022
afe45a6
update dependencies (#3951)
soralit Mar 24, 2022
91d15c9
Solve conflicts
Mar 28, 2022
e7d58a2
Update controllers version
Mar 28, 2022
61a5587
Update attributions
Mar 28, 2022
c878264
Merge branch 'main' into feat/keystone-integration
Mar 29, 2022
fb61ff3
resolve android animated qr code too slow issue (#3966)
soralit Mar 29, 2022
ae42822
Solve conflicts
Mar 29, 2022
eac2d08
Bump version
Mar 29, 2022
cd2ac2d
fix transaction details not shown (#3981)
soralit Mar 30, 2022
5fc2194
Update dependencies
Mar 30, 2022
a3a035d
Update build number
Mar 30, 2022
0aab2e5
Update build number
Mar 30, 2022
872445c
Merge branch 'main' into feat/keystone-integration
Mar 30, 2022
aa99a17
modify QR generation mode to speed up the scanning process (#3991)
soralit Mar 31, 2022
9036860
Merge main
Mar 31, 2022
fe8d6ca
Keystone Integration: fix hardware label and scanning address in keys…
soralit Mar 31, 2022
58e8b7d
ui improvement on android camera access (#4002)
soralit Mar 31, 2022
20f050e
Update build number
Mar 31, 2022
6319c25
Add spacing
Mar 31, 2022
ff4c38c
Update image
Mar 31, 2022
36e15cc
Add spacing
Apr 1, 2022
576039d
fix the issue that iOS check box cannot diable (#4018)
soralit Apr 1, 2022
f549c09
Delete package-lock
Apr 1, 2022
f2c39ee
Bump build number
Apr 1, 2022
2da1239
Revert podfile.lock
Apr 4, 2022
70af794
Remove keyring
Apr 4, 2022
e8db553
Move constant to another file
Apr 4, 2022
6aafd6b
Move supported ur types to constant file
Apr 4, 2022
ec3bb3b
Move supported ur types to constant file
Apr 4, 2022
de7765a
Update text color
Apr 4, 2022
9ca37c6
Fix color and font styles
Cal-L Apr 4, 2022
c1eb3cf
Merge branch 'main' into feat/keystone-integration
Apr 5, 2022
f6fe256
Revert boolean cast
Apr 5, 2022
bd33425
Wrap keyring unlock into try-catch
Apr 5, 2022
bf74a60
Revert canGoBack conditional
Apr 5, 2022
14429a5
Move formatAddress to utils
Apr 5, 2022
d7b92b6
use formatAddress instead of clipAddress
Apr 5, 2022
482a80e
Use EthereumAddress component in account select
Apr 5, 2022
70604c3
Use StyledButton in SelectQRAccounts
Apr 5, 2022
b340ff5
Update snapshots
Apr 5, 2022
e19eaea
fix export hardware private key error text; Add a system settings lin…
soralit Apr 5, 2022
950bc27
Merge branch 'feat/keystone-integration' of https://github.com/MetaMa…
Apr 5, 2022
0ccf01a
Use StyledButton in ConnectQRInstruction and update styles
Apr 5, 2022
43fbdfc
Move urls into constant file
Apr 5, 2022
b166e89
Revert unnecessary boolean cast
Apr 5, 2022
14288b2
Update checkbox style
Apr 5, 2022
512a341
Update checkbox style
Apr 5, 2022
4665b74
Remove getNetworkTypeByChainId
Apr 5, 2022
5d8e47d
Revert config changes
Apr 5, 2022
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
12 changes: 12 additions & 0 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import RevealPrivateCredential from '../../Views/RevealPrivateCredential';
import WalletConnectSessions from '../../Views/WalletConnectSessions';
import OfflineMode from '../../Views/OfflineMode';
import QrScanner from '../../Views/QRScanner';
import ConnectQRHardware from '../../Views/ConnectQRHardware';
import LockScreen from '../../Views/LockScreen';
import EnterPasswordSimple from '../../Views/EnterPasswordSimple';
import ChoosePassword from '../../Views/ChoosePassword';
Expand Down Expand Up @@ -321,6 +322,16 @@ const SetPasswordFlow = () => (
</Stack.Navigator>
);

const ConnectQRHardwareFlow = () => (
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name="ConnectQRHardware" component={ConnectQRHardware} />
gantunesr marked this conversation as resolved.
Show resolved Hide resolved
</Stack.Navigator>
);

const MainNavigator = () => (
<Stack.Navigator
screenOptions={{
Expand All @@ -346,6 +357,7 @@ const MainNavigator = () => (
<Stack.Screen name="Webview" component={Webview} />
<Stack.Screen name="SettingsView" component={SettingsModalStack} />
<Stack.Screen name="ImportPrivateKeyView" component={ImportPrivateKeyView} />
<Stack.Screen name="ConnectQRHardwareFlow" component={ConnectQRHardwareFlow} />
<Stack.Screen name="SendView" component={SendView} />
<Stack.Screen name="SendFlowView" component={SendFlowView} />
<Stack.Screen name="AddBookmarkView" component={AddBookmarkView} />
Expand Down
31 changes: 25 additions & 6 deletions app/components/Nav/Main/RootRPCMethodsUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ import BigNumber from 'bignumber.js';
import { getTokenList } from '../../../reducers/tokens';
import { toLowerCaseEquals } from '../../../util/general';
import { ApprovalTypes } from '../../../core/RPCMethods/RPCMethodMiddleware';
import { KEYSTONE_TX_CANCELED } from '../../../constants/error';
import AnalyticsV2 from '../../../util/analyticsV2';
import { mockTheme, useAppThemeFromContext } from '../../../util/theme';
import withQRHardwareAwareness from '../../UI/QRHardware/withQRHardwareAwareness';
import QRSigningModal from '../../UI/QRHardware/QRSigningModal';
import { networkSwitched } from '../../../actions/onboardNetwork';

const hstInterface = new ethers.utils.Interface(abi);
Expand Down Expand Up @@ -193,7 +197,7 @@ const RootRPCMethodsUI = (props) => {

const autoSign = useCallback(
async (transactionMeta) => {
const { TransactionController } = Engine.context;
const { TransactionController, KeyringController } = Engine.context;
try {
TransactionController.hub.once(`${transactionMeta.id}:finished`, (transactionMeta) => {
if (transactionMeta.status === 'submitted') {
Expand All @@ -213,12 +217,17 @@ const RootRPCMethodsUI = (props) => {
trackSwaps(ANALYTICS_EVENT_OPTS.SWAP_COMPLETED, transactionMeta);
}
});
await KeyringController.resetQRKeyringState();
await TransactionController.approveTransaction(transactionMeta.id);
} catch (error) {
Alert.alert(strings('transactions.transaction_error'), error && error.message, [
{ text: strings('navigation.ok') },
]);
Logger.error(error, 'error while trying to send transaction (Main)');
if (!error?.message.startsWith(KEYSTONE_TX_CANCELED)) {
Alert.alert(strings('transactions.transaction_error'), error && error.message, [
{ text: strings('navigation.ok') },
]);
Logger.error(error, 'error while trying to send transaction (Main)');
} else {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.QR_HARDWARE_TRANSACTION_CANCELED);
}
}
},
[props.swapsTransactions, trackSwaps]
Expand Down Expand Up @@ -380,6 +389,13 @@ const RootRPCMethodsUI = (props) => {
</Modal>
);

const renderQRSigningModal = () => {
const { isSigningQRObject, QRState, approveModalVisible, dappTransactionModalVisible } = props;
const shouldRenderThisModal =
!showPendingApproval && !approveModalVisible && !dappTransactionModalVisible && isSigningQRObject;
return shouldRenderThisModal && <QRSigningModal isVisible={isSigningQRObject} QRState={QRState} />;
};

const onWalletConnectSessionApproval = () => {
const { peerId } = walletConnectRequestInfo;
setWalletConnectRequest(false);
Expand Down Expand Up @@ -674,6 +690,7 @@ const RootRPCMethodsUI = (props) => {
{renderSwitchCustomNetworkModal()}
{renderAccountsApprovalModal()}
{renderWatchAssetModal()}
{renderQRSigningModal()}
</React.Fragment>
);
};
Expand Down Expand Up @@ -720,6 +737,8 @@ RootRPCMethodsUI.propTypes = {
* Chain id
*/
chainId: PropTypes.string,
isSigningQRObject: PropTypes.bool,
QRState: PropTypes.object,
/**
* updates redux when network is switched
*/
Expand All @@ -744,4 +763,4 @@ const mapDispatchToProps = (dispatch) => ({
networkSwitched: ({ networkUrl, networkStatus }) => dispatch(networkSwitched({ networkUrl, networkStatus })),
});

export default connect(mapStateToProps, mapDispatchToProps)(RootRPCMethodsUI);
export default connect(mapStateToProps, mapDispatchToProps)(withQRHardwareAwareness(RootRPCMethodsUI));
gantunesr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`AccountApproval should render correctly 1`] = `
}
dispatch={[Function]}
networkType="ropsten"
selectedAddress="0xe7E125654064EEa56229f273dA586F10DF96B0a1"
tokensLength={0}
/>
`;
9 changes: 8 additions & 1 deletion app/components/UI/AccountApproval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Device from '../../../util/device';
import NotificationManager from '../../../core/NotificationManager';
import AnalyticsV2 from '../../../util/analyticsV2';
import URL from 'url-parse';
import { getAddressAccountType } from '../../../util/address';
import { ThemeContext, mockTheme } from '../../../util/theme';
import { ACCOUNT_APROVAL_MODAL_CONTAINER_ID, CANCEL_BUTTON_ID } from '../../../constants/test-ids';

Expand Down Expand Up @@ -78,6 +79,10 @@ class AccountApproval extends PureComponent {
* Callback triggered on account access rejection
*/
onCancel: PropTypes.func,
/**
* A string that represents the selected address
*/
selectedAddress: PropTypes.string,
/**
* Number of tokens
*/
Expand Down Expand Up @@ -106,9 +111,10 @@ class AccountApproval extends PureComponent {

getAnalyticsParams = () => {
try {
const { currentPageInformation, chainId, networkType } = this.props;
const { currentPageInformation, chainId, networkType, selectedAddress } = this.props;
const url = new URL(currentPageInformation?.url);
return {
account_type: getAddressAccountType(selectedAddress),
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: networkType,
Expand Down Expand Up @@ -219,6 +225,7 @@ class AccountApproval extends PureComponent {

const mapStateToProps = (state) => ({
accountsLength: Object.keys(state.engine.backgroundState.AccountTrackerController.accounts || {}).length,
selectedAddress: state.engine.backgroundState.PreferencesController.selectedAddress,
tokensLength: state.engine.backgroundState.TokensController.tokens.length,
networkType: state.engine.backgroundState.NetworkController.provider.type,
chainId: state.engine.backgroundState.NetworkController.provider.chainId,
Expand Down
83 changes: 75 additions & 8 deletions app/components/UI/AccountInfoCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { strings } from '../../../../locales/i18n';
import { connect } from 'react-redux';
import { renderAccountName, renderShortAddress } from '../../../util/address';
import { getTicker } from '../../../util/transactions';
import Engine from '../../../core/Engine';
import { QR_HARDWARE_WALLET_DEVICE } from '../../../constants/keyringTypes';
import Device from '../../../util/device';
import { ThemeContext, mockTheme } from '../../../util/theme';

Expand All @@ -19,7 +21,8 @@ const createStyles = (colors) =>
borderWidth: 1,
borderColor: colors.border.default,
borderRadius: 10,
padding: 16,
padding: Device.isMediumDevice() ? 8 : 16,
alignItems: 'center',
},
identicon: {
marginRight: 8,
Expand All @@ -29,6 +32,7 @@ const createStyles = (colors) =>
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'flex-start',
marginRight: 8,
},
accountNameAndAddress: {
width: '100%',
Expand All @@ -42,18 +46,40 @@ const createStyles = (colors) =>
marginRight: 2,
color: colors.text.default,
},
accountNameSmall: {
fontSize: 12,
},
accountAddress: {
flexGrow: 1,
...fontStyles.bold,
fontSize: 16,
color: colors.text.default,
},
accountAddressSmall: {
fontSize: 12,
},
balanceText: {
...fontStyles.thin,
fontSize: 14,
alignSelf: 'flex-start',
color: colors.text.default,
},
balanceTextSmall: {
fontSize: 12,
},
tag: {
borderRadius: 14,
borderWidth: 1,
borderColor: colors.text.default,
padding: 4,
minWidth: 42,
},
tagText: {
textAlign: 'center',
fontSize: 8,
...fontStyles.bold,
color: colors.text.default,
},
});

class AccountInfoCard extends PureComponent {
Expand Down Expand Up @@ -82,18 +108,44 @@ class AccountInfoCard extends PureComponent {
* Declares the operation being performed i.e. 'signing'
*/
operation: PropTypes.string,
/**
* Clarify should show fiat balance
*/
showFiatBalance: PropTypes.bool,
/**
* Current selected ticker
*/
ticker: PropTypes.string,
};

state = {
isHardwareKeyring: false,
};

componentDidMount() {
const { KeyringController } = Engine.context;
const { selectedAddress } = this.props;
KeyringController.getAccountKeyringType(selectedAddress).then((type) => {
if (type === QR_HARDWARE_WALLET_DEVICE) {
this.setState({ isHardwareKeyring: true });
}
});
}

render() {
const { accounts, selectedAddress, identities, conversionRate, currentCurrency, operation, ticker } =
this.props;
const {
accounts,
selectedAddress,
identities,
conversionRate,
currentCurrency,
operation,
ticker,
showFiatBalance = true,
} = this.props;
const { isHardwareKeyring } = this.state;
const colors = this.context.colors || mockTheme.colors;
const styles = createStyles(colors);

const weiBalance = hexToBN(accounts[selectedAddress].balance);
const balance = `(${renderFromWei(weiBalance)} ${getTicker(ticker)})`;
const accountLabel = renderAccountName(selectedAddress, identities);
Expand All @@ -104,19 +156,34 @@ class AccountInfoCard extends PureComponent {
<Identicon address={selectedAddress} diameter={40} customStyle={styles.identicon} />
<View style={styles.accountInfoRow}>
<View style={styles.accountNameAndAddress}>
<Text numberOfLines={1} style={styles.accountName}>
<Text
numberOfLines={1}
style={[styles.accountName, isHardwareKeyring ? styles.accountNameSmall : undefined]}
>
{accountLabel}
</Text>
<Text numberOfLines={1} style={styles.accountAddress}>
<Text
numberOfLines={1}
style={[styles.accountAddress, isHardwareKeyring ? styles.accountAddressSmall : undefined]}
>
({address})
</Text>
</View>
{operation === 'signing' ? null : (
<Text numberOfLines={1} style={styles.balanceText}>
{strings('signature_request.balance_title')} {dollarBalance} {balance}
<Text
numberOfLines={1}
style={[styles.balanceText, isHardwareKeyring ? styles.balanceTextSmall : undefined]}
>
{strings('signature_request.balance_title')} {showFiatBalance ? dollarBalance : ''}{' '}
{balance}
</Text>
)}
</View>
{isHardwareKeyring && (
<View style={styles.tag}>
<Text style={styles.tagText}>{strings('transaction.hardware')}</Text>
</View>
)}
</View>
);
}
Expand Down
24 changes: 13 additions & 11 deletions app/components/UI/AccountList/AccountElement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const createStyles = (colors) =>
},
importedView: {
flex: 0.5,
alignItems: 'center',
alignItems: 'flex-start',
marginTop: 2,
},
accountMain: {
Expand All @@ -71,7 +71,6 @@ const createStyles = (colors) =>
...fontStyles.bold,
},
importedWrapper: {
width: 73,
paddingHorizontal: 10,
paddingVertical: 3,
borderRadius: 10,
Expand Down Expand Up @@ -122,18 +121,21 @@ class AccountElement extends PureComponent {

render() {
const { disabled, updatedBalanceFromStore, ticker } = this.props;
const { address, name, ens, isSelected, isImported, balanceError } = this.props.item;
const { address, name, ens, isSelected, isImported, balanceError, isQRHardware } = this.props.item;
const colors = this.context.colors || mockTheme.colors;
const styles = createStyles(colors);

const selected = isSelected ? <Icon name="check-circle" size={30} color={colors.primary.default} /> : null;
const imported = isImported ? (
<View style={styles.importedWrapper}>
<Text numberOfLines={1} style={styles.importedText}>
{strings('accounts.imported')}
</Text>
</View>
) : null;
const tag =
isImported || isQRHardware ? (
<View style={styles.importedView}>
<View style={styles.importedWrapper}>
<Text numberOfLines={1} style={styles.importedText}>
{strings(isImported ? 'accounts.imported' : 'transaction.hardware')}
</Text>
</View>
</View>
) : null;

return (
<View onStartShouldSetResponder={() => true}>
Expand Down Expand Up @@ -161,7 +163,7 @@ class AccountElement extends PureComponent {
)}
</View>
</View>
{!!imported && <View style={styles.importedView}>{imported}</View>}
{!!tag && tag}
gantunesr marked this conversation as resolved.
Show resolved Hide resolved
<View style={styles.selectedWrapper}>{selected}</View>
</View>
</TouchableOpacity>
Expand Down
Loading