Skip to content
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

Docs Audit #2 #3801

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3c103f2
docs audit 1
jessiemongeon1 Nov 18, 2024
a1437e2
docs audit
jessiemongeon1 Nov 19, 2024
df5db70
docs audit
jessiemongeon1 Nov 19, 2024
a0ca73f
Merge branch 'master' into docs-audit-1
jessiemongeon1 Nov 19, 2024
254c022
Update install.mdx
jessiemongeon1 Nov 20, 2024
a2d2c14
Update install.mdx
jessiemongeon1 Nov 20, 2024
36ae28b
Merge branch 'master' into docs-audit-1
jessiemongeon1 Nov 20, 2024
445e054
Update overview.mdx
jessiemongeon1 Nov 20, 2024
2630710
Update overview.mdx
jessiemongeon1 Nov 20, 2024
83ae69b
Update overview.mdx
jessiemongeon1 Nov 20, 2024
3d80f46
Update create.mdx
jessiemongeon1 Nov 20, 2024
b10dec0
Update compile.mdx
jessiemongeon1 Nov 20, 2024
961a399
Update create.mdx
jessiemongeon1 Nov 20, 2024
9ca2d5b
Update compile.mdx
jessiemongeon1 Nov 20, 2024
b2dea3c
Update install.mdx
jessiemongeon1 Nov 20, 2024
a259d52
Update overview.mdx
jessiemongeon1 Nov 20, 2024
a87a7a3
Update custom-testnets.mdx
jessiemongeon1 Nov 20, 2024
bcf076c
Update overview.mdx
jessiemongeon1 Nov 20, 2024
2d5c196
Update create.mdx
jessiemongeon1 Nov 20, 2024
014ac29
Update compile.mdx
jessiemongeon1 Nov 20, 2024
68aac31
Update install.mdx
jessiemongeon1 Nov 20, 2024
79070c2
Update overview.mdx
jessiemongeon1 Nov 20, 2024
9dba035
Update custom-testnets.mdx
jessiemongeon1 Nov 20, 2024
94808b2
Update overview.mdx
jessiemongeon1 Nov 20, 2024
ba3284c
Update overview.mdx
jessiemongeon1 Nov 20, 2024
eeca321
Dev weekly update Nov 20 2024
jessiemongeon1 Nov 20, 2024
fce036b
Update compile.mdx
jessiemongeon1 Nov 20, 2024
93e53f8
Update create.mdx
jessiemongeon1 Nov 20, 2024
c4c0990
Update overview.mdx
jessiemongeon1 Nov 20, 2024
14b2f9d
Update install.mdx
jessiemongeon1 Nov 20, 2024
1630afc
Update overview.mdx
jessiemongeon1 Nov 20, 2024
d84abf7
Update candid-howto.mdx
jessiemongeon1 Nov 20, 2024
9179f19
Merge branch 'docs-audit-1' of github.com:dfinity/portal into docs-au…
jessiemongeon1 Nov 20, 2024
153cd1b
fix tabs
jessiemongeon1 Nov 20, 2024
9793aa0
fix conflicts
jessiemongeon1 Nov 20, 2024
bbc2020
fix conflicts
jessiemongeon1 Nov 20, 2024
a83067d
fix conflicts
jessiemongeon1 Nov 20, 2024
5f63a96
fix conflicts
jessiemongeon1 Nov 20, 2024
0373290
fix conflicts
jessiemongeon1 Nov 21, 2024
ea1d796
revert subs
jessiemongeon1 Nov 21, 2024
f5d17ba
init
jessiemongeon1 Nov 21, 2024
98902dc
init
jessiemongeon1 Nov 21, 2024
e023626
fix link
jessiemongeon1 Nov 22, 2024
cb0a39a
update code snippets
jessiemongeon1 Nov 22, 2024
d14224d
Update docs/developer-docs/smart-contracts/maintain/settings.mdx
jessiemongeon1 Nov 22, 2024
c9c7fd3
Merge branch 'master' into docs-audit-2
jessiemongeon1 Nov 22, 2024
6cb6fce
Update overview.mdx
jessiemongeon1 Nov 22, 2024
4d0af1c
Update overview.mdx
jessiemongeon1 Nov 22, 2024
1e2cbb7
Update overview.mdx
jessiemongeon1 Nov 22, 2024
25e4fb8
Update docs/developer-docs/smart-contracts/write/overview.mdx
jessiemongeon1 Nov 22, 2024
404cf77
Update docs/developer-docs/smart-contracts/write/overview.mdx
jessiemongeon1 Nov 22, 2024
2270aca
Update docs/developer-docs/smart-contracts/write/overview.mdx
jessiemongeon1 Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions docs/developer-docs/smart-contracts/maintain/control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,19 @@ import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";

# Control

