I am facing an issue where every update call to my canister gets rejected with the error:
The replica returned a rejection error: reject code CanisterReject, reject message Error from Canister avqkn-guaaa-aaaaa-qaaea-cai: Canister rejected the message, error code Some(“IC0406”)
This happens after I added an inspect_message
function to block certain method calls. Below is my implementation of inspect_message
:
#[ic_cdk::inspect_message]
fn inspect_message() {
let method_name = ic_cdk::api::call::method_name();
ic_cdk::println!("Inspecting method call: {}", method_name);
if method_name == "faucet" {
ic_cdk::println!("Execution blocked! User has reached the limit.");
ic_cdk::api::call::reject("Limit reached: Cannot click more than 5 times.");
} else {
ic_cdk::println!("Execution allowed for {}", method_name);
}
}
However, after deploying this, all update calls fail, even the ones that should be allowed. For example, calling my simple update function and other update functions as well.
#[update]
pub fn think() {
ic_cdk::println!("i think ");
}