This repository contains the source code for all the Gold DAO controller canisters.
See the official website for more informations about the project.
All the backend canisters are included in the folder backend/canisters
. This includes
gldt_swap (WIP)
: The core logic for the swapping in betweenGLD NFT
andGLDT
.icp_neuron
: The canister that controls the ICP neurons of the Gold DAO.sns_rewards (WIP)
: The canister that manages the staking rewards of the Gold DAO. governance participants.
The frontend canisters of the project are included in the folder client
swap_app
: Contains the NextJS frontend for the swap application.landing_page
: Contains the NextJS frontend for the gldt.org landing page.explorer
: Contains the NextJS frontend for the GLDT explorer.
git clone git@github.com:GoldDAO/gldt-swap.git
(Or from the DAOlink internal Gitlab url, from which this Github repo is automatically mirrored)
First, ensure that you have cargo
and ic-wasm
installed, as well as wasmtime
.
Then from the repository's root folder:
npm install
To deploy and run the project in a local replica, simply run:
npm start
⚠️ Some resources (fonts, images...) will return errors (400
) if accessed fromhttp://127.0.0.1:<REPLICA_PORT>/?canisterId=<FRONTEND_CANISTER_ID>
. Instead, use the following url to access the locally deployed dapp:http://<FRONTEND_CANISTER_ID>.localhost:<REPLICA_PORT>/
.
To redeploy your latest changes on gldt_swap
, or on the frontend:
npm run deploy
If you need to test a redeploy operation for a canister (gldt_swap
or gldt_ledger
), you can use one of those scripts:
scripts/deploy-gldt-core.sh --help
scripts/deploy-gldt-fee-compensation.sh --help
scripts/deploy-ledger.sh --help
Each one contains safeguards against accidental deployments on staging or mainnet.
And to restart a fresh environment and redeploy all canisters, simply redo a npm start
. It will stop the currently running replica if any, and restart a clean one, then redeploy everything.
All frontends are developed in React, using the NextJS compiler to generate the static pages to be deployed in the corresponding assets canisters on the Internet Computer.
To launch a front-end only development server, with HMR:
npm run dev:gldt_swap_app # For the GLDT swap application frontend
The frontend development server will be available at http://localhost:3000
.
npm run build
Follow the instructions at https://github.com/lima-vm/lima#installation. You can use this config file to start: https://github.com/lima-vm/lima/blob/master/examples/docker.yaml and run the commands below.
Note: If you are running on an ARM chip (e.g. Apple M1), you have to add the line arch: "x86_64"
to the top of the docker.yaml
file (see more infos about this here). This will drastically reduce the execution speed of this (building can take >1hr), however, is required on ARM chips! See build/docker.yaml
for an example.
limactl start docker.yaml
docker context create lima-docker --docker "host=unix:///Users/$USER/.lima/docker/sock/docker.sock"
docker context use lima-docker
This step can take a while. Sit back and enjoy some coffee:
docker build -t gld_reproducible_build -f ./build/Dockerfile_backend .
Define the canister you want to build. Check the valid canister names in section Backend Canisters.
export CANISTER_NAME=<THE_CANISTER_NAME>
e.g.
export CANISTER_NAME=gldt_swap
Build the canister
docker run -v /tmp/lima/:/builds/gldt/gldt-swap/backend/canisters/$CANISTER_NAME/target/wasm32-unknown-unknown/release/ -e CANISTER_NAME=$CANISTER_NAME gld_reproducible_build
/tmp/lima/$CANISTER_NAME.wasm
/tmp/lima/$CANISTER_NAME_canister.wasm
/tmp/lima/$CANISTER_NAME_canister.wasm.gz
We are currently using the $CANISTER_NAME_canister.wasm.gz
in production, so you can check using:
shasum -a 256 /tmp/lima/${CANISTER_NAME}_canister.wasm.gz
Compare this value to the wasm hash that is provided with the upgrade proposal.
- Developers documentation still 🚧 WIP (See code comments for now. Documentation will be automatically generated and published at a later time)
- 🚧 WIP on DAOlink's internal Gitlab wiki
you may need to set the max open files on your current shell before running cargo test
by first running ulimit -n 10240