Skip to content

Commit

Permalink
Nep5 ledger (#456)
Browse files Browse the repository at this point in the history
* add ledger NEP5 support

* remove contains tokens
  • Loading branch information
dvdschwrtz committed Jan 3, 2018
1 parent a02445f commit 1bc98e6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 28 deletions.
11 changes: 1 addition & 10 deletions app/components/Modals/SendModal/AddRecipientDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import styles from './AddRecipientDisplay.scss'

type Props = {
balances: Object,
isHardwareLogin: boolean,
onConfirm: Function,
onCancel: Function
}
Expand All @@ -39,7 +38,6 @@ export default class AddRecipientDisplay extends React.Component<Props, State> {

const balance = balances[symbol]
const max = formatBalance(symbol, balance)
const disableNEP5Ledger = this.disableNEP5Ledger()

return (
<div className={styles.addRecipientDisplay}>
Expand Down Expand Up @@ -80,9 +78,6 @@ export default class AddRecipientDisplay extends React.Component<Props, State> {
{isToken(symbol) && (
<div className={styles.tokenInfoMessage}>Sending NEP5 tokens requires holding at least 1 drop of GAS</div>
)}
{disableNEP5Ledger && (
<div className={styles.tokenInfoMessage}>Ledger support is not yet available for NEP5 tokens</div>
)}
</div>
<div className={styles.actions}>
<Button cancel onClick={onCancel}>
Expand All @@ -107,11 +102,7 @@ export default class AddRecipientDisplay extends React.Component<Props, State> {

canConfirm = () => {
const { address, amount } = this.state
return !!address && !!amount && !this.disableNEP5Ledger()
}

disableNEP5Ledger = () => {
return this.props.isHardwareLogin && isToken(this.state.symbol)
return !!address && !!amount
}

getSymbols = () => {
Expand Down
4 changes: 1 addition & 3 deletions app/components/Modals/SendModal/SendModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type Props = {
hideModal: Function,
sendTransaction: Function,
address: string,
isHardwareLogin: boolean,
}

type BalancesType = {
Expand Down Expand Up @@ -65,14 +64,13 @@ export default class SendModal extends Component<Props, State> {
}

renderDisplay = () => {
const { address, isHardwareLogin } = this.props
const { address } = this.props
const { display, balances, entries } = this.state

if (display === DISPLAY_MODES.ADD_RECIPIENT) {
return (
<AddRecipientDisplay
balances={balances}
isHardwareLogin={isHardwareLogin}
onCancel={this.handleCancelAddRecipient}
onConfirm={this.handleConfirmAddRecipient} />
)
Expand Down
6 changes: 2 additions & 4 deletions app/containers/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Props = {
tokens: Object,
loaded: boolean,
loadWalletData: Function,
isHardwareLogin: boolean,
}

const REFRESH_INTERVAL_MS = 30000
Expand Down Expand Up @@ -55,8 +54,7 @@ export default class Dashboard extends Component<Props> {
tokens,
showErrorNotification,
sendTransaction,
loaded,
isHardwareLogin
loaded
} = this.props

if (!loaded) {
Expand All @@ -70,7 +68,7 @@ export default class Dashboard extends Component<Props> {
<div className={styles.walletButtons}>
<div
className={classNames(styles.walletButton, styles.sendButton)}
onClick={() => showModal(MODAL_TYPES.SEND, { NEO, GAS, tokens, showErrorNotification, sendTransaction, address, isHardwareLogin })}>
onClick={() => showModal(MODAL_TYPES.SEND, { NEO, GAS, tokens, showErrorNotification, sendTransaction, address })}>
<FaArrowUpward className={styles.walletButtonIcon} /><span className={styles.walletButtonText}>Send</span>
</div>
<div
Expand Down
5 changes: 2 additions & 3 deletions app/containers/Dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'

import { logout, getAddress, getIsHardwareLogin } from '../../modules/account'
import { logout, getAddress } from '../../modules/account'
import { getNetwork } from '../../modules/metadata'
import { getNotifications, showErrorNotification } from '../../modules/notifications'
import { getNEO, getGAS, getTokens, getIsLoaded, loadWalletData } from '../../modules/wallet'
Expand All @@ -18,8 +18,7 @@ const mapStateToProps = (state: Object) => ({
NEO: getNEO(state),
GAS: getGAS(state),
tokens: getTokens(state),
loaded: getIsLoaded(state),
isHardwareLogin: getIsHardwareLogin(state)
loaded: getIsLoaded(state)
})

const actionCreators = {
Expand Down
8 changes: 0 additions & 8 deletions app/modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export const syncTransactionHistory = (net: NetworkType, address: string) => asy
}
}

const containsTokens = (sendEntries: Array<SendEntryType>) => {
return sendEntries.some(({ symbol }) => isToken(symbol))
}

const extractTokens = (sendEntries: Array<SendEntryType>) => {
return sendEntries.filter(({ symbol }) => isToken(symbol))
}
Expand Down Expand Up @@ -122,10 +118,6 @@ export const sendTransaction = (sendEntries: Array<SendEntryType>) => async (dis
return rejectTransaction(error)
}

if (isHardwareSend && containsTokens(sendEntries)) {
return rejectTransaction('Ledger support is not yet ready for sending NEP5 tokens')
}

dispatch(showInfoNotification({ message: 'Sending Transaction...', autoDismiss: 0 }))

log(net, 'SEND', fromAddress, sendEntries.map(({ address, amount, symbol }) => ({
Expand Down

0 comments on commit 1bc98e6

Please sign in to comment.