Experimental BP DSL

Hi all,

I have scavenged and brushed up a PoC I did on Business Process Modelling in DAML. It is inspired by BPMN - but isn’t in anyway compatible with or an interpreter of BPMN. It’s very much a work in progress, and was made to demonstrate two things:

  • How to implement a simple flexible smart contract language as a state machine inside a DAML contract.
  • How to express that smart contract language with a DSL in DAML.

Here’s a scenario demonstrating it:

commercialFinancing = scenario do

  sales <- getParty "sales"
  risk <- getParty "risk"
  admin <- getParty "administration"
  credit <- getParty "credit"

  cid <- issueProcess do

    ack sales "Consolidate and Digitize Data"
    ack sales "Analyze Financial Data"
    select sales "Qualified Request?" do
      ch "Yes" do
        ack credit "Verify Credit Record with Credit Offices"
        ack risk "Sign-off from Risk"
        ack admin "Prepare Detailed Analysis of Financial Data"
        ack sales "Prepare Detailed Analysis"
        select sales "Qualified Request?" do
          ch "Yes" do
            ack sales "Elaborate Commercial Financing Reporting"
          ch "No" do
            ack sales "Prepare and Transmit Refusal Letter"
            cancel
      ch "No" do
        ack sales "Prepare and Transmit Refusal Letter"
        cancel

    service sales "done!"

  Some cid <- sales `submit` exercise cid $ Select0 "ack"
  Some cid <- sales `submit` exercise cid $ Select0 "ack"
  Some cid <- sales `submit` exercise cid $ Select0 "Yes"
  Some cid <- credit `submit` exercise cid $ Select0 "ack"
  Some cid <- risk `submit` exercise cid $ Select0 "ack"
  Some cid <- admin `submit` exercise cid $ Select0 "ack"
  Some cid <- sales `submit` exercise cid $ Select0 "ack"
  Some cid <- sales `submit` exercise cid $ Select0 "Yes"
  _        <- sales `submit` exercise cid $ Select0 "ack"

It’s defining (at runtime!) a business process involving three parties. At multiple steps a service event is triggered awaiting an acknowledgement from the specified party. At two occasions a specified party needs to make a choice between “Yes” and “No” branching the business process.

Enjoy!

9 Likes

Updated.

Now only a single party is required initially for creating the business process.

commercialFinancing = script do

  sales <- allocateParty "sales"
  risk <- allocateParty "risk"
  admin <- allocateParty "administration"
  credit <- allocateParty "credit"

  cid <- issueProcess sales do

    ack sales "Consolidate and Digitize Data"
    ack sales "Analyze Financial Data"
    select sales "Qualified Request?" do
      ch "Yes" do
        ack credit "Verify Credit Record with Credit Offices"
        ack risk "Sign-off from Risk"
        ack admin "Prepare Detailed Analysis of Financial Data"
        ack sales "Prepare Detailed Analysis"
        select sales "Qualified Request?" do
          ch "Yes" do
            ack sales "Elaborate Commercial Financing Reporting"
          ch "No" do
            ack sales "Prepare and Transmit Refusal Letter"
            cancel
      ch "No" do
        ack sales "Prepare and Transmit Refusal Letter"
        cancel

The business process above will initially have only sales as signatory, and only sales as observer. As the flow proceeds parties required to act will be become observers, and when they have acted they will become signatory.

Each ack step will generate an instance of BusinessProcess_Service with the party required act, the message and with all parties signed so far as signatory parties.

3 Likes

@sofusmortensen I like this DSL, will study it deeper, seems to be even more business friendly than DAML itself!

2 Likes