ISDA CDM model using HTTP JSON API

Hi DAML Forum,

I am extending the ISDA CDM - https://github.com/digital-asset/ex-cdm-swaps - DAML model to our front end using the HTTP-JSON API’s. I am stuck at line 162 (https://github.com/digital-asset/ex-cdm-swaps/blob/ba8e1f0dec418b30a5b5c05c0c46c4111b365c92/daml/Test/Event.daml#L162. I am receiving the following error:

Error: INVALID_ARGUMENT: Command interpretation error in LF-DAMLe: Interpretation error: Error: User abort: no cash available for instruction CAXMKVEHOV_CashTransfer_2018-09-26_1. Details: Last location: [Main.Workflow.Allocate:53], partial transaction: root node 1: NodeFetch(AbsoluteContractId(#11:1),Identifier(7f1e8cc812c83ec590ad24238f3d902cee1578e891fad4e651a7185ef8c8901c,Main.Market.Cash:CashTransferInstruction),Some(Location(7133e9d8c66ca18b2c8d5bfd7458b6426fc2033a6477feb59fc30aaa89dfee1e,DA.Internal.Prelude,$u002b$u002b,(370,25),(370,27))),Some(Set(CSD)),Set(Issuer, CSD),Set(Issuer, CSD)), root node 2: NodeFetch(AbsoluteContractId(#14:1),Identifier(7f1e8cc812c83ec590ad24238f3d902cee1578e891fad4e651a7185ef8c8901c,Main.Market.Cash:Cash),Some(Location(7133e9d8c66ca18b2c8d5bfd7458b6426fc2033a6477feb59fc30aaa89dfee1e,DA.Internal.Prelude,$u002b$u002b,(370,25),(370,27))),Some(Set(CSD)),Set(CentralBank, CSD),Set(CSD, CentralBank)).

I am unsure why the result is returning “no cash available…”. The contractId that I input has enough money in it and the has the same account number as is specified in the CashTransferInstruction contract. Are there other labels that I need to ‘match up’ in order for the Cash contract to be recognized?

The particular function that matches up your cash is here. It checks the following:

\cashCidD ->
  cashCidD.d.owner == payerParty.p &&
  cashCidD.d.account == payerAccount.accountNumber.value &&
  cashCidD.d.currency == ctiCidD.d.d.cashTransfer.amount.currency.value

Can you verify that these in fact do match? If so, can you paste both your CashTransferInstruction as well as your Cash contract messages here so I can have a look?

Hi Georg,

I did confirm that I used the correct account numbers. I think it may have something to do with payerAccountReference being NULL?

Here are the JSON for Cash and CashTransferInstruction.

Cash: 
{
  "issuer": "CentralBank",
  "amount": "100000000.0",
  "currency": "USD",
  "account": "P01547927812",
  "owner": "CSD"
}

CashTransferInstruction:
{
  "ps": [
    {
      "p": "Issuer",
      "id": "9377538274179"
    },
    {
      "p": "CSD",
      "id": "5264151754007"
    }
  ],
  "d": {
    "cashTransfer": {
      "breakdown": [],
      "identifier": null,
      "amount": {
        "amount": "70000.0",
        "currency": {
          "value": "USD",
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        },
        "id": null
      },
      "transferCalculation": null,
      "cashflowType": null,
      "payerReceiver": {
        "payerAccountReference": null,
        "payerPartyReference": {
          "reference": "9377538274179",
          "value": null,
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        },
        "receiverAccountReference": null,
        "receiverPartyReference": {
          "reference": "5264151754007",
          "value": null,
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        }
      }
    },
    "party": [
      {
        "name": {
          "value": "Issuer",
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        },
        "id": "9377538274179",
        "person": [],
        "account": {
          "servicingParty": null,
          "accountName": null,
          "id": null,
          "accountType": null,
          "accountNumber": {
            "value": "D03225622378",
            "meta": {
              "reference": "UNKNOWN",
              "scheme": "UNKOWN",
              "id": "UNKNOWN"
            }
          },
          "accountBeneficiary": null
        },
        "partyId": [
          {
            "value": "9377538274179",
            "meta": {
              "reference": "UNKNOWN",
              "scheme": "UNKOWN",
              "id": "UNKNOWN"
            }
          }
        ]
      },
      {
        "name": {
          "value": "CSD",
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        },
        "id": "5264151754007",
        "person": [],
        "account": {
          "servicingParty": null,
          "accountName": null,
          "id": null,
          "accountType": null,
          "accountNumber": {
            "value": "P01547927812",
            "meta": {
              "reference": "UNKNOWN",
              "scheme": "UNKOWN",
              "id": "UNKNOWN"
            }
          },
          "accountBeneficiary": null
        },
        "partyId": [
          {
            "value": "5264151754007",
            "meta": {
              "reference": "UNKNOWN",
              "scheme": "UNKOWN",
              "id": "UNKNOWN"
            }
          }
        ]
      }
    ],
    "account": [
      {
        "servicingParty": null,
        "accountName": null,
        "id": null,
        "accountType": null,
        "accountNumber": {
          "value": "D03225622378",
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        },
        "accountBeneficiary": null
      },
      {
        "servicingParty": null,
        "accountName": null,
        "id": null,
        "accountType": null,
        "accountNumber": {
          "value": "P01547927812",
          "meta": {
            "reference": "UNKNOWN",
            "scheme": "UNKOWN",
            "id": "UNKNOWN"
          }
        },
        "accountBeneficiary": null
      }
    ],
    "eventReference": "CAXMKVEHOV_CashTransfer_2018-09-26_1"
  },
  "allocatedCashCid": null
}

I don’t think the payerAccountReference is the issue here - the findAccount function would in fact abort if you pass in a reference there, see here.

But if If I see this correctly, the payerParty is the Issuer (id 9377538274179) in your example. But the Cash you’re passing in is owned by CSD. That could be the reason why you’re seeing this error.

3 Likes

Ahh. I will look into this. I may have flipped the parties from the beginning of the workflow. Thanks, Georg!

EDIT:
Thanks @georg. Your observation helped me get this working. Thanks, also for taking the time to explain the model and help me understand the DAML code better!

1 Like