Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
12 changes: 8 additions & 4 deletions .github/workflows/build_and_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ jobs:
name: Build and Test
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@1.85.0
with:
Expand All @@ -31,9 +30,15 @@ jobs:

- name: install ic-wasm
run: |
wget https://github.com/dfinity/ic-wasm/releases/download/0.8.1/ic-wasm-linux64 -O /usr/local/bin/ic-wasm
wget https://github.com/dfinity/ic-wasm/releases/download/0.9.3/ic-wasm-linux64 -O /usr/local/bin/ic-wasm
chmod +x /usr/local/bin/ic-wasm

- name: install candid-extractor
run: |
wget https://github.com/dfinity/cdk-rs/releases/download/candid-extractor-v0.1.4/candid-extractor-x86_64-unknown-linux-gnu.tar.gz -O /tmp/candid-extractor-x86_64-unknown-linux-gnu.tar.gz
tar -xvf /tmp/candid-extractor-x86_64-unknown-linux-gnu.tar.gz -C /usr/local/bin
chmod +x /usr/local/bin/candid-extractor

- name: check rust code style
run: |
just check_code
Expand All @@ -50,4 +55,3 @@ jobs:
run: |
sudo apt install gcc-multilib
just test_i686

3 changes: 3 additions & 0 deletions ic-canister/tests/canister-a/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "canister-a"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
6 changes: 6 additions & 0 deletions ic-canister/tests/canister-a/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ use ic_exports::candid::{CandidType, Deserialize, Principal};
use ic_storage::stable::Versioned;
use ic_storage::IcStorage;

#[ic_canister::export_candid]
pub fn idl() -> String {
let idl = CanisterAImpl::get_idl();
candid::pretty::candid::compile(&idl.env.env, &Some(idl.actor))
}

#[derive(Default, CandidType, Deserialize, IcStorage)]
pub struct StateA {
counter: u32,
Expand Down
5 changes: 0 additions & 5 deletions ic-canister/tests/canister-a/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ic-canister/tests/canister-b/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "canister-b"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
14 changes: 2 additions & 12 deletions ic-canister/tests/canister-b/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::rc::Rc;

use canister_a::{CanisterA, CanisterAImpl, StateA};
use ic_canister::{
canister_call, canister_notify, generate_idl, init, update, virtual_canister_call,
virtual_canister_notify, Canister, PreUpdate,
canister_call, canister_notify, init, update, virtual_canister_call, virtual_canister_notify,
Canister, PreUpdate,
};
use ic_exports::candid::{CandidType, Deserialize, Principal};
use ic_storage::IcStorage;
Expand Down Expand Up @@ -108,16 +108,6 @@ impl CanisterA for CanisterB {
}
}

pub fn idl() -> String {
use ic_canister::Idl;

let canister_b_idl = generate_idl!();
let mut canister_a_idl = <CanisterB as CanisterA>::get_idl();
canister_a_idl.merge(&canister_b_idl);

candid::pretty::candid::compile(&canister_a_idl.env.env, &Some(canister_a_idl.actor))
}

#[cfg(test)]
mod tests {
use ic_exports::ic_kit::mock_principals::alice;
Expand Down
3 changes: 0 additions & 3 deletions ic-canister/tests/canister-b/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ic-canister/tests/canister-c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "canister-c"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
1 change: 1 addition & 0 deletions ic-canister/tests/canister-c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl PreUpdate for CanisterC {
}
}

