Browse Source

Prevent check recipient valid if empty

And add a catch to fallback + warning if check throwed
master
meriadec 7 years ago
parent
commit
f3d40bcb68
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 1
      src/bridge/LibcoreBridge.js
  2. 17
      src/components/modals/Send/fields/RecipientField.js

1
src/bridge/LibcoreBridge.js

@ -52,6 +52,7 @@ const isRecipientValid = (currency, recipient) => {
const key = `${currency.id}_${recipient}` const key = `${currency.id}_${recipient}`
let promise = recipientValidLRU.get(key) let promise = recipientValidLRU.get(key)
if (promise) return promise if (promise) return promise
if (!recipient) return Promise.resolve(false)
promise = libcoreValidAddress promise = libcoreValidAddress
.send({ .send({
address: recipient, address: recipient,

17
src/components/modals/Send/fields/RecipientField.js

@ -3,6 +3,7 @@ import React, { Component } from 'react'
import type { Account } from '@ledgerhq/live-common/lib/types' import type { Account } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common' import type { T } from 'types/common'
import type { WalletBridge } from 'bridge/types' import type { WalletBridge } from 'bridge/types'
import logger from 'logger'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Label from 'components/base/Label' import Label from 'components/base/Label'
import LabelInfoTooltip from 'components/base/LabelInfoTooltip' import LabelInfoTooltip from 'components/base/LabelInfoTooltip'
@ -39,12 +40,16 @@ class RecipientField<Transaction> extends Component<Props<Transaction>, { isVali
async resync() { async resync() {
const { account, bridge, transaction } = this.props const { account, bridge, transaction } = this.props
const syncId = ++this.syncId const syncId = ++this.syncId
const isValid = await bridge.isRecipientValid( try {
account.currency, const isValid = await bridge.isRecipientValid(
bridge.getTransactionRecipient(account, transaction), account.currency,
) bridge.getTransactionRecipient(account, transaction),
if (syncId !== this.syncId) return )
this.setState({ isValid }) if (syncId !== this.syncId) return
this.setState({ isValid })
} catch (err) {
logger.warn(`Can't check if recipient is valid`, err)
}
} }
onChange = (recipient: string, maybeExtra: ?Object) => { onChange = (recipient: string, maybeExtra: ?Object) => {

Loading…
Cancel
Save