ghost-keychain/packages/extension-inject
Antoine Estienne 5c53ee7d02
Add metamask extension web3 (#566)
* added web3source

* tried fixing dependencies

* removed load event listener and added name

* add signer to interface

* added signPayload draft

* lint

* modified signpayload

* switch back to only signRaw

* add types to injecetd accounts

* hash tx and finalize code

* lint and type

* iterate on feedback

* lint index.ts

* prettier lint index.ts

* type optional again

* removed sigenr from injected account type

* lint

* wip remove web3

* remove laod event

* Update packages/extension-dapp/src/compat/metaMaskSource.ts

Co-authored-by: Jaco <jacogr@gmail.com>

* Update packages/extension-dapp/src/compat/metaMaskSource.ts

Co-authored-by: Jaco <jacogr@gmail.com>

* filter accounts by type

* lint

* fix type typing

* Update packages/extension-dapp/src/index.ts

Co-authored-by: Jaco <jacogr@gmail.com>

* filter by array of type, instead of single type

Co-authored-by: Jaco <jacogr@gmail.com>
2021-09-03 11:45:34 +02:00
..
src Add metamask extension web3 (#566) 2021-09-03 11:45:34 +02:00
LICENSE extension-inject (no direct globals for extension/dapp) (#75) 2019-07-12 21:22:06 +02:00
package.json [CI Skip] release/beta 0.39.4-6 2021-09-01 16:45:43 +00:00
README.md Add address encoding option to web3Accounts (#437) 2020-09-11 16:09:02 +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' });