Guest User

Untitled

a guest
Mar 21st, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /** Get the current account */
  2. public currentAccount(): Observable<string | Error> {
  3. if (this.web3.eth.defaultAccount) {
  4. return of(this.web3.eth.defaultAccount);
  5. } else {
  6. return this.getAccounts().pipe(
  7. tap((accounts: string[]) => {
  8. if (accounts.length === 0) { throw new Error(‘No accounts available’); }
  9. }),
  10. map((accounts: string[]) => accounts[0]),
  11. tap((account: string) => this.web3.eth.defaultAccount = account),
  12. catchError((err: Error) => of(err))
  13. );
  14. }
  15. }
Add Comment
Please, Sign In to add comment