2021-11-16 03:23:52 -08:00
# Develop
## prerequsites
- Go >= 1.16
- nodejs >= 16
## Building the blockchain
Run
```shell
make
```
This command creates a `build` directory and in particular, the
2022-10-21 13:28:04 -07:00
`build/wormchaind` binary, which can be used to run and interact with the
2021-11-16 03:23:52 -08:00
blockchain.
You can start a local development instance by running
```shell
make run
```
Or equivalently
```shell
2022-10-21 13:28:04 -07:00
./build/wormchaind --home build
2021-11-16 03:23:52 -08:00
```
If you want to reset the blockchain, just run
```shell
make clean
```
Then you can `make run` again.
## Running tests
Golang tests
make test
2023-01-18 07:56:32 -08:00
Client tests, run against the chain. Wormchain must be running via `make run` or `tilt up -- --wormchain`
2021-11-16 03:23:52 -08:00
cd ./ts-sdk
npm ci
npm run build
cd ../testing/js
npm ci
npm run test
## Interacting with the blockchain
You can interact with the blockchain by using the go binary:
```shell
2022-10-21 13:28:04 -07:00
./build/wormchaind tx --from tiltGuardian --home build
2021-11-16 03:23:52 -08:00
```
Note the flags `--from tiltGuardian --home build` . These have to be passed
in each time you make a transaction (the `tiltGuardian` account is created in
`config.yml` ). Queries don't need the `--from` flag.
2023-01-18 07:56:32 -08:00
## Scaffolding stuff with Ignite
2021-11-16 03:23:52 -08:00
2023-01-18 07:56:32 -08:00
Wormchain was initially scaffolded using the [Ignite CLI ](https://github.com/ignite ) (formerly Starport). Now, we only use Ignite for generating code from protobuf definitions.
To avoid system compatibility issues, we run Ignite using docker. The below commands should be run using the ignite docker container (see the Makefile recipes for examples).
2021-11-16 03:23:52 -08:00
```shell
2023-01-18 07:56:32 -08:00
ignite scaffold type guardian-key key:string --module wormhole --no-message
2021-11-16 03:23:52 -08:00
```
modify `proto/wormhole/guardian_key.proto` (string -> bytes)
```shell
2023-01-18 07:56:32 -08:00
ignite scaffold message register-account-as-guardian guardian-pubkey:GuardianKey address-bech32:string signature:string --desc "Register a guardian public key with a wormhole chain address." --module wormhole --signer signer
2021-11-16 03:23:52 -08:00
```
Scaffold a query:
```shell
2023-01-18 07:56:32 -08:00
ignite scaffold query latest_guardian_set_index --response LatestGuardianSetIndex --module wormhole
2021-11-16 03:23:52 -08:00
```
2022-10-21 13:28:04 -07:00
(then modify "wormchain/x/wormhole/types/query.pb.go" to change the response type)