ghost-keychain/packages/extension-inject
Ryan Lee 727c61663c
chore: update module resolution to bundler (#1387)
* chore: update module resolution to bundler

* fix: linter issues

* fix jest

* fix: build

* use import type

* lint
2024-07-08 15:15:17 -04:00
..
src chore: update module resolution to bundler (#1387) 2024-07-08 15:15:17 -04:00
package.json chore: update module resolution to bundler (#1387) 2024-07-08 15:15:17 -04:00
README.md Add address encoding option to web3Accounts (#437) 2020-09-11 16:09:02 +02:00
tsconfig.build.json Adjust tsconfig usage (w/ latest dev) (#1258) 2023-05-18 12:54:23 +03:00
tsconfig.spec.json Adjust tsconfig usage (w/ latest dev) (#1258) 2023-05-18 12:54:23 +03: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' });