Constructor Does Not Have Strict Frields

Hi All,

I have been working on the following:

  • Template_A
    ** Choice_Accept
    ** Choice_Reject
  • Template_B
    ** Choice_Accept
    ** Choice_Reject

The error message is:

Source:   typecheck
Severity: DsError
Message: 
  daml/Fruitbox.daml:67:18: error:
  • Constructor ‘IssueFruit’ does not have the required strict field(s): message
  • In the first argument of ‘create’, namely
  ‘IssueFruit {fruitbox, fruitbat}’
  In a stmt of a 'do' block: create IssueFruit {fruitbox, fruitbat}
  In the expression: do create IssueFruit {fruitbox, fruitbat}
ERROR: Creation of DAR file failed.

The full contract is:

app/daml/Fruitbat.daml
-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0 --}

module Fruitbox where

type IssueFruitOfferId = ContractId IssueFruitOffer
type IssueFruitId = ContractId IssueFruit

template IssueFruit -- Issue Fruit
  with
    -- Signatory
    fruitbox : Party -- issue
    fruitbat : Party -- eat
    {-- fruitman : Party -- recommend --}
    {-- fruithelp : Party -- get --}
    {-- fruitcheck : Party -- oversee --}
    {-- fruitbad : Party --} -- investigate
    {-- fruitorchard : Party -- supply --}
    message : Text

  where
    agreement "We will issue you with Fruit"
      <> "unless restrictions apply"
      <> "More placeholder text to test"
    
    ensure
      show fruitbox == "'Fruit Box'" -- only a Fruit Box can issue Fruit
    
    -- Signatory
    signatory fruitbox, fruitbat -- Fruit Box, Fruit Man
    
    controller fruitbox can -- Offer & Reject Fruit issue
      IssueFruit_Offer : ContractId IssueFruitOffer
        with
          newCustodian : Party
          {--
          date : Date
          time : Time
          notes : Text -- Enter further information --}
        do
          -- test the assertion
          assert (fruitbox /= newCustodian) -- Cannot issue Fruit to Fruit Box
          create IssueFruitOffer with
              fruitbox,
                fruitbat = newCustodian
                
      IssueFruit_Reject : () do return ()

template IssueFruitOffer
  with
    -- signatory
    fruitbox : Party
    -- controller
    fruitbat : Party
  
  where
    agreement "This recommendation will be cancelled."
      <> "For further information, see the notes above."

    ensure
      show fruitbox == "'Fruit Box'" -- only the Fruit Box can cancel Fruit

    signatory fruitbox -- Fruit Box
    
    controller fruitbat can -- only the Fruit Bat can accept Fruit
      {-- IssueFruitOffer_Accept : ContractId IssueFruit --}
      IssueFruitOffer_Accept : IssueFruitId
        do
          create IssueFruit with
            fruitbox,
              fruitbat

      IssueFruitOffer_Reject : () do return ()

The issue is Lines 69-71:

    do
        create IssueFruit with
            fruitbox,
                fruitbat

I have chased this issue up and down the two templates for a while now. There was a typo in the first template that started this, but it is now persistent.

Odd that the 2nd template is almost a copy of the first, yet has this error. It must be Logic not formatting related.

From your example, it looks like the IssueFruit has a message : Text field that is not commented out; you’ll have to supply a value for that field when doing create IssueFruit.

1 Like

Thank you @dtanabe That was so simple it is galling :no_mouth:

Wood/Trees …

1 Like