npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

filsnap

v1.0.2

Published

Connect to Filecoin dapps using Metamask. Manage Filecoin accounts, send FIL to Native and FEVM accounts and enable FEVM transaction insights.

Downloads

8,127

Readme

filsnap

NPM Version License: MIT License Snap

Connect to Filecoin dapps using Metamask. Manage Filecoin accounts, send FIL to Native and FEVM accounts and enable FEVM transaction insights.

Usage

You can install and use filsnap using the Metamask provider.

import { getRequestProvider } from 'filsnap-adapter'

const provider = await getRequestProvider()

// Install filsnap
try {
  const result = await provider.request({
    method: 'wallet_requestSnaps',
    params: {
      'npm:filsnap': {
        version: '^0.4.0', // Optional, defaults to latest
      },
    },
  })

  console.log(result)
  /**
{
  'npm:filsnap': {
    version: '1.0.0',
    id: 'npm:filsnap',
    enabled: true,
    blocked: false,
  },
}
   */
} catch (error) {
  console.log(error)
}
import { getRequestProvider } from 'filsnap-adapter'

const provider = await getRequestProvider()
// Get filsnap metadata
const result = await provider.request({ method: 'wallet_getSnaps' })

console.log(result)
/**
{
  'npm:filsnap': {
    version: '1.0.0',
    id: 'npm:filsnap',
    enabled: true,
    blocked: false,
  },
}
 */
import { getRequestProvider } from 'filsnap-adapter'

const provider = await getRequestProvider()
// Get filsnap metadata
const result = await provider.request({
  method: 'wallet_invokeSnap',
  params: { snapId: 'npm:filsnap', method: 'fil_getBalance' },
})

console.log(result)
/**
{
  result: '100699819802794525019',
  error: null
}
 */

We recommend using filsnap-adapter to interact with filsnap for a simpler interface. Check the full API documentation here.

RPC Methods

  • fil_configure - Configure the snap.
  • fil_getBalance - Get the balance of the connected account.
  • fil_getAddress - Get the address of the connected account.
  • fil_getPublicKey - Get the public key of the connected account.
  • fil_getAccountInfo - Get the account info of the connected account.
  • fil_getGasForMessage - Get the gas for a message.
  • fil_signMessage - Sign a message with the connected account.
  • fil_signMessageRaw - Sign a raw message (string) with the connected account.
  • fil_exportPrivateKey - Export the private key of the connected account.
  • fil_sendMessage - Send a message.

Check the full RPC methods documentation here.

Architecture

sequenceDiagram
    participant Dapp
    box rgb(76, 86, 106) Metamask Extension
    participant Metamask
    participant filsnap
    end
    Dapp-)Metamask: connect('npm:filsnap', '0.4.0')
    Note over Dapp,Metamask: `wallet_requestSnaps`
    Metamask--> Metamask: Install filsnap
    Metamask--)filsnap: Connect Dapp to filsnap
    activate filsnap
    filsnap--)Metamask: Connected
    Metamask-)Dapp: filsnap metadata
    Dapp-)filsnap: configure({network: 'mainnet'})
    Note over Dapp,Metamask: `wallet_invokeSnap` method `fil_configure`
    filsnap-)Dapp: filsnap configuration
    Dapp-)filsnap: getBalance()
    Note over Dapp,Metamask: `wallet_invokeSnap` method `fil_getBalance`
    filsnap-)Dapp: 100 FIL (balance)
    deactivate filsnap

Current limitations

  • Multiple accounts are not supported yet. Only the first account is used.
    • One workaround currently supported is to use the derivation path from the configuration to get the account you want to use.
  • Ledger is not supported, this is a Metamask limitation.
  • There's no UI native in the extension for the user to interact with the snap, this is a Metamask limitation.
  • Transaction insights are supported but forces the Filsnap tab to be opened even if the snap doesn't return any data. This is a Metamask limitation.

Recommendations for future work

  • Add support for multiple accounts.
  • Sync with Metamask team to work through the limitations.

Contributing

Read contributing guidelines here.

Open in GitHub Codespaces

License

Dual-licensed: MIT, Apache Software License v2, by way of the Permissive License Stack.