@enjin-io/metamask-enjin-adapter
Version:
48 lines (35 loc) • 1.71 kB
Markdown




Metamask <> Enjin snap adapter is used to inject [enjin snap](https://github.com/enjin/metamask-snap-enjin) as web3 provider. It lists snap inside `window.injectedWeb3[metamask-enjin-snap]` so it can be enabled using `@polkadot/extension-dapp` package.
For more details on Enjin snap itself see [snap repo](https://github.com/enjin/metamask-snap-enjin) or read [Enjin snap guide](https://support.enjin.io/hc/en-gb/articles/23053873072274-Enjin-Snap).
Adapter has only one exposed function for enabling snap as web3 provider.
```typescript
function enablePolkadotSnap(
config?: SnapConfig,
snapOrigin?: string,
snapInstallationParams?: Record<SnapInstallationParamNames, unknown> = {}
): Promise<MetamaskPolkadotSnap>
```
By providing `config` as argument it is possible to override default configurations.
Configuration structure is shown below.
```
export type SnapConfig = {
wsRpcUrl?: string;
addressPrefix?: number;
unit?: UnitConfiguration;
} & (
| { networkName: SupportedSnapNetworks; genesisHash?: `0x${string}` }
| { networkName: SnapNetworks; genesisHash: `0x${string}` }
);
SnapNetworks = 'enjin-relaychain' | 'enjin-matrixchain' | 'canary-relaychain' | 'canary-matrixchain';
export interface UnitConfiguration {
symbol: string;
decimals: number;
image?: string;
customViewUrl?: string;
}
```