Skip to content
CCPEDIAby Unity Nodes
App Development

React - try catch of ledger.exercise issue

18 posts790 views2 likesLast activity Jul 2020

  1. alexanderOP

    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

  2. cocreature

    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.

  3. alexander

    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:

  4. alexander

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

  5. cocreature

    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.

  6. alexander

    Okay let me try to follow your suggestion right now.

  7. alexander

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

  8. cocreature

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

  9. alexander

    Not available at the moment.

  10. cocreature

    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.

  11. alexander

    I always get errors. And version of SDK is 1.1.1

  12. cocreature 1

    Have you tried upgrading to 1.2.0?

  13. alexander

    I didn’t test it with 1.2.0

  14. alexander

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

  15. Gary_Verhaegen

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

  16. alexander

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

  17. Gary_Verhaegen

    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.

  18. alexander 1

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