-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEscrow.daml
More file actions
68 lines (59 loc) · 1.57 KB
/
Escrow.daml
File metadata and controls
68 lines (59 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module Escrow where
import Daml.Finance.Interface.Holding.V4.Holding qualified as Holding (I)
import Daml.Finance.Interface.Types.Common.V3.Types (AccountKey, InstrumentKey)
import Holding.Transfer (splitAndTransfer)
template EscrowProposal
with
buyer : Party
seller : Party
arbiter : Party
bank : Party
instrumentKey : InstrumentKey
amount : Decimal
buyerAccount : AccountKey
sellerAccount : AccountKey
escrowAccount : AccountKey
description : Text
where
signatory buyer
observer seller, bank, arbiter
ensure amount > 0.0
choice Accept : ContractId Escrow
with
holdingCid : ContractId Holding.I
controller seller, bank
do
escrowHoldingCid <- splitAndTransfer [buyer, bank] escrowAccount amount holdingCid
create Escrow with
buyer
seller
arbiter
bank
instrumentKey
amount
sellerAccount
escrowAccount
escrowHoldingCid
description
choice Cancel : ()
controller buyer
do pure ()
template Escrow
with
buyer : Party
seller : Party
arbiter : Party
bank : Party
instrumentKey : InstrumentKey
amount : Decimal
sellerAccount : AccountKey
escrowAccount : AccountKey
escrowHoldingCid : ContractId Holding.I
description : Text
where
signatory buyer, seller
observer bank, arbiter
choice Release : ContractId Holding.I
controller buyer, bank
do
splitAndTransfer [bank, seller] sellerAccount amount escrowHoldingCid