JSPM

@stfil/metalink-filecoin-adapter

1.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17
  • Score
    100M100P100Q30460F
  • License (Apache-2.0 AND MIT)

MetaLinkFilecoin adapter is used to install MetaLinkFilecoin snap and expose API toward snap.

Package Exports

  • @stfil/metalink-filecoin-adapter
  • @stfil/metalink-filecoin-adapter/build/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stfil/metalink-filecoin-adapter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MetaLinkFilecoin adapter

License: MIT License

MetaLinkFilecoin adapter is used to install MetaLinkFilecoin snap and expose API toward snap.

For more details on MetaLinkFilecoin snap itself see snap repo.

Usage

Adapter has only exposed function for installing MetaLinkFilecoin snap.

async function enableMetaLinkFilecoinSnap(
  config: Partial<SnapConfig>,
  snapOrigin?: string
): Promise<MetaLinkFilecoinSnap>

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 MetaLinkFilecoinSnap object that can be used to retrieve snap API. An example of initializing MetaLinkFilecoin snap and invoking snap API is shown below.

// install snap and fetch API
const snap = await enableMetaLinkFilecoinSnap({network: "t"});
const api = await MetaLinkFilecoinSnap.getApi();

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

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

For more details about exposed API see API documentation.