-
+
{ token.name }
diff --git a/js/src/modals/Transfer/transfer.js b/js/src/modals/Transfer/transfer.js
index 01e77d93762..78dc6f77080 100644
--- a/js/src/modals/Transfer/transfer.js
+++ b/js/src/modals/Transfer/transfer.js
@@ -49,6 +49,7 @@ export default class Transfer extends Component {
account: PropTypes.object,
balance: PropTypes.object,
balances: PropTypes.object,
+ images: PropTypes.object.isRequired,
onClose: PropTypes.func
}
@@ -147,7 +148,7 @@ export default class Transfer extends Component {
}
renderDetailsPage () {
- const { account, balance } = this.props;
+ const { account, balance, images } = this.props;
return (
.
import { newError } from '../ui/Errors/actions';
+import { setAddressImage } from './providers/imagesActions';
import { clearStatusLogs, toggleStatusLogs } from './providers/statusActions';
import { toggleView } from '../views/Settings';
export {
newError,
clearStatusLogs,
+ setAddressImage,
toggleStatusLogs,
toggleView
};
diff --git a/js/src/redux/providers/balances.js b/js/src/redux/providers/balances.js
index d262a3f19c7..151cb014dd4 100644
--- a/js/src/redux/providers/balances.js
+++ b/js/src/redux/providers/balances.js
@@ -15,23 +15,16 @@
// along with Parity. If not, see
.
import { getBalances, getTokens } from './balancesActions';
+import { setAddressImage } from './imagesActions';
import * as abis from '../../contracts/abi';
-import imagesEthereum from '../../images/contracts/ethereum-56.png';
-import imagesGavcoin from '../../images/contracts/gavcoin-56.png';
-import imagesUnknown from '../../images/contracts/unknown-56.png';
-
-// TODO: Images should not be imported like this, should be via the content from GitHubHint contract (here until it is ready)
-const images = {
- ethereum: imagesEthereum,
- gavcoin: imagesGavcoin
-};
+import imagesEthereum from '../../images/contracts/ethereum-black-64x64.png';
const ETH = {
name: 'Ethereum',
tag: 'ΞTH',
- image: images.ethereum
+ image: imagesEthereum
};
export default class Balances {
@@ -89,18 +82,25 @@ export default class Balances {
return tokenreg.instance.tokenCount
.call()
.then((numTokens) => {
- const promises = [];
+ const promisesTokens = [];
+ const promisesImages = [];
+
+ while (promisesTokens.length < numTokens.toNumber()) {
+ const index = promisesTokens.length;
- while (promises.length < numTokens.toNumber()) {
- promises.push(tokenreg.instance.token.call({}, [promises.length]));
+ promisesTokens.push(tokenreg.instance.token.call({}, [index]));
+ promisesImages.push(tokenreg.instance.meta.call({}, [index, 'IMG']));
}
- return Promise.all(promises);
+ return Promise.all([
+ Promise.all(promisesTokens),
+ Promise.all(promisesImages)
+ ]);
});
})
- .then((_tokens) => {
+ .then(([_tokens, images]) => {
const tokens = {};
- this._tokens = _tokens.map((_token) => {
+ this._tokens = _tokens.map((_token, index) => {
const [address, tag, format, name] = _token;
const token = {
@@ -108,10 +108,10 @@ export default class Balances {
name,
tag,
format: format.toString(),
- image: images[name.toLowerCase()] || imagesUnknown,
contract: this._api.newContract(abis.eip20, address)
};
tokens[address] = token;
+ this._store.dispatch(setAddressImage(address, images[index]));
return token;
});
diff --git a/js/src/redux/providers/imagesActions.js b/js/src/redux/providers/imagesActions.js
new file mode 100644
index 00000000000..ce9221a3b97
--- /dev/null
+++ b/js/src/redux/providers/imagesActions.js
@@ -0,0 +1,23 @@
+// Copyright 2015, 2016 Ethcore (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity. If not, see
.
+
+export function setAddressImage (address, hashArray) {
+ return {
+ type: 'setAddressImage',
+ address,
+ hashArray
+ };
+}
diff --git a/js/src/redux/providers/imagesReducer.js b/js/src/redux/providers/imagesReducer.js
new file mode 100644
index 00000000000..af4be49b5f5
--- /dev/null
+++ b/js/src/redux/providers/imagesReducer.js
@@ -0,0 +1,35 @@
+// Copyright 2015, 2016 Ethcore (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity. If not, see
.
+
+import { handleActions } from 'redux-actions';
+import { bytesToHex } from '../../api/util/format';
+
+const ZERO = '0x0000000000000000000000000000000000000000000000000000000000000000';
+
+const initialState = {
+ images: {}
+};
+
+export default handleActions({
+ setAddressImage (state, action) {
+ const { address, hashArray } = action;
+ const hash = hashArray ? bytesToHex(hashArray) : ZERO;
+
+ return Object.assign({}, state, {
+ [address]: hash === ZERO ? null : `/api/content/${hash.substr(2)}`
+ });
+ }
+}, initialState);
diff --git a/js/src/redux/providers/index.js b/js/src/redux/providers/index.js
index a6f52fdaf3d..a29e9c32d08 100644
--- a/js/src/redux/providers/index.js
+++ b/js/src/redux/providers/index.js
@@ -19,5 +19,6 @@ export Personal from './personal';
export Status from './status';
export balancesReducer from './balancesReducer';
+export imagesReducer from './imagesReducer';
export personalReducer from './personalReducer';
export statusReducer from './statusReducer';
diff --git a/js/src/redux/reducers.js b/js/src/redux/reducers.js
index 42cbc6ef4f9..e98e17acc2b 100644
--- a/js/src/redux/reducers.js
+++ b/js/src/redux/reducers.js
@@ -17,7 +17,7 @@
import { combineReducers } from 'redux';
import { routerReducer } from 'react-router-redux';
-import { balancesReducer, personalReducer, statusReducer as nodeStatusReducer } from './providers';
+import { balancesReducer, imagesReducer, personalReducer, statusReducer as nodeStatusReducer } from './providers';
import { errorReducer } from '../ui/Errors';
import { settingsReducer } from '../views/Settings';
@@ -36,6 +36,7 @@ export default function () {
settings: settingsReducer,
balances: balancesReducer,
+ images: imagesReducer,
nodeStatus: nodeStatusReducer,
personal: personalReducer,
diff --git a/js/src/ui/Balance/balance.js b/js/src/ui/Balance/balance.js
index 6b94b60b302..9c18849cb1e 100644
--- a/js/src/ui/Balance/balance.js
+++ b/js/src/ui/Balance/balance.js
@@ -16,21 +16,25 @@
import BigNumber from 'bignumber.js';
import React, { Component, PropTypes } from 'react';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import unknownImage from '../../images/contracts/unknown-64x64.png';
import styles from './balance.css';
-export default class Balance extends Component {
+class Balance extends Component {
static contextTypes = {
api: PropTypes.object
}
static propTypes = {
- balance: PropTypes.object
+ balance: PropTypes.object,
+ images: PropTypes.object.isRequired
}
render () {
const { api } = this.context;
- const { balance } = this.props;
+ const { balance, images } = this.props;
if (!balance) {
return null;
@@ -43,13 +47,14 @@ export default class Balance extends Component {
const value = token.format
? new BigNumber(balance.value).div(new BigNumber(token.format)).toFormat(3)
: api.util.fromWei(balance.value).toFormat(3);
+ const imagesrc = token.image || images[token.address] || unknownImage;
return (
{ value } { token.tag }
@@ -71,3 +76,18 @@ export default class Balance extends Component {
);
}
}
+
+function mapStateToProps (state) {
+ const { images } = state;
+
+ return { images };
+}
+
+function mapDispatchToProps (dispatch) {
+ return bindActionCreators({}, dispatch);
+}
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(Balance);
diff --git a/js/src/ui/Form/AddressSelect/addressSelect.js b/js/src/ui/Form/AddressSelect/addressSelect.js
index 6cd0996ff75..c7500846cbd 100644
--- a/js/src/ui/Form/AddressSelect/addressSelect.js
+++ b/js/src/ui/Form/AddressSelect/addressSelect.js
@@ -63,14 +63,11 @@ export default class AddressSelect extends Component {
}
renderSelectEntry = (entry) => {
- const { tokens } = this.props;
-
const item = (
diff --git a/js/src/ui/Form/InputAddress/inputAddress.js b/js/src/ui/Form/InputAddress/inputAddress.js
index dde7c3a7cc0..5bc0f1a4d68 100644
--- a/js/src/ui/Form/InputAddress/inputAddress.js
+++ b/js/src/ui/Form/InputAddress/inputAddress.js
@@ -56,7 +56,7 @@ export default class InputAddress extends Component {
}
renderIcon () {
- const { value, tokens } = this.props;
+ const { value } = this.props;
if (!value || !value.length) {
return null;
@@ -66,7 +66,6 @@ export default class InputAddress extends Component {
);
diff --git a/js/src/ui/IdentityIcon/identityIcon.js b/js/src/ui/IdentityIcon/identityIcon.js
index 292e99b9a8d..928a340a737 100644
--- a/js/src/ui/IdentityIcon/identityIcon.js
+++ b/js/src/ui/IdentityIcon/identityIcon.js
@@ -15,11 +15,13 @@
// along with Parity. If not, see
.
import React, { Component, PropTypes } from 'react';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
import ContractIcon from 'material-ui/svg-icons/action/code';
import styles from './identityIcon.css';
-export default class IdentityIcon extends Component {
+class IdentityIcon extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
}
@@ -32,7 +34,7 @@ export default class IdentityIcon extends Component {
padded: PropTypes.bool,
inline: PropTypes.bool,
tiny: PropTypes.bool,
- tokens: PropTypes.object
+ images: PropTypes.object.isRequired
}
state = {
@@ -40,31 +42,27 @@ export default class IdentityIcon extends Component {
}
componentDidMount () {
- const { address } = this.props;
-
- this.updateIcon(address);
+ this.updateIcon(this.props.address, this.props.images);
}
componentWillReceiveProps (newProps) {
- const { address, tokens } = this.props;
+ const sameAddress = newProps.address === this.props.address;
+ const sameImages = Object.keys(newProps.images).length === Object.keys(this.props.images).length;
- if (newProps.address === address && newProps.tokens === tokens) {
+ if (sameAddress && sameImages) {
return;
}
- this.updateIcon(newProps.address);
+ this.updateIcon(newProps.address, newProps.images);
}
- updateIcon (_address) {
+ updateIcon (_address, images) {
const { api } = this.context;
- const { button, tokens, inline, tiny } = this.props;
- const token = (tokens || {})[_address];
-
- if (token && token.image) {
- this.setState({
- iconsrc: token.image
- });
+ const { button, inline, tiny } = this.props;
+ const iconsrc = images[_address];
+ if (iconsrc) {
+ this.setState({ iconsrc });
return;
}
@@ -121,3 +119,18 @@ export default class IdentityIcon extends Component {
);
}
}
+
+function mapStateToProps (state) {
+ const { images } = state;
+
+ return { images };
+}
+
+function mapDispatchToProps (dispatch) {
+ return bindActionCreators({}, dispatch);
+}
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(IdentityIcon);
diff --git a/js/src/ui/MethodDecoding/methodDecoding.js b/js/src/ui/MethodDecoding/methodDecoding.js
index 58aeb68f857..fc9254c42f9 100644
--- a/js/src/ui/MethodDecoding/methodDecoding.js
+++ b/js/src/ui/MethodDecoding/methodDecoding.js
@@ -270,13 +270,12 @@ export default class Method extends Component {
}
renderAddressName (address, withName = true) {
- const { tokens } = this.props;
const account = this.getAccount(address);
const name = account ? account.name.toUpperCase() : null;
return (
-
+
{ withName ? (name || address) : address }
);
diff --git a/js/src/views/Account/Transactions/Transaction/transaction.js b/js/src/views/Account/Transactions/Transaction/transaction.js
index 9fcd5744ebb..af10086a2ab 100644
--- a/js/src/views/Account/Transactions/Transaction/transaction.js
+++ b/js/src/views/Account/Transactions/Transaction/transaction.js
@@ -132,7 +132,6 @@ export default class Transaction extends Component {
diff --git a/js/src/views/Account/account.js b/js/src/views/Account/account.js
index bbba53479a1..0470653643a 100644
--- a/js/src/views/Account/account.js
+++ b/js/src/views/Account/account.js
@@ -35,6 +35,7 @@ class Account extends Component {
params: PropTypes.object,
accounts: PropTypes.object,
balances: PropTypes.object,
+ images: PropTypes.object.isRequired,
isTest: PropTypes.bool
}
@@ -141,7 +142,7 @@ class Account extends Component {
}
const { address } = this.props.params;
- const { accounts, balances } = this.props;
+ const { accounts, balances, images } = this.props;
const account = accounts[address];
const balance = balances[address];
@@ -150,6 +151,7 @@ class Account extends Component {
account={ account }
balance={ balance }
balances={ balances }
+ images={ images }
onClose={ this.onTransferClose } />
);
}
@@ -184,12 +186,14 @@ class Account extends Component {
function mapStateToProps (state) {
const { accounts } = state.personal;
const { balances } = state.balances;
+ const { images } = state;
const { isTest } = state.nodeStatus;
return {
isTest,
accounts,
- balances
+ balances,
+ images
};
}
diff --git a/js/src/views/Dapps/Summary/summary.js b/js/src/views/Dapps/Summary/summary.js
index 43377be5fd7..3182d19d700 100644
--- a/js/src/views/Dapps/Summary/summary.js
+++ b/js/src/views/Dapps/Summary/summary.js
@@ -32,7 +32,7 @@ export default class Summary extends Component {
}
render () {
- const { app, tokens } = this.props;
+ const { app } = this.props;
if (!app) {
return null;
@@ -43,8 +43,7 @@ export default class Summary extends Component {
return (
+ address={ app.address } />
{ app.name } }
byline={ app.description } />
diff --git a/js/src/views/Signer/components/Account/Account.js b/js/src/views/Signer/components/Account/Account.js
index 248a9d497ae..618292fd138 100644
--- a/js/src/views/Signer/components/Account/Account.js
+++ b/js/src/views/Signer/components/Account/Account.js
@@ -56,15 +56,14 @@ class Account extends Component {
}
render () {
- const { address, chain, className, tokens } = this.props;
+ const { address, chain, className } = this.props;
return (
+ address={ address } />
{ this.renderName() }
{ this.renderBalance() }
diff --git a/js/src/views/Signer/containers/LoadingPage/LoadingPage.css b/js/src/views/Signer/containers/--remove-LoadingPage/LoadingPage.css
similarity index 100%
rename from js/src/views/Signer/containers/LoadingPage/LoadingPage.css
rename to js/src/views/Signer/containers/--remove-LoadingPage/LoadingPage.css
diff --git a/js/src/views/Signer/containers/LoadingPage/LoadingPage.js b/js/src/views/Signer/containers/--remove-LoadingPage/LoadingPage.js
similarity index 100%
rename from js/src/views/Signer/containers/LoadingPage/LoadingPage.js
rename to js/src/views/Signer/containers/--remove-LoadingPage/LoadingPage.js
diff --git a/js/src/views/Signer/containers/LoadingPage/index.js b/js/src/views/Signer/containers/--remove-LoadingPage/index.js
similarity index 100%
rename from js/src/views/Signer/containers/LoadingPage/index.js
rename to js/src/views/Signer/containers/--remove-LoadingPage/index.js
diff --git a/js/src/views/Signer/containers/OfflinePage/OfflinePage.js b/js/src/views/Signer/containers/--remove-OfflinePage/OfflinePage.js
similarity index 100%
rename from js/src/views/Signer/containers/OfflinePage/OfflinePage.js
rename to js/src/views/Signer/containers/--remove-OfflinePage/OfflinePage.js
diff --git a/js/src/views/Signer/containers/OfflinePage/index.js b/js/src/views/Signer/containers/--remove-OfflinePage/index.js
similarity index 100%
rename from js/src/views/Signer/containers/OfflinePage/index.js
rename to js/src/views/Signer/containers/--remove-OfflinePage/index.js
diff --git a/js/src/views/Signer/containers/UnAuthorizedPage/UnAuthorizedPage.css b/js/src/views/Signer/containers/--remove-UnAuthorizedPage/UnAuthorizedPage.css
similarity index 100%
rename from js/src/views/Signer/containers/UnAuthorizedPage/UnAuthorizedPage.css
rename to js/src/views/Signer/containers/--remove-UnAuthorizedPage/UnAuthorizedPage.css
diff --git a/js/src/views/Signer/containers/UnAuthorizedPage/UnAuthorizedPage.js b/js/src/views/Signer/containers/--remove-UnAuthorizedPage/UnAuthorizedPage.js
similarity index 100%
rename from js/src/views/Signer/containers/UnAuthorizedPage/UnAuthorizedPage.js
rename to js/src/views/Signer/containers/--remove-UnAuthorizedPage/UnAuthorizedPage.js
diff --git a/js/src/views/Signer/containers/UnAuthorizedPage/index.js b/js/src/views/Signer/containers/--remove-UnAuthorizedPage/index.js
similarity index 100%
rename from js/src/views/Signer/containers/UnAuthorizedPage/index.js
rename to js/src/views/Signer/containers/--remove-UnAuthorizedPage/index.js
diff --git a/js/src/views/Signer/signer.js b/js/src/views/Signer/signer.js
index 88c5d360bcd..b9aace59530 100644
--- a/js/src/views/Signer/signer.js
+++ b/js/src/views/Signer/signer.js
@@ -14,59 +14,23 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see
.
-import React, { Component, PropTypes } from 'react';
-import { connect } from 'react-redux';
+import React, { Component } from 'react';
import { Actionbar, Page } from '../../ui';
-
-import LoadingPage from './containers/LoadingPage';
import RequestsPage from './containers/RequestsPage';
import styles from './signer.css';
-export class Signer extends Component {
- static propTypes = {
- signer: PropTypes.shape({
- isLoading: PropTypes.bool.isRequired
- }).isRequired
- };
-
+export default class Signer extends Component {
render () {
return (
- { this.renderPage() }
+
);
}
-
- renderPage () {
- const { isLoading } = this.props.signer;
-
- if (isLoading) {
- return (
-
- );
- }
-
- return (
-
- );
- }
-}
-
-function mapStateToProps (state) {
- return state;
}
-
-function mapDispatchToProps (dispatch) {
- return {};
-}
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(Signer);