From cbff7324d8673b95aa79a6d97f69071d6d48df43 Mon Sep 17 00:00:00 2001 From: Seungheon Oh Date: Mon, 25 Apr 2022 11:16:17 -0400 Subject: [PATCH] PTryFrom for Treasury Withdrawal Effect! --- agora/Agora/Effect/TreasuryWithdrawal.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agora/Agora/Effect/TreasuryWithdrawal.hs b/agora/Agora/Effect/TreasuryWithdrawal.hs index abf23bf..f39ad92 100644 --- a/agora/Agora/Effect/TreasuryWithdrawal.hs +++ b/agora/Agora/Effect/TreasuryWithdrawal.hs @@ -15,10 +15,12 @@ module Agora.Effect.TreasuryWithdrawal ( import GHC.Generics qualified as GHC import Generics.SOP (Generic, I (I)) +import Control.Applicative (Const) import Agora.Effect (makeEffect) import Agora.Utils (findTxOutByTxOutRef, paddValue, passert) import Plutarch (popaque) +import Plutarch.Internal (punsafeCoerce) import Plutarch.Api.V1 ( PCredential (..), PTuple, @@ -32,6 +34,7 @@ import Plutarch.DataRepr ( PDataFields, PIsDataReprInstances (..), ) +import Plutarch.TryFrom ( PTryFrom(..) ) import Plutarch.Lift (PUnsafeLiftDecl (..)) import Plutarch.Monadic qualified as P import Plutus.V1.Ledger.Credential (Credential) @@ -71,6 +74,13 @@ deriving via instance (PConstant TreasuryWithdrawalDatum) +instance PTryFrom PData PTreasuryWithdrawalDatum where + type PTryFromExcess PData PTreasuryWithdrawalDatum = Const () + ptryFrom' opq cont = + -- this will need to not use punsafeCoerce... + cont (punsafeCoerce opq, ()) + + {- | 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.