<MarkdownChipRow labels={["Beginner", "Tutorial"]} />
<MarkdownChipRow labels={["Beginner", "Concept"]} />

## Overview

A <GlossaryTooltip>canister</GlossaryTooltip> is managed by a list of controllers. A controller is specified by a <GlossaryTooltip>principal</GlossaryTooltip>, which can be self-authenticating, e.g. a `dfx` developer identity, or another canister. Canisters can have multiple controllers where each controller has the same administrative rights, or it has no controller, in which case the canister becomes immutable, or blackholed, and cannot be upgraded or deleted.
A <GlossaryTooltip>canister</GlossaryTooltip> is managed by a list of controllers. A controller is specified by a <GlossaryTooltip>principal</GlossaryTooltip>, which can be self-authenticating, e.g. a `dfx` developer identity, or another canister. Canisters can have multiple controllers where each has the same administrative rights, or it can have no controller, in which case the canister becomes immutable (blackholed) and cannot be upgraded or deleted.

## Setting the controllers of a canister

The controllers of a canister are set when the canister is created. If no explicit controller settings are specified, the default controller is the principal that created the canister. If the canister is created with `dfx` then the default controller list contains the current developer identity.
When a canister is created, the default controller list contains the developer identity used to create the canister. Additional controllers can be specified during canister creation or they can be added in the future.

## Update the controllers of a canister
To specify controllers upon canister creation, the [`dfx canister create --controller`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-create) command can be used.

The controllers of a canister can be updated by any of the existing controllers. To update the controllers with `dfx`, the following commands can be used:

### Add a controller

```sh
dfx canister update-settings CANISTER_NAME --add-controller CONTROLLER
```

### Remove a controller

```sh
dfx canister update-settings CANISTER_NAME --remove-controller CONTROLLER
```

### Set the controller

The following command sets only the specified controller and removes all other controllers:

```sh
dfx canister update-settings CANISTER_NAME --set-controller CONTROLLER
```
To update a canister's controllers after the canister has been created, the [`dfx canister update-settings`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-update-settings) command can be used with the `--add-controller` or `--remove-controller` flag to add or remove controllers respectively.

## Actions available only to controllers

