POA tokens support - including of poa-contract-metadata package
This commit is contained in:
parent
d50d957fa3
commit
285e406dcd
|
@ -96,7 +96,7 @@ workflows:
|
|||
jobs:
|
||||
prep-deps-npm:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -111,7 +111,7 @@ jobs:
|
|||
- node_modules
|
||||
prep-deps-firefox:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -126,7 +126,7 @@ jobs:
|
|||
|
||||
prep-build:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -145,7 +145,7 @@ jobs:
|
|||
|
||||
prep-docs:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -160,7 +160,7 @@ jobs:
|
|||
|
||||
prep-scss:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -179,7 +179,7 @@ jobs:
|
|||
|
||||
test-lint:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -190,7 +190,7 @@ jobs:
|
|||
|
||||
test-deps:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -201,7 +201,7 @@ jobs:
|
|||
|
||||
test-e2e-chrome:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -217,7 +217,7 @@ jobs:
|
|||
|
||||
test-e2e-firefox:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -238,7 +238,7 @@ jobs:
|
|||
|
||||
test-e2e-beta-chrome:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -254,7 +254,7 @@ jobs:
|
|||
|
||||
test-e2e-beta-firefox:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -275,7 +275,7 @@ jobs:
|
|||
|
||||
job-screens:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -292,7 +292,7 @@ jobs:
|
|||
|
||||
job-publish-prerelease:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -319,7 +319,7 @@ jobs:
|
|||
|
||||
job-publish-release:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -332,7 +332,7 @@ jobs:
|
|||
|
||||
job-publish-postrelease:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -355,7 +355,7 @@ jobs:
|
|||
|
||||
test-unit:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -368,7 +368,7 @@ jobs:
|
|||
environment:
|
||||
browsers: '["Firefox"]'
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -392,7 +392,7 @@ jobs:
|
|||
environment:
|
||||
browsers: '["Chrome"]'
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -411,7 +411,7 @@ jobs:
|
|||
environment:
|
||||
browsers: '["Firefox"]'
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -435,7 +435,7 @@ jobs:
|
|||
environment:
|
||||
browsers: '["Chrome"]'
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
|
@ -452,7 +452,7 @@ jobs:
|
|||
|
||||
all-tests-pass:
|
||||
docker:
|
||||
- image: circleci/node:8.11.4-browsers
|
||||
- image: circleci/node:8.12.0-browsers
|
||||
steps:
|
||||
- run:
|
||||
name: All Tests Passed
|
||||
|
|
|
@ -115,7 +115,8 @@ class AddTokenScreen extends Component {
|
|||
const { network } = this.props
|
||||
const networkID = parseInt(network)
|
||||
let views = []
|
||||
networkID === 1 ? views = [h(TabBar, {
|
||||
const isProdNetwork = networkID === 1 || networkID === 99
|
||||
isProdNetwork ? views = [h(TabBar, {
|
||||
tabs: [
|
||||
{ content: 'Search', key: SEARCH_TAB },
|
||||
{ content: 'Custom', key: CUSTOM_TOKEN_TAB },
|
||||
|
@ -279,15 +280,14 @@ class AddTokenScreen extends Component {
|
|||
}
|
||||
|
||||
renderTabBar () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
const { tokenSelectorError, selectedTokens, searchResults } = state
|
||||
const { clearPendingTokens, goHome } = props
|
||||
const { tokenSelectorError, selectedTokens, searchResults } = this.state
|
||||
const { clearPendingTokens, goHome, network } = this.props
|
||||
return h('div', [
|
||||
h('.add-token__search-token', [
|
||||
h(TokenSearch, {
|
||||
onSearch: ({ results = [] }) => this.setState({ searchResults: results }),
|
||||
error: tokenSelectorError,
|
||||
network: network
|
||||
}),
|
||||
h('.add-token__token-list', {
|
||||
style: {
|
||||
|
|
|
@ -2,6 +2,7 @@ var iconFactory
|
|||
const isValidAddress = require('ethereumjs-util').isValidAddress
|
||||
const toChecksumAddress = require('ethereumjs-util').toChecksumAddress
|
||||
const contractMap = require('eth-contract-metadata')
|
||||
const contractMapPOA = require('poa-contract-metadata')
|
||||
const colors = require('../../colors')
|
||||
|
||||
module.exports = function (jazzicon) {
|
||||
|
|
|
@ -23820,6 +23820,10 @@
|
|||
"integrity": "sha1-HMfCEjA6yr50Jj7DrHgAlYAkLZM=",
|
||||
"dev": true
|
||||
},
|
||||
"poa-contract-metadata": {
|
||||
"version": "github:poanetwork/poa-contract-metadata#daee2eab58db1cb2aad50cd58c45374f614f029e",
|
||||
"from": "github:poanetwork/poa-contract-metadata#master"
|
||||
},
|
||||
"pojo-migrator": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pojo-migrator/-/pojo-migrator-2.1.0.tgz",
|
||||
|
|
|
@ -161,6 +161,7 @@
|
|||
"percentile": "^1.2.0",
|
||||
"pify": "^3.0.0",
|
||||
"ping-pong-stream": "^1.0.0",
|
||||
"poa-contract-metadata": "github:poanetwork/poa-contract-metadata#master",
|
||||
"pojo-migrator": "^2.1.0",
|
||||
"polyfill-crypto.getrandomvalues": "^1.0.0",
|
||||
"post-message-stream": "^3.0.0",
|
||||
|
@ -318,7 +319,7 @@
|
|||
"watchify": "^3.11.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "8.11.4",
|
||||
"npm": "^6.1.0"
|
||||
"node": "8.12.0",
|
||||
"npm": "^6.4.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,13 @@
|
|||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import contractMap from 'eth-contract-metadata'
|
||||
import contractMapETH from 'eth-contract-metadata'
|
||||
import contractMapPOA from 'poa-contract-metadata'
|
||||
import Fuse from 'fuse.js'
|
||||
import InputAdornment from '@material-ui/core/InputAdornment'
|
||||
import TextField from '../../../text-field'
|
||||
|
||||
const contractList = Object.entries(contractMap)
|
||||
.map(([ _, tokenData]) => tokenData)
|
||||
.filter(tokenData => Boolean(tokenData.erc20))
|
||||
|
||||
const fuse = new Fuse(contractList, {
|
||||
shouldSort: true,
|
||||
threshold: 0.45,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: [
|
||||
{ name: 'name', weight: 0.5 },
|
||||
{ name: 'symbol', weight: 0.5 },
|
||||
],
|
||||
})
|
||||
let contractList
|
||||
let fuse
|
||||
|
||||
export default class TokenSearch extends Component {
|
||||
static contextTypes = {
|
||||
|
@ -42,6 +29,26 @@ export default class TokenSearch extends Component {
|
|||
this.state = {
|
||||
searchQuery: '',
|
||||
}
|
||||
|
||||
const networkID = parseInt(props.network)
|
||||
const contractMap = networkID === 1 ? contractMapETH : contractMapPOA
|
||||
|
||||
contractList = Object.entries(contractMap)
|
||||
.map(([ _, tokenData]) => tokenData)
|
||||
.filter(tokenData => Boolean(tokenData.erc20))
|
||||
|
||||
fuse = new Fuse(contractList, {
|
||||
shouldSort: true,
|
||||
threshold: 0.45,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: [
|
||||
{ name: 'name', weight: 0.5 },
|
||||
{ name: 'symbol', weight: 0.5 },
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
handleSearch (searchQuery) {
|
||||
|
|
|
@ -17,7 +17,13 @@ function mapStateToProps (state) {
|
|||
}
|
||||
|
||||
const defaultTokens = []
|
||||
const contracts = require('eth-contract-metadata')
|
||||
const contractsETH = require('eth-contract-metadata')
|
||||
const contractsPOA = require('poa-contract-metadata')
|
||||
let contracts
|
||||
|
||||
// const { network } = this.props
|
||||
// contracts = network === 1 ? contractsETH : contractsPOA
|
||||
contracts = contractsETH
|
||||
for (const address in contracts) {
|
||||
const contract = contracts[address]
|
||||
if (contract.erc20) {
|
||||
|
@ -169,17 +175,4 @@ TokenList.prototype.componentWillUnmount = function () {
|
|||
this.tracker.stop()
|
||||
this.tracker.removeListener('update', this.balanceUpdater)
|
||||
this.tracker.removeListener('error', this.showError)
|
||||
}
|
||||
|
||||
// function uniqueMergeTokens (tokensA, tokensB = []) {
|
||||
// const uniqueAddresses = []
|
||||
// const result = []
|
||||
// tokensA.concat(tokensB).forEach((token) => {
|
||||
// const normal = normalizeAddress(token.address)
|
||||
// if (!uniqueAddresses.includes(normal)) {
|
||||
// uniqueAddresses.push(normal)
|
||||
// result.push(token)
|
||||
// }
|
||||
// })
|
||||
// return result
|
||||
// }
|
||||
}
|
|
@ -2,6 +2,7 @@ var iconFactory
|
|||
const isValidAddress = require('ethereumjs-util').isValidAddress
|
||||
const { checksumAddress } = require('../app/util')
|
||||
const contractMap = require('eth-contract-metadata')
|
||||
const contractMapPOA = require('poa-contract-metadata')
|
||||
const colors = require('../../colors')
|
||||
|
||||
module.exports = function (jazzicon) {
|
||||
|
|
Loading…
Reference in New Issue