Skip to content

Commit

Permalink
Modified phishing detection method to use axios/async/await instead o…
Browse files Browse the repository at this point in the history
…f node-fetch/promises
  • Loading branch information
alexhulbert committed Mar 17, 2018
1 parent 4b2cc67 commit f52e582
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
17 changes: 7 additions & 10 deletions app/core/wallet.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
// @flow
import { wallet } from 'neon-js'
import { map, extend } from 'lodash'
import fetch from 'node-fetch'
import axios from 'axios'

import { ASSETS } from './constants'
import { toBigNumber } from './math'

const MIN_PASSPHRASE_LEN = 4

let addressBlacklist: Array<string> | null = null
export const isInBlacklist = (address: string): Promise<boolean> => {
if (addressBlacklist !== null) return Promise.resolve(addressBlacklist.includes(address))
return fetch('https://raw.githubusercontent.com/CityOfZion/phishing/master/blockedAddresses.json')
.catch(() => false)
.then(res => res.json())
.then(blacklist => {
addressBlacklist = blacklist
return blacklist.includes(address)
})
export const isInBlacklist = async (address: string): Promise<boolean> => {
if (addressBlacklist === null) {
const { data } = await axios.get('https://raw.githubusercontent.com/CityOfZion/phishing/master/blockedAddresses.json')
addressBlacklist = data
}
return addressBlacklist.includes(address)
}

export const validatePassphraseLength = (passphrase: string): boolean =>
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"isomorphic-fetch": "2.2.1",
"lodash": "4.17.4",
"neon-js": "git+https://github.com/cityofzion/neon-js.git#3.3.3",
"node-fetch": "^2.1.1",
"qrcode": "0.9.0",
"raf": "3.4.0",
"react": "16.1.1",
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6598,10 +6598,6 @@ node-fetch@^1.0.1:
encoding "^0.1.11"
is-stream "^1.0.1"

node-fetch@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.1.tgz#369ca70b82f50c86496104a6c776d274f4e4a2d4"

[email protected]:
version "0.7.1"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.7.1.tgz#9da611ea08982f4b94206b3beb4cc9665f20c300"
Expand Down

0 comments on commit f52e582

Please sign in to comment.