Since queryContractId exists in both Daml.Trigger and Daml.Script, is it illegal to use it inside template choice as it won’t return the default computational context of the choice - “Update”?
The context here is trying to catch the “CONTRACT_NOT_FOUND” issue in case the ContractId (input param of a choice) is not valid. Or is there any other way to catch this error? I’ve tried catching DA.Exception.GeneralError but in vain.
No contract not found errors cannot be caught within Daml. If you want to handle that case, you need to perform on the client side before you submit your command. To guard against the contract being archived concurrently, you can retry both the client side lookup and the command submission. Assuming the only reason for the command to fail is this contract not being active eventually it will either go through or your client side lookup will fail before you do the submission and you can chose how you want to handle this.
Thanks!! May I know which GRPC API I can call for looking up the contractId?
There is no gRPC API for looking up a contract by contract id at the moment. The best option is to go through GetActiveContracts and query all contracts of a given template visible to your party and then check for the contract id in there. Ofc if you expect that to return a lot of contracts you probably want to cache that on the client side.
An endpoint to lookup contracts by contract id is currently being worked on and should be available in one of the next versions.