• R/O
  • HTTP
  • SSH
  • HTTPS

Bytom-Dapp-Demo: Commit

A simple deposit and profit bytom dapp demo


Commit MetaInfo

Revisioned6b30da8fbe6289d2d00c28737f409991d18a00 (tree)
Zeit2019-07-22 15:34:48
AutorZhiting Lin <zlin035@uott...>
CommiterZhiting Lin

Log Message

update the account referesh balance.

Ändern Zusammenfassung

Diff

--- a/src/components/App.js
+++ b/src/components/App.js
@@ -15,6 +15,16 @@ import GetContractArgs from "./constants";
1515 import Bytom from 'bytom-js-sdk'
1616
1717 class App extends Component {
18+ constructor(props){
19+ super(props)
20+ let networks = {
21+ solonet: 'http://app.bycoin.io:3000/',
22+ testnet: 'http://app.bycoin.io:3020/',
23+ mainnet: 'https://api.bycoin.im:8000/'
24+ };
25+ global.bytomAPI = new Bytom(networks, '')
26+ }
27+
1828 componentWillMount(){
1929 const { bytom, setBytom } = this.props;
2030 if(!bytom){
@@ -30,21 +40,14 @@ class App extends Component {
3040
3141 async bytomLoaded (bytom){
3242 let bytomPollInterval = 3 * 1000;
33- let networks = {
34- solonet: 'http://app.bycoin.io:3000/',
35- testnet: 'http://app.bycoin.io:3020/',
36- mainnet: 'https://api.bycoin.im:8000/'
37- };
3843
3944 try {
4045 const BYTOM_ACCOUNT = await bytom.enable()
4146
42- const bytomAPI = new Bytom(networks, '')
43- bytomAPI.setNetType(bytom.net)
47+ this.props.updateConnection(true)
4448
45- global.bytomAPI = bytomAPI
49+ global.bytomAPI.setNetType(bytom.net)
4650
47- this.props.updateConnection(true)
4851
4952 // Check to see if the user has signed in/out of their
5053 // bytom wallet or switched accounts
--- a/src/components/layout/account/index.jsx
+++ b/src/components/layout/account/index.jsx
@@ -28,6 +28,7 @@ class Account extends Component {
2828 this.setState({ account })
2929 if(account){
3030 if(global.bytomAPI){
31+ global.bytomAPI.setNetType(bytom.net)
3132 this.props.updateBalances(account.accountId)
3233 }
3334 this.listBalance(account, GetContractArgs().assetDeposited)
Show on old repository browser