2020-08-11 17:02:32 +02:00
|
|
|
|
<h1><p align="center"><img alt="CosmJS" src="docs/logo-vertical-light.png" width="180" /></p></h1>
|
2020-01-22 09:41:48 +01:00
|
|
|
|
|
2021-08-05 10:26:58 +02:00
|
|
|
|
<div align="center">
|
|
|
|
|
<a href="https://lgtm.com/projects/g/cosmos/cosmjs/context:javascript"><img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/cosmos/cosmjs.svg?logo=lgtm&logoWidth=18"/></a>
|
|
|
|
|
<a href="https://github.com/cosmos/cosmjs/blob/main/LICENSE">
|
|
|
|
|
<img alt="License: Apache-2.0" src="https://img.shields.io/github/license/cosmos/cosmjs.svg" />
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-06-18 11:58:00 +02:00
|
|
|
|
CosmJS is the Swiss Army knife to power JavaScript based client solutions
|
2020-06-18 09:48:56 +02:00
|
|
|
|
ranging from Web apps/explorers over browser extensions to server-side clients
|
|
|
|
|
like faucets/scrapers in the Cosmos ecosystem.
|
|
|
|
|
|
2020-06-18 11:58:00 +02:00
|
|
|
|
"Cosm" is short for Cosmos and "JS" is short for _runs everywhere_ – we actually
|
2020-06-18 09:48:56 +02:00
|
|
|
|
develop in TypeScript.
|
|
|
|
|
|
2021-02-10 22:54:45 +01:00
|
|
|
|
## Documentation
|
2021-02-11 08:55:27 +01:00
|
|
|
|
|
2021-02-11 09:08:43 +01:00
|
|
|
|
[Here is a list of examples][guided tour] using the Stargate package for use
|
|
|
|
|
with [Cosmos SDK 0.41] applications (like [gaia 4]). Take a look at the wiki
|
|
|
|
|
page,
|
2021-02-11 08:55:27 +01:00
|
|
|
|
["What can CosmJS do for me?"](https://github.com/cosmos/cosmjs/wiki/What-can-CosmJS-do-for-me%3F)
|
|
|
|
|
and various tests
|
|
|
|
|
([ex](https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/signingstargateclient.spec.ts))
|
|
|
|
|
for more example usage of the packages.
|
2021-02-10 22:54:45 +01:00
|
|
|
|
|
2021-02-11 09:08:43 +01:00
|
|
|
|
[guided tour]:
|
|
|
|
|
https://gist.github.com/webmaster128/8444d42a7eceeda2544c8a59fbd7e1d9
|
|
|
|
|
[cosmos sdk 0.41]: https://github.com/cosmos/cosmos-sdk/tree/v0.41.0
|
|
|
|
|
[gaia 4]: https://github.com/cosmos/gaia/tree/v4.0.0
|
|
|
|
|
|
|
|
|
|
### API documentation
|
|
|
|
|
|
|
|
|
|
The full API documentation is hosted at [cosmos.github.io/cosmjs]. This is a bit
|
|
|
|
|
tricky to navigate and requires basic TypeScript understanding. It is helpful if
|
|
|
|
|
you have want to look up details for advanced use cases. This documentation is
|
|
|
|
|
auto-generated based on the current main branch and can occasionally diverge
|
|
|
|
|
from the latest release.
|
|
|
|
|
|
|
|
|
|
[cosmos.github.io/cosmjs]: https://cosmos.github.io/cosmjs
|
|
|
|
|
|
2021-03-18 12:25:06 +01:00
|
|
|
|
### Using custom Stargate modules
|
|
|
|
|
|
|
|
|
|
Documentation on how to use your own custom modules with CosmJS for Stargate
|
|
|
|
|
chains (Cosmos SDK v0.41) can be found
|
|
|
|
|
[here](https://github.com/cosmos/cosmjs/blob/main/packages/stargate/CUSTOM_PROTOBUF_CODECS.md).
|
|
|
|
|
|
2020-06-18 09:48:56 +02:00
|
|
|
|
## Packages
|
|
|
|
|
|
|
|
|
|
CosmJS is a library that consists of many smaller npm packages within the
|
|
|
|
|
[@cosmjs namespace](https://www.npmjs.com/org/cosmjs), a so called monorepo.
|
|
|
|
|
Here are some of them to get an idea:
|
|
|
|
|
|
2021-07-22 14:44:41 +02:00
|
|
|
|
| Package | Description | Latest |
|
|
|
|
|
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
2022-03-02 21:55:49 +01:00
|
|
|
|
| [@cosmjs/stargate](packages/stargate) | A client library for the Cosmos SDK 0.40+ (Stargate) | [](https://www.npmjs.com/package/@cosmjs/stargate) |
|
2021-07-22 14:44:41 +02:00
|
|
|
|
| [@cosmjs/faucet](packages/faucet) | A faucet application for node.js | [](https://www.npmjs.com/package/@cosmjs/faucet) |
|
|
|
|
|
| [@cosmjs/cosmwasm-stargate](packages/cosmwasm-stargate) | Client for Stargate chains with the CosmWasm module enabled | [](https://www.npmjs.com/package/@cosmjs/cosmwasm-stargate) |
|
2022-03-02 21:55:49 +01:00
|
|
|
|
| [@cosmjs/crypto](packages/crypto) | Cryptography for blockchain projects, e.g. hashing (SHA-2, Keccak256, Ripemd160), signing (secp256k1, ed25519), HD key derivation (BIP-39, SLIP-0010), KDFs and symmetric encryption for key storage (PBKDF2, Argon2, XChaCha20Poly1305) | [](https://www.npmjs.com/package/@cosmjs/crypto) |
|
2021-07-22 14:44:41 +02:00
|
|
|
|
| [@cosmjs/encoding](packages/encoding) | Encoding helpers for blockchain projects | [](https://www.npmjs.com/package/@cosmjs/encoding) |
|
|
|
|
|
| [@cosmjs/math](packages/math) | Safe integers; decimals for handling financial amounts | [](https://www.npmjs.com/package/@cosmjs/math) |
|
2020-06-18 09:48:56 +02:00
|
|
|
|
|
|
|
|
|
### Modularity
|
|
|
|
|
|
|
|
|
|
We're pretty proud of the modularity and a clean dependency tree in this
|
|
|
|
|
monorepo. This ensures software quality on our side and lets users pick exactly
|
2020-06-18 10:09:01 +02:00
|
|
|
|
what they need. Here you see how everything fits together (every item is a npm
|
2020-06-18 09:48:56 +02:00
|
|
|
|
package; right depends on left):
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
2020-06-29 08:37:32 +02:00
|
|
|
|
If this was not enough to scare you away, check out the version including app
|
|
|
|
|
runtime dependencies: [cosmjs-tree-full.png](docs/cosmjs-tree-full.png).
|
2020-06-28 20:26:46 +02:00
|
|
|
|
|
2020-06-18 09:48:56 +02:00
|
|
|
|
<!--
|
|
|
|
|
Build with depsight (https://github.com/webmaster128/depsight), using:
|
|
|
|
|
|
2020-08-10 06:46:38 +02:00
|
|
|
|
from_npm . | depsight --include "^@cosmjs" --format png --dpi 150 --output docs/cosmjs-tree.png
|
|
|
|
|
from_npm . | depsight --exclude cosmjs-monorepo-root --format png --dpi 150 --output docs/cosmjs-tree-full.png
|
2020-06-28 20:26:46 +02:00
|
|
|
|
optipng docs/cosmjs-tree*.png
|
2020-06-18 09:48:56 +02:00
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
### Supported JS environments
|
|
|
|
|
|
2020-06-18 10:09:01 +02:00
|
|
|
|
Currently the codebase supports the following runtime environments:
|
2020-06-18 09:48:56 +02:00
|
|
|
|
|
2021-06-09 16:13:15 +02:00
|
|
|
|
1. Node.js 12+
|
2020-06-18 10:09:01 +02:00
|
|
|
|
2. Modern browsers (Chromium/Firefox/Safari, no Internet Explorer or
|
|
|
|
|
[Edge Spartan](https://en.wikipedia.org/wiki/Microsoft_Edge#Development))
|
2020-06-18 09:48:56 +02:00
|
|
|
|
3. Browser extensions (Chromium/Firefox)
|
|
|
|
|
|
2022-01-27 09:52:49 +01:00
|
|
|
|
Our current JavaScript target standard is ES2018. We use WebAssembly to
|
|
|
|
|
implement certain cryptographic functions.
|
2020-06-18 09:48:56 +02:00
|
|
|
|
|
|
|
|
|
We're happy to adjust this list according to users' needs as long as you don't
|
2020-06-18 10:09:01 +02:00
|
|
|
|
ask for Internet Explorer support. If your environment does not support Wasm, we
|
2022-01-27 09:52:49 +01:00
|
|
|
|
can work on a solution with swappable implementations.
|
2020-01-22 09:41:48 +01:00
|
|
|
|
|
2020-06-19 18:04:21 +02:00
|
|
|
|
## Roadmap
|
|
|
|
|
|
2021-02-11 09:14:33 +01:00
|
|
|
|
We maintain a [development board](https://github.com/orgs/cosmos/projects/6),
|
|
|
|
|
use [release milestones](https://github.com/cosmos/cosmjs/milestones) and share
|
|
|
|
|
important updates in the [CosmWasm Community Call]. For higher level roadmap
|
|
|
|
|
discussion please reach out to the team.
|
|
|
|
|
|
|
|
|
|
[cosmwasm community call]:
|
|
|
|
|
https://github.com/CosmWasm/cosmwasm/issues?q=label%3A%22Community+Call+%F0%9F%97%BA%F0%9F%93%9E%22
|
2020-06-19 18:04:21 +02:00
|
|
|
|
|
2021-03-15 16:36:36 +01:00
|
|
|
|
## Known limitations
|
|
|
|
|
|
2021-10-24 22:35:45 +02:00
|
|
|
|
### 0.26
|
|
|
|
|
|
|
|
|
|
1. When connecting to a Cosmos SDK 0.44+ backend, the verified queries from
|
|
|
|
|
`AuthExtension` and `BankExtension` as well as
|
|
|
|
|
`StargateClient.getAccountVerified` will fail because the storage keys are
|
|
|
|
|
not stable. Unverified queries can be used instead. Those queries are
|
|
|
|
|
deprecated now and will be removed in 0.27 ([#910]).
|
|
|
|
|
|
|
|
|
|
[#910]: https://github.com/cosmos/cosmjs/pull/910
|
|
|
|
|
|
2021-06-23 13:35:43 +02:00
|
|
|
|
### 0.25
|
|
|
|
|
|
|
|
|
|
1. Decoding blocks of height 1 is unsupported. This is fixed in [#815] and will
|
|
|
|
|
be released as part of CosmJS 0.26.
|
|
|
|
|
|
|
|
|
|
[#815]: https://github.com/cosmos/cosmjs/pull/815
|
|
|
|
|
|
2021-03-15 16:36:36 +01:00
|
|
|
|
### 0.24
|
|
|
|
|
|
|
|
|
|
1. `AuthExtension` and all higher level Stargate clients only support
|
|
|
|
|
`BaseAccount`s for all functionality, including getting account numbers and
|
2021-03-16 14:10:24 +01:00
|
|
|
|
sequences for transaction signing. This will be implemented for all common
|
|
|
|
|
Cosmos SDK account types in the 0.25 series.
|
2021-03-15 16:36:36 +01:00
|
|
|
|
|
2021-02-11 09:14:44 +01:00
|
|
|
|
## Get in touch
|
|
|
|
|
|
|
|
|
|
The CosmJS development team is happy to get in touch with you for all questions
|
|
|
|
|
and suggestions.
|
|
|
|
|
|
|
|
|
|
- [GitHub issues](https://github.com/cosmos/cosmjs/issues) for bugs and feature
|
|
|
|
|
requests
|
|
|
|
|
- The #cosmjs channel on the
|
|
|
|
|
["Cosmos Community" Discord server](https://discord.gg/vcExX9T) for questions
|
|
|
|
|
and open discussions
|
|
|
|
|
- [#CosmJS on Twitter](https://twitter.com/search?q=%23CosmJS) to spread the
|
|
|
|
|
word
|
|
|
|
|
|
2020-01-22 22:24:09 +01:00
|
|
|
|
## Development
|
|
|
|
|
|
2020-06-29 09:04:41 +02:00
|
|
|
|
See [HACKING.md](HACKING.md).
|