Skip to content
Discussions/App Development/Automation with Daml Triggers full codeForum ↗

Automation with Daml Triggers full code

App Development10 posts307 views12 likesLast activity Jun 2021
LI
lisandro_iraguenOP
Jun 2021

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??

QU
quidagis
Jun 2021

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.

LI
lisandro_iraguen
Jun 2021

yes, the code of this sample


best regards

QU
quidagis
Jun 2021

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

QU
quidagis
Jun 2021

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
LI
lisandro_iraguen
Jun 2021

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.

QU
quidagis
Jun 2021

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

@cocreature ?

CO
cocreature
Jun 2021

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

QU
quidagis
Jun 2021

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

LI
lisandro_iraguen
Jun 2021

thanks @quidagis and @cocreature :smiley:

← Back to Discussions