remove console.log
This commit is contained in:
parent
cd69b9b960
commit
592fc7254e
|
@ -4,6 +4,7 @@ import ethNetProps from 'eth-net-props'
|
||||||
import { default as Select } from 'react-select'
|
import { default as Select } from 'react-select'
|
||||||
import Button from '../../../../ui/app/components/button'
|
import Button from '../../../../ui/app/components/button'
|
||||||
import { capitalizeFirstLetter } from '../../../../app/scripts/lib/util'
|
import { capitalizeFirstLetter } from '../../../../app/scripts/lib/util'
|
||||||
|
import { isLedger } from './util'
|
||||||
|
|
||||||
class AccountList extends Component {
|
class AccountList extends Component {
|
||||||
constructor (props, context) {
|
constructor (props, context) {
|
||||||
|
@ -67,26 +68,50 @@ class AccountList extends Component {
|
||||||
<h3 className="hw-connect">
|
<h3 className="hw-connect">
|
||||||
<h3 className="hw-connect__unlock-title">{`Unlock ${capitalizeFirstLetter(device)}`}</h3>
|
<h3 className="hw-connect__unlock-title">{`Unlock ${capitalizeFirstLetter(device)}`}</h3>
|
||||||
{device.toLowerCase() === 'ledger' ? this.renderHdPathSelector() : null}
|
{device.toLowerCase() === 'ledger' ? this.renderHdPathSelector() : null}
|
||||||
<p className="hw-connect__msg">Select the account to view in Nifty Wallet</p>
|
<p className="hw-connect__msg">Select the accounts to view in Nifty Wallet</p>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderInput = (a, i) => {
|
||||||
|
const { device } = this.props
|
||||||
|
if (isLedger(device)) {
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name={`selectedAccount-${i}`}
|
||||||
|
id={`address-${i}`}
|
||||||
|
value={a.index}
|
||||||
|
onChange={(e) => {
|
||||||
|
console.log('onChange event')
|
||||||
|
this.props.onAccountChange(e.target.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checked={this.props.selectedAccounts.includes(a.index.toString())}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="selectedAccount"
|
||||||
|
id={`address-${i}`}
|
||||||
|
value={a.index}
|
||||||
|
onChange={(e) => this.props.onAccountChange(e.target.value)}
|
||||||
|
checked={this.props.selectedAccount === a.index.toString()}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderAccounts = () => {
|
renderAccounts = () => {
|
||||||
const rows = []
|
const rows = []
|
||||||
this.props.accounts.forEach((a, i) => {
|
this.props.accounts.forEach((a, i) => {
|
||||||
rows.push(
|
rows.push(
|
||||||
<div className="hw-account-list__item" key={a.address}>
|
<div className="hw-account-list__item" key={a.address}>
|
||||||
<div className="hw-account-list__item__radio">
|
<div className="hw-account-list__item__radio">
|
||||||
<input
|
{this.renderInput(a, i)}
|
||||||
type="radio"
|
|
||||||
name="selectedAccount"
|
|
||||||
id={`address-${i}`}
|
|
||||||
value={a.index}
|
|
||||||
onChange={(e) => this.props.onAccountChange(e.target.value)}
|
|
||||||
checked={this.props.selectedAccount === a.index.toString()}
|
|
||||||
/>
|
|
||||||
<label className="hw-account-list__item__label" htmlFor={`address-${i}`}>
|
<label className="hw-account-list__item__label" htmlFor={`address-${i}`}>
|
||||||
{`${a.address.slice(0, 4)}...${a.address.slice(-4)}`}
|
{`${a.address.slice(0, 4)}...${a.address.slice(-4)}`}
|
||||||
<span
|
<span
|
||||||
|
@ -125,7 +150,7 @@ class AccountList extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderButtons = () => {
|
renderButtons = () => {
|
||||||
const disabled = this.props.selectedAccount === null
|
const disabled = !this.props.selectedAccount && this.props.selectedAccounts.length === 0
|
||||||
const buttonProps = {}
|
const buttonProps = {}
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
buttonProps.disabled = true
|
buttonProps.disabled = true
|
||||||
|
@ -182,6 +207,7 @@ AccountList.propTypes = {
|
||||||
getPage: PropTypes.func.isRequired,
|
getPage: PropTypes.func.isRequired,
|
||||||
network: PropTypes.string,
|
network: PropTypes.string,
|
||||||
selectedAccount: PropTypes.string,
|
selectedAccount: PropTypes.string,
|
||||||
|
selectedAccounts: PropTypes.array,
|
||||||
history: PropTypes.object,
|
history: PropTypes.object,
|
||||||
onUnlockAccount: PropTypes.func,
|
onUnlockAccount: PropTypes.func,
|
||||||
onCancel: PropTypes.func,
|
onCancel: PropTypes.func,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import AccountList from './account-list'
|
||||||
import { formatBalance } from '../../util'
|
import { formatBalance } from '../../util'
|
||||||
import { getPlatform } from '../../../../app/scripts/lib/util'
|
import { getPlatform } from '../../../../app/scripts/lib/util'
|
||||||
import { PLATFORM_FIREFOX } from '../../../../app/scripts/lib/enums'
|
import { PLATFORM_FIREFOX } from '../../../../app/scripts/lib/enums'
|
||||||
|
import { isLedger } from './util'
|
||||||
|
|
||||||
class ConnectHardwareForm extends Component {
|
class ConnectHardwareForm extends Component {
|
||||||
constructor (props, context) {
|
constructor (props, context) {
|
||||||
|
@ -14,6 +15,7 @@ class ConnectHardwareForm extends Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
error: null,
|
error: null,
|
||||||
selectedAccount: null,
|
selectedAccount: null,
|
||||||
|
selectedAccounts: [],
|
||||||
accounts: [],
|
accounts: [],
|
||||||
browserSupported: true,
|
browserSupported: true,
|
||||||
unlocked: false,
|
unlocked: false,
|
||||||
|
@ -69,7 +71,24 @@ class ConnectHardwareForm extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onAccountChange = (account) => {
|
onAccountChange = (account) => {
|
||||||
this.setState({selectedAccount: account.toString(), error: null})
|
let selectedAcc = account.toString()
|
||||||
|
if (isLedger(this.state.device)) {
|
||||||
|
const selectedAccounts = this.state.selectedAccounts
|
||||||
|
if (!selectedAccounts.includes(selectedAcc)) {
|
||||||
|
selectedAccounts.push(selectedAcc)
|
||||||
|
} else {
|
||||||
|
const indToRemove = selectedAccounts.indexOf(selectedAcc)
|
||||||
|
selectedAccounts.splice(indToRemove, 1)
|
||||||
|
selectedAcc = selectedAccounts[selectedAccounts.length - 1]
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
selectedAccounts,
|
||||||
|
selectedAccount: selectedAcc,
|
||||||
|
error: null,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.setState({selectedAccount: account.toString(), error: null})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onAccountRestriction = () => {
|
onAccountRestriction = () => {
|
||||||
|
@ -136,6 +155,7 @@ class ConnectHardwareForm extends Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
error: null,
|
error: null,
|
||||||
selectedAccount: null,
|
selectedAccount: null,
|
||||||
|
selectedAccounts: [],
|
||||||
accounts: [],
|
accounts: [],
|
||||||
unlocked: false,
|
unlocked: false,
|
||||||
})
|
})
|
||||||
|
@ -146,16 +166,29 @@ class ConnectHardwareForm extends Component {
|
||||||
|
|
||||||
onUnlockAccount = (device) => {
|
onUnlockAccount = (device) => {
|
||||||
|
|
||||||
if (this.state.selectedAccount === null) {
|
if (!this.state.selectedAccount && this.state.selectedAccounts.length === 0) {
|
||||||
this.setState({ error: 'You need to select an account!' })
|
this.setState({ error: 'You need to select an account!' })
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.unlockHardwareWalletAccount(this.state.selectedAccount, device)
|
if (this.state.selectedAccounts.length > 0) {
|
||||||
.then(_ => {
|
const whenUnlocks = []
|
||||||
this.props.goHome()
|
this.state.selectedAccounts.forEach((selectedAcc) => {
|
||||||
}).catch(e => {
|
whenUnlocks.push(this.props.unlockHardwareWalletAccount(selectedAcc, device))
|
||||||
this.setState({ error: (e.message || e.toString()) })
|
})
|
||||||
})
|
Promise.all(whenUnlocks)
|
||||||
|
.then(_ => {
|
||||||
|
this.props.goHome()
|
||||||
|
}).catch(e => {
|
||||||
|
this.setState({ error: (e.message || e.toString()) })
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.props.unlockHardwareWalletAccount(this.state.selectedAccount, device)
|
||||||
|
.then(_ => {
|
||||||
|
this.props.goHome()
|
||||||
|
}).catch(e => {
|
||||||
|
this.setState({ error: (e.message || e.toString()) })
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCancel = () => {
|
onCancel = () => {
|
||||||
|
@ -185,6 +218,7 @@ class ConnectHardwareForm extends Component {
|
||||||
device={this.state.device}
|
device={this.state.device}
|
||||||
accounts={this.state.accounts}
|
accounts={this.state.accounts}
|
||||||
selectedAccount={this.state.selectedAccount}
|
selectedAccount={this.state.selectedAccount}
|
||||||
|
selectedAccounts={this.state.selectedAccounts}
|
||||||
onAccountChange={this.onAccountChange}
|
onAccountChange={this.onAccountChange}
|
||||||
network={this.props.network}
|
network={this.props.network}
|
||||||
getPage={this.getPage}
|
getPage={this.getPage}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
function isLedger (device) {
|
||||||
|
return device && device.toLowerCase().includes('ledger')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
isLedger,
|
||||||
|
}
|
|
@ -337,7 +337,6 @@ class SendTransactionScreen extends PersistentForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
setOutputValue = (val, type) => {
|
setOutputValue = (val, type) => {
|
||||||
console.log(val)
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return val || ''
|
return val || ''
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue