-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added a docusaurus tutorial (#69)
* docs: ran 'npx create-docusaurus@latest docs classic' * deps: ran 'npm install -D tailwindcss' * imp: ran 'npx tailwindcss init --ts' * imp: added tailwindcss script * lint: ran 'npm init @eslint/config@latest' * docs: removed docusaurus * docs: cloned docs form cw-ica-controller * imp: removed versioned docs * docs: adapted the landing page for go-codegen * deps: ran 'npm i @docusaurus/core@latest @docusaurus/plugin-client-redirects@latest @docusaurus/preset-classic@latest @docusaurus/module-type-aliases@latest @docusaurus/tsconfig@latest @docusaurus/types@latest' * imp: tutorial page loads now * imp: highlight box fixed * imp: more tags and info * docs: removed unneeded files * imp: added setup env page * docs: imp * imp: things are ready to go * docs: added more content * imp: improved * docs: reorganized section 2 * docs: added scaffold suite * imp: additional codeblock options * docs: added todo * docs: added 'add-contracts' section * imp: added ci info * docs: closer to the final version * docs: added ending remark * ci: added docs ci * fix: remove broken redirects
- Loading branch information
Showing
49 changed files
with
20,329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This check-docs workflow was created based on instructions from: | ||
# https://docusaurus.io/docs/deployment | ||
name: Check docs build | ||
# This workflow runs when a PR is labeled with `docs` | ||
# This will check if the docs build successfully by running `npm run build` | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'docs/**' | ||
- '.github/workflows/check-docs.yml' | ||
|
||
jobs: | ||
check-docs-build: | ||
name: Check docs build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: npm | ||
cache-dependency-path: docs/package-lock.json | ||
|
||
- name: Install dependencies | ||
run: cd docs && npm ci | ||
- name: Test build website | ||
run: cd docs && npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# This deploy-docs workflow was created based on instructions from: | ||
# https://docusaurus.io/docs/deployment | ||
name: Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
# Review gh actions docs if you want to further define triggers, paths, etc | ||
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy to GitHub Pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: npm | ||
cache-dependency-path: docs/package-lock.json | ||
|
||
- name: Install dependencies | ||
run: cd docs && npm ci | ||
- name: Build website | ||
run: cd docs && npm run build | ||
|
||
# Popular action to deploy to GitHub Pages: | ||
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# Build output to publish to the `gh-pages` branch: | ||
publish_dir: ./docs/build | ||
# The following lines assign commit authorship to the official | ||
# GH-Actions bot for deploys to `gh-pages` branch: | ||
# https://github.com/actions/checkout/issues/13#issuecomment-724415212 | ||
# The GH actions bot is used by default if you didn't specify the two fields. | ||
# You can swap them out with your own user credentials. | ||
user_name: github-actions[bot] | ||
user_email: 41898282+github-actions[bot]@users.noreply.github.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:react/recommended" | ||
], | ||
"overrides": [ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"files": [ | ||
".eslintrc.{js,cjs}" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
} | ||
} | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"react" | ||
], | ||
"rules": { | ||
"react/prop-types": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Website | ||
|
||
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
``` | ||
$ npm i | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ npm start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ npm run build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/css/globals.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
title: Introduction | ||
sidebar_label: Introduction | ||
sidebar_position: 0 | ||
slug: / | ||
--- | ||
|
||
import HighlightTag from '@site/src/components/HighlightTag'; | ||
import HighlightBox from '@site/src/components/HighlightBox'; | ||
|
||
# `go-codegen` Interchaintest Tutorial | ||
|
||
<HighlightTag type="tutorial"/><HighlightTag type="guided-coding"/><HighlightTag type="cosmwasm"/><HighlightTag type="developer"/><HighlightTag type="ibc-go"/><HighlightTag type="advanced"/> | ||
|
||
This is a tutorial for writing end-to-end test suite for IBC enabled CosmWasm applications using go-codegen. | ||
Powered by [interchaintest](https://github.com/strangelove-ventures/interchaintest). | ||
|
||
<HighlightBox type="prerequisite" title="Prerequisites"> | ||
|
||
- Basic knowledge of [golang](https://go.dev/) | ||
- Basic knowledge of [CosmWasm](https://cosmwasm.com/) | ||
- Basic knowledge of [github actions](https://github.com/features/actions) | ||
|
||
</HighlightBox> | ||
|
||
## Context | ||
|
||
### What is go-codegen? | ||
|
||
go-codegen is a tool that generates go code for CosmWasm applications. It can currently generate the following: | ||
|
||
- Message definitions for a contract. | ||
- gRPC query client for a contract. | ||
- An end-to-end test suite for a contract based on interchaintest. | ||
|
||
<HighlightBox type="info" title="What is interchaintest?"> | ||
|
||
`interchaintest` is a framework for testing blockchain functionality and interoperability between chains, primarily with the Inter-Blockchain Communication (IBC) protocol. | ||
|
||
It can quickly spin up custom testnets and dev environments to test IBC, Relayer setup, chain infrastructure, smart contracts, etc. Interchaintest orchestrates Go tests that utilize Docker containers for multiple IBC-compatible blockchains. | ||
|
||
In order to ship production-grade software for the Interchain, we needed sophisticated developer tooling...but IBC and Web3 have a lot of moving parts, which can lead to a steep learning curve and all sorts of pain. | ||
|
||
- repeatedly building repo-specific, Docker- and shell-based testing solutions, | ||
- duplication of effort, and | ||
- difficulty in repurposing existing testing harnesses for new problem domains. | ||
|
||
Read more about interchaintest in its [README.md](https://github.com/strangelove-ventures/interchaintest/blob/main/README.md). | ||
|
||
</HighlightBox> | ||
|
||
### Why use this over other scripting solutions? | ||
|
||
- **Go as a Scripting Language** | ||
- **Local Testing Environment:** The testing framework operates entirely locally, mirroring a production environment closely. This ensures that tests are reliable and can be seamlessly integrated into continuous integration (CI) pipelines. | ||
- **Industry Adoption:** Interchaintest, the underlying framework, is widely adopted by leading projects and core teams in the CosmWasm ecosystem, including Strangelove, the IBC team, Noble, DAODAO, and others. | ||
- **Funding and Support:** The development of Interchaintest is supported by the Interchain Foundation (ICF), ensuring ongoing improvements and stability. | ||
|
||
By using go-codegen, your CosmWasm application can benefit from a well-supported, reliable, widely-adopted testing framework. | ||
|
||
## Scope | ||
|
||
This tutorial will cover spinning up a local testing environment with interchaintest. We will be testing [cw-ica-controller](https://github.com/srdtrk/cw-ica-controller) to control a native interchain account in the host chain. | ||
|
||
<HighlightBox type="learning" title="Learning Goals"> | ||
|
||
In this tutorial, you will: | ||
|
||
- Compile a CosmWasm contract into wasm and generate its JSON schema | ||
- Scaffold an end-to-end testsuite with github actions consisting of two chains using go-codegen. | ||
- Add our contract to the testsuite using go-codegen. | ||
- Create a transfer channel between the two chains. | ||
- Create an IBC channel between the contract and the counterparty go module. | ||
- Send an ICA transaction and verify it. | ||
|
||
</HighlightBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
title: Set Up Your Work Environment | ||
sidebar_label: Set Up Your Work Environment | ||
sidebar_position: 1 | ||
slug: /setup-env | ||
--- | ||
|
||
import HighlightBox from '@site/src/components/HighlightBox'; | ||
|
||
# Set Up Your Work Environment | ||
|
||
On this page, you can find helpful links to set up your work environment. | ||
|
||
<HighlightBox type="info" title="Dependencies"> | ||
|
||
In this section, you can find all you need to install: | ||
|
||
- [Git](https://git-scm.com/) | ||
- [Go v1.22.3](https://go.dev/) | ||
- [go-codegen v0.2.2](https://github.com/srdtrk/go-codegen) | ||
- [Docker](https://www.docker.com/) | ||
- [Rust and Cargo](https://www.rust-lang.org/) | ||
- [just](https://just.systems/) (optional) | ||
|
||
</HighlightBox> | ||
|
||
<HighlightBox type="note" title="Note"> | ||
|
||
On a general note, it is advisable to prepare a separate project folder to keep all your Cosmos exercises. | ||
|
||
</HighlightBox> | ||
|
||
## Git | ||
|
||
Install Git following the instructions on the [Git website](https://git-scm.com/). Test if Git is installed by running the following command: | ||
|
||
```bash | ||
git --version | ||
``` | ||
|
||
## Go | ||
|
||
Install the latest version of Go following the instructions on the [Go website](https://go.dev/). Test if Go is installed by running the following command: | ||
|
||
```bash | ||
go version | ||
``` | ||
|
||
## go-codegen | ||
|
||
Install go-codegen by following the instructions on the [README.md](https://github.com/srdtrk/go-codegen/blob/main/README.md) or by using the command below. | ||
|
||
```bash | ||
go install github.com/srdtrk/[email protected] | ||
``` | ||
|
||
Test if go-codegen is installed by running the following command: | ||
|
||
```bash | ||
go-codegen version | ||
``` | ||
|
||
## Docker | ||
|
||
Install Docker following the instructions on the [Docker documentation](https://docs.docker.com/get-docker/). Test if Docker is installed by running the following command: | ||
|
||
```bash | ||
docker --version | ||
``` | ||
|
||
## Rust and Cargo | ||
|
||
Install Rust and Cargo following the instructions on the [Rust book](https://doc.rust-lang.org/book/ch01-01-installation.html). Test if Rust is installed by running the following commands: | ||
|
||
```bash | ||
cargo --version | ||
``` | ||
|
||
## just | ||
|
||
<HighlightBox type="info" title="Just"> | ||
|
||
[Just](https://just.systems/) is a handy `make` alternative written in Rust. It is optional but recommended for this tutorial. Instead of writing a `Makefile`, you can write a `justfile` to automate your tasks. | ||
|
||
</HighlightBox> | ||
|
||
Install just following the instructions on the [just manual](https://just.systems/man/en/chapter_4.html) or by using the command below. | ||
|
||
```bash | ||
cargo install just | ||
``` | ||
|
||
Test if just is installed by running the following command: | ||
|
||
```bash | ||
just --version | ||
``` | ||
|
||
<HighlightBox type="tip" title="Just"> | ||
|
||
If you don't want to install `just`, you can simply run the commands in the `justfile` manually. | ||
|
||
</HighlightBox> |
Oops, something went wrong.