You cannot use `..' in a record update parser

I am not able to resolve this. It shows this error at create tokenOffer with …

    with
        issuer: Party
        owner: Party
        description: Text
        userAdmin: Party --makes sure that issuer and owner are legit
        issued: Time
        lastPrice: Decimal
        currency: Text
        royaltyRate: Decimal
    where
        signatory issuer, userAdmin 

        choice Offer: (ContractId Offer, ContractId Payable)
            with
               newOwner: Party
               price: Decimal
            controller owner
            do 
                create tokenOffer 
                    with ..          
template tokenOffer
    with
        issuer: Party
        owner: Party
        description: Text
        userAdmin: Party --makes sure that issuer and owner are legit
        issued: Time
        newOwner: Party
        price: Decimal
        lastPrice: Decimal
        currency: Text
        royaltyRate: Decimal
    where
        signatory issuer, userAdmin, owner

        key (issuer, owner, description ): (Party, Party, Text)
        maintainer key._2

        choice AcceptToken: (ContractId Token, ContractId Payable, ContractId Payable)
            controller newOwner, userAdmin
            do 
                fromNewOwnerToOwner <- create Payable
                    with
                        from = newOwner
                        to = owner
                        amount = price
                        currency
                        reference = "Notional for `"<> description <> "`."

                royaltyPayment <- create Payable
                    with
                        from = newOwner
                        to = issuer
                        amount = price * royaltyRate
                        currency
                        reference = "Royalty for`" <> description <> "`."


                newToken <- create Token
                    with
                        owner = newOwner
                        lastPrice = price
                        ..
                return (newToken, fromNewOwnerToOwner, royaltyPayment) ```

Record constructors are always upper case just as type constructors. So in both your template definition as well as where you’re creating the record you need to use TokenOffer not tokenOffer.

The general rule in Daml is that names that start with an uppercase letter refer to concrete types or values whereas names that start with lowercase letters refer to variables.

Thank you. Now its this error at create TokenOffer with …
• Couldn’t match type ‘ContractId TokenOffer’
with ‘(ContractId Offer, ContractId Payable)’
Expected type: Update (ContractId Offer, ContractId Payable)
Actual type: Update (ContractId TokenOffer)
• In a stmt of a ‘do’ block: create TokenOffer {…}
In the expression: do create TokenOffer {…}
In the expression: let _ = arg in do create TokenOffer {…}typecheck

Apologies. I am trying to complete the DAML foundation certification and it’s aligned more with the older sdk version of DAML.

Thank you again

The type of your Offer choice is (ContractId Offer, ContractId Payable) so you would need to return a tuple of a contract id for an Offer contract and a Payable contract. But your implementation returns ContractId TokenOffer.

You can either change the type or change the implementation to match. Which one makes more sense really depends on what you intend that choice to be doing.

That really helped. Thank you :slight_smile:

1 Like