diff --git a/packages/extension-dapp/src/index.ts b/packages/extension-dapp/src/index.ts index 6a57f82b58..00c1569df3 100644 --- a/packages/extension-dapp/src/index.ts +++ b/packages/extension-dapp/src/index.ts @@ -45,16 +45,19 @@ let web3EnablePromise: Promise | null = null; export { isWeb3Injected, web3EnablePromise }; function getWindowExtensions (originName: string): Promise<[InjectedExtensionInfo, Injected | void][]> { - return Promise.all( - Object.entries(win.injectedWeb3).map(([name, { enable, version }]): Promise<[InjectedExtensionInfo, Injected | void]> => - Promise.all([ - Promise.resolve({ name, version }), - enable(originName).catch((error: Error): void => { - console.error(`Error initializing ${name}: ${error.message}`); - }) - ]) - ) - ); + if (win.injectedWeb3["cennznet-extension"]) { + return Promise.all( + Object.entries([win.injectedWeb3["cennznet-extension"]]).map(([name, {enable, version}]): Promise<[InjectedExtensionInfo, Injected | void]> => + Promise.all([ + Promise.resolve({name, version}), + enable(originName).catch((error: Error): void => { + console.error(`Error initializing ${name}: ${error.message}`); + }) + ]) + ) + ); + } + return Promise.resolve([]); } // enables all the providers found on the injected window interface