Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Adds dynamic min ammount to the wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Oct 6, 2017
1 parent b27bf34 commit cb2ef1c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 39 deletions.
4 changes: 1 addition & 3 deletions app/browser/reducers/ledgerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ const ledgerReducer = (state, action, immutableAction) => {
}
case appConstants.APP_RECOVER_WALLET:
{
// TODO FIX
state = ledgerApi.recoverKeys(
state,
action.get('useRecoveryKeyFile'),
action.get('firstRecoveryKey'),
action.get('secondRecoveryKey')
action.get('recoveryKey')
)
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class AddFundsDialog extends React.Component {
return this.props.addFundsDialog.get('currency')
}

get funds () {
return this.props.funds
}

get currencyQRCode () {
const walletQR = this.props.walletQR

Expand All @@ -47,7 +43,8 @@ class AddFundsDialog extends React.Component {
case 'addFundsWizardAddress':
return (
<AddFundsWizardAddress
funds={this.funds}
funds={this.props.funds}
minAmount={this.props.minAmount}
currency={this.currency}
qrCode={this.currencyQRCode}
address={this.currencyAddress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class AddFundsWizardAddress extends React.Component {
<p data-l10n-id='addFundsWizardAddressInputNote'
data-l10n-args={JSON.stringify({
currency: this.currency,
funds: this.props.funds
funds: this.props.minAmount
} || {})}
className={css(styles.wizardAddress__text_note)}
/>
Expand Down
15 changes: 5 additions & 10 deletions app/renderer/components/preferences/payment/ledgerRecovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ const appActions = require('../../../../../js/actions/appActions')
class LedgerRecoveryContent extends ImmutableComponent {
constructor () {
super()
this.handleFirstRecoveryKeyChange = this.handleFirstRecoveryKeyChange.bind(this)
this.handleSecondRecoveryKeyChange = this.handleSecondRecoveryKeyChange.bind(this)
this.handleRecoveryKeyChange = this.handleRecoveryKeyChange.bind(this)
}

handleFirstRecoveryKeyChange (e) {
this.props.handleFirstRecoveryKeyChange(e.target.value)
}

handleSecondRecoveryKeyChange (e) {
this.props.handleSecondRecoveryKeyChange(e.target.value)
handleRecoveryKeyChange (e) {
this.props.handleRecoveryKeyChange(e.target.value)
}

clearRecoveryStatus () {
Expand Down Expand Up @@ -108,7 +103,7 @@ class LedgerRecoveryContent extends ImmutableComponent {
)}
id='recoveryKey'
spellCheck='false'
onChange={this.handleFirstRecoveryKeyChange}
onChange={this.handleRecoveryKeyChange}
/>
</SettingItem>
</SettingsList>
Expand All @@ -123,7 +118,7 @@ class LedgerRecoveryFooter extends ImmutableComponent {
}

recoverWallet () {
aboutActions.ledgerRecoverWallet(this.props.state.FirstRecoveryKey, this.props.state.SecondRecoveryKey)
aboutActions.ledgerRecoverWallet(this.props.state.recoveryKey)
}

recoverWalletFromFile () {
Expand Down
23 changes: 9 additions & 14 deletions app/renderer/components/preferences/paymentsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,21 @@ const batIcon = require('../../../extensions/brave/img/ledger/cryptoIcons/BAT_ic
// other
const getSetting = require('../../../../js/settings').getSetting
const settings = require('../../../../js/constants/settings')
const {formatCurrentBalance} = require('../../../common/lib/ledgerUtil')
const appConfig = require('../../../../js/constants/appConfig')
const {formatCurrentBalance, batToCurrencyString} = require('../../../common/lib/ledgerUtil')

class PaymentsTab extends ImmutableComponent {
constructor () {
super()
this.state = {
FirstRecoveryKey: '',
SecondRecoveryKey: ''
recoveryKey: ''
}

this.handleFirstRecoveryKeyChange = this.handleFirstRecoveryKeyChange.bind(this)
this.handleSecondRecoveryKeyChange = this.handleSecondRecoveryKeyChange.bind(this)
this.handleRecoveryKeyChange = this.handleRecoveryKeyChange.bind(this)
}

handleFirstRecoveryKeyChange (key) {
this.setState({FirstRecoveryKey: key})
this.forceUpdate()
}

handleSecondRecoveryKeyChange (key) {
this.setState({SecondRecoveryKey: key})
handleRecoveryKeyChange (key) {
this.setState({recoveryKey: key})
this.forceUpdate()
}

Expand All @@ -83,10 +77,12 @@ class PaymentsTab extends ImmutableComponent {
const walletQR = ledgerData.get('walletQR') || Immutable.List()
const wizardData = ledgerData.get('wizardData') || Immutable.Map()
const funds = formatCurrentBalance(ledgerData)
const minAmount = batToCurrencyString(appConfig.defaultSettings[settings.PAYMENTS_CONTRIBUTION_AMOUNT], ledgerData)

return <AddFundsDialog
addFundsDialog={wizardData}
funds={funds}
minAmount={minAmount}
addresses={addresses}
walletQR={walletQR}
/>
Expand Down Expand Up @@ -183,8 +179,7 @@ class PaymentsTab extends ImmutableComponent {
content={<LedgerRecoveryContent
ledgerData={this.props.ledgerData}
hideAdvancedOverlays={this.props.hideAdvancedOverlays.bind(this)}
handleFirstRecoveryKeyChange={this.handleFirstRecoveryKeyChange.bind(this)}
handleSecondRecoveryKeyChange={this.handleSecondRecoveryKeyChange.bind(this)}
handleRecoveryKeyChange={this.handleRecoveryKeyChange.bind(this)}
/>}
footer={<LedgerRecoveryFooter
state={this.state}
Expand Down
5 changes: 2 additions & 3 deletions js/about/aboutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@ const aboutActions = {
/**
* Recover wallet by merging old wallet into new one
*/
ledgerRecoverWallet: function (firstRecoveryKey, secondRecoveryKey) {
ledgerRecoverWallet: function (recoveryKey) {
aboutActions.dispatchAction({
actionType: appConstants.APP_RECOVER_WALLET,
firstRecoveryKey,
secondRecoveryKey
recoveryKey
})
},

Expand Down
5 changes: 2 additions & 3 deletions test/unit/app/browser/reducers/ledgerReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,14 @@ describe('ledgerReducer unit tests', function () {
returnedState = ledgerReducer(appState, Immutable.fromJS({
actionType: appConstants.APP_RECOVER_WALLET,
useRecoveryKeyFile: 'useKeyFile',
firstRecoveryKey: 'firstKey',
secondRecoveryKey: 'secondKey'
recoveryKey: 'firstKey'
}))
})
after(function () {
recoverKeysSpy.restore()
})
it('calls ledgerApi.recoverKeys', function () {
assert(recoverKeysSpy.withArgs(appState, 'useKeyFile', 'firstKey', 'secondKey').calledOnce)
assert(recoverKeysSpy.withArgs(appState, 'useKeyFile', 'firstKey').calledOnce)
})
it('returns a modified state', function () {
assert.notDeepEqual(returnedState, appState)
Expand Down

0 comments on commit cb2ef1c

Please sign in to comment.