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

f8n-pvinis-lib

v0.2.0

Published

Get foundationed.

Downloads

5

Readme

a bunch of trials here: 0xD72a90e87c79452d1f03f4ABAb09d31C3F80536F

  • make lib
  • add tests
  • use git tags for lib in package.json deps
  • add lib to example and readme instructions
  • make some way (.env?) to change the address of the f8n contract

i would probably not use that template to generate this repo https://github.com/tomchen/example-typescript-package

not sure what to do for cjs, modules, es6, etc for exports from ts

maybe ethers could be a peer dep

i didnt like i have to setup the whole project

Setup

  • Install, npm add x, yarn add x

  • import { bla } from "x"

  • use to deploy

  • use to mint

Contributing

  • docs about npm link

Log

  • I created a vite app which will end up being the app that will import the final lib.

  • I made it so that the app fully works, and then extracted the code that will become the lib. That way I could have a clear "api" for my lib. What is called, where, and how.

  • I had to download the ABIs for both the factory and the collection contracts, and generate types for these to use with typescript.

    For a future version of this lib, I would have some scripts to pull the latest ABIs and generate the types. For this version, pulling is manual, and after the ABIs are in the ./abi directory, I can run npm run generate-types to get freshly generated types in ./src/types.

    eg: https://api.etherscan.io/api?module=contract&action=getabi&address=0xe38f942db7a1b4213d6213f70c499b59287b01f1&apiKey=your-api-key-here

  • I assume metamask is installed on the browser, to make it easier for me to develop this.

    In a very near future version of the lib, I would add support for walletconnect etc, with the usual popup and all that jazz. That's key to lib adoption.

  • For the lib, I decided to go for a simple function that takes a provider and returns the createCollection and mint functions, all set up with the provider.

    I could have put the signer at the start function, but I decided not too. I think keeping it as an argument to the functions is a bit more verbose and explicit, but it is an important part of the functions, and having it as an arg reminds that to the user of the lib.

    I could have used a class or some other "singleton" situation to keep the provider and signer for all things, but again, I went for the simple solution.

  • The mint function is returning the token id at the end of a successful transaction.

    I wanted to "hide" the transaction id since the request for this lib is to hide as much of the web3 things from the user of the lib, and make it more like any other regular lib.

    I know the choice of keeping the signer as an arg goes against the above, but I still think this is one important bit that is worth having repeated. Very easy to change and hide it though, if we decide the api must hide as many web3 things as possible.

  • For types, I hooked on things like Parameters<FNDCollectionABI["mint"]>[0] in order to have a direct type connection for the things i just pass on, and a separate type when I use them elsewhere like string or Signer.

    This helps me for when the contract changes, and the ABI is updates, so the types might be different. If that happens, then typescript will complain for possible breakages.

    That is not enough, because maybe two args of the same type might swap places, so typescript will have no type issues, but things like the CollectionCreated filter might break. For these cases I would write tests. I will not write tests here, but I would not ship this to npm without tests. I have used things like hardhat and set up tests, but I have not set up tests on a lib that calls to contracts, and I think that might take a bit too much time for me to try and set up, and it's not required for this assignment. My guess is that with hardhat the contract would run on a local node, and then the tests can run and verify a few things like the newly created collection extraction.

  • I left some commented out console.logs in there, just for easy debugging for this assignment.

  • Since I only have the addresses to mainnet and goerli for the f8n factory, I throw when someone tries to use any other network.

    In the future this would be best to allow for .env value setting.

Future plans

  • support for walletconnect.
  • tests for the actual functions.
  • scripts for ABIs pulling.
  • event listener for events like txn started, pending, succeeded, failed?
  • support for web3js and not just ethersjs for provider.
  • support for .env file, for FND_COLLECTION_FACTORY_ADDR etc.