Daml test scrip usage

HI
I am trying to filter out contracts using queryFilter inside a test script

  let
    cancelPredicate = (\swiftOutboundMsg -> case swiftOutboundMsg.swiftMessage of 
      MT548 mt548 -> mt548.status == CAND 
      other -> False)

  swiftTradeConfirmationMsgs <- queryFilter @SwiftOutboundMessage settlementAgent (\t -> (t.swiftMessageType == MT548_buy_t) && (cancelPredicate))

The above code executes with the following error:

h:/work/dtip/src/test/daml/Tests/Syndicate/SwiftReporting.daml:98:130: error:
    • Couldn't match expected type ‘Bool’ with actual type ‘r0 -> Bool’
    • Probable cause: ‘cancelPredicate’ is applied to too few arguments

Is there a better way to achieve this?

cancelPredicate is a function that you need to apply to the swift message. Try something like

swiftTradeConfirmationMsgs <- queryFilter @SwiftOutboundMessage settlementAgent (\t -> (t.swiftMessageType == MT548_buy_t) && (cancelPredicate t))

Thanks. this is cool

1 Like