From ed6b30da8fbe6289d2d00c28737f409991d18a00 Mon Sep 17 00:00:00 2001 From: Zhiting Lin Date: Mon, 22 Jul 2019 14:34:48 +0800 Subject: [PATCH] update the account referesh balance. --- src/components/App.js | 21 ++++++++++++--------- src/components/layout/account/index.jsx | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/App.js b/src/components/App.js index da45f08..ad47c0a 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -15,6 +15,16 @@ import GetContractArgs from "./constants"; import Bytom from 'bytom-js-sdk' class App extends Component { + constructor(props){ + super(props) + let networks = { + solonet: 'http://app.bycoin.io:3000/', + testnet: 'http://app.bycoin.io:3020/', + mainnet: 'https://api.bycoin.im:8000/' + }; + global.bytomAPI = new Bytom(networks, '') + } + componentWillMount(){ const { bytom, setBytom } = this.props; if(!bytom){ @@ -30,21 +40,14 @@ class App extends Component { async bytomLoaded (bytom){ let bytomPollInterval = 3 * 1000; - let networks = { - solonet: 'http://app.bycoin.io:3000/', - testnet: 'http://app.bycoin.io:3020/', - mainnet: 'https://api.bycoin.im:8000/' - }; try { const BYTOM_ACCOUNT = await bytom.enable() - const bytomAPI = new Bytom(networks, '') - bytomAPI.setNetType(bytom.net) + this.props.updateConnection(true) - global.bytomAPI = bytomAPI + global.bytomAPI.setNetType(bytom.net) - this.props.updateConnection(true) // Check to see if the user has signed in/out of their // bytom wallet or switched accounts diff --git a/src/components/layout/account/index.jsx b/src/components/layout/account/index.jsx index b1e53a9..abce9b4 100644 --- a/src/components/layout/account/index.jsx +++ b/src/components/layout/account/index.jsx @@ -28,6 +28,7 @@ class Account extends Component { this.setState({ account }) if(account){ if(global.bytomAPI){ + global.bytomAPI.setNetType(bytom.net) this.props.updateBalances(account.accountId) } this.listBalance(account, GetContractArgs().assetDeposited) -- 2.11.0