Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Merge pull request #128 from Conflux-Chain/dev
Browse files Browse the repository at this point in the history
mutiple err fix
  • Loading branch information
zctocm authored Apr 24, 2020
2 parents fb2da45 + eb05ef6 commit 4ec49af
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 110 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"description": "Conflux Blockchain Explorer",
"main": "index.js",
"scripts": {
"start": "NODE_ENV=development webpack-dev-server --config webpack.dev.config.js",
"build": "NODE_ENV=production webpack --config webpack.prod.config.js",
"start": "cross-env NODE_ENV=development webpack-dev-server --config webpack.dev.config.js",
"build": "cross-env NODE_ENV=production webpack --config webpack.prod.config.js",
"prettier": "pretty-quick --staged",
"lint:staged": "lint-staged",
"lintfix": "eslint . --fix",
"lint:eslint": "eslint --ignore-path .eslintignore --fix",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check",
"serve:dev": "NODE_ENV=development API_HOST=http://testnet-jsonrpc.conflux-chain.org:18084/api SERVER_PORT=3000 SERVER_HOST=127.0.0.1 SERVER_PREFIX=/proxy node ./service/index.js"
"serve:dev": "cross-env NODE_ENV=development API_HOST=http://testnet-jsonrpc.conflux-chain.org:18084/api SERVER_PORT=3000 SERVER_HOST=127.0.0.1 SERVER_PREFIX=/proxy node ./service/index.js"
},
"keywords": [],
"author": "Angelia",
Expand All @@ -36,6 +36,7 @@
"antd": "^3.19.1",
"bignumber.js": "^9.0.0",
"classnames": "^2.2.6",
"cross-env": "^7.0.2",
"echarts": "^4.2.1",
"history": "^4.9.0",
"humanize-number": "^0.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import GlobalStyle from './globalStyles';
import zhTranslationMessages from './lang/zh';
import enTranslationMessages from './lang/en';

Sentry.init({ dsn: 'https://2a65cc47c686438ebde60b1237a8a8ec@sentry.io/5168571' });
Sentry.init({ dsn: 'https://2a65cc47c686438ebde60b1237a8a8ec@sentry.io/5168571', environment: process.env.NODE_ENV });

require('./assets/iconfont/iconfont.js');

Expand Down
10 changes: 5 additions & 5 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ function Header(props) {
network: v.name,
},
});
// if (v.name === 'mainnet') {
// window.location.href = 'https://etherscan.io';
// } else {
// window.location.href = 'https://ropsten.etherscan.io';
// }
if (v.name === 'mainnet') {
window.location.href = 'https://confluxscan.io';
} else {
window.location.href = 'https://testnet.confluxscan.io';
}
};

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/SearchBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Dimmer, Loader, Image, Segment } from 'semantic-ui-react';
import compose from 'lodash/fp/compose';
import media from '../../globalStyles/media';
import { reqUtilType } from '../../utils/api';
import { tranferToLowerCase } from '../../utils';

