Created
April 20, 2019 20:48
-
-
Save alexytiger/ccd9f002b2b8458507e37d7f8f51f181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, InjectionToken, Inject } from '@angular/core'; | |
import { providers } from 'ethers'; | |
export const MetamaskWeb3Provider = new InjectionToken('Metamask Web3 provider', { | |
providedIn: 'root', | |
factory: () => (window as any).ethereum | |
}); | |
@Injectable({ providedIn: 'root' }) | |
export class Provider extends providers.Web3Provider { | |
constructor(@Inject(MetamaskWeb3Provider) web3Provider) { | |
super(web3Provider); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment