You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem statement: The interpreter determines the caller incorrectly if the call is made not from the actor directly, but inside the object that the actor uses. In a call made from an object, the caller is always ID:0
Command used: moc -r
Motoko version: 0.11.1
Code:
import Debug "mo:base/Debug";
import Principal "mo:base/Principal";
import Text "mo:base/Text";
actor exampleActor {
public shared (msg) func printCaller() : async () {
Debug.print("caller: " # debug_show Text.decodeUtf8(Principal.toBlob(msg.caller)));
};
};
class ExampleClass() {
public func exampleMethod() : async* () {
await exampleActor.printCaller();
};
};
actor agent = {
public func test() : async () {
let example : ExampleClass = ExampleClass();
let agentPrincipal = Principal.fromActor(agent);
Debug.print("agent: " # debug_show Text.decodeUtf8(Principal.toBlob(agentPrincipal)));
await exampleActor.printCaller();
await* example.exampleMethod();
};
};
await agent.test();
Actual output:
agent: ?"ID:2"
caller: ?"ID:2"
caller: ?"ID:0"
Expected output:
agent: ?"ID:2"
caller: ?"ID:2"
caller: ?"ID:2"
The text was updated successfully, but these errors were encountered:
Yeah, that looks like a bug. Thanks for reporting it! I would regard this as low priority, since the IC doesn't support multiple actors in the same canister.
Problem statement: The interpreter determines the caller incorrectly if the call is made not from the actor directly, but inside the object that the actor uses. In a call made from an object, the caller is always ID:0
Command used:
moc -r
Motoko version: 0.11.1
Code:
Actual output:
Expected output:
The text was updated successfully, but these errors were encountered: