ghost-keychain/packages/extension-inject
Tarik Gul 3d37f5918c
Update polkadot-js deps (#1571)
* Update polkadot-js deps

* chore: minor change

* chore: updated yarn.lock

* fix: tests

* fix: lint issues

* fix: build issues

* fix: replace sleep with waitForRateLimit for better rate limiting in tests

* Revert "fix: replace sleep with waitForRateLimit for better rate limiting in tests"

* fix: increase sleep duration in tests for better stability

* fix: remove sleep function and update State constructor for rate limiting

* chore: minor change

---------

Co-authored-by: Arjun Porwal <porwalarjun95@gmail.com>
2025-07-04 15:07:41 +03:00
..
src [CI Skip] release/stable 0.61.1 2025-06-27 13:45:35 +00:00
package.json Update polkadot-js deps (#1571) 2025-07-04 15:07:41 +03: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' });