I am filtering through transactions like this.Datum is represented as d in the below function.
utxos <- Map.filter (isSuitable (cpFund cp)) <$> utxosAt scrAddress
isSuitable :: Integer -> ChainIndexTxOut -> Bool
isSuitable fundRound o = case _ciTxOutDatum o of
Left _ -> False
Right (Datum e) -> case PlutusTx.fromBuiltinData e of
Nothing -> False
Just d -> startFund d == fundRound
This worked when my datum was set up like this
data StartDatum = StartDatum
{ startFund :: Integer
, fundPrize :: Integer
}deriving (Show)
So i was able to parse the value by just doing
startFund d
After i change the datum from StartDatum to DatumAction below it does not work anymore.
data DatumAction = Start StartDatum | Voting VotingDatum
data VotingDatum = VotingDatum
{ projectPubKey :: PaymentPubKeyHash
, amount :: Integer
, fund :: Integer
, paymentKey :: PaymentPubKeyHash
}deriving (Show)
data StartDatum = StartDatum
{ startFund :: Integer
, fundPrize :: Integer
}deriving (Show)