ghost-keychain/packages/extension-inject
Jaco Greeff 78b5738e2a
Fix zip output to correctly include all source files (#435)
* Fix zip output to correctly include all source files

* 0.33.2

* Update CHANGELOG.md
2020-09-07 10:21:08 +02:00
..
src Add base known chain info to icon/ss58 display (#386) 2020-07-07 14:30:16 +02:00
LICENSE extension-inject (no direct globals for extension/dapp) (#75) 2019-07-12 21:22:06 +02:00
package.json Fix zip output to correctly include all source files (#435) 2020-09-07 10:21:08 +02:00
README.md extension-inject (no direct globals for extension/dapp) (#75) 2019-07-12 21:22:06 +02:00

@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 windo 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' });