ghost-keychain/packages/extension-inject
Jaco b5efebca82
Bump dev deps (& swap to using build:before) (#1227)
* Bump dev deps (& swap to using build:before)

* Dedupe
2023-03-10 09:38:01 +02:00
..
src [CI Skip] bump/beta 0.45.2-5-x 2023-03-10 06:23:53 +00:00
package.json Bump dev deps (& swap to using build:before) (#1227) 2023-03-10 09:38:01 +02:00
README.md Add address encoding option to web3Accounts (#437) 2020-09-11 16:09:02 +02:00
tsconfig.build.json Align tsconfig.build.json with other polkadot-js (#973) 2022-01-12 11:39:30 +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 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' });