shared(installer) actor class canister() = this{
public query func test() : async Text{
"test canister"
};
};
test.mo :
private type interface = actor{
test : query() -> async Text;
};
public shared func test() : async (){
let canister = await Canister.canister();
let principal = Principal.fromActor(canister);
let text = Principal.toText(principal);
let c = actor text : interface;
}
The code of test.mo is wrong at :
let c = actor text : interface;
How can I call a canister from canisterโs principal in a canister ?
&
other use case of โthisโ beside :
shared(installer) actor class canister() = this { ยทยทยทยทยทยท };
ยทยทยท
Principal.fromActor(this)
ยทยทยท
shared(installer) actor class canister() = this{
public query(msg) func test() : async Text{
"test canister"
};
};
main.mo
import Debug "mo:base/Debug";
import Principal "mo:base/Principal";
import c "canister";
actor {
private type testCanister = actor{
test : query() -> async Text;
};
public func test() : async (){
var canister = await c.canister();
var principal = Principal.fromActor(canister);
var text = Principal.toText(principal);
let canister_ = actor (text) : testCanister;
Debug.print(await canister_.test())
};
};
I am guessing we have to define the type otherwise we get type error [M0058], no type can be inferred for actor reference. Edit. Yup that seems to be the case.