import Bytom from 'bytom-js-sdk'
class App extends Component {
- componentDidMount(){
+ componentWillMount(){
const { bytom, setBytom } = this.props;
if(!bytom){
document.addEventListener('chromeBytomLoaded', bytomExtension => {
const bytom = window.bytom;
- setBytom(bytom);
this.bytomLoaded(bytom);
+ setBytom(bytom);
});
}else {
this.bytomLoaded(bytom);
try {
const BYTOM_ACCOUNT = await bytom.enable()
- this.props.updateConnection(true)
const bytomAPI = new Bytom(networks, '')
bytomAPI.setNetType(bytom.net)
global.bytomAPI = bytomAPI
+ this.props.updateConnection(true)
+
// Check to see if the user has signed in/out of their
// bytom wallet or switched accounts
let accountInterval = setInterval(function () {
const account = bytom.default_account
this.setState({ account })
if(account){
- this.props.updateBalances(account.accountId)
+ if(global.bytomAPI){
+ this.props.updateBalances(account.accountId)
+ }
this.listBalance(account, GetContractArgs().assetDeposited)
}
}