Skip to content

Commit

Permalink
Spellcheck (#4099)
Browse files Browse the repository at this point in the history
# Motivation
The spell checker has a lot of false hits in markdown files, which makes
it hard to see genuine errors. The false hits are primarily from
unformatted code.

# Changes
- Format code as code, so that spellcheck ignores it.
- Add legitimate well known words to the dictionary.

# Tests
I have NOT added the markdown spellchecker to CI as it chokes on the
fancy HTML in `README.html`. Probably want to address that first. Just
having less noise is a huge improvement.

# Todos

- [ ] Add entry to changelog (if necessary).
  - Too minor
  • Loading branch information
bitdivine authored Jan 4, 2024
1 parent 177b022 commit 66c04ea
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 52 deletions.
14 changes: 14 additions & 0 deletions .config/spellcheck.dic
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Wasms
OWASP
<
>
+
iframe
SNSs
deserialization
Expand All @@ -23,6 +24,9 @@ clippy
dapp
dockerfile
dockerfiles
dockerized
e2e
Eslint
4xx
5xx
sha256
Expand All @@ -38,3 +42,13 @@ Vitest
npm
PR
PRs
vitest
promisified
utils
Node.js
js
SvelteKit
M1
M2
protobuf
se
8 changes: 4 additions & 4 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ environment. The following steps _should_ build the official Wasm image.
brew install git
```
- [Docker](https://www.docker.com/) is a container environment. It lets you build the nns-dapp code in a sandbox, fairly reliably, and without you having to install a lot of custom tools that you may not trust. Please use [one of the official installers](https://docs.docker.com/get-docker/).
- [Docker buildx](https://github.com/docker/buildx) is an extension that makes it easier to compile under docker. `buildx` is included in the standard docker installer for Mac desktops. If you have installed docker for an os-x server, please follow [the official guide](https://docs.docker.com/build/install-buildx/).
- [Docker `buildx`](https://github.com/docker/buildx) is an extension that makes it easier to compile under docker. `buildx` is included in the standard docker installer for Mac desktops. If you have installed docker for an os-x server, please follow [the official guide](https://docs.docker.com/build/install-buildx/).
- [Rosetta]() allows Mac M1 and M2 processors to run programs that use the AMD64 instruction set. If you have an M1 or M2 CPU, please:
- Install Rosetta:
```sh
Expand All @@ -44,7 +44,7 @@ environment. The following steps _should_ build the official Wasm image.
apt-get install git
```
- [Docker](https://www.docker.com/) is a container environment. It lets you build the nns-dapp code in a sandbox, fairly reliably, and without you having to install a lot of custom tools that you may not trust. Please use [one of the official installers](https://docs.docker.com/get-docker/).
- [Docker buildx](https://github.com/docker/buildx) is an extension that makes it easier to compile under docker. `buildx` is included in recent docker releases. You can check whether it is installed with:
- [Docker `buildx`](https://github.com/docker/buildx) is an extension that makes it easier to compile under docker. `buildx` is included in recent docker releases. You can check whether it is installed with:

```sh
$ docker build --help
Expand All @@ -53,7 +53,7 @@ environment. The following steps _should_ build the official Wasm image.
...
```

If you do not have buildx installed, please follow [the official guide](https://docs.docker.com/build/install-buildx/). In particular, to install version `0.10.4` on a x86-64 Linux machine:
If you do not have `buildx` installed, please follow [the official guide](https://docs.docker.com/build/install-buildx/). In particular, to install version `0.10.4` on a x86-64 Linux machine:

```sh
wget https://github.com/docker/buildx/releases/download/v0.10.4/buildx-v0.10.4.linux-amd64
Expand All @@ -76,7 +76,7 @@ When you have the tools installed, you can build the container with:
git checkout THE_COMMIT
```
- Verify that docker is running. If not, please start it.
- Mac: Press cmd+space and enter docker
- Mac: Press `cmd`+`space` and enter docker
- Ubuntu: `pgrep docker || sudo systemctl start docker`
- Now you can build:
```sh
Expand Down
30 changes: 15 additions & 15 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ That is why we are providing a `./config.sh` script that generate the above envi
To run the dapp against canisters deployed locally on a simulated IC network, use the steps below, or run `./scripts/dev-local.sh` which guides you through these steps

- Make sure you have a clean local replica running with `dfx start --clean`. This will stay running so use a separate terminal for this.
- Deploy the NNS backend canisters locally with `dfx nns install`
- Deploy the NNS back-end canisters locally with `dfx nns install`
- From the last line of output of `dfx nns install` note down the value URL for `nns-dapp`
- Run `DFX_NETWORK=local ./config.sh` to populate the `./frontend/.env` file.
- Manually edit the `./frontend/.env` and replace `null` with the nns-dapp canister id from the URL you noted down before.
Expand All @@ -46,15 +46,15 @@ To run the dapp against canisters deployed locally on a simulated IC network, us
- In the `./frontend/` folder, first run `npm ci` and then `npm run dev` to serve the application.

With this setup, you can work on the frontend code without building the
nns-dapp canister. If you want to change the backend code, you can deploy it
nns-dapp canister. If you want to change the back-end code, you can deploy it
with `dfx deploy nns-dapp` and it replace the provided canister.

Once you have a running replica with nns installed and a fixed
Once you have a running replica with NNS installed and a fixed
`./frontend/.env` file, don't have to take all the steps every time.

## Testnet

The [canister_ids.json] data provides the list of canister IDs available for various test environments.
The [`canister_ids.json`] data provides the list of canister IDs available for various test environments.

## Preview

Expand All @@ -70,18 +70,18 @@ npm run preview

To develop and run locally the dapp against a testnet, proceed as following:

- Copy the [canister_ids.json] to the root of your local project
- Copy the [`canister_ids.json`] to the root of your local project
- Run `DFX_NETWORK=<testnet_name> ./config.sh` to populate the `.env` file
- Start `npm run dev` in the `./frontend/` folder to serve the application

e.g. replace `<testnet_name>` with `small11`

## Requirements

The `dfx` version installed locally should match the one defined in [dfx.json](https://github.com/dfinity/nns-dapp/blob/main/dfx.json). If not, you will have to either upgrade or manually change the version in the local file. In such case, please do not commit the change!
The `dfx` version installed locally should match the one defined in [`dfx.json`](https://github.com/dfinity/nns-dapp/blob/main/dfx.json). If not, you will have to either upgrade or manually change the version in the local file. In such case, please do not commit the change!

[canister_ids.json]: https://github.com/dfinity/nns-dapp/blob/testnets/testnets/canister_ids.json
[package.json]: https://github.com/dfinity/nns-dapp/blob/main/frontend/package.json
[`canister_ids.json`]: https://github.com/dfinity/nns-dapp/blob/testnets/testnets/canister_ids.json
[`package.json`]: https://github.com/dfinity/nns-dapp/blob/main/frontend/package.json

## Dependencies

Expand All @@ -91,7 +91,7 @@ In this guide, we will walk you through the process of checking for newer depend

1. Install `npm-check-updates`:

First, make sure you have Node.js and npm (Node Package Manager) installed on your system. If not, you can download and install them from the official Node.js website (https://nodejs.org).
First, make sure you have Node.js and npm (Node Package Manager) installed on your system. If not, you can download and install them from the official Node.js website [](https://nodejs.org).

To install the `npm-check-updates` tool, open your terminal and run the following command:

Expand Down Expand Up @@ -153,7 +153,7 @@ To deploy a local Bitcoin network, the [documentation](https://internetcomputer.

As ckBTC is not yet implemented in our pipeline, enabling it in `dfx.json` has not yet be done neither - i.e. it needs to be manually configured for testing / development purpose:

Add following in `defaults` of [dfx.json](./dfx.json).
Add following in `defaults` of [`dfx.json`](./dfx.json).

```
"bitcoin": {
Expand All @@ -168,15 +168,15 @@ Add following in `defaults` of [dfx.json](./dfx.json).

Deploying ckBTC ledger, index and minter are as well not yet automated.

Their Wasm and candid file can be downloaded with a script which finds place in [./scripts/ckbtc/download-ckbtc](./scripts/ckbtc/download-ckbtc).
Their Wasm and candid file can be downloaded with a script which finds place in [`./scripts/ckbtc/download-ckbtc`](./scripts/ckbtc/download-ckbtc).

```
./scripts/ckbtc/download-ckbtc
```

To deploy the canisters locally, a script is provided in [./scripts/ckbtc/deploy-ckbtc](./scripts/ckbtc/deploy-ckbtc) as well.
To deploy the canisters locally, a script is provided in [`./scripts/ckbtc/deploy-ckbtc`](./scripts/ckbtc/deploy-ckbtc) as well.

However, it requires first to manually edit [dfx.json](./dfx.json).
However, it requires first to manually edit [`dfx.json`](./dfx.json).

e.g. in `canisters`:

Expand Down Expand Up @@ -211,15 +211,15 @@ Once set, the script can be executed.
DFX_NETWORK=local ./scripts/ckbtc/deploy-ckbtc
```

After deployment, their respective IDs shall be collected and updated in [ckbtc-canister-ids.constants.ts](./frontend/src/lib/constants/ckbtc-canister-ids.constants.ts).
After deployment, their respective IDs shall be collected and updated in [`ckbtc-canister-ids.constants.ts`](./frontend/src/lib/constants/ckbtc-canister-ids.constants.ts).

Likewise, as the configuration is not yet automated, there are no `.env` variable that are yet generated.

### Feature flag

Because the e2e tests are using the `local` environment to perform, we cannot enable the `ENABLE_CKBTC` and `ENABLE_CKTESTBTC` per default.

Therefore, this flag should also be manually set to `true` in [dfx.json](./dfx.json) and the `.env` should be generated.
Therefore, this flag should also be manually set to `true` in [`dfx.json`](./dfx.json) and the `.env` should be generated.

Use `scripts/nns-dapp/test-config --update` to update `arg.did` and `env` files under `nns-dapp/test-config-assets`

Expand Down
47 changes: 23 additions & 24 deletions HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This means that we need to upgrade the candid files and related, and synchronize

#### How To Upgrade IC Dependencies

The Internet Computer dependencies are in the [Cargo.toml](./rs/backend/Cargo.toml) of the backend project. They are the ones that point to `git = "https://github.com/dfinity/ic"`. For example:
The Internet Computer dependencies are in the [`Cargo.toml`](./rs/backend/Cargo.toml) of the `backend` project. They are the ones that point to `git = "https://github.com/dfinity/ic"`. For example:

```
ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "89129b8212791d7e05cab62ff08eece2888a86e0" }
Expand Down Expand Up @@ -102,14 +102,14 @@ Yet, a proposal of that topic won't be rendered properly until the changes are m
**Changes in nns-js:**

- Add to topic entry in the [governance enum](https://github.com/dfinity/ic-js/blob/main/packages/nns/src/enums/governance.enums.ts#L15).
- Add topic entry in the `Topic` for [proto files](https://github.com/dfinity/ic-js/tree/main/packages/nns/proto). You can search for `TOPIC_NEURON_MANAGEMENT` to better see where to add them.
- Add topic entry in the `Topic` for [protobuf files](https://github.com/dfinity/ic-js/tree/main/packages/nns/proto). You can search for `TOPIC_NEURON_MANAGEMENT` to better see where to add them.

**Changes in nns-dapp:**

- Add i18n labels in `en.governance.json`. "topics" and "topics_description".
- Add i18n labels in `en.json`: "follow_neurons.topic_XX_title" and "follow_neurons.topic_XX_description"
- Add i18n labels in `en.governance.json`: `topics` and `topics_description`.
- Add i18n labels in `en.json`: `follow_neurons.topic_XX_title` and `follow_neurons.topic_XX_description`

The topic descriptions can be found in [governance.proto](https://github.com/dfinity/ic/blob/master/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto) in IC repo.
The topic descriptions can be found in [`governance.proto`](https://github.com/dfinity/ic/blob/master/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto) in IC repo.

### Upgrade dependencies: Ledger ICP App

Expand Down Expand Up @@ -153,13 +153,13 @@ changes are made and released.

### 3. Install a new governance canister

Here we explain how to do it on dfx network `local`. It's possible to do the
Here we explain how to do it on `dfx` network `local`. It's possible to do the
same on testnet but that's not described here.

First you need to determine from which commit you want to install the governance
canister. This can be the commit that added the new proposal type or the latest
commit which provides built artifacts. The latter you can get by running
`newest_sha_with_disk_image.sh` in the ic repo.
`newest_sha_with_disk_image.sh` in the `ic` repo.

1. `git clone [email protected]:dfinity/ic.git`
2. `cd ic`
Expand All @@ -168,7 +168,7 @@ commit which provides built artifacts. The latter you can get by running
5. `echo $IC_COMMIT`

The governance canister is installed by `dfx` when you run `dfx nns install`.
However, if there is a version of the canister in the dfx cache, that version
However, if there is a version of the canister in the `dfx` cache, that version
is the one that will be used. So we first need to remove the canister from the
cache and then run `dfx nns install`.

Expand Down Expand Up @@ -247,7 +247,7 @@ the proposal.

You'll need to make a 1-line change in the `ic-js`
[repository](https://github.com/dfinity/ic-js) to add the new NNS function to
the [NnsFunction
the [`NnsFunction`
enum](https://github.com/dfinity/ic-js/blame/main/packages/nns/src/enums/governance.enums.ts#:~:text=export%20enum%20NnsFunction%20%7B)
in `packages/nns/src/enums/governance.enums.ts`. Use the name and number that
you noted down above in the section "Verify that the intended change is for a
Expand All @@ -257,11 +257,11 @@ new NNS function".

You'll need to change the following files:

1. [rs/backend/Cargo.toml](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/Cargo.toml)
2. [frontend/src/lib/i18n/en.governance.json](https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/i18n/en.governance.json)
3. [rs/backend/src/proposals.rs](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/src/proposals.rs)
1. [`rs/backend/Cargo.toml`](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/Cargo.toml)
2. [`frontend/src/lib/i18n/en.governance.json`](https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/i18n/en.governance.json)
3. [`rs/backend/src/proposals.rs`](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/src/proposals.rs)

##### Cargo.toml
##### `Cargo.toml`

For each dependency that has `git = "https://github.com/dfinity/ic"`, change
the value of `rev =` to the commit you decided to use above in the section
Expand All @@ -277,7 +277,7 @@ add do the following:
2. Then look for the `Cargo.toml` in the parent directory of the `/src/`
directory.
3. In the `Cargo.toml` file you should find the package name. For example for
[this Cargo.toml
[this `Cargo.toml`
file](https://github.com/dfinity/bitcoin-canister/blob/master/interface/Cargo.toml),
it's `ic-btc-interface`.
4. Use that name to add a line in `rs/backend/Cargo.toml` like this:
Expand All @@ -295,25 +295,25 @@ ic-btc-interface = { git = "https://github.com/dfinity/bitcoin-canister", rev="2
**Note**: The updated dependencies might have breaking changes which need to
be fixed when building nns-dapp later.

##### en.governance.json
##### `en.governance.json`

In `en.governance.json`, you'll have to add entries to 2 different maps:
[nns_functions](https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/i18n/en.governance.json#:~:text=%22nns_functions%22%3A%20%7B) and
[nns_functions_description](https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/i18n/en.governance.json#:~:text=%22nns_functions_description%22%3A%20%7B).
[`nns_functions`](https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/i18n/en.governance.json#:~:text=%22nns_functions%22%3A%20%7B) and
[`nns_functions_description`](https://github.com/dfinity/nns-dapp/blob/main/frontend/src/lib/i18n/en.governance.json#:~:text=%22nns_functions_description%22%3A%20%7B).

As the key in both maps, use the name that you noted down before and also used
in the enum in the ic-js repo.

For `nns_functions` use a label that's more or less the enum value name but
human readable. For example, for `BitcoinSetConfig` use "Set Bitcoin Config".
human readable. For example, for `BitcoinSetConfig` use `"Set Bitcoin Config"`.

For `nns_functions_description` you might be able to find a good description
as a comment on the [enum value definition](https://github.com/dfinity/ic/blame/master/rs/nns/governance/src/gen/ic_nns_governance.pb.v1.rs#:~:text=pub%20enum%20NnsFunction%20%7B).
If not, you'll just have to ask someone for a good description. This
description will be displayed when someone clicks on the (i) icon on the
proposal detail page.

##### proposals.rs
##### `proposals.rs`

You will need to know the fully qualified name of the proposal type you are
adding. If you have the name of the type and the file it is defined in, you
Expand All @@ -326,16 +326,15 @@ find the fully qualified name as follows:
hyphens with underscores.

For example for
[BitcoinSetConfigProposal](https://github.com/dfinity/ic/blame/ae00aff1373e9f6db375ff7076250a20bbf3eea0/rs/nns/governance/src/governance.rs#L8930),
[`BitcoinSetConfigProposal`](https://github.com/dfinity/ic/blame/ae00aff1373e9f6db375ff7076250a20bbf3eea0/rs/nns/governance/src/governance.rs#L8930),
you would get `ic_nns_governance::governance::BitcoinSetConfigProposal`.

If you're lucky, the new type can be used as-is. But in some cases a
transformation to the type is required to render it in a human readable way.

If no transformation is required:

1. Add a new entry to [match
nns_function](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/src/proposals.rs#:~:text=match%20nns_function%20%7B).
1. Add a new entry to [`match nns_function`](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/src/proposals.rs#:~:text=match%20nns_function%20%7B).
Use the number you noted down above in the section "Verify that the intended
change is for a new NNS function". And use the (non-fully qualified) name of
the new proposal type. For example:
Expand All @@ -359,8 +358,8 @@ pub type UpdateElectedReplicaVersionsPayload =

If a transformation is required:

1. Add a new entry to [match
nns_function](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/src/proposals.rs#:~:text=match%20nns_function%20%7B).
1. Add a new entry to [`match
nns_function`](https://github.com/dfinity/nns-dapp/blob/main/rs/backend/src/proposals.rs#:~:text=match%20nns_function%20%7B).
Use the number you noted down above in the section "Verify that the intended
change is for a new NNS function". And use the (non-fully qualified) name of
the new proposal type, and then repeat it with the `HumanReadable` suffix.
Expand Down
Loading

0 comments on commit 66c04ea

Please sign in to comment.