@bifrost-finance/metamask-bifrost-adapter
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

Metamask <> Polkadot snap adapter

Discord

Metamask <> Polkadot snap adapter is used to inject polkadot snap as web3 provider. It lists snap inside window.injectedWeb3[injectedSnapId](*) so it can be enabled using @polkadot/extension-dapp package.

*injectedSnapId default is "metamask-polkadot-snap"

For more details on polkadot snap itself see snap repo or read full polkadot snap documentation.

Usage

function enablePolkadotSnap(
  config?: SnapConfig,
  snapOrigin?: string,
  snapInstallationParams?: Record<SnapInstallationParamNames, unknown> = {}
): Promise<MetamaskPolkadotSnap>

Usage to inject snap in injectedWeb3 object

function initPolkadotSnap(
  {
    config?: SnapConfig,
    snapOrigin?: string,
    snapInstallationParams?: Record<SnapInstallationParamNames, unknown> = {}
  },
  injectedSnapId?: string
): Promise<MetamaskPolkadotSnap>

By providing config as argument it is possible to override default configurations.

Default config:

{
  networkName: 'westend'
}

Configuration structure is shown below.

SnapConfig {
  networkName: SnapNetworks;
  wsRpcUrl?: string;
  addressPrefix?: number;
  unit?: UnitConfiguration;
}

SnapNetworks = "polkadot" | "kusama" | "westend";

UnitConfiguration {
  symbol: string;
  decimals: number;
  image?: string;
  customViewUrl?: string;
}

Package Sidebar

Install

npm i @bifrost-finance/metamask-bifrost-adapter

Weekly Downloads

1

Version

0.6.0

License

Apache-2.0

Unpacked Size

20.2 kB

Total Files

11

Last publish

Collaborators

  • ark930
  • herryheyi
  • janpo
  • sorvik
  • chencheng_bifrost