This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
feat(rest): Implement evmos and cometbft all rest interfaces for us to query information about the chain #180
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
evmos and cometbft provide many interfaces for us to query information about the chain. However, unfortunately, evmosjs does not implement these interfaces in the provider package. In actual business scenarios, when these interfaces are needed, they are individually encapsulated. To solve the above problem, the
packages/provider/src/rest/cometbft.ts
file in evmosjs implements the related request interfaces of cometbft, and thepackages/provider/src/rest/app.ts
file implements the related request interfaces of evmos.To be able to use both in Node.js and browsers, axios is used as the underlying network library.
Usage and Examples
Below is a simple code example that demonstrates how to use the provider package in evmosjs to query information about the evmos chain.
If the returned data is correct, you can directly retrieve the values from the returned
Object
. For example, if the data returned bybank.allBalances
is as follows:If the returned data is an error, the evmos declares the error data as follows:
Cometbft declares the error data as follows: