Candid's export_service macro doesn't read method names provided to ic_cdk_macros::query.
In this example we write a function in rust called rust_method
and then expose it to the IC as candid_method
.
#[candid::candid_method(query)]
#[ic_cdk_macros::query(name = "candid_method")]
pub fn rust_method() -> bool {
true
}
Calling the export_service
macro should generate a candid file where the method is named candid_method
.
Calling the export_service
macro generates a candid file where the method is named rust_method
.
- Start the replica:
dfx start --background
- Deploy the canister:
dfx deploy
- Verify the method is callable as "candid_method":
dfx canister call backend candid_method
- Generate the candid file using the export service:
node generate_candid_file.js
- Note that src/backend/canister.did now lists
rust_method
instead ofcandid_method
. - Try to call the canister with "rust_method" as the candid indicates:
dfx canister call backend rust_method
- Note that the canister has no query method "rust_method"
Note The checked-in version of src/backend/canister.did is the expected output, not what is actually generated by the export service.