Repository navigation
chore(local): add a ckRED test token and a mock exchange rate canister to the local network #8131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yhabib
wants to merge
21
commits into
governance-dfx-icp-cli-migration-bb2c0e
Choose a base branch
from
feat/local-ckred-token
base: governance-dfx-icp-cli-migration-bb2c0e
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+301
−35
Open
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4fce746
chore(local): add a ckRED test token to the local network
yhabib 8b886ec
chore(local): add a mock exchange rate canister and install the mocks…
yhabib 34d06ba
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib ae5dcea
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib d9e36ef
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 81d7073
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib f3de59d
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 52e67ae
fix(local): stop on a failed status request and keep the exchange rat…
yhabib 40f1f9d
chore(local): seed the mock exchange rate at install
yhabib 879b445
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 9efd9a0
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 10af372
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 0bdbeb4
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 61c5e41
fix(local): stop the start script when a canister status request fails
yhabib bd78f96
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 80c8054
docs(local): explain the zero total value locked without a wasm
yhabib ea85318
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 3a0a54b
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 894c65a
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib 8108587
fix(spellcheck): remove the stray count line from the dictionary
yhabib 8ad4a49
Merge branch 'governance-dfx-icp-cli-migration-bb2c0e' into feat/loca…
yhabib File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| 89 | ||
| 90 | ||
| Monterey | ||
| IC | ||
| ICP | ||
|
|
@@ -87,4 +87,5 @@ Cmd | |
| Banxa | ||
| dfx | ||
| IC0542 | ||
| ckRED | ||
| MCP | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,5 @@ | ||
| # ckRED test token | ||
|
|
||
| `scripts/icp-network-start` deploys an ICRC-1 ledger and index for the ckRED test token on the local network. The import token end-to-end tests import it. The ledger has 7 decimals and a fee of 4000 units, like the snsdemo environment had. | ||
|
|
||
| The test account of the "Get tokens" menu, see `frontend/src/lib/api/dev.api.ts`, holds the initial supply. The anonymous principal is the minting account. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,128 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| SOURCE_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" | ||
| PATH="$SOURCE_DIR:$PATH" | ||
|
|
||
| print_help() { | ||
| cat <<-EOF | ||
|
|
||
| Creates a canister with a given ID on a local icp-cli network. | ||
|
|
||
| icp canister create cannot choose the ID. This script calls the | ||
| provisional_create_canister_with_cycles method of the management canister | ||
| through the PocketIC REST API, which accepts any canister ID in the range | ||
| of a subnet of the network. The current icp identity becomes the controller. | ||
|
|
||
| The network must run in the background, so that | ||
| .icp/cache/networks/<network>/descriptor.json exists. | ||
| EOF | ||
| } | ||
|
|
||
| CYCLES=100_000_000_000_000 | ||
| MAX_ATTEMPTS=120 | ||
| RETRY_DELAY_SECONDS=0.5 | ||
|
|
||
| # Source the clap.bash file --------------------------------------------------- | ||
| source "$SOURCE_DIR/clap.bash" | ||
| # Define options | ||
| clap.define short=n long=network desc="The icp network" variable=NETWORK default="local" | ||
| clap.define short=c long=canister desc="The canister ID to create" variable=CANISTER_ID | ||
| clap.define short=p long=principal desc="The controller of the new canister" variable=CONTROLLER default="$(icp identity principal)" | ||
| # Source the output file ---------------------------------------------------------- | ||
| source "$(clap.build)" | ||
|
|
||
| test -n "${CANISTER_ID:-}" || { | ||
| echo "ERROR: Please specify the canister ID with --canister." | ||
| exit 1 | ||
| } >&2 | ||
|
|
||
| if icp canister status "$CANISTER_ID" --network "$NETWORK" >/dev/null 2>&1; then | ||
| echo "Canister $CANISTER_ID exists already." | ||
| exit 0 | ||
| fi | ||
|
|
||
| DESCRIPTOR="$SOURCE_DIR/../.icp/cache/networks/$NETWORK/descriptor.json" | ||
| test -f "$DESCRIPTOR" || { | ||
| echo "ERROR: The '$NETWORK' network is not running in the background." | ||
| echo " Expected the network descriptor at: $DESCRIPTOR" | ||
| exit 1 | ||
| } >&2 | ||
| POCKETIC_URL="http://127.0.0.1:$(jq -r '.["pocketic-config-port"]' "$DESCRIPTOR")" | ||
| INSTANCE_URL="$POCKETIC_URL/instances/$(jq -r '.["pocketic-instance-id"]' "$DESCRIPTOR")" | ||
|
|
||
| # Converts a textual principal to the base64 of its raw bytes, as the PocketIC REST API expects. | ||
| principal_to_base64() { | ||
| convert-id --input text --output hex "$1" | xxd -r -p | base64 | tr -d '\n' | ||
| } | ||
|
|
||
| # Polls an operation that PocketIC answered with 202 and a handle. | ||
| poll_operation() { | ||
| local state_label op_id url response | ||
| state_label="$(jq -r .state_label <<<"$1")" | ||
| op_id="$(jq -r .op_id <<<"$1")" | ||
| url="$POCKETIC_URL/read_graph/$state_label/$op_id" | ||
| for ((attempt = 0; attempt < MAX_ATTEMPTS; attempt++)); do | ||
| response="$(curl -s -w '\n%{http_code}' "$url")" | ||
| if [[ "$(tail -n1 <<<"$response")" != "404" ]]; then | ||
| sed '$d' <<<"$response" | ||
| return | ||
| fi | ||
| sleep "$RETRY_DELAY_SECONDS" | ||
| done | ||
| echo "ERROR: Timed out on operation $op_id." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| # Posts to the PocketIC instance. The network runs in live mode, so PocketIC | ||
| # answers 409 while it advances time. Retry until it is free. | ||
| post() { | ||
| local path body response code | ||
| path="$1" | ||
| body="$2" | ||
| for ((attempt = 0; attempt < MAX_ATTEMPTS; attempt++)); do | ||
| response="$(curl -s -w '\n%{http_code}' -X POST -H 'content-type: application/json' "$INSTANCE_URL/update/$path" -d "$body")" | ||
| code="$(tail -n1 <<<"$response")" | ||
| case "$code" in | ||
| 202) poll_operation "$(sed '$d' <<<"$response")" && return ;; | ||
| 409) sleep "$RETRY_DELAY_SECONDS" ;; | ||
| *) | ||
| sed '$d' <<<"$response" | ||
| return | ||
| ;; | ||
| esac | ||
| done | ||
| echo "ERROR: Timed out on $path." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| payload="$( | ||
| didc encode "(record { | ||
| amount = opt ($CYCLES : nat); | ||
| settings = null; | ||
| specified_id = opt principal \"$CANISTER_ID\"; | ||
| })" | xxd -r -p | base64 | tr -d '\n' | ||
| )" | ||
|
|
||
| submitted="$(post submit_ingress_message "$(jq -n \ | ||
| --arg sender "$(principal_to_base64 "$CONTROLLER")" \ | ||
| --arg effective "$(principal_to_base64 "$CANISTER_ID")" \ | ||
| --arg payload "$payload" \ | ||
| '{ | ||
| sender: $sender, | ||
| canister_id: "", | ||
| effective_principal: { CanisterId: $effective }, | ||
| method: "provisional_create_canister_with_cycles", | ||
| payload: $payload | ||
| }')")" | ||
| jq -e .Ok <<<"$submitted" >/dev/null || { | ||
| echo "ERROR: Failed to submit the create call: $submitted" | ||
| exit 1 | ||
| } >&2 | ||
|
|
||
| result="$(post await_ingress_message "$(jq .Ok <<<"$submitted")")" | ||
| jq -e 'has("Ok")' <<<"$result" >/dev/null || { | ||
| echo "ERROR: The create call failed: $result" | ||
| exit 1 | ||
| } >&2 | ||
|
|
||
| echo "Created canister $CANISTER_ID with controller $CONTROLLER." |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.