Giter VIP home page Giter VIP logo

tm2-js-client's Introduction

⚛️ Tendermint2 JS/TS Client ⚛️

Overview

@gnolang/tm2-js-client is a JavaScript/TypeScript client implementation for Tendermint2-based chains. It is designed to make it easy for developers to interact with TM2 chains, providing a simplified API for account and transaction management. By doing all the heavy lifting behind the scenes, @gnolang/tm2-js-client enables developers to focus on what really matters - building their dApps.

Key Features

  • JSON-RPC and WebSocket client support via a Provider
  • Simple account and transaction management API with a Wallet
  • Designed for easy extension for custom TM2 chains, such as Gnoland

Installation

To install @gnolang/tm2-js-client, use your preferred package manager:

yarn add @gnolang/tm2-js-client
npm install @gnolang/tm2-js-client

Common Terminology

Provider

A Provider is an interface that abstracts the interaction with the Tendermint2 chain, making it easier for users to communicate with it. Rather than requiring users to understand which endpoints are exposed, what their return types are, and how they are parsed, the Provider abstraction handles all of this behind the scenes. It exposes useful API methods that users can use and expects concrete types in return.

Currently, the @gnolang/tm2-js-client package provides support for two Provider implementations:

  • JSON-RPC Provider: executes each call as a separate HTTP RPC call.
  • WS Provider: executes each call through an active WebSocket connection, which requires closing when not needed anymore.

Signer

A Signer is an interface that abstracts the interaction with a single Secp256k1 key pair. It exposes methods for signing data, verifying signatures, and getting metadata associated with the key pair, such as the address.

Currently, the @gnolang/tm2-js-client package provides support for two Signer implementations:

  • Key: a signer that is based on a raw Secp256k1 key pair.
  • Ledger: a signer that is based on a Ledger device, with all interaction flowing through the user's device.

Wallet

A Wallet is a user-facing API that is used to interact with an account. A Wallet instance is tied to a single key pair and essentially wraps the given Provider for that specific account.

A wallet can be generated from a randomly generated seed, a private key, or instantiated using a Ledger device.

Using the Wallet, users can easily interact with the Tendermint2 chain using their account without having to worry about account management.

Documentation

For the sake of keeping the README short and sweet, you can find the documentation and usage examples for the package here.

Acknowledgements

@gnolang/tm2-js-client is, and will continue to be, licensed under Apache 2.

It is made by the community, for the community, and any contribution is greatly appreciated.

A special thank-you goes out to the Onbloc team, building Adena wallet and other gno projects, whose extended supported made this package possible.

tm2-js-client's People

Contributors

2woongjae avatar clockworkgr avatar dependabot[bot] avatar jinoosss avatar thehowl avatar zivkovicmilos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jinoosss iam-agf

tm2-js-client's Issues

evaluateExpression does not return the error log

image

$ gnokey query vm/qeval --data 'gno.land/r/demo/chess'$'\n''Leaderboard("asd")'
Log: --= Error =--
Data: &errors.errorString{s:"invalid category"}
Msg Traces:
    0  /home/howl/go/pkg/mod/github.com/gnolang/[email protected]/gno.land/pkg/sdk/vm/keeper.go:387 - VM query eval panic: invalid category

It would be useful if the client parsed the error and returned it in the thrown exception, so the underlying error could be captured & parsed by any caller.

Error handling in the sendTransaction function

Currently, providers only validate for success/failure of calls in general.
However, when we call broadcast_tx of the sendTransaction function,
we can get an error about the transaction as a response.
This error cannot be checked in the block, so I think error handling is necessary.

@zivkovicmilos I have a few questions.

  1. Is it intended that when a transaction error occurs, a hash is the response?
  2. Do you think tm2-js-client should handle gno's errors?
    (If we use the gno response as is, the error types need to be checked in the gno repository and handled)
    ** gno errors: https://github.com/gnolang/gno/blob/0b38c8d793f83d50929ca27351f2b3cb89e9b974/tm2/pkg/std/errors.go

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.