Fixing unbound provider (metamask v7.7 incorrectly binds this)

This commit is contained in:
John Johnson
2019-12-04 15:09:00 -08:00
parent 761d0a0f18
commit 104cc24dfc

View File

@@ -42,6 +42,10 @@ export const providerUtils = {
enable: (supportedProvider as any).enable,
sendAsync: _.noop.bind(_), // Will be replaced
};
if (provider.enable) {
// Need to bind, metamask can lose reference to function without binding as of 7.7.0
provider.enable.bind(supportedProvider);
}
// Case 1: We've already converted to our ZeroExProvider so noop.
if ((supportedProvider as any).isStandardizedProvider) {
// tslint:disable-next-line:no-unnecessary-type-assertion