Unhandled Rejection (Error): Trying to look up template

Hi,

I am using the updated daml-ui-template for our internal project and running into following issue.

Model

template BuyerInvitation
   with 
        buyer : Party 
        operator : Party
where 
        signatory operator
        controller buyer can 
          AcceptBuyerInvitation : ContractId BuyerRole 
            do 
              create UserRole with userParty = buyer, role = "BUYER"
              create BuyerRole with buyer, operator  

UI : js code

export default function Report() {

  const ledger = useLedger();
  const assets = useStreamQuery(Main.BuyerInvitation);
  const exerciseInvite = function(cid) {
    ledger.exercise(Main.BuyerInvitation.AcceptBuyerInvitation, cid, {  });
  };

  return (
    <>
      <Contracts
        contracts={assets.contracts}
        columns={[
          ["ContractId", "contractId"],
          ["User", "payload.buyer"],
        ]}
        actions={[["Accept", (c) => { exerciseInvite(c.contractId); }]]}
      />
    </>
  );
}	

Behaviour

Site shows the page correctly with the default Accept button.

On clicking it, the Ledger gets updated, but then the browser shows the error page

Unhandled Rejection (Error): Trying to look up template a7830cfe0a3c035aa616b1a12e4e6722b90725815a4bfa253974a716dace1644:Main:BuyerInvitation.
▼ 2 stack frames were expanded.
push.../node_modules/@daml/ledger/node_modules/@daml/types/index.js.exports.lookupTemplate
C:/Work/DigitalAsset/POC/node_modules/@daml/ledger/node_modules/@daml/types/index.js:30
(anonymous function)
C:/Work/DigitalAsset/POC/node_modules/@daml/ledger/index.js:96
▲ 2 stack frames were expanded.
(anonymous function)
C:/Work/DigitalAsset/POC/src/decoder.ts:795
  792 |  */
  793 | andThen = <B>(f: (value: A) => Decoder<B>): Decoder<B> =>
  794 |   new Decoder<B>((json: unknown) =>
> 795 |     Result.andThen(value => f(value).decode(json), this.decode(json))
      | ^  796 |   );
  797 | 
  798 | /**
View compiled

Any ideas on what the issue might be?

1 Like

We’ve encountered this a couple of times before. It usually means that your node_modules dependencies got messed up. See if the solution in this thread helps to resolve your issue. If not, try deleting the yarn.lock file and repeat the steps mentioned in the linked thread.

2 Likes

Ok will try. Thanks greg…

1 Like

No luck, get the same errors on UI :slightly_frowning_face:

Have you deleted all node_modules directories, the yarn.lock as well as the generated code dir? Doing a full clean of these should definitely resolve this. Ah, and check that you have the right versions of the DAML libs in your package.json, eg 1.1.1 if you’re on that SDK version

2 Likes

Hey @Arvind_Rao was wondering if @georg’s answer above solved your issue and if it did can you mark it as solved?

If not can you let us know if you fixed your issue and how?

I was experiencing the same problem too but followed @georg advice tips which fixed the issue for me so far.

Ensuring the package.json version for all daml libs is the same as what you use in your daml.yaml config is what made it work for me. Easy to forget about that bit when you use create-daml-app skeleton to get going fast :slight_smile:

3 Likes

BTW, welcome @matt in the community!

1 Like