React - try catch of ledger.exercise issue

Hi, I’ve met some strange issue.

Here is my code snippet;
try {
await ledger.exercise(Main.Network.InviteCitizen, contractId, { … } )
} catch (error) {
console.log("error: " + error);
}

Issue is it always takes to catch with error. In my opinions, it happens because of error in ledger.exercise func. It says “Error: Trying to look up template 92332076d3b238b61e42ee43f7a2dc113348507827f7f86a6102e8013b5f247d:Main:CitizenInvitation.”

It’s very urgent and pls help me asap.

Thanks,
Alexander

Hi @alexander,

That usually arises if your codegen ends up in an inconsistent state somehow.
Take a look at my explanation at Warning message in JSON-API " Illegal header: Illegal 'origin' header: Illegal origin: Invalid input '/" and in particular the link to the steps in Daml-ui-template React function and Action with 2 arguments that should hopefully resolve your issue.

Hi, @cocreature Thanks for your fast response.

Actually I already tried as you mentioned in other ticket but it didn’t solve current issue :frowning:

Of course Warning message in JSON-API it’s related to current issue i think also.

The JSON-API warning is unrelated and only a warning (for now, it will turn into an error in future SDK version).
Did you see the suggestion to delete the yarn.lock as well at Daml-ui-template React function and Action with 2 arguments? Note that you should do that before running the other steps.

Okay let me try to follow your suggestion right now.

Still same. I removed yarn.lock & node_modules & yarn install with out any parameters but still same issue :frowning:

Not quite sure what could be going wrong there. Is your project available publicly somewhere?

Not available at the moment.

Which SDK version are you using and have you upgraded from a previous version or is this a fresh project? Also did it work at some point and things broke or did you always get this error.

I always get errors. And version of SDK is 1.1.1

Have you tried upgrading to 1.2.0?

1 Like

I didn’t test it with 1.2.0

What is the function of daml codegen js -o daml2js daml/model/.daml/dist/*.dar?

It generates JS/TS files in the folder daml2js based on the types defines in the DAR file daml/model/.daml/dist/*.dar.

Where is daml/model located ? I am on ubuntu at the moment.

If you do not have a daml/model folder in your current working directory, there is little chance of that command working. Where did you get the command from? In general, you can expect the .daml/dist folder to be created by the daml build command in the same folder where your daml.yaml file is.

After upgraded version, it’s fixed. Thanks :slight_smile:

1 Like