I can import one canister’s Actor class into another canister, but it seems I can’t call any of that imported Actor’s functions from my Actor’s functions, even if they’re query functions themselves. Shouldn’t I be allowed to call query functions from other query functions, even if they live in different Actors?
I see in the docs that “It is a compile-time error for a query method to call an actor function since this would violate dynamic restrictions imposed by the Internet Computer. Calls to ordinary functions are permitted.”
I understand why I can’t call a normal Actor function from a Query function, as that normal function might modify state and that’s not allowed from a query function. But shouldn’t I be able to safely call into other Actors’ query functions, since those also can’t modify state?
Here’s an example that I think should work just fine:
src/database/main.mo:
actor {
public query func query_something() : async Text {
return "Something";
};
};
src/app/main.mo:
import Database "canister:database";
actor {
public query func get_data() : async Text {
return Database.query_something();
}
};
The build error I get says type error, send capability required, but not available (need an enclosing async expression or function body)
I’m not sure what “send capability” means. I tried adding await
to the Database.query_something()
call (the line producing the above error), but that just results in type error, misplaced await
.
I’m at a loss. I have an Actor that I’m using as a sort of database and I would like to be able to quickly (and non-trustworthily) pull data out of it into another Actor for processing and, eventually, display.