From cb0a39a79bdb6a5ba1ac783bb8a27841975df7a7 Mon Sep 17 00:00:00 2001 From: Jessie Mongeon Date: Fri, 22 Nov 2024 13:19:53 -0600 Subject: [PATCH] update code snippets --- .../smart-contracts/maintain/history.mdx | 15 ++------------- .../smart-contracts/maintain/import.mdx | 2 +- .../smart-contracts/maintain/logs.mdx | 12 ++++++------ .../smart-contracts/maintain/recovery.mdx | 17 ----------------- .../smart-contracts/maintain/settings.mdx | 17 +++++++---------- .../smart-contracts/maintain/storage.mdx | 2 +- 6 files changed, 17 insertions(+), 48 deletions(-) diff --git a/docs/developer-docs/smart-contracts/maintain/history.mdx b/docs/developer-docs/smart-contracts/maintain/history.mdx index 6f155bcf45..44ed083d9c 100644 --- a/docs/developer-docs/smart-contracts/maintain/history.mdx +++ b/docs/developer-docs/smart-contracts/maintain/history.mdx @@ -73,31 +73,20 @@ actor Info { -View the [Rust `canister-info` sample project](https://github.com/dfinity/examples/blob/master/rust/canister-info/src/lib.rs) for a detailed example of how to use `canister_info` in a Rust canister. +```rust file=../../../references/samples/rust/canister-info/src/lib.rs +``` }> -```typescript - -Azle code coming soon. - [Learn more about Azle](https://demergent-labs.github.io/azle/get_started.html). -``` - }> -```typescript - -Kybra code coming soon. - [Learn more about Kybra](https://demergent-labs.github.io/kybra/). -``` - \ No newline at end of file diff --git a/docs/developer-docs/smart-contracts/maintain/import.mdx b/docs/developer-docs/smart-contracts/maintain/import.mdx index 6cf2e1725e..37ce6a3b54 100644 --- a/docs/developer-docs/smart-contracts/maintain/import.mdx +++ b/docs/developer-docs/smart-contracts/maintain/import.mdx @@ -100,7 +100,7 @@ Service providers should use the following deployment process to deploy their `p - #### Step 1: From within your project's repo, deploy the canister to the mainnet with the command: ``` -dfx deploy --network ic +dfx deploy --network ic ``` - #### Step 2: If you're using GitHub, `git tag` and `GitHub release` with the commands: diff --git a/docs/developer-docs/smart-contracts/maintain/logs.mdx b/docs/developer-docs/smart-contracts/maintain/logs.mdx index 08b1c246de..6ee3077c4a 100644 --- a/docs/developer-docs/smart-contracts/maintain/logs.mdx +++ b/docs/developer-docs/smart-contracts/maintain/logs.mdx @@ -26,7 +26,7 @@ The canister logging feature is designed to p A canister's controller is able to retrieve the canister's logs, even when executions trap, using [`dfx canister logs`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-logs): ``` -dfx canister logs +dfx canister logs ``` :::info @@ -38,7 +38,7 @@ Non-replicated calls are not currently supported for logging. By default, a canister's logs are only visible to the controllers of the canister. A canister's logs can be made public by updating the canister's settings with [`dfx canister update-settings`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-update-settings) command: ```bash -dfx canister update-settings CANISTER_ID --log-visibility public +dfx canister update-settings --log-visibility public ``` ### Log viewer allow lists @@ -47,16 +47,16 @@ Canister log allow lists enable principals that are not controllers of the canis To add a principal to the canister's log allow list, update the canister's settings with the flags: -- `dfx canister update-settings CANISTER_ID --set-log-viewer PRINCIPAL_ID`: Set a single principal as a log viewer. +- `dfx canister update-settings --set-log-viewer PRINCIPAL_ID`: Set a single principal as a log viewer. -- `dfx canister update-settings CANISTER_ID --add-log-viewer PRINCIPAL_ID`: Add a principal to a list of log viewers. +- `dfx canister update-settings --add-log-viewer PRINCIPAL_ID`: Add a principal to a list of log viewers. -- `dfx canister update-settings CANISTER_ID --remove-log-viewer PRINCIPAL_ID`: Remove a principal from the log viewer list. +- `dfx canister update-settings --remove-log-viewer PRINCIPAL_ID`: Remove a principal from the log viewer list. You can also configure a principal as a log viewer when you create a canister: ``` -dfx canister create CANISTER_NAME --log-viewer PRINCIPAL_ID +dfx canister create --log-viewer PRINCIPAL_ID ``` Or, you can set the `canisters[].initialization_values.log_visibility.allowed_viewers` configuration setting in your project's `dfx.json` file. diff --git a/docs/developer-docs/smart-contracts/maintain/recovery.mdx b/docs/developer-docs/smart-contracts/maintain/recovery.mdx index 14b9dfff8d..86fca0769f 100644 --- a/docs/developer-docs/smart-contracts/maintain/recovery.mdx +++ b/docs/developer-docs/smart-contracts/maintain/recovery.mdx @@ -20,20 +20,3 @@ One method for recovering a canister is to roll the canister back to a snapshot ## Recovering a canister that does not have controllers If a canister is unable to be upgraded via any of the canister's existing controllers, either due to the canister not having controllers or loss of access to the canister's controllers, there is no supported method to recover that canister. - -## Recovering a canister with an NNS proposal - -If a canister does not have a snapshot that can be used for recovery, one possible last resort recovery method can be used, however it requires that the canister have the NNS root canister `r7inp-6aaaa-aaaaa-aaabq-cai` configured as a controller of the canister. - -To add the NNS root canister as a controller of your canister, use the command: - -```sh -dfx canister update-settings CANISTER_NAME --network ic --add-controller r7inp-6aaaa-aaaaa-aaabq-cai -``` - -:::info -This step cannot be taken after access to a canister's controllers is already lost, since only a current controller of the canister can add additional controllers. If a canister's code has failed and cannot be upgraded, but access to the canister's controllers is possible, then this step can be performed. -::: - -Then, when the canister needs to be recovered, it may be recovered by using the System Canister Management NNS proposal used for upgrading all system canisters. When submitting this proposal, include the canister ID of the broken canister and a new Wasm module for the canister. Once this proposal is submitted, the NNS DAO will vote on whether to upgrade the canister using the proposed new Wasm file or not. If the proposal is passed, the canister will be upgraded and potentially recovered. - diff --git a/docs/developer-docs/smart-contracts/maintain/settings.mdx b/docs/developer-docs/smart-contracts/maintain/settings.mdx index 5d5e08e118..53dd8e2be0 100644 --- a/docs/developer-docs/smart-contracts/maintain/settings.mdx +++ b/docs/developer-docs/smart-contracts/maintain/settings.mdx @@ -33,7 +33,7 @@ Currently, there are seven canister setting fields: There are two ways to read the settings of a canister: -1. Command line: [`dfx canister status `](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-status). Note that this command returns the canister's settings, along with other canister status information. +1. Command line: [`dfx canister status `](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-status). Note that this command returns the canister's settings, along with other canister status information. 2. Programmatically: Call the [`canister_status`](https://internetcomputer.org/docs/current/references/ic-interface-spec) endpoint of the IC management canister. The canister's settings will be in the `settings` field of the result. ### Command line @@ -71,27 +71,24 @@ Log visibility: controllers -For an example of how to use `canister_status` in your Motoko code, view the [sample application](https://github.com/dfinity/examples/blob/master/motoko/query_stats/src/query_stats_backend/main.mo). +```motoko no-repl file=../../../references/samples/motoko/query_stats/src/query_stats_backend/main.mo +``` -For an example of how to use `canister_status` in your Rust code, view the [sample application](https://github.com/dfinity/examples/blob/master/rust/query_stats/src/lib.rs). - +```rust file=../../../references/samples/rust/query_stats/src/query_stats_backend/src/lib.rs +``` }> -Azle code coming soon. - [Learn more about Azle](https://demergent-labs.github.io/azle/the_azle_book.html). }> -Kybra code coming soon. - [Learn more about Kybra](https://demergent-labs.github.io/kybra/). @@ -101,7 +98,7 @@ Kybra code coming soon. There are two ways to modify the settings of a canister: -1. Command line: `dfx canister update-settings -- `. +1. Command line: `dfx canister update-settings -- `. 1. Programmatically: Call the [`update_settings`](/docs/current/references/ic-interface-spec#ic-update_settings) endpoint of the IC management canister. Note that only a controller of the canister can modify canister settings. @@ -109,7 +106,7 @@ Note that only a controller of the canister can modify canister settings. ### Command line ```bash -dfx canister update-settings ajuq4-ruaaa-aaaaa-qaaga-cai --wasm-memory-limit 3000000000 +dfx canister update-settings my_canister --wasm-memory-limit 3000000000 ``` ### Programmatically diff --git a/docs/developer-docs/smart-contracts/maintain/storage.mdx b/docs/developer-docs/smart-contracts/maintain/storage.mdx index 166fdebb79..6cb008eaf1 100644 --- a/docs/developer-docs/smart-contracts/maintain/storage.mdx +++ b/docs/developer-docs/smart-contracts/maintain/storage.mdx @@ -105,7 +105,7 @@ This garbage collector is still in beta testing and should be used with caution. ### Rust storage handling -To utilize stable memory for canisters written in Rust, the crates [ic-stable-memory](https://github.com/seniorjoinu/ic-stable-memory) and [ic-stable-structures](https://github.com/dfinity/stable-structures) can be used. It is recommended to review the documentation for these crates to learn more, or [review the tutorial on the stable structures crate](https://mmapped.blog/posts/14-stable-structures.html). +To utilize stable memory for canisters written in Rust, the crate [ic-stable-structures](https://github.com/dfinity/stable-structures) can be used. It is recommended to review the documentation for these crates to learn more, or [review the tutorial on the stable structures crate](https://mmapped.blog/posts/14-stable-structures.html). As good practice, stable memory should be versioned since the stable memory decoding mechanism may need to guess the data's format in situations where the serialization format or stable data layout of a canister drastically changes. This can be as simple as declaring that the first byte of the canister's stable memory will be used to represent the version number.