This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
providers
/
8.2.2
providers 8.2.2
Install from the command line:
Learn more about npm packages
$ npm install @onekeyhq/providers@8.2.2
Install via package.json:
"@onekeyhq/providers": "8.2.2"
About this version
The Ethereum provider object injected by OneKey into various environments. Contains a lot of implementation details specific to OneKey, and is probably not suitable for out-of-the-box use with other wallets.
The BaseProvider
implements the Ethereum JavaScript provider specification, EIP-1193. OneKeyInpageProvider
implements EIP-1193 and legacy interfaces.
yarn add @onekeyhq/providers
import { initializeProvider } from '@onekeyhq/providers';
// Create a stream to a remote provider:
const onekeyStream = new LocalMessageDuplexStream({
name: 'inpage',
target: 'contentscript',
});
// this will initialize the provider and set it as window.ethereum
initializeProvider({
connectionStream: onekeyStream,
});
const { ethereum } = window;
Types are exposed at index.d.ts
.
They require Node.js EventEmitter
and Duplex
stream types, which you can grab from e.g. @types/node
.
The Provider object should not be mutated by consumers under any circumstances. The maintainers of this package will neither fix nor take responsbility for bugs caused by third parties mutating the provider object.
yarn test