Skip to content

Commit

Permalink
settings: add view account key (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithvikvibhu committed Jun 30, 2022
1 parent 901a521 commit 9c7b651
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/ducks/walletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const setWallet = opts => {
apiKey = '',
changeDepth,
receiveDepth,
accountKey,
} = opts;

return {
Expand All @@ -49,6 +50,7 @@ export const setWallet = opts => {
apiKey,
changeDepth,
receiveDepth,
accountKey,
},
};
};
Expand Down Expand Up @@ -101,6 +103,7 @@ export const fetchWallet = () => async (dispatch, getState) => {
balance: accountInfo.balance,
changeDepth: accountInfo.changeDepth,
receiveDepth: accountInfo.receiveDepth,
accountKey: accountInfo.accountKey,
}));
};

Expand Down
2 changes: 2 additions & 0 deletions app/ducks/walletReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function getInitialState() {
},
changeDepth: 0,
receiveDepth: 0,
accountKey: null,
transactions: new Map(),
idle: 0,
maxIdle: 5,
Expand Down Expand Up @@ -75,6 +76,7 @@ export default function walletReducer(state = getInitialState(), {type, payload}
},
changeDepth: payload.changeDepth,
receiveDepth: payload.receiveDepth,
accountKey: payload.accountKey,
initialized: typeof payload.initialized === 'undefined' ? state.initialized : payload.initialized,
};
case SET_BALANCE:
Expand Down
43 changes: 43 additions & 0 deletions app/pages/Settings/AccountKeyModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import MiniModal from '../../components/Modal/MiniModal';
import {I18nContext} from "../../utils/i18n";
import './account-key-modal.scss';

@connect(
(state) => ({
accountKey: state.wallet.accountKey,
}),
dispatch => ({
})
)
class AccountKeyModal extends Component {
static contextType = I18nContext;

constructor(props) {
super(props);

this.state = {};
}

render() {
const {t} = this.context;

return (
<MiniModal
closeRoute="/settings/wallet"
title={t('settingAccountKeyCTA')}
centered
>
<div className="account-key__instructions">
{t('settingAccountKeyDesc')}
</div>
<div className="account-key__seed-phrase">
{this.props.accountKey}
</div>
</MiniModal>
);
}
}

export default AccountKeyModal;
21 changes: 21 additions & 0 deletions app/pages/Settings/account-key-modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import '../../variables';


.account-key {
&__instructions {
font-size: 14px;
line-height: 1.2rem;
margin-bottom: 1rem;
}

&__seed-phrase {
background-color: $athens-gray;
margin: 0 auto;
padding: 12px;
border-radius: 8px;
font-size: 14px;
line-height: 18px;
line-break: anywhere;
user-select: all;
}
}
8 changes: 8 additions & 0 deletions app/pages/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { connect } from 'react-redux';
import './index.scss';
import AccountIndexModal from './AccountIndexModal';
import MaxIdleModal from './MaxIdleModal';
import AccountKeyModal from './AccountKeyModal';
import RevealSeedModal from './RevealSeedModal';
import ZapTXsModal from './ZapTXsModal';
import * as logger from '../../utils/logClient';
Expand Down Expand Up @@ -379,6 +380,12 @@ export default class Settings extends Component {
t('settingZapCTA'),
() => history.push('/settings/wallet/zap-txs'),
)}
{this.renderSection(
t('settingAccountKeyTitle'),
t('settingAccountKeyDesc'),
t('settingAccountKeyCTA'),
() => history.push('/settings/wallet/account-key'),
)}
{this.renderSection(
t('settingRevealSeedTitle'),
t('settingRevealSeedDesc'),
Expand Down Expand Up @@ -604,6 +611,7 @@ export default class Settings extends Component {
/>
)}
/>
<Route path="/settings/wallet/account-key" component={AccountKeyModal} />
<Route path="/settings/wallet/reveal-seed" component={RevealSeedModal} />
<Route path="/settings/wallet/zap-txs" component={ZapTXsModal} />
<Route path="/settings/connection/configure" component={CustomRPCConfigModal} />
Expand Down
3 changes: 3 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@
"sendTxSizeLabel": "Estimated TX Size:",
"sendTxTimeLabel": "Transaction time",
"setReminder": "Set reminder",
"settingAccountKeyCTA": "View Account Key",
"settingAccountKeyDesc": "Anyone with this public key has read-only access to this wallet account and all its transaction history.",
"settingAccountKeyTitle": "Account Key (xPub key)",
"settingAPIKeyCTA": "View API Key",
"settingAPIKeyDesc": "API key for hs-client. Make sure you select the wallet id \"%s\".",
"settingBackupListingDesc": "Download backup of all your listings and fulfillments",
Expand Down

0 comments on commit 9c7b651

Please sign in to comment.