2020-06-29 09:04:41 +02:00
|
|
|
# Hacking CosmJS
|
|
|
|
|
|
|
|
Welcome to CosmJS, glad to see you here. This document explains all you need to
|
|
|
|
work on CosmJS, i.e. modify it. It is not intended for users of CosmJS.
|
|
|
|
|
|
|
|
## Prerequisite
|
|
|
|
|
|
|
|
- A UNIX-like development environment
|
2021-06-09 16:13:15 +02:00
|
|
|
- Node.js 12+, Docker and yarn
|
2020-06-29 09:04:41 +02:00
|
|
|
- `sha256sum`, which you
|
|
|
|
[can get on macOS as well](https://unix.stackexchange.com/questions/426837/no-sha256sum-in-macos)
|
2021-06-09 17:17:12 +02:00
|
|
|
- `gsed`, which you
|
|
|
|
[can get on macOS as well](https://formulae.brew.sh/formula/gnu-sed)
|
2020-06-29 09:04:41 +02:00
|
|
|
|
|
|
|
## Checking out code
|
|
|
|
|
|
|
|
We use Git for version control. In addition to the well-known basics, we use the
|
|
|
|
extension Git Large File Storage (LFS) to store blobs (currently \*.png and
|
|
|
|
\*.wasm). A git-lfs package is available directly in modern package repositories
|
|
|
|
(Debian 10+, Ubuntu 18.04+, Homebrew, MacPorts) and as a backport for older
|
|
|
|
systems. Please see [this website](https://git-lfs.github.com/) for instructions
|
|
|
|
how to install it.
|
|
|
|
|
|
|
|
If you installed git-lfs after cloning this repo, use this command to replace
|
2020-06-30 11:37:09 +02:00
|
|
|
the links with the original files: `git lfs fetch && git lfs checkout`.
|
2020-06-29 09:04:41 +02:00
|
|
|
|
|
|
|
To verify everything worked as expected, check if the testing contracts are
|
|
|
|
correctly checked out:
|
|
|
|
|
|
|
|
```sh
|
2020-11-05 13:27:37 +01:00
|
|
|
cd scripts/launchpad/contracts
|
2020-06-29 09:04:41 +02:00
|
|
|
sha256sum -c checksums.sha256
|
|
|
|
```
|
|
|
|
|
2021-07-26 14:18:52 +02:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
1. Install dependencies: `yarn install`
|
|
|
|
2. Install SDKs (to make IDE integration work): `yarn dlx @yarnpkg/sdks`
|
|
|
|
|
2020-06-29 09:04:41 +02:00
|
|
|
## Running tests
|
|
|
|
|
|
|
|
For unit tests that don't connect to any blockchain, just do:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
yarn test
|
|
|
|
```
|
|
|
|
|
|
|
|
To run the entire test suite, you need to run some local blockchain to test
|
|
|
|
against. We use [wasmd](https://github.com/CosmWasm/wasmd) for both CosmWasm
|
2020-11-05 13:27:37 +01:00
|
|
|
tests and as a generic Cosmos SDK 0.39 (Launchpad) blockchain. We also spawn
|
|
|
|
multiple versions of raw Tendermint and a basic WebSocket server.
|
2020-06-29 09:04:41 +02:00
|
|
|
|
|
|
|
```sh
|
|
|
|
# Start wasmd
|
2020-11-05 13:27:37 +01:00
|
|
|
./scripts/launchpad/start.sh
|
|
|
|
./scripts/launchpad/init.sh
|
|
|
|
export LAUNCHPAD_ENABLED=1
|
2020-10-08 11:48:58 +02:00
|
|
|
export ERC20_ENABLED=1
|
2020-06-29 09:04:41 +02:00
|
|
|
|
|
|
|
# Start Tendermint
|
|
|
|
./scripts/tendermint/all_start.sh
|
|
|
|
export TENDERMINT_ENABLED=1
|
|
|
|
|
|
|
|
# Start WebSocket server
|
|
|
|
./scripts/socketserver/start.sh
|
|
|
|
export SOCKETSERVER_ENABLED=1
|
|
|
|
|
|
|
|
# now more tests are running that were marked as "pending" before
|
|
|
|
yarn test
|
|
|
|
|
|
|
|
# And at the end of the day
|
|
|
|
unset SOCKETSERVER_ENABLED
|
|
|
|
unset TENDERMINT_ENABLED
|
2020-10-08 11:48:58 +02:00
|
|
|
unset ERC20_ENABLED
|
2020-11-05 13:27:37 +01:00
|
|
|
unset LAUNCHPAD_ENABLED
|
2020-06-29 09:04:41 +02:00
|
|
|
./scripts/socketserver/stop.sh
|
|
|
|
./scripts/tendermint/all_stop.sh
|
2020-11-05 13:27:37 +01:00
|
|
|
./scripts/launchpad/stop.sh
|
2020-06-29 09:04:41 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Sanity
|
|
|
|
|
|
|
|
After you modified a file, check if the linter is happy:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
yarn lint
|
|
|
|
|
2020-06-30 11:37:09 +02:00
|
|
|
# or if you want linting plus automatic fixing
|
2020-06-29 09:04:41 +02:00
|
|
|
yarn lint-fix
|
|
|
|
```
|
2020-08-06 10:22:54 +02:00
|
|
|
|
|
|
|
## Ports
|
|
|
|
|
|
|
|
In the `scripts/` folder, a bunch of blockchains and other backend systems are
|
|
|
|
started for testing purposes. Some ports need to be changed from the default in
|
|
|
|
order to avoid conflicts. Here is an overview of the ports used:
|
|
|
|
|
2021-07-22 14:44:41 +02:00
|
|
|
| Port | Application | Usage |
|
|
|
|
| ----- | --------------------- | ------------------------------- |
|
|
|
|
| 1317 | wasmd LCD API | @cosmjs/launchpad tests |
|
|
|
|
| 1318 | simapp LCD API | Manual Stargate debugging |
|
|
|
|
| 1319 | wasmd LCD API | Manual Stargate debugging |
|
|
|
|
| 4444 | socketserver | @cosmjs/sockets tests |
|
|
|
|
| 4445 | socketserver slow | @cosmjs/sockets tests |
|
|
|
|
| 11133 | Tendermint 0.33 RPC | @cosmjs/tendermint-rpc tests |
|
|
|
|
| 11134 | Tendermint 0.34 RPC | @cosmjs/tendermint-rpc tests |
|
|
|
|
| 26658 | simapp Tendermint RPC | Stargate client tests |
|
|
|
|
| 26659 | wasmd Tendermint RPC | @cosmjs/cosmwasm-stargate tests |
|