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

@mantrachain/mantrajs

v1.0.0-beta.2

Published

JS and TS types relating to Protocol Buffers for MANTRA Chain

Downloads

507

Readme

MANTRA Chain Kit - MANTRAJS

npm downloads npm npm

Installation

npm install @mantrachain/mantrajs

Usage

Import the package

import { mantrachain } from "@mantrachain/mantrajs/index";

or

const mantrachain = require('@mantrachain/mantrajs');

Query Balances (LCD Client)

    const client = await mantrachain.ClientFactory.createAppApiClient({
      restEndpoint,
    });

    const response = await client.cosmos.bank.v1beta1.allBalances({
      address: "mantra15m77x4pe6w9vtpuqm22qxu0ds7vn4ehzwx8pls",
      resolveDenom: false,
    });

Response:

    {
      balances: [
        {
          denom: 'factory/mantra15m77x4pe6w9vtpuqm22qxu0ds7vn4ehzwx8pls/MATT2',
          amount: '250'
        },
        { denom: 'uom', amount: '78883121160383' }
      ],
      pagination: { next_key: null, total: '2' }
    }

Query Balance (RPC Client)

    const client = await mantrachain.ClientFactory.createAppRPCQueryClient({
      rpcEndpoint,
    });

    const response = await client.cosmos.bank.v1beta1.allBalances({
      address: "mantra15m77x4pe6w9vtpuqm22qxu0ds7vn4ehzwx8pls",
      resolveDenom: false,
    });

Response:

    {
      balances: [
        {
          denom: 'factory/mantra15m77x4pe6w9vtpuqm22qxu0ds7vn4ehzwx8pls/MATT2',
          amount: '250'
        },
        { denom: 'uom', amount: '78883121160383' }
      ],
      pagination: { nextKey: Uint8Array(0) [], total: 2n }
    }

Signing Transactions

Use the MessageComposer in the required namespace to create the message and the SigningMantrachainClient to sign and broadcast. For example to using the Cosmos SDK Bank Send:

const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonicSender, {
      prefix: "mantra",
    });
    const accounts = await wallet.getAccounts();
    const address = accounts[0].address;

    const signingClient = await getSigningMantrachainClient({
      rpcEndpoint,
      signer: wallet,
    });

    const { send } = cosmos.bank.v1beta1.MessageComposer.withTypeUrl;

    const sendMsg = send({
      fromAddress: address,
      toAddress: "mantra12z5kd26nlggsrmt3dx3v3eyxy7pmgdz5h7qf4t",
      amount: [{ denom: "uom", amount: "1000" }],
    });

    const fee = { amount: [{ denom: "uom", amount: "5000" }], gas: "200000" };

    const response = await signingClient.signAndBroadcast(
      address,
      [sendMsg],
      fee,
      "Test transfer"
    );

Contributors

First Build?

This repo uses submodules that need to be synced. The first time you clone this repo and build follow the following steps:

  1. Run git submodule update --init --recursive --remote
  2. Run cd packages/mantrajs && ./scripts/set-versions.sh
  3. Run npm install
  4. Run npm run rebuild

Tests

Test are run against the DuKong Test Network and only test a limited number of items. For more comprehensive tests use the E2E test repo.

To run the tests:

npm test

Submodules

The proto files are referenced from the submodules. You can modify and use ./scripts/set-versions.sh to set the versions/commits you wish to use for each submodule.

If it's the first time you check-out a repo you need to use --init first:

git submodule update --recursive --remote

otherwise use:

git submodule update --recursive

or

git pull --recurse-submodules

Adding a new Cosmos SDK Module

  1. To add a new submodule use:
git submodule add -f [email protected]:skip-mev/feemarket.git packages/mantrajs/protos/feemarket-src

then checkout the version/commit you want use the script or manually run it

git -C protos/feemarket-src checkout v1.1.1

NOTE: you should update ./scripts/set-versions.sh and run it

  1. then in package.json add the new protogen:newxxx task and update the clean task

  2. next update ./scripts/codegen.js

git submodule add -f [email protected]:MANTRA-Chain/mantrachain.git packages/mantrajs/protos/mantrachain-src git submodule add -f [email protected]:MANTRA-Chain/cosmos-sdk.git packages/mantrajs/protos/cosmos-sdk-src git submodule add -f [email protected]:skip-mev/connect.git packages/mantrajs/protos/connect-src git submodule add -f [email protected]:cosmos/ibc-go.git packages/mantrajs/protos/ibc-go-src