diff --git a/package.json b/package.json index 97247d5bd..c40fae5be 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "preelectron": "yarn build", "electron": "cd packages/fether-electron && yarn electron", "lint-files": "./scripts/lint-files.sh", - "lint": "yarn lint-files '**/*.{js,ts}'", + "lint": "yarn lint-files '**/*.js'", "prepackage": "yarn build", "package": "cd packages/fether-electron && yarn package", "release": "cd packages/fether-electron && yarn release", @@ -53,7 +53,8 @@ "start-electron": "cd packages/fether-electron && yarn start", "start-react": "cd packages/fether-react && yarn start", "start-ui": "cd packages/fether-ui && yarn start", - "test": "semistandard '**/*.{js,ts}' --parser babel-eslint && CI=true lerna run test --parallel" + "test": "semistandard '**/*.js' --parser babel-eslint && CI=true lerna run test --parallel", + "update-tokens": "yarn run ts-node --project scripts/updateTokens/tsconfig.json scripts/updateTokens" }, "husky": { "hooks": { @@ -71,6 +72,8 @@ "dependencies": { "download": "^7.1.0", "node-fetch": "^2.3.0", - "semver": "^5.6.0" + "semver": "^5.6.0", + "ts-node": "^8.0.3", + "typescript": "^3.3.4000" } -} +} \ No newline at end of file diff --git a/packages/fether-react/scripts/updateTokens.js b/packages/fether-react/scripts/updateTokens.js deleted file mode 100644 index 43d7b543e..000000000 --- a/packages/fether-react/scripts/updateTokens.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity. -// -// SPDX-License-Identifier: BSD-3-Clause - -const Api = require('@parity/api'); -const { bytesToHex } = require('@parity/api/lib/util'); -const Contracts = require('@parity/contracts').default; -const fs = require('fs'); - -// A node serving a HTTP server needs to be running at the following port. The -// chain this script is fetching the tokens is the chain which this node -// connects to. -const api = new Api(new Api.Provider.Http('http://127.0.0.1:8545')); - -const run = async () => { - const { tokenReg, githubHint } = new Contracts(api); - - const chainName = await api.parity.netChain(); - console.log(`Fetching all tokens on ${chainName}, please wait...`); - - // Create file to write tokens to - const filePath = `src/assets/tokens/${chainName}.json`; - const wstream = fs.createWriteStream(filePath); - - // The JSON file will be an array, so we start by opening a bracket - wstream.write('[\n'); - - const tokenRegContract = await tokenReg.getContract(); - const githubHintContract = await githubHint.getContract(); - - // Get tokenCount to loop through all tokens - const tokenCount = +(await tokenRegContract.instance.tokenCount.call()); - for (let i = 0; i < tokenCount; i++) { - // Get token information - const token = await tokenRegContract.instance.token.call({}, [i]); - - // Some tokens are empty (unregistered), we skip them - // token[0] is the token address - if (+token[0] === 0) { - continue; - } - - // Get image hash of this token (stored inside the metadata) - const imageHash = bytesToHex( - await tokenRegContract.instance.meta.call({}, [i, 'IMG']) - ); - // Variable result will contain the line to be added to our final JSON file - const result = { - address: token[0], - decimals: token[2].e, // token[2] gives a BigNumber(100000000), the number of decimals is the exponent - name: token[3], - symbol: token[1] - }; - - // If there is an imageHash, then we fetch on GithubHint the url of that - // image - if (+imageHash !== 0) { - const [logo] = await githubHintContract.instance.entries.call({}, [ - imageHash - ]); - result.logo = logo; - } - - // Add this line to the buffer - wstream.write( - `${JSON.stringify(result)}${i === tokenCount - 1 ? '' : ','}\n` - ); - } - - // Close the opening bracket, and then exit - wstream.write(']', () => { - wstream.close(); - - // Finished, we can exit - console.log(`Wrote ${tokenCount} tokens to ${filePath}.`); - process.exit(0); - }); -}; - -run(); diff --git a/packages/fether-react/src/Send/TxForm/TxForm.js b/packages/fether-react/src/Send/TxForm/TxForm.js index a825084a2..a55b78f37 100644 --- a/packages/fether-react/src/Send/TxForm/TxForm.js +++ b/packages/fether-react/src/Send/TxForm/TxForm.js @@ -19,8 +19,8 @@ import { OnChange } from 'react-final-form-listeners'; import { startWith } from 'rxjs/operators'; import { withProps } from 'recompose'; -import { estimateGas } from '../../utils/transaction'; import Debug from '../../utils/debug'; +import { estimateGas } from '../../utils/transaction'; import RequireHealthOverlay from '../../RequireHealthOverlay'; import TokenBalance from '../../Tokens/TokensList/TokenBalance'; import TxDetails from './TxDetails'; diff --git a/packages/fether-react/src/Tokens/TokensList/TokenBalance/TokenBalance.js b/packages/fether-react/src/Tokens/TokensList/TokenBalance/TokenBalance.js index 256dfc099..247756382 100644 --- a/packages/fether-react/src/Tokens/TokensList/TokenBalance/TokenBalance.js +++ b/packages/fether-react/src/Tokens/TokensList/TokenBalance/TokenBalance.js @@ -3,12 +3,13 @@ // // SPDX-License-Identifier: BSD-3-Clause -import React, { Component } from 'react'; import { inject } from 'mobx-react'; import PropTypes from 'prop-types'; +import React, { Component } from 'react'; import { TokenCard } from 'fether-ui'; import { withRouter } from 'react-router-dom'; +import defaultTokenImage from '../../../assets/img/tokens/default-token-128x128.jpg'; import withAccount from '../../../utils/withAccount'; import withBalance from '../../../utils/withBalance'; @@ -38,7 +39,13 @@ class TokenBalance extends Component { }; render () { - return ; + return ( + + ); } } diff --git a/packages/fether-react/src/Tokens/TokensList/TokensList.js b/packages/fether-react/src/Tokens/TokensList/TokensList.js index f9f29359a..3966fee0b 100644 --- a/packages/fether-react/src/Tokens/TokensList/TokensList.js +++ b/packages/fether-react/src/Tokens/TokensList/TokensList.js @@ -4,6 +4,7 @@ // SPDX-License-Identifier: BSD-3-Clause import React, { Component } from 'react'; + import RequireHealthOverlay from '../../RequireHealthOverlay'; import TokenBalance from './TokenBalance'; import withTokens from '../../utils/withTokens'; @@ -14,7 +15,6 @@ class TokensList extends Component { const { tokensArray } = this.props; // Show empty token placeholder if tokens have not been loaded yet const shownArray = tokensArray.length ? tokensArray : [{}]; - return (
diff --git a/packages/fether-react/src/Whitelist/NewTokenItem/NewTokenItem.js b/packages/fether-react/src/Whitelist/NewTokenItem/NewTokenItem.js index baa7d5b17..3aac93a88 100644 --- a/packages/fether-react/src/Whitelist/NewTokenItem/NewTokenItem.js +++ b/packages/fether-react/src/Whitelist/NewTokenItem/NewTokenItem.js @@ -7,6 +7,7 @@ import React, { Component } from 'react'; import { TokenCard } from 'fether-ui'; import { withRouter } from 'react-router-dom'; +import defaultTokenImage from '../../assets/img/tokens/default-token-128x128.jpg'; import withTokens from '../../utils/withTokens'; @withRouter @@ -29,7 +30,13 @@ class NewTokenItem extends Component { return (
  • - +
    {tokens[token.address] ? (