From efb0776730709c69845224efd7a10d546fd432ed Mon Sep 17 00:00:00 2001 From: Seungheon Oh Date: Fri, 22 Apr 2022 08:23:54 -0400 Subject: [PATCH] simple fixes suggested from review --- agora-test/Spec/Util.hs | 18 +++----------- agora/Agora/Effect/TreasuryWithdrawal.hs | 30 ++++++++++++------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/agora-test/Spec/Util.hs b/agora-test/Spec/Util.hs index 32fa1b1..069c7e3 100644 --- a/agora-test/Spec/Util.hs +++ b/agora-test/Spec/Util.hs @@ -142,13 +142,7 @@ effectSucceedsWith :: ScriptContext -> TestTree effectSucceedsWith tag eff datum scriptContext = - scriptSucceeds tag $ - compile - ( eff - # pforgetData (pconstantData datum) - # pforgetData (pconstantData ()) - # pconstant scriptContext - ) + validatorSucceedsWith tag eff datum () scriptContext -- | Check that a validator script fails, given a name and arguments. effectFailsWith :: @@ -161,14 +155,8 @@ effectFailsWith :: ScriptContext -> TestTree effectFailsWith tag eff datum scriptContext = - scriptFails tag $ - compile - ( eff - # pforgetData (pconstantData datum) - # pforgetData (pconstantData ()) - # pconstant scriptContext - ) - + validatorFailsWith tag eff datum () scriptContext + -- | Check that an arbitrary script doesn't error when evaluated, given a name. scriptSucceeds :: String -> Script -> TestTree scriptSucceeds name script = testCase name $ do diff --git a/agora/Agora/Effect/TreasuryWithdrawal.hs b/agora/Agora/Effect/TreasuryWithdrawal.hs index ddf3f32..d8a496a 100644 --- a/agora/Agora/Effect/TreasuryWithdrawal.hs +++ b/agora/Agora/Effect/TreasuryWithdrawal.hs @@ -67,18 +67,18 @@ deriving via (PConstant TreasuryWithdrawalDatum) {- | Withdraws given list of values to specific target addresses. -It can be evoked by burning GAT. The transaction should have correct -outputs to the users and any left overs should be paid back to the treasury. + It can be evoked by burning GAT. The transaction should have correct + outputs to the users and any left overs should be paid back to the treasury. -The validator does not accept any Redeemer as all "parameters" are provided -via encoded Datum. + The validator does not accept any Redeemer as all "parameters" are provided + via encoded Datum. -Note: -It should check... -1. Transaction outputs should contain all of what Datum specified -2. Left over assests should be redirected back to Treasury -It can be more flexiable over... -- The number of outputs themselves + Note: + It should check... + 1. Transaction outputs should contain all of what Datum specified + 2. Left over assests should be redirected back to Treasury + It can be more flexiable over... + - The number of outputs themselves -} treasuryWithdrawalValidator :: forall {s :: S}. CurrencySymbol -> Term s PValidator treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $ @@ -104,11 +104,11 @@ treasuryWithdrawalValidator currSymbol = makeEffect currSymbol $ pdata $ ptuple # txOut.address # txOut.value ) # txInfo.inputs - treasuryInputValues = - pfilter - # plam (\((pfield @"_0" #) . pfromData -> addr) -> pnot #$ addr #== effInput.address) - # inputValues - treasuryCredentials = + treasuryInputValues <- plet $ + pfilter + # plam (\((pfield @"_0" #) . pfromData -> addr) -> pnot #$ addr #== effInput.address) + # inputValues + let treasuryCredentials = pmap # plam ((pfield @"credential" #) . pfromData . (pfield @"_0" #) . pfromData) # treasuryInputValues