const Input = styled.input`
height: 100%;
Expand Down Expand Up @@ -138,7 +139,7 @@ class SearchBox extends Component {

if (filterValue === 0) {
try {
const { code, result } = await reqUtilType({ value }, { showError: false });
const { code, result } = await reqUtilType({ value: tranferToLowerCase(value) }, { showError: false });
if (code !== 0) {
history.push(`/search-notfound?searchId=${value}`);
hideLoading();
Expand Down
14 changes: 10 additions & 4 deletions src/pages/Account/accountHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import React, { Component, Fragment } from 'react';
import styled from 'styled-components';
import moment from 'moment';
import { Link } from 'react-router-dom';
import { Link, withRouter } from 'react-router-dom';
import PropTypes from 'prop-types';
import { injectIntl } from 'react-intl';
import compose from 'lodash/fp/compose';
import * as commonCss from '../../globalStyles/common';
import CopyButton from '../../components/CopyButton';
import QrcodeButton from '../../components/QrcodeButton';
Expand All @@ -14,7 +15,7 @@ import EllipsisLine from '../../components/EllipsisLine';
import { reqContract, reqAccount, reqTokenList } from '../../utils/api';
import { errorCodes } from '../../constants';
import media from '../../globalStyles/media';
import { convertToValueorFee, i18n, renderAny, isContract } from '../../utils';
import { convertToValueorFee, valToTokenVal, i18n, renderAny, isContract } from '../../utils';
import TokenSelect from '../../components/TokenSelect';
import imgtokenIcon from '../../assets/images/icons/token-icon.svg';
import contractNameIcon from '../../assets/images/icons/contract-nameicon.svg';
Expand Down Expand Up @@ -386,7 +387,7 @@ class AccountHead extends Component {
value: v.address,
imgSrc: v.tokenIcon,
label1: `${v.tokenName} (${v.tokenSymbol})`,
label2: `${v.balance} ${v.tokenSymbol}`,
label2: `${valToTokenVal(v.balance, v.tokenDecimal)} ${v.tokenSymbol}`,
};
});

Expand Down Expand Up @@ -522,4 +523,9 @@ AccountHead.propTypes = {
}).isRequired,
};

export default injectIntl(AccountHead);
const hoc = compose(
injectIntl,
withRouter
);

export default hoc(AccountHead);
55 changes: 28 additions & 27 deletions src/pages/Account/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from 'styled-components';
import PropTypes from 'prop-types';
import { injectIntl } from 'react-intl';
import compose from 'lodash/fp/compose';
import { i18n, isContract } from '../../utils';
import { i18n, isContract, tranferToLowerCase } from '../../utils';
import * as commonCss from '../../globalStyles/common';
import media from '../../globalStyles/media';
import MinedBlocks from './minedBlocks';
Expand Down Expand Up @@ -63,14 +63,6 @@ function removeHash() {
class Detail extends Component {
constructor(...args) {
super(...args);
this.getAccountId = () => {
const {
match: { params },
} = this.props;
const { accountid } = params;
return accountid;
};

this.state = {
blockCount: 0,
currentTab: null,
Expand All @@ -80,6 +72,7 @@ class Detail extends Component {
tokenTotal: 0,
accountid: this.getAccountId(),
};
this.getAccountId = this.getAccountId.bind(this);
}

componentDidMount() {
Expand All @@ -92,10 +85,11 @@ class Detail extends Component {
}

componentDidUpdate(prevProps) {
if (this.props.match.params.accountid !== prevProps.match.params.accountid) {
const accountid = this.getAccountId();
const prevAccountId = tranferToLowerCase(prevProps.match.params.accountid);
if (accountid !== prevAccountId) {
// eslint-disable-next-line react/no-did-update-set-state
this.autoSwitchTab();
const accountid = this.getAccountId();
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
accountid,
Expand All @@ -107,6 +101,14 @@ class Detail extends Component {
}
}

getAccountId() {
const {
match: { params },
} = this.props;
const { accountid } = params;
return tranferToLowerCase(accountid);
}

autoSwitchTab() {
const { location } = this.props;
if (location.hash === `#${tabEnum.tokentxns}`) {
Expand All @@ -124,18 +126,20 @@ class Detail extends Component {
reqTokenList({
address: accountid,
}).then((body) => {
const listSorted = (body.result.list || []).sort((a, b) => {
return b.balance - a.balance;
});
const tokenMap = {};
listSorted.forEach((v) => {
tokenMap[v.address] = v;
});
this.setState({
tokenTotal: body.result.list.length,
tokenList: listSorted,
tokenMap,
});
if (body.code === 0) {
const listSorted = (body.result.list || []).sort((a, b) => {
return b.balance - a.balance;
});
const tokenMap = {};
listSorted.forEach((v) => {
tokenMap[v.address] = v;
});
this.setState({
tokenTotal: body.result.list.length,
tokenList: listSorted,
tokenMap,
});
}
});
}

