Is there a way of making a catch-all canister method? For example
/// Handles any update call, regardless of function name
#[update]
async fn __catchall(method_name: &str, args: CandidArgs) -> CandidArgs {
println!("User called method '{method_name}'");
}
The use case is a proxy canister, that takes any update call and passes it on to another canister and returns the response the selfsame way, without having to know all the methods on the upstream canister.
Sorry, there’s no way to do that with the current setup. The interface to a canister must be declared in the Wasm module, so you couldn’t have a “generic” proxy that works for any interface.
However, it would be possible to make a rust macro which takes the desired candid interface as an argument (or reads it from a file) and generates the desired proxy canister for that interface. Think that could work for you?
Thank you. Sorry it took me a while to get back. We changed the strategy as it looked as if a generic proxy wasn’t going to solve our problems anyway.