#[ic_canister::export_candid]
pub fn idl() -> String {
use ic_canister::Idl;

Expand Down
3 changes: 0 additions & 3 deletions ic-canister/tests/canister-c/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ic-canister/tests/canister-d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "canister-d"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
1 change: 1 addition & 0 deletions ic-canister/tests/canister-d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub trait CanisterD: Canister {

generate_exports!(CanisterD, CanisterDImpl);

#[ic_canister::export_candid]
pub fn idl() -> String {
let trait_idl = <CanisterDImpl as CanisterD>::get_idl();
candid::pretty::candid::compile(&trait_idl.env.env, &Some(trait_idl.actor))
Expand Down
3 changes: 0 additions & 3 deletions ic-canister/tests/canister-d/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ic-canister/tests/canister-e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "canister-e"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ impl CounterCanister {
generate_idl!()
}
}

#[ic_canister::export_candid]
pub fn idl() -> String {
let idl = CounterCanister::idl();

candid::pretty::candid::compile(&idl.env.env, &Some(idl.actor))
}
10 changes: 0 additions & 10 deletions ic-canister/tests/canister-e/src/main.rs

This file was deleted.

11 changes: 10 additions & 1 deletion ic-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "ic-log"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand All @@ -24,7 +27,13 @@ serde = { workspace = true }
ic-canister = { path = "../ic-canister/ic-canister" }

[features]
canister = ["export-api", "ic-canister", "ic-storage", "ic-stable-structures", "cfg-if"]
canister = [
"export-api",
"ic-canister",
"ic-storage",
"ic-stable-structures",
"cfg-if",
]
export-api = []

[[example]]
Expand Down
7 changes: 7 additions & 0 deletions ic-log/examples/log_canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ use ic_stable_structures::stable_structures::DefaultMemoryImpl;
use ic_stable_structures::{IcMemoryManager, MemoryId};
use ic_storage::IcStorage;

#[ic_canister::export_candid]
pub fn idl() -> String {
let idl = LoggerCanister::get_idl();

candid::pretty::candid::compile(&idl.env.env, &Some(idl.actor))
}

thread_local! {
static MEMORY_MANAGER: IcMemoryManager<DefaultMemoryImpl> = IcMemoryManager::init(DefaultMemoryImpl::default());
}
Expand Down
3 changes: 3 additions & 0 deletions ic-payments/test-payment-canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "test-payment-canister"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
6 changes: 5 additions & 1 deletion ic-payments/test-payment-canister/src/canister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::collections::HashMap;

use candid::Nat;
use ic_canister::{init, update, Canister, PreUpdate};
use ic_canister::{generate_idl, init, update, Canister, Idl, PreUpdate};
use ic_exports::candid::{CandidType, Deserialize, Principal};
use ic_exports::ic_kit::ic;
use ic_exports::icrc_types::icrc1::account::Account;
Expand Down Expand Up @@ -148,4 +148,8 @@ impl PaymentCanister {

(local_balance, token_canister_balance)
}

pub fn idl() -> Idl {
generate_idl!()
}
}
10 changes: 10 additions & 0 deletions ic-payments/test-payment-canister/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use canister::PaymentCanister;

pub mod canister;

#[ic_canister::export_candid]
pub fn idl() -> String {
let idl = PaymentCanister::idl();

candid::pretty::candid::compile(&idl.env.env, &Some(idl.actor))
}
4 changes: 0 additions & 4 deletions ic-payments/test-payment-canister/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ic-stable-structures/tests/dummy_canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "dummy_canister"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
10 changes: 10 additions & 0 deletions ic-stable-structures/tests/dummy_canister/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pub mod canister;

use canister::DummyCanister;

#[ic_canister::export_candid]
pub fn idl() -> String {
let canister_e_idl = DummyCanister::idl();

candid::pretty::candid::compile(&canister_e_idl.env.env, &Some(canister_e_idl.actor))
}
10 changes: 0 additions & 10 deletions ic-stable-structures/tests/dummy_canister/src/main.rs

This file was deleted.

3 changes: 3 additions & 0 deletions ic-task-scheduler/tests/dummy_scheduler_canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "dummy_scheduler_canister"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = []
export-api = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ thread_local! {

}

#[ic_canister::export_candid]
fn idl() -> String {
let canister_e_idl = DummyCanister::idl();

candid::pretty::candid::compile(&canister_e_idl.env.env, &Some(canister_e_idl.actor))
}

#[derive(CandidType, Serialize, Deserialize, Debug, Clone)]
pub enum DummyTask {
Panicking,
Expand Down
10 changes: 0 additions & 10 deletions ic-task-scheduler/tests/dummy_scheduler_canister/src/main.rs

This file was deleted.

Loading