Smarter balance fetching (#3605)

* Smarter dApps Manifest fetching...

* Fetching only visible accounts (and don't delete other balances) #3590

* Moved balances action into BalancesActions #3590

* Fetch balances for accounts and contracts #3590

* Add balances to contract/address/account views #3590

* Fix transaction not fetching on first load

* Remove console.warn

* Fix pending tokens not showing #3154

* Fix tokens image update

* Remove unused name in Header

* Separate Tokens and ETH fetching #3590

* Remove unused isTest

* Fetch Tokens Balance via Filter #3590

* Fix linting

* Fix updating tokens image (#3590)

* Fix contract balances

* Improved Status

* Fixing secureApi issues...

* Fetch all tokens every 2 minutes (for safety) #3590

* PR changes fix

* Fix Account error
This commit is contained in:
Nicolas Gotchac
2016-11-25 16:46:35 +01:00
committed by Jaco Greeff
parent 9fdab84305
commit 08c507daaa
27 changed files with 798 additions and 355 deletions

View File

@@ -24,6 +24,8 @@ import EyeIcon from 'material-ui/svg-icons/image/remove-red-eye';
import ContentClear from 'material-ui/svg-icons/content/clear';
import { newError } from '../../redux/actions';
import { setVisibleAccounts } from '../../redux/providers/personalActions';
import { EditMeta, ExecuteContract } from '../../modals';
import { Actionbar, Button, Page, Modal, Editor } from '../../ui';
@@ -41,6 +43,8 @@ class Contract extends Component {
}
static propTypes = {
setVisibleAccounts: PropTypes.func.isRequired,
accounts: PropTypes.object,
balances: PropTypes.object,
contracts: PropTypes.object,
@@ -68,21 +72,29 @@ class Contract extends Component {
this.attachContract(this.props);
this.setBaseAccount(this.props);
this.setVisibleAccounts();
api
.subscribe('eth_blockNumber', this.queryContract)
.then(blockSubscriptionId => this.setState({ blockSubscriptionId }));
}
componentWillReceiveProps (newProps) {
const { accounts, contracts } = newProps;
componentWillReceiveProps (nextProps) {
const { accounts, contracts } = nextProps;
if (Object.keys(contracts).length !== Object.keys(this.props.contracts).length) {
this.attachContract(newProps);
this.attachContract(nextProps);
}
if (Object.keys(accounts).length !== Object.keys(this.props.accounts).length) {
this.setBaseAccount(newProps);
this.setBaseAccount(nextProps);
}
const prevAddress = this.props.params.address;
const nextAddress = nextProps.params.address;
if (prevAddress !== nextAddress) {
this.setVisibleAccounts(nextProps);
}
}
@@ -92,6 +104,13 @@ class Contract extends Component {
api.unsubscribe(blockSubscriptionId);
contract.unsubscribe(subscriptionId);
this.props.setVisibleAccounts([]);
}
setVisibleAccounts (props = this.props) {
const { params, setVisibleAccounts } = props;
const addresses = [ params.address ];
setVisibleAccounts(addresses);
}
render () {
@@ -112,7 +131,6 @@ class Contract extends Component {
{ this.renderExecuteDialog() }
<Page>
<Header
isTest={ isTest }
account={ account }
balance={ balance } />
<Queries
@@ -430,7 +448,7 @@ function mapStateToProps (state) {
}
function mapDispatchToProps (dispatch) {
return bindActionCreators({ newError }, dispatch);
return bindActionCreators({ newError, setVisibleAccounts }, dispatch);
}
export default connect(