How have the codegen'd clients changed to support the SCU feature?

The Smart Contract Upgrades feature means that I can interact with the ledger using “package names” instead of “package ids.” What does that look like in the codegen’d client code?

The codegen’d client code defaults to using the package name instead of the package id.

The easiest way to see this is as follows:

  1. Create a new project.
DAML_SDK_VERSION=2.10.0 daml new codegend

cd codegend

git init
  1. Edit the daml.yaml file to use daml-script-lts:
sdk-version: 2.10.0
name: codegend
source: daml
init-script: Main:setup
version: 0.0.1
dependencies:
  - daml-prim
  - daml-stdlib
  - daml-script-lts
  1. Build, codegen, and commit with --target=1.15:
daml build --target=1.15

daml codegen js -o js/ .daml/dist/codegend-0.0.1.dar

daml codegen java -o java/ .daml/dist/codegend-0.0.1.dar

git add .

git commit -m "for target 1.15"
  1. Build, codegen, and diff with --target=1.17:
rm -rf js

rm -rf java

daml build --target=1.17

daml codegen js -o js/ .daml/dist/codegend-0.0.1.dar

daml codegen java -o java/ .daml/dist/codegend-0.0.1.dar

git diff

You will see that with --target=1.17, the codegen client code defaults to using the package name instead of the package id.

TypeScript example:

Java example:

2 Likes