Can I imitate the passing of time with REPL?
- gyorgybalazsiOP 3
Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
In scenarios, we have the
passfunction to imitate the passing of time.Do we have something similar which can be used in REPL?
I want to demonstrate to a client how a check result with expiry date behaves.
- cocreature 2
The latest snapshot (which will end up in 1.3.0 released next week) adds a
setTimefunction to DAML Script and therefore also DAML REPL that allows you to set the time. There is nopassfunction atm but you can easily build your own on top ofgetTimeandsetTime. - cocreature 1
Note that
setTimeonly works if your ledger is running in static time mode since the time service is not available in wallclock mode. - gyorgybalazsi
- cocreature
You have to change the version in the URL. We deliberately only list stable versions. E.g., https://docs.daml.com/1.3.0-snapshot.20200708.4686.0.95dfa18e/ for this one. Note that there are no public release notes for snapshots (but since this will be the 1.3.0 RC, you’ll get release notes for this later today).
- gyorgybalazsi
Almost there:
I have set in daml.yaml
sandbox-options: - --static-timeAfter
daml startSandbox started in static time mode:/ __/__ ____ ___/ / / ___ __ __ _\ \/ _ `/ _ \/ _ / _ \/ _ \\ \ / /___/\_,_/_//_/\_,_/_.__/\___/_\_\ INFO: Initialized sandbox version 1.3.0-snapshot.20200708.4686.0.95dfa18e with ledger-id = b9740e15-074b-4037-ab58-3b08a916f688, port = 6865, dar file = List(.daml/dist/ven-iteration-first-0.0.1.dar), time mode = static time, ledger = in-memory, auth-service = AuthServiceWildcard$, contract ids seeding = strong Waiting for navigator to start: _ __ _ __ / |/ /__ __ __(_)__ ____ _/ /____ ____ / / _ `/ |/ / / _ `/ _ `/ __/ _ \/ __/ /_/|_/\_,_/|___/_/\_, /\_,_/\__/\___/_/ /___/ Version 1.3.0-snapshot.20200708.4686.0.95dfa18e Frontend running at http://localhost:7500.But still, REPL gives an error message for
setTimelike Sandbox was running in wallclock time:daml> setTime $ time (date 2020 Jul 9) 14 00 00 java.lang.RuntimeException: setTime is not supported in wallclock mode daml> - cocreature 1
You also need to start
daml replin static time mode viadaml repl --static-time. - gyorgybalazsi 2
Perfect, thank you! REPL is another great feature which helps me to demo how a business process implementation works to domain owners.
- cocreature 1
And here’s the RC announcement that I hinted at earlier if you want the full release notes DAML SDK 1.3.0 RC is out!
