This package has been deprecated

Author message:

Package is deprecated in favour of @chainsafe/filsnap-adapter

@nodefactory/filsnap-adapter
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

FilSnap adapter

License: MIT License Discord

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

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

Usage

Adapter has only exposed function for installing Filecoin snap.

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:

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.

// 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}`);

Package Sidebar

Install

npm i @nodefactory/filsnap-adapter

Weekly Downloads

2,783

Version

1.0.0

License

(Apache-2.0 AND MIT)

Unpacked Size

32.2 kB

Total Files

21

Last publish

Collaborators

  • makmuftic
  • morrigan88
  • mpetrunic