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

@mvts/resolver-js

v0.4.1

Published

Using npm:

Downloads

7

Readme

@mvts/resolver-js

Installation

Using npm:

npm install @mvts/resolver-js

Using yarn:

yarn add @mvts/resolver-js

Once the package is installed, you can import the library using import or require approach:

// CommonJS
const {Resolver} = require('@mvts/resolver-js');

// ES6
import {Resolver} from '@mvts/resolver-js';

Usage

import {Resolver} from '@mvts/resolver-js';
import {JsonRpcProvider} from '@ethersproject/providers';


const resolver = new Resolver({
    rpcUrlsAndProviders: {
        1: 'https://example.com/rpc/ethereum-mainnet', // Ethereum Mainnet
        137: new JsonRpcProvider('https://example.com/rpc/polygon-mainnet') // Polygon Mainnet
    },
    useDefaultRpcUrls: false
});

resolver.getSipUri('30010645')
    .then((sipUri) => console.log('SIP URI:', sipUri))
    .catch((error) => console.log(`Failed to get SIP URI: ${error.message}`));

Options

| Name | Type | Default | Description | |--------------------------------|---------------------------------------------|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------| | curator (optional) | Curator | getActualCurator() | Custom curator. You can specify your curator, for example, for faster routing through your pool of numbers. | | rpcUrlsAndProviders (optional) | {[chainId: number]: string | Provider} | DEFAULT_RPC_URLS if useDefaultRpcUrls | DEFAULT_RPC_URLS are public so can be unreliable and slow, so you can specify your own RPC URLs and providers. | | useDefaultRpcUrls (optional) | boolean | true | This option allows you to disable the use of RPC URLs by default. By default are used. | | useCache (optional) | boolean | true | The resolver caches the data and uses it according to TTL. This option allows you to disable cache usage. The cache is used by default. |

Methods

| Name | Description | |-------------------------------------------------|----------------------------------------------------------------------------------------------| | getUseCache(): boolean | Returns the current value of the useCache flag, which enables/disables the use of the cache. | | setUseCache(useCache: boolean): void | Changes the value of the useCache flag, which enables/disables the use of the cache. | | clearCache(): void | Clears the cache. | | getSipUri(phoneNumber: string): Promise | Returns SIP URI for making a call. |

Constants

| Name | Type | Description | |-------------------------|--------|-------------------------------------------------------------------------------------------------------------------------------| | ACTUAL_CURATOR_CHAIN_ID | number | The chain ID of the current smart contract Curator. | | ACTUAL_CURATOR_ADDRESS | string | The address of the current smart contract Curator. | | DEFAULT_RPC_URLS | object | Default RPC URLs. It is guaranteed that this is enough to work with chains in which the curator and root router are deployed. |

Utils

| Name | Description | |-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | getActualCurator(signerOrProvider?: Signer | Provider): Curator | Returns the actual curator. | | getActualRootRouter(getSignerOrProvider?: (chainId: number) => Signer | Provider): Promise<RootRouter> | Returns the actual root router. The root router can change and be in any chain, so getSignerOrProvider is a function that returns the appropriate provider or signer depending on the current chainId of the root router. See example below. | | nodeIsNumber(nodeData: Router.NodeDataStructOutput): boolean | Returns true if the node is a number. | | nodeIsPool(nodeData: Router.NodeDataStructOutput): boolean | Returns true if the node is a pool. |

getActualRootRouter usage example

import {getActualRootRouter, DEFAULT_RPC_URLS} from '@mvts/resolver-js';
import {JsonRpcProvider} from '@ethersproject/providers';


function getSignerOrProvider(chainId) {
    const rpcUrl =  DEFAULT_RPC_URLS[chainId];
    if (!rpcUrl) {
        throw new Error(`Missing provider for chain ${chainId}.`);
    }

    return new JsonRpcProvider(rpcUrl);
}


getActualRootRouter(getSignerOrProvider)
    .then((rootRouter) => console.log(`Address of the actual root router: ${rootRouter.address}`))
    .catch((error) => console.log(`Failed to get the actual root router: ${error.message}`));

License

MIT