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

lnsjs

v0.4.0

Published

A light javascript library for Lightlink naming service contract interaction

Downloads

13

Readme

The LNS Javascript Library is the ultimate solution for working with the LNS on the Lightlink ecosystem, with ethers.js at its core and inspired by and modelled on the ENS Package

NOTE!!!

lnsjs is currently in the early development stage, meaning that the projects are subject to change.

Given the current development status, we're actively seeking feedback so feel free to create an issue or PR if you notice something!

Installation

npm i lnsjs ethers

Getting Started

All that's needed to get started is an ethers provider instance(https://replicator.pegasus.lightlink.io/rpc/v1). Once you create a new LNS instance, you can pass it in using setProvider.

import { LNS } from 'lnsjs'
import { ethers } from 'ethers'

const provider = new ethers.providers.JsonRpcProvider(providerUrl)

const LNSInstance = new LNS()
await LNSInstance.setProvider(provider)

NOTE: If using lnsjs with Node, you may need to pass the --experimental-specifier-resolution=node flag.

node --experimental-specifier-resolution=node ./index.js

Single-use Providers

If you want to use a specific provider to make a single call occasionally, you can easily do so.

import { LNS } from 'lnsja'

const LNSInstance = new LNS()

const callWithProvider = await LNSInstance.withProvider(otherProvider).getText(
  'arome.link',
  'foo',
)

Name Availability

Check if a name is available to be registered on the FEVM Naming Service.

const name = "arome.link"
const isAvailable = await LNSInstance.getAvailable(name);

Price

View the current price of registering or updating a name on the FEVM Naming Service. The price is determined by market demand and is subject to change.

const name = "arome.link"
const price = await LNSInstance.getPrice(name, duration);

Profiles

You can fetch almost all information about an LNS name (or address) using getProfile. If an address is used as the first argument, it will fetch the primary name and give the same response as a name would. It will automatically get all the records for a name, as well as get the resolver address for the name. Specific records can also be used as an input, if you only want to get certain ones. If an address is used as an input alongside this, you also save 1 RPC call.

NOTE:
The profile function will always request an ETH addr record. For names, this means the address will always at the top level of the returned object. For addresses, this means the "match" property (a boolean value for matching reverse/forward resolution) will always be at the top level of the returned object.

/* Normal profile fetching */
const profile = await LNSInstance.getProfile('arome.link')

/* Normal address fetching */
const address = await LNSInstance.getAddress('arome.link')

/* Normal content fetching */
const contentHash = await LNSInstance.getContent('arome.link')

/* Get Name from Address */
const node = await LNSInstance.getNameNode(address);
const name = await LNSInstance.getAddrName(node);

/* Profile fetching from an address */
const profile = await LNSInstance.getProfile(
  '0x562937835cdD5C92F54B94Df658Fd3b50A68ecD5',
)

/* Get all records of a specific type (or multiple) */
const profile = await LNSInstance.getProfile('arome.link', {
  texts: true,
  coinTypes: true,
  contentHash: true,
})

/* Get specific records */
const profile = await LNSInstance.getProfile('arome.link', {
  texts: ['foo'],
  coinTypes: ['FIL'],
})

Returns:

type RecordItem = {
  key: string | number
  type: 'addr' | 'text' | 'contentHash'
  coin?: string
  addr?: string
  value?: string
}

type ProfileReturn = {
  address?: string // ONLY RETURNED AT TOP-LEVEL FOR NAME QUERIES
  name?: string // ONLY RETURNED AT TOP-LEVEL FOR ADDRESS QUERIES
  records: {
    contentHash?: ContentHashObject | null
    texts?: RecordItem[]
    coinTypes?: RecordItem[]
  }
  resolverAddress: string
}

Contribution

Feel free to create an issue or raise a PR