Skip to content

Commit

Permalink
enable on cennznet extension
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 14, 2021
1 parent 1b556ae commit c98ae21
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/extension-dapp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ let web3EnablePromise: Promise<InjectedExtension[]> | 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
Expand Down

0 comments on commit c98ae21

Please sign in to comment.