• R/O
  • HTTP
  • SSH
  • HTTPS

Bytom-Dapp-Demo: Commit

A simple deposit and profit bytom dapp demo


Commit MetaInfo

Revision4f7638eef514506b9ef927078700c163c051f775 (tree)
Zeit2019-07-22 14:57:36
AutorZhiting Lin <zlin035@uott...>
CommiterZhiting Lin

Log Message

fixed the account referesh error.

Ändern Zusammenfassung

Diff

--- a/src/components/App.js
+++ b/src/components/App.js
@@ -15,13 +15,13 @@ import GetContractArgs from "./constants";
1515 import Bytom from 'bytom-js-sdk'
1616
1717 class App extends Component {
18- componentDidMount(){
18+ componentWillMount(){
1919 const { bytom, setBytom } = this.props;
2020 if(!bytom){
2121 document.addEventListener('chromeBytomLoaded', bytomExtension => {
2222 const bytom = window.bytom;
23- setBytom(bytom);
2423 this.bytomLoaded(bytom);
24+ setBytom(bytom);
2525 });
2626 }else {
2727 this.bytomLoaded(bytom);
@@ -38,13 +38,14 @@ class App extends Component {
3838
3939 try {
4040 const BYTOM_ACCOUNT = await bytom.enable()
41- this.props.updateConnection(true)
4241
4342 const bytomAPI = new Bytom(networks, '')
4443 bytomAPI.setNetType(bytom.net)
4544
4645 global.bytomAPI = bytomAPI
4746
47+ this.props.updateConnection(true)
48+
4849 // Check to see if the user has signed in/out of their
4950 // bytom wallet or switched accounts
5051 let accountInterval = setInterval(function () {
--- a/src/components/layout/account/index.jsx
+++ b/src/components/layout/account/index.jsx
@@ -27,7 +27,9 @@ class Account extends Component {
2727 const account = bytom.default_account
2828 this.setState({ account })
2929 if(account){
30- this.props.updateBalances(account.accountId)
30+ if(global.bytomAPI){
31+ this.props.updateBalances(account.accountId)
32+ }
3133 this.listBalance(account, GetContractArgs().assetDeposited)
3234 }
3335 }
Show on old repository browser