Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ens/dfx-core-0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity committed Jan 22, 2025
2 parents b121b04 + 2b33821 commit 1fca6ec
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

### fix: correctly detects hyphenated Rust bin crates

### fix: removes unnecessary tsc step in sveltekit build script

### feat!: `dfx info pocketic-config-port`
Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ license = "Apache-2.0"
candid = "0.10.11"
candid_parser = "0.1.4"
dfx-core = { path = "src/dfx-core", version = "0.1.0" }
ic-agent = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "0a51f2a65dde7d9e1790c378bd60e1768e3be257" }
ic-agent = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "a96022bd185e97f52c5cde1c82c7592abddcff86" }
ic-asset = { path = "src/canisters/frontend/ic-asset", version = "0.21.0" }
ic-cdk = "0.13.1"
ic-identity-hsm = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "0a51f2a65dde7d9e1790c378bd60e1768e3be257" }
ic-utils = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "0a51f2a65dde7d9e1790c378bd60e1768e3be257" }
ic-identity-hsm = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "a96022bd185e97f52c5cde1c82c7592abddcff86" }
ic-utils = { version = "0.39", git = "https://github.com/dfinity/agent-rs", rev = "a96022bd185e97f52c5cde1c82c7592abddcff86" }

aes-gcm = "0.10.3"
anyhow = "1.0.56"
Expand Down
3 changes: 3 additions & 0 deletions e2e/assets/hyphenated-project/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["hyphenated-lib", "hyphenated-bin"]
15 changes: 15 additions & 0 deletions e2e/assets/hyphenated-project/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1,
"canisters": {
"hyphenated-bin": {
"type": "rust",
"candid": "name.did",
"package": "hyphenated-bin"
},
"hyphenated-lib": {
"type": "rust",
"candid": "name.did",
"package": "hyphenated-lib"
}
}
}
8 changes: 8 additions & 0 deletions e2e/assets/hyphenated-project/hyphenated-bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "hyphenated-bin"
version = "0.0.0"
publish = false

[dependencies]
ic-cdk = "0.17"
candid = "0.10"
6 changes: 6 additions & 0 deletions e2e/assets/hyphenated-project/hyphenated-bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![no_main]

#[ic_cdk::query]
fn name() -> String {
"bin".into()
}
11 changes: 11 additions & 0 deletions e2e/assets/hyphenated-project/hyphenated-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "hyphenated-lib"
version = "0.0.0"
publish = false

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

[dependencies]
ic-cdk = "0.17"
candid = "0.10"
4 changes: 4 additions & 0 deletions e2e/assets/hyphenated-project/hyphenated-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[ic_cdk::query]
fn name() -> String {
"lib".into()
}
3 changes: 3 additions & 0 deletions e2e/assets/hyphenated-project/name.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service : {
name : () -> (text) query;
}
11 changes: 11 additions & 0 deletions e2e/tests-dfx/deploy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,14 @@ teardown() {
assert_command_fail dfx deploy --mode reinstall --wasm-memory-persistence keep
assert_contains "--skip-pre-upgrade and --wasm-memory-persistence can only be used with mode 'upgrade' or 'auto'."
}

@test "can deploy a hyphenated project" {
setup_rust
install_asset hyphenated-project
dfx_start
assert_command dfx deploy
assert_command dfx canister call hyphenated-bin name
assert_contains bin
assert_command dfx canister call hyphenated-lib name
assert_contains lib
}
1 change: 1 addition & 0 deletions src/dfx/src/commands/canister/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ pub fn get_effective_canister_id(
}
MgmtMethod::StartCanister
| MgmtMethod::StopCanister
| MgmtMethod::CanisterInfo
| MgmtMethod::CanisterStatus
| MgmtMethod::DeleteCanister
| MgmtMethod::DepositCycles
Expand Down
6 changes: 5 additions & 1 deletion src/dfx/src/lib/canister_info/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ impl CanisterInfoFactory for RustCanisterInfo {
"More than one bin/cdylib {phrasing} found"
);

let wasm_name = target.name.replace('-', "_");
let wasm_name = if target.kind.iter().any(|t| t == "bin") {
target.name.clone()
} else {
target.name.replace('-', "_")
};
let output_wasm_path = metadata
.target_directory
.join(format!("wasm32-unknown-unknown/release/{wasm_name}.wasm"))
Expand Down

0 comments on commit 1fca6ec

Please sign in to comment.