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 🙏

© 2025 – Pkg Stats / Ryan Hefner

oraichain-common-test

v1.1.9

Published

[![NPM Package][common-npm-badge]][common-npm-link] [![GitHub Issues][common-issues-badge]][common-issues-link] [![Discord][discord-badge]][discord-link]

Downloads

30

Readme

Oraichain Common

NPM Package GitHub Issues Discord

| Resources common to all Oraichain ecosystem. | | -------------------------------------------- |

Installation

To obtain the latest version, simply require the project using npm:

npm install @oraichain/common

yarn:

yarn add @oraichain/common

Quickstart

import / require

import (ESM, TypeScript):

import { OraiCommon } from "@oraichain/common";

Initialization

The OraiCommon class can be initialized via several ways:

1. via Github API

import { OraiCommon } from "@oraichain/common";

(async () => {
  const githubAccessToken = ""; // optional for rate limit increase
  const common = await OraiCommon.initializeFromGit(githubAccessToken);
})();

initializeFromGit() will fetch all the chain infos registered on our chain-registry using Github API and initializes the necessary dependency classes before returning our main OraiCommon class.

Note that if you don't have an access token, the rate limit for using this method will be according to the Github docs.

2. via Github rawusercontent

import { OraiCommon } from "@oraichain/common";

(async () => {
  const common = await OraiCommon.initializeFromGitRaw({
    chainIds: ["Oraichain", "osmosis-1", "0x01"]
  });
  expect(common.chainInfos).not.undefined;
  expect(common.chainInfos?.chainInfos.length).toEqual(3);
  expect(common.chainInfos?.cosmosChains.length).toEqual(2);
  expect(common.tokenItems?.evmTokens.length).toBeGreaterThan(0);
})();

initializeFromGitRaw() takes a list of chainIds as arguments fetch their chain infos registered on our chain-registry using Github rawusercontent and initializes the necessary dependency classes before returning our main OraiCommon class.

3. via Oraichain Labs's backend API

import { OraiCommon } from "@oraichain/common";

(async () => {
  const common = await OraiCommon.initializeFromBackend();
})();

initializeFromBackend() will fetch all the chain infos registered on our chain-registry using a backend service and initializes the necessary dependency classes before returning our main OraiCommon class.

This method is preferred, as there's no rate limit.

4. via a custom chain info reader (private / custom chains)

You can create a custom ChainInfoReader that retrieves your custom chain infos and use that to initialize the OraiCommon class:

import {
  ChainInfoReader,
  CustomChainInfo,
  OraiCommon
} from "@oraichain/common";

export class OurCustomChainInfoReader implements ChainInfoReader {
  async readChainInfos() {
    return [
      {
        chainId: "oraibtc-mainnet-1",
        chainName: "OraiBtc Bridge",
        rpc: "https://btc.rpc.orai.io",
        rest: "https://btc.lcd.orai.io",
        networkType: "cosmos",
        stakeCurrency: {
          coinDenom: "ORAIBTC",
          coinMinimalDenom: "uoraibtc",
          coinDecimals: 6,
          gasPriceStep: {
            low: 0,
            average: 0,
            high: 0
          },
          coinImageUrl:
            "https://assets.coingecko.com/coins/images/1/small/bitcoin.png"
        },
        bip44: {
          coinType: 118
        },
        coinType: 118,
        bech32Config: {
          bech32PrefixAccAddr: "oraibtc",
          bech32PrefixAccPub: "oraibtcpub",
          bech32PrefixValAddr: "oraibtcvaloper",
          bech32PrefixValPub: "oraibtcvaloperpub",
          bech32PrefixConsAddr: "oraibtcvalcons",
          bech32PrefixConsPub: "oraibtcvalconspub"
        },
        currencies: [
          {
            coinDenom: "ORAIBTC",
            coinMinimalDenom: "uoraibtc",
            coinDecimals: 6,
            gasPriceStep: {
              low: 0,
              average: 0,
              high: 0
            },
            coinImageUrl:
              "https://assets.coingecko.com/coins/images/1/small/bitcoin.png"
          },
          {
            coinDenom: "oBTC",
            coinMinimalDenom: "usat",
            coinDecimals: 14,
            gasPriceStep: {
              low: 0,
              average: 0,
              high: 0
            },
            coinImageUrl:
              "https://assets.coingecko.com/coins/images/1/small/bitcoin.png"
          }
        ],
        feeCurrencies: [
          {
            coinDenom: "ORAIBTC",
            coinMinimalDenom: "uoraibtc",
            coinDecimals: 6,
            gasPriceStep: {
              low: 0,
              average: 0,
              high: 0
            },
            coinImageUrl:
              "https://assets.coingecko.com/coins/images/1/small/bitcoin.png"
          },
          {
            coinDenom: "oBTC",
            coinMinimalDenom: "usat",
            coinDecimals: 14,
            gasPriceStep: {
              low: 0,
              average: 0,
              high: 0
            },
            coinImageUrl:
              "https://assets.coingecko.com/coins/images/1/small/bitcoin.png"
          }
        ],
        features: ["stargate", "ibc-transfer", "cosmwasm"]
      }
    ] as CustomChainInfo[];
  }
}

(async () => {
  const chainInfoReader = new OurCustomChainInfoReader();
  const common = await OraiCommon.initializeFromChainInfoReader(
    chainInfoReader
  );
  console.dir(common.chainInfos, { depth: null });
})();

Usage

Here are some simple usage examples:

import { ChainInfoReader, OraiCommon } from "@oraichain/common";

(async () => {
  const common = await OraiCommon.initializeFromGit();
  // get total length of list cosmos chains, which is 9 by the time of writing this docs
  console.log(common.chainInfos.cosmosChains.length);
  // get total length of list evm chains, which is 4 by the time of writing this docs
  console.log(common.chainInfos.evmChains.length);
  // find the first cosmos token having chain id === "Oraichain" and show its coingeckoId, which is oraichain-token
  console.log(
    common.tokenItems.cosmosTokens.find(
      (token) => token.chainId === "Oraichain"
    )?.coinGeckoId
  );
  // get the first key of cw20 token map, which is 0xd567B3d7B8FE3C79a1AD8dA978812cfC4Fa05e75
  console.log(Object.keys(common.tokenItems.cw20TokenMap)[0]);
})();

Browser

The package works on browser by default using the provided ESM build.

// declare a new global field
interface Window {
  ...;
  common: OraiCommon;
}

// initialization when init app
window.common = await OraiCommon.initializeFromGit();

// access to inner attributes like cosmos chains, token items on browser
const cosmosInfos = window.common.chainInfos.chainInfos.filter(
    (chainInfo) =>
      (chainInfo.networkType === 'cosmos' || chainInfo.bip44.coinType === 118) &&
      // TODO: ignore oraibtc
      chainInfo.chainId !== ('oraibtc-mainnet-1' as string)
  );

License

GPL 3.0