Team,
I want to set a default time while bringing up sandbox in --static-time mode
and there after trigger time change using http-json
service . Is it possible?
I don’t see any documentation around this.
Please suggest any other way of easily switching b/w time in development mode.
You cannot set the time via the JSON API at this point. There are a few other options:
- Navigator allows you to change the time via the drop down at the top right.
- Daml script and Daml repl provide
setTime
to change the time. - You can access the gRPC API directly, e.g., via grpcurl
grpcurl -plaintext -d '{"ledger_id": "yourledgeridhere", "currentTime": "1970-01-01T00:00:00Z", "newTime": "2000-01-01T00:00:00Z"}' localhost:6865 com.daml.ledger.api.v1.testing.TimeService/SetTime
Oh Understood. Thanks @cocreature for quick turnaround.
Please find my responses below.
- Navigator allows you to change the time via the drop down at the top right.
[True, but the date in navigator is not so intuitive, ex : If i want to set the date to 2021 , I cannot select dates from the date picker… Will have to click the next button those many times…]
- Daml script and Daml repl provide
setTime
to change the time.
Do we need to start the sandbox with script for it. ? Can you please point me to an example where i have a sandbox running already and using
Daml Repl
i can just dosetTime
- You can access the gRPC API directly, e.g., via grpcurl .
Understood. Do we have any documentation around this ?
I believe if HTTP-JSON service has this capability , it would really be a great feature for internal development/testing. Let me know if we already have any plan to build this?
- Daml Repl accepts the host and port to connect to an existing ledger. It doesn’t matter how you started the ledger as long as it’s running in static time. Here is an example
daml repl --static-time --ledger-host localhost --ledger-port 6865
daml> import DA.Time
daml> import DA.Date
daml> setTime (time (date 2021 Sep 20) 1 2 3)
- You can find the generated docs for the gRPC service at Ledger API Reference — Daml SDK 1.16.0 documentation. We don’t have specific docs for
grpcurl
, I recommend looking at the upstream readme for that.