Expand Down Expand Up @@ -174,10 +178,7 @@ class Detail extends Component {

render() {
const { currentTab, showMaintaining, blockCount, contractInfo, tokenTotal, tokenList, tokenMap } = this.state;
const {
intl,
match: { params },
} = this.props;
const { intl } = this.props;

const { accountid } = this.state;
const isContractAddr = isContract(accountid);
Expand Down
40 changes: 20 additions & 20 deletions src/pages/Block/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Countdown from '../../components/Countdown';
import TableLoading from '../../components/TableLoading';
import DataList from '../../components/DataList';
import EllipsisLine from '../../components/EllipsisLine';
import { convertToValueorFee, converToGasPrice, i18n, sendRequest } from '../../utils';
import { convertToValueorFee, converToGasPrice, i18n, sendRequest, tranferToLowerCase } from '../../utils';
import media from '../../globalStyles/media';
import * as commonCss from '../../globalStyles/common';
import { reqBlock, reqBlockTransactionList, reqBlockRefereeBlockList } from '../../utils/api';
Expand Down Expand Up @@ -294,9 +294,6 @@ const pageSize = 10;
class Detail extends Component {
constructor(...args) {
super(...args);
const {
match: { params },
} = this.props;
this.state = {
currentTab: 1,
TxTotalCount: 0,
Expand All @@ -308,26 +305,32 @@ class Detail extends Component {
refBlockCurPage: 1,
refTotal: 0,
};
this.getBlockHash = this.getBlockHash.bind(this);
}

componentDidMount() {
const {
match: { params },
} = this.props;
this.fetchBlockDetail(params.blockhash, { activePage: 1 });
this.fetchReffereBlock(params.blockhash, { refBlockCurPage: 1 });
this.fetchBlockDetail(this.getBlockHash(), { activePage: 1 });
this.fetchReffereBlock(this.getBlockHash(), { refBlockCurPage: 1 });
}

componentDidUpdate(prevProps) {
const blockhash = this.getBlockHash();
const prevBlockHash = tranferToLowerCase(prevProps.match.params.blockhash);
// eslint-disable-next-line react/destructuring-assignment
const { blockhash } = this.props.match.params;
// eslint-disable-next-line react/destructuring-assignment
if (blockhash !== prevProps.match.params.blockhash) {
if (blockhash !== prevBlockHash) {
this.fetchBlockDetail(blockhash, { activePage: 1 });
this.fetchReffereBlock(blockhash, { refBlockCurPage: 1 });
}
}

getBlockHash() {
const {
match: { params },
} = this.props;
const { blockhash } = params;
return tranferToLowerCase(blockhash);
}

fetchBlockDetail(blockHash, { activePage }) {
const { history } = this.props;
this.setState({ isLoading: true });
Expand Down Expand Up @@ -385,16 +388,13 @@ class Detail extends Component {

render() {
const { blockDetail, TxList, TxTotalCount, isLoading, currentTab, refereeBlockList, curPage, refBlockCurPage, refTotal } = this.state;
const {
match: { params },
} = this.props;

return (
<div className="page-block-detail">
<Wrapper>
<HeadBar>
<h1>{i18n('Block')}</h1>
<p>{params.blockhash}</p>
<p>{this.getBlockHash()}</p>
</HeadBar>
{isLoading ? (
<TableLoading />
Expand Down Expand Up @@ -492,7 +492,7 @@ class Detail extends Component {
}}
onPageChange={(e, data) => {
e.preventDefault();
this.fetchBlockDetail(params.blockhash, data);
this.fetchBlockDetail(this.getBlockHash(), data);
}}
activePage={curPage}
totalPages={Math.ceil(TxTotalCount / pageSize)}
Expand All @@ -512,7 +512,7 @@ class Detail extends Component {
activePage={curPage}
onPageChange={(e, data) => {
e.preventDefault();
this.fetchBlockDetail(params.blockhash, data);
this.fetchBlockDetail(this.getBlockHash(), data);
}}
ellipsisItem={null}
firstItem={null}
Expand Down Expand Up @@ -544,7 +544,7 @@ class Detail extends Component {
}}
onPageChange={(e, data) => {
e.preventDefault();
this.fetchReffereBlock(params.blockhash, { refBlockCurPage: data.activePage });
this.fetchReffereBlock(this.getBlockHash(), { refBlockCurPage: data.activePage });
}}
activePage={refBlockCurPage}
totalPages={Math.ceil(refTotal / pageSize)}
Expand All @@ -564,7 +564,7 @@ class Detail extends Component {
activePage={refBlockCurPage}
onPageChange={(e, data) => {
e.preventDefault();
this.fetchReffereBlock(params.blockhash, { refBlockCurPage: data.activePage });
this.fetchReffereBlock(this.getBlockHash(), { refBlockCurPage: data.activePage });
}}
ellipsisItem={null}
firstItem={null}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Contract/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormattedMessage } from 'react-intl';
import { Icon, Popup } from 'semantic-ui-react';
import AceEditor from 'react-ace';
import media from '../../globalStyles/media';
import { i18n, getQuery } from '../../utils';
import { i18n, getQuery, tranferToLowerCase } from '../../utils';
import TableLoading from '../../components/TableLoading';
import { reqContractCreate } from '../../utils/api';
import { defaultContractIcon, defaultTokenIcon, contractTypes, contractTypeCodeGeneral } from '../../constants';
Expand Down Expand Up @@ -482,7 +482,7 @@ class ContractUpdate extends Component {
const parsed = getQuery(location.search);
if (parsed.address) {
this.setState({
addressVal: parsed.address,
addressVal: tranferToLowerCase(parsed.address),
});
}
}
Expand Down Expand Up @@ -641,7 +641,7 @@ class ContractUpdate extends Component {
addressVal,
} = this.state;
const bodyparams = {};
bodyparams.address = addressVal;
bodyparams.address = tranferToLowerCase(addressVal);
bodyparams.name = nameTagVal;
bodyparams.website = websiteVal;
bodyparams.icon = iconContractSource;
Expand Down
Loading

1 comment on commit 4ec49af

@vercel
Copy link

@vercel vercel bot commented on 4ec49af Apr 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.