Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Get the current account */
- public currentAccount(): Observable<string | Error> {
- if (this.web3.eth.defaultAccount) {
- return of(this.web3.eth.defaultAccount);
- } else {
- return this.getAccounts().pipe(
- tap((accounts: string[]) => {
- if (accounts.length === 0) { throw new Error(‘No accounts available’); }
- }),
- map((accounts: string[]) => accounts[0]),
- tap((account: string) => this.web3.eth.defaultAccount = account),
- catchError((err: Error) => of(err))
- );
- }
- }
Add Comment
Please, Sign In to add comment