* Add typings to messages * Fix eslint (after merge) * Fix TypeScript error * Lint * Consistent naming * Better promise error handling * Constraint handle typings as much as tsc will allow * Revert to empty Props interfaces * SeedLengths type * Add type to transport subscription message * nit * Typecheck passing callback to sendMessage when none expected * Type subscription cb and replace KeyringJson w/ InjectedAccount Use InjectedAccount for `accounts.list`, `accounts.subscribe` |
||
|---|---|---|
| .. | ||
| src | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
@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' });