-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When an actor is passed as a part of a struct, it isn't an Actor
instance
#775
Comments
This is working as expected. Here is the did file from the Motoko code:
|
But it should be an Actor instance. This is what I ask in my bug report. |
You can construct an Actor from the principal, but it's current not done automatically. It can be a feature request, but it's not a bug, the current format is specified in the doc. |
No, Moreover, public query func getRootItem(): async ?(CanDBPartition.CanDBPartition, Nat) {
rootItem;
}; (here main.getRootItem().then((data) => {
}) crashed with the browser console message |
The reverse case of passing an actor as an argument does work, but its value needs to be converted into a principal before passing. This seems to work: actor class canvalue_backend() = this {
public query func test(value: canvalue_backend) : async () {
};
}; import { Actor } from "@dfinity/agent";
import { canvalue_backend } from "../../declarations/canvalue_backend";
await canvalue_backend.test(Actor.canisterIdOf(canvalue_backend)); A bad thing here is that if we allow (as it would be in an ideal world) passing directly an actor, this would create past compatibility problems (that however can be solved by expecting |
|
Describe the bug
When an actor is passed as a part of a struct, it isn't an
Actor
instance (but should be).To Reproduce
Create a Motoko and a JavaScript file (this repo):
Motoko:
TypeScript:
Error:
Generate:
Inspect the TypeScript code
src/canvalue_frontend/src/index.ts
in a text editor (such as MS Code) capable to spot TypeScript type errors.Expected behavior
ac
should be an instance ofActor
.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: