OSDN Git Service

update the account referesh balance. master
authorZhiting Lin <zlin035@uottawa.ca>
Mon, 22 Jul 2019 06:34:48 +0000 (14:34 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Mon, 22 Jul 2019 06:34:48 +0000 (14:34 +0800)
src/components/App.js
src/components/layout/account/index.jsx

index da45f08..ad47c0a 100644 (file)
@@ -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
index b1e53a9..abce9b4 100644 (file)
@@ -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)