# @nodefactory/filsnap-adapter

> Adapter for installing Filsnap

Latest version **1.0.0** (published 2020-10-13) · (Apache-2.0 AND MIT) license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @nodefactory/filsnap-adapter
pnpm add @nodefactory/filsnap-adapter
yarn add @nodefactory/filsnap-adapter
bun add @nodefactory/filsnap-adapter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-10-13 |
| First published | 2020-08-26 |
| Weekly downloads | 0 |
| License | (Apache-2.0 AND MIT) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | NodeFactory |
| Maintainers | makmuftic, mpetrunic, morrigan88 |
| Keywords | filecoin, metamask, snap, plugin, dapp |

## Links

- npm: https://www.npmjs.com/package/@nodefactory/filsnap-adapter
- Homepage: https://github.com/NodeFactoryIo/filecoin-metamask-snap/tree/master/packages/adapter
- npm.io page: https://npm.io/package/@nodefactory/filsnap-adapter

## Recent versions

- 1.0.0 (latest) — 2020-10-13
- 0.2.2 — 2020-09-28
- 0.2.1 — 2020-09-02
- 0.2.0 — 2020-09-02
- 0.1.1 — 2020-08-31
- 0.1.0 — 2020-08-26

## README

# FilSnap adapter
![](https://github.com/nodefactoryio/filecoin-metamask-snap/workflows/ci/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![](https://img.shields.io/badge/yarn-%3E%3D1.17.0-orange.svg?style=flat-square)
![Discord](https://img.shields.io/discord/608204864593461248?color=blue&label=Discord&logo=discord)

FilSnap adapter is used to install Filecoin snap and expose API toward snap.

For more details on Filecoin snap itself see [snap repo](https://github.com/NodeFactoryIo/filecoin-metamask-snap) or read full [Filecoin snap documentation](https://github.com/NodeFactoryIo/filecoin-metamask-snap/wiki).

## Usage

Adapter has only exposed function for installing Filecoin snap.

```typescript
async function enableFilecoinSnap(
  config: Partial<SnapConfig>, 
  pluginOrigin?: string
): Promise<MetamaskFilecoinSnap> 
```

On snap installation, it is possible to send full or partial configuration.
If you only provide `network` property a predefined configuration for the specified network will be used.
Other properties are optional but will override default values if provided.

Below you can see structure of config object:

```typescript
export interface SnapConfig {
  derivationPath: string;
  token: string;
  network: FilecoinNetwork; // "f" || "t"
  rpcUrl: string;
  unit?: UnitConfiguration;
}

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

After snap installation, this function returns `MetamaskFilecoinSnap` object that can be used to retrieve snap API. 
An example of initializing Filecoin snap and invoking snap API is shown below.

```typescript
// install snap and fetch API
const snap = await enableFilecoinSnap({network: "t"});
const api = await metamaskFilecoinSnap.getFilecoinSnapApi();

// invoke API
const address = await api.getAddress();

console.log(`Snap installed, account generated with address: ${address}`);
```

---
_Source: https://npm.io/package/@nodefactory/filsnap-adapter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
