mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-27 17:38:07 +00:00
Merge pull request #283 from trezor/fix/ripple-address-validation
validate via wallet-address-validator lib
This commit is contained in:
commit
633f15b5e8
@ -70,6 +70,7 @@
|
||||
"styled-components": "^4.1.2",
|
||||
"styled-normalize": "^8.0.4",
|
||||
"trezor-connect": "6.0.3-beta.5",
|
||||
"wallet-address-validator": "^0.2.4",
|
||||
"web3": "1.0.0-beta.35",
|
||||
"webpack": "^4.16.3",
|
||||
"webpack-build-notifier": "^0.1.29",
|
||||
|
@ -12,8 +12,8 @@ import type {
|
||||
} from 'flowtype';
|
||||
import type { State, FeeLevel } from 'reducers/SendFormRippleReducer';
|
||||
|
||||
import AddressValidator from 'wallet-address-validator';
|
||||
// general regular expressions
|
||||
const XRP_ADDRESS_RE = new RegExp('^r[1-9A-HJ-NP-Za-km-z]{25,34}$');
|
||||
const NUMBER_RE: RegExp = new RegExp('^(0|0\\.([0-9]+)?|[1-9][0-9]*\\.?([0-9]+)?|\\.[0-9]+)$');
|
||||
const XRP_6_RE = new RegExp('^(0|0\\.([0-9]{0,6})?|[1-9][0-9]*\\.?([0-9]{0,6})?|\\.[0-9]{0,6})$');
|
||||
|
||||
@ -113,7 +113,7 @@ const addressValidation = ($state: State): PayloadAction<State> => (dispatch: Di
|
||||
|
||||
if (address.length < 1) {
|
||||
state.errors.address = 'Address is not set';
|
||||
} else if (!address.match(XRP_ADDRESS_RE)) {
|
||||
} else if (!AddressValidator.validate(address, 'XRP')) {
|
||||
state.errors.address = 'Address is not valid';
|
||||
} else if (address.toLowerCase() === account.address.toLowerCase()) {
|
||||
state.errors.address = 'Cannot send to myself';
|
||||
|
17
yarn.lock
17
yarn.lock
@ -1707,6 +1707,12 @@ balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
|
||||
base-x@^3.0.4:
|
||||
version "3.0.5"
|
||||
resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.5.tgz#d3ada59afed05b921ab581ec3112e6444ba0795a"
|
||||
dependencies:
|
||||
safe-buffer "^5.0.1"
|
||||
|
||||
base16@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/base16/-/base16-1.0.0.tgz#e297f60d7ec1014a7a971a39ebc8a98c0b681e70"
|
||||
@ -6021,6 +6027,10 @@ jsprim@^1.2.2:
|
||||
json-schema "0.2.3"
|
||||
verror "1.10.0"
|
||||
|
||||
jssha@2.3.1:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/jssha/-/jssha-2.3.1.tgz#147b2125369035ca4b2f7d210dc539f009b3de9a"
|
||||
|
||||
jsx-ast-utils@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f"
|
||||
@ -10281,6 +10291,13 @@ walker@~1.0.5:
|
||||
dependencies:
|
||||
makeerror "1.0.x"
|
||||
|
||||
wallet-address-validator@^0.2.4:
|
||||
version "0.2.4"
|
||||
resolved "https://registry.yarnpkg.com/wallet-address-validator/-/wallet-address-validator-0.2.4.tgz#717ce316143b679645639986cc0847a107255881"
|
||||
dependencies:
|
||||
base-x "^3.0.4"
|
||||
jssha "2.3.1"
|
||||
|
||||
warning@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
|
||||
|
Loading…
Reference in New Issue
Block a user