Skip to content

Commit

Permalink
Merge branch 'main' into bindgen_next
Browse files Browse the repository at this point in the history
  • Loading branch information
lwshang committed Jul 22, 2024
2 parents c29bc3e + 5ae0552 commit bd8ab61
Show file tree
Hide file tree
Showing 22 changed files with 260 additions and 328 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ opt-level = 'z'

[workspace.dependencies]
ic0 = { path = "src/ic0", version = "0.23.0" }
ic-cdk = { path = "src/ic-cdk", version = "0.14.0"}
ic-cdk-timers = { path = "src/ic-cdk-timers", version = "0.8.0" }
ic-cdk = { path = "src/ic-cdk", version = "0.15.0" }
ic-cdk-timers = { path = "src/ic-cdk-timers", version = "0.9.0" }

candid = "0.10.4"
candid_parser = "0.1.4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ In Cargo.toml:
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.12"
ic-cdk = "0.15"
# Only necessary if you want to define Candid data types
candid = "0.10"
```
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/canisters/canister_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async fn canister_lifecycle() -> Principal {
memory_allocation: None,
freezing_threshold: None,
reserved_cycles_limit: None,
log_visibility: None,
wasm_memory_limit: None,
},
canister_id: canister_id.canister_id,
Expand Down
7 changes: 7 additions & 0 deletions e2e-tests/canisters/management_caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mod main {
memory_allocation: Some(10000u16.into()),
freezing_threshold: Some(u64::MAX.into()),
reserved_cycles_limit: Some(u128::MAX.into()),
log_visibility: Some(LogVisibility::Public),
wasm_memory_limit: Some((2u64.pow(48) - 1).into()),
}),
};
Expand All @@ -37,6 +38,10 @@ mod main {
assert_eq!(definite_canister_setting.memory_allocation, 10000u16);
assert_eq!(definite_canister_setting.freezing_threshold, u64::MAX);
assert_eq!(definite_canister_setting.reserved_cycles_limit, u128::MAX);
assert_eq!(
definite_canister_setting.log_visibility,
LogVisibility::Public
);
assert_eq!(
definite_canister_setting.wasm_memory_limit,
2u64.pow(48) - 1
Expand Down Expand Up @@ -72,6 +77,7 @@ mod main {

mod provisional {
use super::*;
use api::management_canister::main::LogVisibility;
use ic_cdk::api::management_canister::provisional::*;

#[update]
Expand All @@ -82,6 +88,7 @@ mod provisional {
memory_allocation: Some(10000u16.into()),
freezing_threshold: Some(10000u16.into()),
reserved_cycles_limit: Some(10000u16.into()),
log_visibility: Some(LogVisibility::Public),
wasm_memory_limit: Some(10000u16.into()),
};
let arg = ProvisionalCreateCanisterWithCyclesArgument {
Expand Down
6 changes: 6 additions & 0 deletions library/ic-ledger-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.12.0] - 2024-07-01

### Changed

- Upgrade `ic-cdk` to v0.15.

## [0.11.0] - 2024-05-17

### Changed
Expand Down
2 changes: 1 addition & 1 deletion library/ic-ledger-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-ledger-types"
version = "0.11.0"
version = "0.12.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions src/ic-cdk-bindgen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

- Support canister setting `log_visibility`.

### Changed

- Refactor!: move Rust code generation logic from candid_parser. (#480)
Expand Down
4 changes: 4 additions & 0 deletions src/ic-cdk-macros/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Fixed

- `cargo build` should no longer give a confusing linkage error on Linux.

## [0.13.2] - 2024-04-08

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/ic-cdk-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-cdk-macros"
version = "0.14.0" # sync with ic-cdk
version = "0.15.0" # sync with ic-cdk
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
25 changes: 17 additions & 8 deletions src/ic-cdk-macros/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ fn dfn_macro(
}
format!("canister_{method} {function_name}")
};
let host_compatible_name = export_name.replace(' ', ".").replace(['-', '<', '>'], "_");

let function_call = if is_async {
quote! { #name ( #(#arg_tuple),* ) .await }
Expand Down Expand Up @@ -256,7 +257,8 @@ fn dfn_macro(
};

Ok(quote! {
#[export_name = #export_name]
#[cfg_attr(target_family = "wasm", export_name = #export_name)]
#[cfg_attr(not(target_family = "wasm"), export_name = #host_compatible_name)]
fn #outer_function_ident() {
ic_cdk::setup();

Expand Down Expand Up @@ -327,7 +329,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down Expand Up @@ -369,7 +372,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down Expand Up @@ -412,7 +416,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down Expand Up @@ -455,7 +460,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down Expand Up @@ -498,7 +504,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down Expand Up @@ -541,7 +548,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down Expand Up @@ -584,7 +592,8 @@ mod test {
};

let expected = quote! {
#[export_name = "canister_query custom_query"]
#[cfg_attr(target_family = "wasm", export_name = "canister_query custom_query")]
#[cfg_attr(not(target_family = "wasm"), export_name = "canister_query.custom_query")]
fn #fn_name() {
ic_cdk::setup();
ic_cdk::spawn(async {
Expand Down
6 changes: 6 additions & 0 deletions src/ic-cdk-timers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.9.0] - 2024-07-01

### Changed

- Upgrade `ic-cdk` to v0.15.

## [0.8.0] - 2024-05-17

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/ic-cdk-timers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-cdk-timers"
version = "0.8.0"
version = "0.9.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/ic-cdk-timers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In `Cargo.toml`:

```toml
[dependencies]
ic-cdk-timers = "0.4.0"
ic-cdk-timers = "0.9.0"
```

To schedule a one-shot task to be executed 1s later:
Expand Down
15 changes: 12 additions & 3 deletions src/ic-cdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.15.0] - 2024-07-01

### Changed

- BREAKING: Stable Memory always use 64-bit addresses and `stable64_*` system API. (#498)
- BREAKING: Add `log_visibility` to the management canister API types: (#497)
- `CanisterSettings`
- `DefiniteCanisterSettings`.

## [0.14.0] - 2024-05-17
## [0.13.3] - 2024-05-10 (yanked)

### Added

- Add `wasm_memory_limit` to the management canister API types: (#483)
* `CanisterSettings`
* `DefiniteCanisterSettings`.
- Provide safe wrapper of `in_replicated_execution` in ic-cdk. (#489)

### Changed

- Upgrade `ic0` to v0.23.0. (#489)
- BREAKING: Add `wasm_memory_limit` to the management canister API types: (#483)
- `CanisterSettings`
- `DefiniteCanisterSettings`.

## [0.13.2] - 2024-04-08

Expand Down
4 changes: 2 additions & 2 deletions src/ic-cdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-cdk"
version = "0.14.0" # sync with ic-cdk-macros
version = "0.15.0" # sync with ic-cdk-macros
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -27,7 +27,7 @@ ic0.workspace = true
# Dependents won't accidentaly upgrading ic-cdk-macros only but not ic-cdk.
# ic-cdk-macros is a hidden dependency, re-exported by ic-cdk.
# It should not be included by users direcly.
ic-cdk-macros = { path = "../ic-cdk-macros", version = "=0.14.0" }
ic-cdk-macros = { path = "../ic-cdk-macros", version = "=0.15.0" }
serde.workspace = true
serde_bytes.workspace = true
slotmap = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/ic-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ In Cargo.toml:
crate-type = ["cdylib"]

[dependencies]
ic-cdk = "0.12"
ic-cdk = "0.15"
# Only necessary if you want to define Candid data types
candid = "0.10"
```
Expand Down
20 changes: 20 additions & 0 deletions src/ic-cdk/src/api/management_canister/main/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ use serde::{Deserialize, Serialize};
/// Canister ID is Principal.
pub type CanisterId = Principal;

