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

test-mina-snap

v0.1.36

Published

This snap helps you interact with Mina protocol using Metamask Flask

Downloads

37

Readme

Mina Snap

This snap helps you interact with Mina protocol using Metamask Flask

Important

This snap only works with Metamask Flask. If you have normal Metamask enabled, please disable it and install Metamask Flask before using this snap.

Setup

yarn install

Building

Run yarn build to build this snap

Run yarn build:clean to remove old dist folder and re-build snap

Start local snap

Run yarn serve to start local snap

The snap will be running on http://localhost:8080. You can change port number in snap.config.js as well

Your DApp now can connect to the snap by calling wallet_requestSnaps method with http://localhost:8080 as the snapId

(Reference: https://docs.metamask.io/guide/snaps-rpc-api.html#wallet-requestsnaps)

Using published snap

Connect to the snap by calling wallet_requestSnaps method with npm:test-mina-snap as the snapId

Notes

  • Babel is used for transpiling TypeScript to JavaScript, so when building with the CLI, transpilationMode must be set to localOnly (default) or localAndDeps.
  • For the global wallet type to work, you have to add the following to your tsconfig.json:
    {
      "files": ["./node_modules/@metamask/snap-types/global.d.ts"]
    }
  • This snap uses a patched version of mina-signer. It may need to update if there's a new version of mina-signer. We are using this repo as the dependency http://www.github.com/sotatek-dev/mina-signer-for-snap

Publish snap to NPM

  • Update the version in package.json then run:
yarn build
  • Run the below command to publish to NPM:
npm publish

Methods

| Method | Description | | ------------------------------ | --------------------------------------------- | | mina_accountInfo | Get current account info | | mina_accountList | Return account list | | mina_createAccount | Create new account | | mina_changeAccount | Change Address | | mina_changeNetwork | Change Network | | mina_importAccountByPrivateKey | Import account by private key | | mina_exportPrivateKey | Return private key of the current account | | mina_editAccountName | Edit account name | | mina_networkConfig | Return current network config | | mina_signMessage | Sign custom message | | mina_sendPayment | Transfer Mina Token | | mina_resetSnapConfig | Reset snap config to default | | mina_getTxHistory | Return transaction history by user address | | mina_getTxDetail | Return transaction detail by transaction hash | | mina_getTxStatus | Return transaciton status by transaction id | | mina_sendStakeDelegation | Send stake delegation | | mina_verifyMessage | Verify signed message | | mina_requestNetwork | Request network | | mina_sendTransaction | Send ZkApp transaction |

Implement ZkApp transaction

  • To make ZkApp transactions with your smart contract, you will need to have the built file of the smart contract (the .js file).
  • Install snarkyjs on your front-end site and use snarkyjs to make the transaction.
  • Then submit your transaction using snap.

Here is an example:

import {
    Mina,
    isReady,
    PublicKey,
    fetchAccount,
    Field,
  } from 'snarkyjs';

(async() => {
    await isReady;
    const { <Your smart contract class name> } = await import(<Path to your built smart contract>);
    const zkAppAddress = <Your deployed smart contract address>
    const graphqlEndpoint = <replace the graphql endpoint here>
    const zkApp = new <Your smart contract class name>(PublicKey.fromBase58(zkAppAddress));
    Mina.setActiveInstance(Mina.Network(<graphqlEndpoint>));
    <Your smart contract class name>.compile();
    const account = await fetchAccount({publicKey: zkAppAddress, ...zkApp}, <graphqlEndpoint>);
    const tx = await Mina.transaction({
        sender: PublicKey.fromBase58(<sender address>),
        fee: <replace the fee here>
    }, () => {
        zkApp.update(<your parameter>);
    });
    const provedTx = await tx.prove();
    await ethereum.request({
      method: 'wallet_invokeSnap',
      params: {
        snapId: <the mina snap id>,
        request: {
          method: 'mina_sendTransaction',
          params: {
            transaction: tx.toJSON(),
            feePayer: {
              fee: <replace the fee here>,
              memo: <user' memo>,
            }
          }
        },
      },
    });
})();