JSPM

@polkadot/extension-inject

0.39.4-9
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21583
  • Score
    100M100P100Q152087F
  • License Apache-2

A generic injector (usable to any extension), that populates the base exposed interfaces to be used by dapps.

Package Exports

  • @polkadot/extension-inject
  • @polkadot/extension-inject/README.md
  • @polkadot/extension-inject/chrome
  • @polkadot/extension-inject/chrome.d.ts
  • @polkadot/extension-inject/index.d.ts
  • @polkadot/extension-inject/package.json
  • @polkadot/extension-inject/packageInfo
  • @polkadot/extension-inject/packageInfo.d.ts
  • @polkadot/extension-inject/types
  • @polkadot/extension-inject/types.d.ts

Readme

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