If this is the first time setting up this project, follow the steps in the System Setup section.
Every other time, make sure that dfx
is running.
If you want to run it within the same terminal:
dfx start --background
If you would prefer to run it in a separate terminal:
dfx start
To deploy all canisters at once:
dfx deploy
To deploy the canisters with backend dev
features enabled:
FEATURES=dev dfx deploy
Else, refer to the following sections.
Command | Description |
---|---|
dfx deploy marketing |
Deploy to a local DFX replica |
pnpm turbo start -F marketing |
Run a local development server |
Command | Description |
---|---|
dfx deploy frontend |
Deploy to a local DFX replica |
pnpm turbo start -F frontend |
Run a local development server |
pnpm turbo build -F frontend |
Create a prod build |
pnpm turbo test -F frontend |
Run unit tests |
Command | Description |
---|---|
dfx deploy docs |
Deploy to a local DFX replica |
pnpm turbo start -F docs |
Run a local development server |
Command | Description |
---|---|
pnpm turbo build -F @cg/ui |
Build the library |
pnpm turbo test -F @cg/ui |
Run unit tests |
Command | Description |
---|---|
pnpm turbo build -F @cg/ui-angular |
Build the library |
pnpm turbo test -F @cg/ui-angular |
Run unit tests |
The primary backend canister for CodeGov proposal review management.
Command | Description |
---|---|
dfx deploy backend |
Deploy to a local DFX replica |
cargo test |
Run unit tests |
pnpm turbo test -F backend-integration |
Run integration tests |
An NNS testing utility tool.
This tool currently supports:
- Random identity generation
- Neuron staking
- RVM proposal creation
All supported actions are performed through self-documenting prompts in the terminal window.
Command | Description |
---|---|
pnpm -F nns-testing start |
Run the tool |
Add the following to the ~/.bashrc
(or .zprofile
on Mac) file:
# bin
export PATH="~/bin:$PATH"
Additionally add the following to .zprofile
(Mac only):
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
Enable .bashrc
(or .zprofile
on Mac) changes in your current shell:
source ~/.bashrc
Install Homebrew (Mac only):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install system dependencies (Mac only):
brew install jq wget
Install system dependencies (Linux only):
sudo apt install -y unzip jq
WARNING! The following setup script will install software on your system, please review it before running it. Most notably, it will reinstall DFX and wipe out any local state that you have. Follow the steps manually if you don't want to lose state or if you prefer to install the software manually. This will not affect any global or other project-specific networks. Running this script multiple times will not cause any issues and can be used to update the software it installs or to clean up the local project state.
The system setup script installs dfxvm
to manage versions of DFX. If dfxvm
is already installed, it will be updated to the latest version.
If dfx
is installed, but dfxvm
is not, it's recommended to uninstall dfx
first. This can be done by running the following (this will affect any global or other project-specific networks):
~/.cache/dfinity/uninstall.sh
Run the system setup script.
Note:
fnm
will warn about missing environment variables, this is fine.- The script may also pause execution to prompt for an administrator password.
./scripts/system-setup.sh
Add the following to the ~/.bashrc
(or .zprofile
on Mac) file:
# fnm
export PATH="~/.fnm:$PATH"
eval "$(fnm env --use-on-cd)"
Enable .bashrc
(or .zprofile
on Mac) changes in your current shell:
source ~/.bashrc
Additionaly, on Mac, run:
source "$HOME/Library/Application Support/org.dfinity.dfx/env"
Install NPM dependencies:
pnpm i
Create a src/marketing/.env
file with the following contents:
STORYBLOK_TOKEN=YOUR_PREVIEW_TOKEN
Create a src/frontend/.env
file with the following contents:
STORYBLOK_TOKEN=YOUR_PREVIEW_TOKEN
A Google Chrome installation is required to run Angular unit tests in WSL. Google Chrome installation instructions are based on those provided by Microsoft.
Change directory to temporary folder:
cd /tmp
Download the latest stable Google Chrome:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Install the downloaded package:
sudo dpkg -i google-chrome-stable_current_amd64.deb
Fix the package:
sudo apt install --fix-broken -y
Configure the package:
sudo dpkg -i google-chrome-stable_current_amd64.deb
Test the installation by running Google Chrome:
google-chrome
The controller of the canister has an admin role assigned to it when the canister is deployed for the first time. This role can be used to manage other users. The controller of the canister is whatever identity is selected when the canister is first deployed. Using the default
identity is recommended for this purpose locally for simplicity.
The user must exist before they can be assigned a role. To create another user, first create a new identity with DFX with the following command, replacing ${identityName}
with a name of your choice. --storage-mode plaintext
is optional, but easier to use when simply testing locally. The default storage mode will require a password every time a call is made with that identity.
dfx identity new --storage-mode plaintext ${identityName}
To view all of the identities that have been created, and also the current selected identity (it will have an *
next to it), run:
dfx identity list
To select your new identity, run:
dfx identity use ${identityName}
To then create a profile for this identity, run the following command. This command will return the ID of the profile that was created. This ID is needed to assign roles to the user.
dfx canister call backend create_my_user_profile
To get the profile (including the id
) of the current identity at any other time, run:
dfx canister call backend get_my_user_profile
Before changing the role of this user, switch back to the controller identity:
dfx identity use default
To assign a user as an admin, run the following command:
- Replace
${userId}
with the ID of the profile that was created earlier. - Replace
${username}
with this user's username. - Replace
${bio}
with this user's bio.
dfx canister call backend update_user_profile '(record { user_id = "${userId}"; username = opt "${username}"; config = opt variant { admin = record { bio = opt "${bio}" } } })'
To only upgrade a user to admin without changing any other properties:
dfx canister call backend update_user_profile '(record { user_id = "${userId}"; config = opt variant { admin = record {} } })'
To assign a user as a reviewer, run the following command:
- Replace
${userId}
with the ID of the profile that was created earlier. - Replace
${username}
with this user's username. - Replace
${bio}
with this user's bio. - Replace
${neuronId}
with the neuron ID of the neuron that this user will use to vote. - Replace
${walletAddress}
with the wallet address that this user will use to receive bounties.
Valid values for neuronId
and walletAddress
can be found on the Internet Computer dashboard.
dfx canister call backend update_user_profile '(record { user_id = "${userId}"; username = opt "${username}"; config = opt variant { reviewer = record { bio = opt "${bio}"; neuron_id = opt ${neuronId}; wallet_address = opt "${walletAddress}" } } })'
Any property preceded by opt
is optional and can be omitted. For example, to only change the username of a user:
dfx canister call backend update_user_profile '(record { user_id = "${userId}"; username = opt "${username}"; })'
Or to only upgrade a user to a reviewer:
dfx canister call backend update_user_profile '(record { user_id = "${userId}"; config = opt variant { reviewer = record {} } })'
To list open IcOsVersionElection proposals:
./scripts/list-open-ic-os-version-election-proposals.sh
To list open IcOsVersionDeployment proposals on mainnet:
./scripts/list-open-ic-os-version-election-proposals.sh --ic
- Make sure the
backend
canister has been deployed withdev
features enabled:FEATURES=dev dfx deploy backend
- Check if there are any existing proposals:
dfx canister call backend list_proposals
- If needed, create additional proposals using the
nns-testing
tool:pnpm -F nns-testing start
- Manually sync proposals:
dfx canister call backend sync_proposals
- Check if the proposals have been created:
dfx canister call backend list_proposals
- Close a proposal:
dfx canister call backend close_proposal '("${id}")'
- The method to call on the NNS governance canister is
manage_neuron
. - This method takes a
ManageNeuron
record as an argument.id
is optional and can be omitted.neuron_id_or_subaccount
should be the ID of the proposing neuron using a [NeuronIdOrSubaccount::NeuronId
] record.command
takes aCommand::MakeProposal
variant as a value.
Command::MakeProposal
takes aProposal
record as its value.url
can be an empty string.title
is the title of the proposal.summary
is the summary of the proposal.action
is the most important property and determines the type of proposal, it takes anAction
variant as its value.
- The
Action::ExecuteNnsFunction
variant can execute several different NNS function. It takes the identically namedExecuteNnsFunction
record as a value.nns_function
is a number corresponding to the NNS function to execute. The mapping between numbers and NNS functions can be found in theNnsFunction
enum.payload
is the Candid encoded argument for the corresponding NNS function. The types for this argument can be found in the appropriate canister's declaration. A mapping between NNS functions and their corresponding canisters can be found in theNnsFunction::canister_and_function
function definition.- For example, the
UpdateElectedReplicaVersions
uses number38
and its payload is theUpdateElectedReplicaVersionsPayload
record.
To manually trigger the proposals synchronization from the Nervous Systems, run the following command:
dfx canister call backend sync_proposals
This method can be called at any time, since if the proposals were already synced in the cron job, they won't be synced again.
To update the Candid files for external canisters, update the RELEASE
variable in the ./scripts/update-scripts-canisters.sh
file. Make sure to also update referenced tag for the ic-nns-governance
and ic-nns-common
crates in the Cargo.toml
file.
Then run the following script:
./scripts/update-external-canisters.sh