0.0.14 • Published 8 months ago

ens-tools v0.0.14

Weekly downloads
-
License
lgpl-3.0
Repository
-
Last release
8 months ago

ens-tools

Note

This project aims to extend the functionality of wagmi, in addition to providing utility to the ENS ecosystem.

Features

  • 🪝 React Hook for Multichain Addresses
  • 💾 React Hook for getting Records
  • 🔠 React Hook for preferred name Capitalization
  • 💼 Easily Normalize Records
  • 📝 Easily truncate Ethereum Addresses

...and a lot more.

Documentation

For documentation. Stick to the Typescript Intellisense.

Installation

Install ens-tools and let the magic happen.

npm install ens-tools

Usage

This library thingiemajig contains the following bits and bobs:

⚛️🪝 React Hook for Multichain Addresses

The coinType variable supports all the coins following the SLIP-0044 specification.

import { useMultichainAddress } from 'ens-tools/react';

export const BtcAddress = () => {
    const { address } = useMultichainAddress({
        name: 'vitalik.eth',
        coinType: 2,
    });

    return <div>BTC Address: {address}</div>;
};

⚛️🪝 React Hook for getting Records

This react hook lets you easily get records from an ENS name. Simply specify the records and wether you would like them normalized and you're good to go.

import { useRecords } from 'ens-tools/react';

export const Records = () => {
    const { data } = useRecords({
        name: 'vitalik.eth',
        records: ['com.twitter', 'com.github'],
        normalize: true,
    });

    return (
        <div>
            {data.map((record) => (
                <div key={record.key}>
                    {record.key}: {record.value}
                </div>
            ))}
        </div>
    );
};

⚛️🪝 React Hook for name Capitalization

This react hook lets you easily get the preferred capitalization for an ENS name. It does this by reading the display record of the ENS name and defaults to the inputted validation. Optionally you can specify a fallback name to use in case the ENS name does not have a display record. Simply specify the name you're good to go.

import { usePreferredName } from 'ens-tools/react';

export const Name = () => {
    const { data } = usePreferredName({
        name: 'vitalik.eth',
        fallback: 'vItAlIk.eth',
    });

    return (
        <div>
            Hey there <b>{data}</b>!
        </div>
    );
};

📝 Format Ethereum Addresses

Easily truncate Ethereum Addresses to 10 characters.

import { formatAddress } from 'ens-tools';

const address = formatAddress('0x1234567890123456789012345678901234567890');
// Outputs: 0x1234...7890

📝 Format Records

Easily normalize records.

Record TypeOutputRules Applied
com.twitter@lucemansnlTwitter
com.githublucemansGithub
com.linkedinlucemansLinkedIn
org.redditu/lucemans, r/oddlysatisfyingReddit
org.telegramlucemansTelegram
com.discordLucemans#2066, discord.gg/v3xDiscord
websitehttps://luc.computerWebsite
import { formatRecord } from 'ens-tools';

const cleanTwitter = formatRecord(
    'com.twitter',
    'https://mobile.twitter.com/lucemansnl'
);
// Outputs: @lucemansnl

⚖️ License

LGPL-3.0 License

0.0.15-2

8 months ago

0.0.15-1

9 months ago

0.0.14-1

12 months ago

0.0.14-3

12 months ago

0.0.14-2

12 months ago

0.0.14-5

12 months ago

0.0.14

12 months ago

0.0.14-4

12 months ago

0.0.14-7

12 months ago

0.0.14-6

12 months ago

0.0.14-9

12 months ago

0.0.14-8

12 months ago

0.0.6-2

1 year ago

0.0.6-1

1 year ago

0.0.13

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.3-alpha.6

1 year ago

0.0.3-alpha.3

1 year ago

0.0.3-alpha.2

1 year ago

0.0.3-alpha.5

1 year ago

0.0.3-alpha.4

1 year ago

0.0.3-alpha.1

1 year ago

0.0.2-alpha.1

1 year ago

0.0.1

1 year ago