mirror of
https://github.com/pezkuwichain/pezkuwi-extension.git
synced 2026-11-03 00:01:06 +00:00
Raising the @pezkuwi dependency floors to ^14.0.26 and ^16.5.37 also rewrote the peerDependencies of extension-dapp, extension-inject, extension-chains and extension-compat-metamask, which were "*" (as they are upstream). A peer range is a requirement on the dApp's own @pezkuwi/api and util; narrowing it would make npm refuse to install these packages next to an api release from before 16.5.37. They are "*" again.
@polkadot/extension-inject
This is a basic extension injector that manages access to the global objects available. As an extension developer, you don't need to manage access to the window object manually, by just calling enable here, the global object is setup and managed properly. From here any dapp can access it with the @polkadot/extension-dapp package;
Usage
import { injectExtension } from '@polkadot/extension-inject';
// this a the function that will be exposed to be callable by the dapp. It resolves a promise
// with the injected interface, (see `Injected`) when the dapp at `originName` (url) is allowed
// to access functionality
function enableFn (originName: string): Promise<Injected> {
...
}
// injects the extension into the page
injectExtension(enableFn, { name: 'myExtension', version: '1.0.1' });