Interacting with Governance canister

I’m trying to interact with the governance canister, I tried doing it locally but it seems to be quite complex so I decided to use Motoko Playground, problem is when I import the canister I get this error:

file idl/rrkah-fqaaa-aaaaa-aaaaq-cai.did uses Candid types without corresponding Motoko type

More specically caused by these lines:

Error in file Main.mo:0:0 file idl/rrkah-fqaaa-aaaaa-aaaaq-cai.did uses Candid types without corresponding Motoko type
Error in file rrkah-fqaaa-aaaaa-aaaaq-cai.did:326:10 cannot import a Candid service constructor

Am i doing something wrong? Ledger canister works just fine.

It was fixed a few weeks ago. Maybe try to refresh the browser?

Trust me I refreshed the browser plenty of times, maybe Motoko Playground runs on an outdated version?

Fixed now. I was fixing the ledger canister, not the NNS :sweat_smile:

That’s great! Just tested it and it works.

I also have another question, while trying to bypass this issue, I found another solution but at times the Playground gets stuck on “Compiling Code”, this code for example causes it to get stuck:

public func getProposals(): async [GT.ProposalInfo] {
let proposals = await Governance.get_pending_proposals();
return proposals;
};

public type ProposalInfo = {
id : ?NeuronId;
status : Int32;
topic : Int32;
failure_reason : ?GovernanceError;
ballots : [(Nat64, Ballot)];
proposal_timestamp_seconds : Nat64;
reward_event_round : Nat64;
deadline_timestamp_seconds : ?Nat64;
failed_timestamp_seconds : Nat64;
reject_cost_e8s : Nat64;
latest_tally : ?Tally;
reward_status : Int32;
decided_timestamp_seconds : Nat64;
proposal : ?Proposal;
proposer : ?NeuronId;
executed_timestamp_seconds : Nat64;
};

Does it have to do with Optional types?

If you look at the console log, there is a stack overflow error from the moc.js compiler. It is a usual problem when converting an OCaml program to JS. I will try to minimize the example and see if we can fix it. You won’t see this error if you are running the compiler locally.

I actually expect this kind of errors to come up more often. But this is the first time I see it happen :slight_smile:

I understand, I can send you the project link if you want. Should save you some time.

I’m quite enjoying the Playground btw, only things I’d add are dark mode, a way to delete files/folders and save to device option. Other than that its already more advanced than dfx, errors look nicer when they work and the import canister/bindings functionality is quite nice. Thinking about it I’d be nice to wrap it in Electron and ship it with an integrated dfx so we could choose if we want to run stuff on locally or on mainnet easily, the current VS code DX for IC and Motoko specifically is quite lacking.