Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template GardeningOffer
- with
- gardener : Party
- beneficiary : Party
- trustedOperators : [Party]
- amount : Amount
- invoiceId : Text
- where
- signatory gardener
- controller beneficiary can
- AcceptOffer : (ContractId GardeningContract, ReceiveFundsRequestCid)
- with
- customerCid : CustomerCid
- fundingSourceId : Text
- do
- customer <- fetch customerCid
- assert (elem customer.operator trustedOperators)
- assert (customer.user == beneficiary)
- let memo = Metadata with
- key = "memo"
- value = "Payment for mowing " <>
- partyToText beneficiary <> "'s lawn"
- invoice = Metadata with key = "invoiceId", value = invoiceId
- receiveFundsCid <- exercise customerCid Customer_SendFunds
- with
- to = gardener
- optClearingSrc = None
- optMetadata = Some [memo, invoice]
- ..
- gardeningCid <- create GardeningContract
- with
- optAchId = None
- ..
- return (gardeningCid, receiveFundsCid)
- RefuseOffer : ()
- do return ()
- mowTheLawn = scenario do
- [alice, bob, operator] <- mapA getParty ["Alice", "Bob", "Operator"]
- gardeningOfferCid <- bob `submit`
- create GardeningOffer
- with
- gardener = bob
- beneficiary = alice
- trustedOperators = [operator]
- amount = Amount with value = "59.99", currency = "USD"
- invoiceId = "GARDENING123"
- return ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement