Browse Source

Merge pull request #1812 from juan-cortes/LL-1028

LL-1028 Added generic error for zero fees on bitcoinkind currencies
develop
Gaëtan Renaudeau 6 years ago
committed by GitHub
parent
commit
c4d8811f9d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 24
      src/bridge/LibcoreBridge.js
  3. 10
      src/components/FeesField/BitcoinKind.js
  4. 3
      static/i18n/en/app.json
  5. 28
      yarn.lock

2
package.json

@ -35,7 +35,7 @@
}
},
"dependencies": {
"@ledgerhq/errors": "^4.35.1",
"@ledgerhq/errors": "^4.39.0",
"@ledgerhq/hw-app-btc": "^4.35.0",
"@ledgerhq/hw-app-eth": "^4.35.0",
"@ledgerhq/hw-app-xrp": "^4.35.0",

24
src/bridge/LibcoreBridge.js

@ -103,17 +103,19 @@ const getFees = async (a, transaction) => {
const checkValidTransaction = (a, t) =>
!t.feePerByte
? Promise.reject(new FeeNotLoaded())
: !t.amount
? Promise.resolve(true)
: getFees(a, t)
.then(() => true)
.catch(e => {
if (e.code === NOT_ENOUGH_FUNDS) {
throw new NotEnoughBalance()
}
feesLRU.del(getFeesKey(a, t))
throw e
})
: t.feePerByte.eq(0)
? Promise.resolve(false)
: !t.amount
? Promise.resolve(true)
: getFees(a, t)
.then(() => true)
.catch(e => {
if (e.code === NOT_ENOUGH_FUNDS) {
throw new NotEnoughBalance()
}
feesLRU.del(getFeesKey(a, t))
throw e
})
const LibcoreBridge: WalletBridge<Transaction> = {
scanAccountsOnDevice(currency, devicePath) {

10
src/components/FeesField/BitcoinKind.js

@ -8,7 +8,7 @@ import { translate } from 'react-i18next'
import type { T } from 'types/common'
import { FeeNotLoaded } from '@ledgerhq/errors'
import { FeeNotLoaded, FeeRequired } from '@ledgerhq/errors'
import InputCurrency from 'components/base/InputCurrency'
import Select from 'components/base/Select'
import type { Fees } from '@ledgerhq/live-common/lib/api/Fees'
@ -147,7 +147,13 @@ class FeesField extends Component<OwnProps, State> {
onChange={onChange}
onChangeFocus={this.onChangeFocus}
loading={!feePerByte && !error}
error={!feePerByte && error ? new FeeNotLoaded() : null}
error={
!feePerByte && error
? new FeeNotLoaded()
: feePerByte && feePerByte.isZero()
? new FeeRequired()
: null
}
renderRight={
<InputRight>{t('send.steps.amount.unitPerByte', { unit: satoshi.code })}</InputRight>
}

3
static/i18n/en/app.json

@ -925,6 +925,9 @@
"FeeNotLoaded": {
"title": "Couldn’t load fee rates, please set manual fees"
},
"FeeRequired": {
"title": "Fees are required"
},
"UnknownMCU": {
"title": "Unknown MCU version",
"description": "Please contact Ledger Support"

28
yarn.lock

@ -1677,10 +1677,10 @@
camelcase "^5.0.0"
prettier "^1.13.7"
"@ledgerhq/errors@^4.32.0", "@ledgerhq/errors@^4.35.1":
version "4.35.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-4.35.1.tgz#3f162dc05480e444083b6381bd098df187751633"
integrity sha512-2Bo3/NRKyz3ddR07TvZ87VpDJc8fz4+ONLJnhzC0mwIwu+Pxal6SgCBiGtv503oGxkgDuG5PtODZBaehWkGRnQ==
"@ledgerhq/errors@^4.32.0", "@ledgerhq/errors@^4.39.0":
version "4.39.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-4.39.0.tgz#10b9889f78df94ce36a4b34d9a3a45aac77be0e9"
integrity sha512-kBr2rnoYDACRCxTLtEufE4oCvYj6vx2oFWVVjwskBxYsF5LC9R8Mbg5C4GgvDweiWW4Io8HA9p9jCsOfdCDygg==
"@ledgerhq/hw-app-btc@^4.32.0", "@ledgerhq/hw-app-btc@^4.35.0":
version "4.35.0"
@ -13495,17 +13495,7 @@ react-treebeard@^2.1.0:
shallowequal "^0.2.2"
velocity-react "^1.3.1"
react@*, react@^16.2.0:
version "16.6.1"
resolved "https://registry.yarnpkg.com/react/-/react-16.6.1.tgz#ee2aef4f0a09e494594882029821049772f915fe"
integrity sha512-OtawJThYlvRgm9BXK+xTL7BIlDx8vv21j+fbQDjRRUyok6y7NyjlweGorielTahLZHYIdKUoK2Dp9ByVWuMqxw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.11.0"
react@^16.6.3:
react@*, react@^16.2.0, react@^16.6.3:
version "16.6.3"
resolved "https://registry.yarnpkg.com/react/-/react-16.6.3.tgz#25d77c91911d6bbdd23db41e70fb094cc1e0871c"
integrity sha512-zCvmH2vbEolgKxtqXL2wmGCUxUyNheYn/C+PD1YAjfxHC54+MhdruyhO7QieQrYsYeTxrn93PM2y0jRH1zEExw==
@ -14424,14 +14414,6 @@ sax@^1.2.4, sax@~1.2.1, sax@~1.2.4:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
scheduler@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.0.tgz#def1f1bfa6550cc57981a87106e65e8aea41a6b5"
integrity sha512-MAYbBfmiEHxF0W+c4CxMpEqMYK+rYF584VP/qMKSiHM6lTkBKKYOJaDiSILpJHla6hBOsVd6GucPL46o2Uq3sg==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
scheduler@^0.11.2:
version "0.11.3"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.3.tgz#b5769b90cf8b1464f3f3cfcafe8e3cd7555a2d6b"

Loading…
Cancel
Save