Automation with Daml Triggers full code

good day
I want to run Automation with Daml Triggers tutorial in my local machine
is there a way to get the full code of Automation with Daml Triggers tutorial full code??

1 Like

Hi, can you please post in the actual document reference link that you are using? I can then take a look and see if we can address your question.

1 Like

yes, the code of this sample


best regards

1 Like

Thanks, give me 20 minutes. I am doing something ITRW now :grinning:

1 Like

OK, now I understand: You are looking for the code that underpins the online IDE & Tooling for this module?

Some of the community experts (@cocreature @Gary_Verhaegen) might be able to help. The Trigger code and in particular that example (Wine Shop) is very interesting.

Edit: @nemanja and the Developer Relations team have upgraded the tutorials, the code is actually visible as a Copy&Paste if you start the actual Scenario. See below :point_down:t2:

Trigger_Tutorial/Market.daml

module Market where

import DA.Date

template User
with
party : Party
where
signatory party
key party : Party
maintainer key

nonconsuming choice NewSellOffer : ()
  with
    observers : [Party]
    title : Text
    description : Text
    price : Int
  controller party
    do
      now <- getTime
      create $ SellOffer {seller = party, date = toDateUTC now, ..}
      pure ()

nonconsuming choice TakeSellOffer : ()
  with
    offer : ContractId SellOffer
  controller party
    do
      exercise offer DoTrade with tradePartner = party
      pure ()

nonconsuming choice ConfirmPayment : ()
  with
    invoice : ContractId Invoice
  controller party
    do
      Invoice{..} <- fetch invoice
      assert $ owner == party
      create $ PaymentConfirmation
                  with
                    invoice = invoice
                    party = party
                    obligor = obligor
      pure ()

template SellOffer
with
observers : [Party]
title : Text
description : Text
price : Int
seller : Party
date : Date
where
signatory seller
observer observers

nonconsuming choice DoTrade : ()
  with
    tradePartner : Party
  controller tradePartner
    do
      assert $ tradePartner `elem` observers
      archive self
      create $ Invoice {owner = seller, obligor = tradePartner, amount = price, description = title}
      pure ()

template Invoice
with
owner : Party
obligor : Party
amount : Int
description : Text
where
signatory obligor
observer owner

template PaymentConfirmation
with
invoice : ContractId Invoice
party : Party
obligor : Party
where
signatory party
observer obligor

nonconsuming choice ArchiveInvoice : ()
  controller obligor
  do
    archive invoice
    archive self

OK, now I understand: You are looking for the code that underpins the online IDE & Tooling for this module?

yes this is correct, DAML code is not a problem, but it would be great if you can share the UI frontend.

Ah, the UI front end, sorry I cannot help you with that.

@cocreature ?

2 Likes

You should be able to download the full example from https://github.com/digital-asset/daml-katacoda/raw/master/triggers/writing-triggers/assets/market.tar.gz

4 Likes

OK, as thought, it was there somewhere. Thank you @cocreature

1 Like

thanks @quidagis and @cocreature :smiley:

1 Like