Expand All @@ -68,7 +48,7 @@ A canister that can be used for this purpose is the [Threshold canister](https:/

The [Launchtrail canister](https://github.com/spinner-cash/launchtrail) can be used to schedule the upgrade of a canister at a future time to give the public enough time to review the proposed changes. The canister also keeps a complete record of all actions and their execution results. The Launchtrail canister itself should be immutable without a controller.

### Decentralized Autonomous Organization (DAO)
### Decentralized autonomous organization (DAO)

A canister is controlled by a DAO, and all upgrades and administrative actions are decided by a vote of the DAO members. The most common DAO model for applications on the Internet Computer is the [Service Nervous System (SNS)](/docs/developer-docs/daos/sns/index.mdx).

Expand Down
36 changes: 3 additions & 33 deletions docs/developer-docs/smart-contracts/maintain/delete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,15 @@ keywords: [beginner, tutorial, maintain canisters, delete canisters, delete]
import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";


# Delete

<MarkdownChipRow labels={["Beginner", "Tutorial"]} />
<MarkdownChipRow labels={["Beginner", "Concept"]} />

## Overview

If you want to permanently delete a specific <GlossaryTooltip>canister</GlossaryTooltip> or all canisters for a specific project on a given deployment (either local or remote), you can do so by running the command:

```
dfx canister delete <canister-name> // Delete local canister
dfx canister delete <canister-name> --network ic // Delete canister on mainnet
```

Deleting a canister removes the canister identifier, code, and state. Before you can delete a canister, however, you must first stop the canister to clear any pending message requests or replies.

## Delete all canisters

To delete all canisters for a project:

- #### Step 1: Open a new terminal and navigate to your project directory.

- #### Step 2: Start the local canister execution environment, if necessary.

In most cases, this step is only necessary if you are running the canisters locally.

If you were deleting canisters to run on a remote execution environment, e.g. ICP blockchain, you would include the `--network` command-line option to perform tasks on the environment specified under this parameter.

- #### Step 3: Check the status of the project canisters running on the local canister execution environment by running the following command:

dfx canister status --all

- #### Step 4: Stop all of the project canisters by running the following command:

dfx canister stop --all

- #### Step 5: Delete all of the project canisters by running the following command:
If you want to permanently delete a specific <GlossaryTooltip>canister</GlossaryTooltip> or all canisters for a project, you can use the [`dfx canister delete`](/docs/current/developer-docs/developer-tools/cli-tools/cli-reference/dfx-canister#dfx-canister-delete) command.

dfx canister delete --all
Deleting a canister removes the canister identifier, code, and state. Before you can delete a canister, you must first stop the canister to clear any pending message requests or replies.

## Errors related to canister deletion

Expand Down
88 changes: 31 additions & 57 deletions docs/developer-docs/smart-contracts/maintain/history.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import { BetaChip } from "/src/components/Chip/BetaChip"
import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";
import { GlossaryTooltip } from "/src/components/Tooltip/GlossaryTooltip";


# History

<MarkdownChipRow labels={["Beginner", "Tutorial"]} />

## Overview

The Internet Computer tracks the history of a deployed <GlossaryTooltip>canister</GlossaryTooltip> through the canister's Wasm module hashes and controller changes. This tracking provides insight into the canister's history, such as what code has been used to run the canister, and which controller deployed that code.
The Internet Computer tracks the history of a deployed <GlossaryTooltip>canister</GlossaryTooltip> through the canister's Wasm module hashes and controller changes. This tracking provides insight into the canister's history, such as what code has been used to run the canister and which controller deployed that code.

Viewing a canister's history can be important in use cases such as:

Expand All @@ -31,8 +30,8 @@ Canister history was introduced and released by the NNS DAO proposal [122617](ht

Canister history information is made available via inter-canister calls made to the `canister_info` method of the management canister, using a canister's ID as an argument for the call. A canister's history stores the 20 most recent changes to the canister, including the canister's creation, Wasm module installations, reinstallations, upgrades, and changes to the list of canister controllers. It is important to note that since only the 20 most recent changes are stored, this feature cannot be used for auditing canisters that are frequently changed within a short period of time.

:::info
Note that canister history is only available for changes that have happened since this feature was rolled out on 023-06-05, 9:47:46 AM UTC, across all <GlossaryTooltip>subnets</GlossaryTooltip>.
:::danger
Canister history is only available for changes that have happened since this feature was rolled out on 023-06-05, 9:47:46 AM UTC, across all <GlossaryTooltip>subnets</GlossaryTooltip>.
:::

You can read more about this feature on the [developer forum](https://forum.dfinity.org/t/canister-history-on-the-ic/21745).
Expand All @@ -45,74 +44,49 @@ To get a canister's history, make a call to the IC management canister's `canist
<TabItem value="motoko" label="Motoko" default>

```motoko
actor {
let IC =
actor "aaaaa-aa" : actor {
import Principal "mo:base/Principal";

actor Info {
type canister_info_args = {
canister_id : Principal;
num_requested_changes : ?Nat64
};

type canister_info_result = {
total_num_changes : Nat64;
module_hash : ?Blob;
controllers : [Principal]
};

canister_info : { canister_id : Principal } ->
async ();
let IC = actor "aaaaa-aa" : actor {
canister_info : {canister_id : Principal} -> async canister_info_result
};

};
};
public func getInfo() : async canister_info_result {
await IC.canister_info {canister_id = Principal.fromActor(Info)}
}

}
```

</TabItem>

<TabItem value="rust" label="Rust">

```rust
use candid::{CandidType, Principal};
use ic_cdk::api::management_canister::main::{
canister_info, CanisterChange,
CanisterChangeDetails::{CodeDeployment, CodeUninstall, ControllersChange, Creation},
CanisterChangeOrigin::{FromCanister, FromUser},
CanisterInfoRequest, CanisterInfoResponse,
};
use serde::Deserialize;

/// Returns canister info with all available canister changes for a canister characterized by a given principal.
/// Traps if the canister_info management call is rejected (in particular, if the principal does not characterize a canister).
#[ic_cdk::update]
async fn info(canister_id: Principal) -> CanisterInfoResponse {
let request = CanisterInfoRequest {
canister_id,
num_requested_changes: Some(20),
};
canister_info(request).await.unwrap().0
}
```rust file=../../../references/samples/rust/canister-info/src/lib.rs
```

</TabItem>

<AdornedTab value={"typescript"} label="TypeScript" endAdornment={<BetaChip />}>

```typescript
import { call, IDL, Principal, query, update } from 'azle';
import {
CanisterInfoArgs,
CanisterInfoResult,
} from 'azle/canisters/management';

type State = {
createdCanisterId: Principal;
};

let state: State = {
createdCanisterId: Principal.fromText('aaaaa-aa')
};

export default class {
@update([CanisterInfoArgs], CanisterInfoResult)
async getCanisterInfo(args: CanisterInfoArgs): Promise<CanisterInfoResult> {
return await call('aaaaa-aa', 'canister_info', {
paramIdlTypes: [CanisterInfoArgs],
returnIdlType: CanisterInfoResult,
args: [args]
});
}
}
[Learn more about Azle](https://demergent-labs.github.io/azle/get_started.html).

```
</AdornedTab>

<AdornedTab value={"python"} label="Python" endAdornment={<BetaChip />}>

[Learn more about Kybra](https://demergent-labs.github.io/kybra/).

</AdornedTab>
</AdornedTabs>
Loading
Loading