/// todo
#[derive(
CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default,
)]
pub enum LogVisibility {
#[default]
#[serde(rename = "controllers")]
/// Only controllers of the canister can access the logs.
Controllers,
#[serde(rename = "public")]
/// Everyone is allowed to access the canister's logs.
Public,
}

/// Canister settings.
///
/// The settings are optional. If they are not explicitly set, the default values will be applied automatically.
Expand Down Expand Up @@ -52,6 +66,10 @@ pub struct CanisterSettings {
///
/// Default value: 5_000_000_000_000 (5 trillion cycles).
pub reserved_cycles_limit: Option<Nat>,
/// Defines who is allowed to read the canister's logs.
///
/// Default value: Controllers
pub log_visibility: Option<LogVisibility>,
/// Must be a number between 0 and 2<sup>48</sup>-1 (i.e 256TB), inclusively.
///
/// It indicates the upper limit on the WASM heap memory consumption of the canister.
Expand Down Expand Up @@ -317,6 +335,8 @@ pub struct DefiniteCanisterSettings {
pub freezing_threshold: Nat,
/// Reserved cycles limit.
pub reserved_cycles_limit: Nat,
/// Visibility of canister logs.
pub log_visibility: LogVisibility,
/// The Wasm memory limit.
pub wasm_memory_limit: Nat,
}
Expand Down
Loading

0 comments on commit bd8ab61

Please sign in to comment.