Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
gte account from server function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstep committed Dec 7, 2017
1 parent 62167b2 commit 1ddc920
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/model/Eth/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,36 @@ export default class Wallet {
})
}

getAccountFromServer(){
if (localStorage && localStorage.account_from_server) {
if (localStorage.account_from_server=='wait') {
return new Promise((resolve, reject) => {
let waitTimer = ()=>{ setTimeout(()=>{
if (localStorage.account_from_server.privateKey) {
resolve(localStorage.account_from_server)
} else {
waitTimer()
}
}, 1000) }
waitTimer()
})
}
return
}

if (localStorage) localStorage.account_from_server = 'wait'
return fetch('https://platform.dao.casino/faucet?get=account').then(res=>{
return res.json()
}).then(acc=>{
console.log('Server account data:', acc)
if (localStorage) localStorage.account_from_server = acc
_wallet.openkey = acc.address
return acc.privateKey
}).catch(e=>{
return false
})
}

async getNonce(callback=false){
if (this.nonce) {
this.nonce++
Expand Down

0 comments on commit 1ddc920

Please sign in to comment.