Skip to content

Commit

Permalink
Revert "Revert "rename ReclaimMint -> RequiredMint""
Browse files Browse the repository at this point in the history
This reverts commit f09da6a.
  • Loading branch information
keyan-m committed Sep 4, 2024
1 parent f09da6a commit fe30aef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
30 changes: 15 additions & 15 deletions src/SingleValidator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ pcountInputsAtScript =
n
in go # 0

data ReclaimMint
data RequiredMint
= Singleton CurrencySymbol TokenName Integer
| None

PlutusTx.makeLift ''ReclaimMint
PlutusTx.makeLift ''RequiredMint
PlutusTx.makeIsDataIndexed
''ReclaimMint
''RequiredMint
[ ('Singleton, 0)
, ('None, 1)
]

data PReclaimMint (s :: S)
data PRequiredMint (s :: S)
= PSingleton
( Term
s
Expand All @@ -59,19 +59,19 @@ data PReclaimMint (s :: S)
deriving stock (Generic)
deriving anyclass (PlutusType, PIsData)

instance DerivePlutusType PReclaimMint where
instance DerivePlutusType PRequiredMint where
type DPTStrat _ = PlutusTypeData

instance PTryFrom PData PReclaimMint
instance PTryFrom PData PRequiredMint

instance PUnsafeLiftDecl PReclaimMint where type PLifted PReclaimMint = ReclaimMint
deriving via (DerivePConstantViaData ReclaimMint PReclaimMint) instance PConstantDecl ReclaimMint
instance PUnsafeLiftDecl PRequiredMint where type PLifted PRequiredMint = RequiredMint
deriving via (DerivePConstantViaData RequiredMint PRequiredMint) instance PConstantDecl RequiredMint

data SmartHandleDatum
= Simple Address -- <-- owner
| Advanced (Maybe Address) Integer Integer ReclaimMint PlutusTx.BuiltinData
| Advanced (Maybe Address) Integer Integer RequiredMint PlutusTx.BuiltinData

-- ^-------------^ ^-----^ ^-----^ ^------------------^
-- ^-------------^ ^-----^ ^-----^ ^------------------^
-- mOwner routerFee reclaimRouterFee extraInfo

PlutusTx.makeLift ''SmartHandleDatum
Expand All @@ -97,7 +97,7 @@ data PSmartHandleDatum (s :: S)
'[ "mOwner" ':= PMaybeData PAddress
, "routerFee" ':= PInteger
, "reclaimRouterFee" ':= PInteger
, "reclaimMint" ':= PReclaimMint
, "requiredMint" ':= PRequiredMint
, "extraInfo" ':= PData
]
)
Expand Down Expand Up @@ -260,12 +260,12 @@ prouter = phoistAcyclic $ plam $ \validateFn routeAddress dat ownIndex routerInd
, ptraceIfFalse "Incorrect Route Output Value" (pvalueHasChangedByLovelaces # ownInputF.value # routerOutputF.value # negativeRouterFeeForSimpleRoutes)
]
PAdvanced dat' -> P.do
datF <- pletFields @'["mOwner", "routerFee", "reclaimRouterFee", "reclaimMint", "extraInfo"] dat'
let inputIncludingMint = pmatch datF.reclaimMint $ \case
datF <- pletFields @'["mOwner", "routerFee", "reclaimRouterFee", "requiredMint", "extraInfo"] dat'
let inputIncludingMint = pmatch datF.requiredMint $ \case
PSingleton rm -> P.do
rmF <- pletFields @'["policy", "name", "quantity"] rm
let reclaimMintValue = Value.psingleton # rmF.policy # rmF.name # rmF.quantity
inputAppendedWithMint = reclaimMintValue <> pforgetPositive ownInputF.value
let requiredMintValue = Value.psingleton # rmF.policy # rmF.name # rmF.quantity
inputAppendedWithMint = requiredMintValue <> pforgetPositive ownInputF.value
pif
( ptraceIfFalse
"Tx mint doesn't match the reclaim mint"
Expand Down
10 changes: 5 additions & 5 deletions src/StakingValidator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import "liqwid-plutarch-extra" Plutarch.Extra.TermCont
import BatchValidator (PSmartRedeemer (..))
import Constants (negativeRouterFeeForSimpleRoutes, routerFeeForSimpleRoutes)
import Plutarch.Builtin (PIsData (pdataImpl), ppairDataBuiltin)
import SingleValidator (PReclaimMint (..), PSmartHandleDatum (..))
import SingleValidator (PRequiredMint (..), PSmartHandleDatum (..))
import Utils

pcountScriptInputs :: Term s (PBuiltinList PTxInInfo :--> PInteger)
Expand Down Expand Up @@ -125,7 +125,7 @@ psmartHandleSuccessor validateFn datums ctx routeAddress smartInputRouteFlagPair
)
(psignedByOwner # ctx # owner)
PAdvanced dat' -> P.do
datF <- pletFields @'["mOwner", "routerFee", "reclaimRouterFee", "reclaimMint", "extraInfo"] dat'
datF <- pletFields @'["mOwner", "routerFee", "reclaimRouterFee", "requiredMint", "extraInfo"] dat'
pif
forRoute
( pand'List
Expand All @@ -138,11 +138,11 @@ psmartHandleSuccessor validateFn datums ctx routeAddress smartInputRouteFlagPair
PDJust ((pfield @"_0" #) -> owner) -> P.do
let txInfo = pfield @"txInfo" # ctx
mint = pfield @"mint" # txInfo
inputIncludingMint = pmatch datF.reclaimMint $ \case
inputIncludingMint = pmatch datF.requiredMint $ \case
PSingleton rm -> P.do
rmF <- pletFields @'["policy", "name", "quantity"] rm
let reclaimMintValue = Value.psingleton # rmF.policy # rmF.name # rmF.quantity
inputAppendedWithMint = reclaimMintValue <> pforgetPositive smartInputF.value
let requiredMintValue = Value.psingleton # rmF.policy # rmF.name # rmF.quantity
inputAppendedWithMint = requiredMintValue <> pforgetPositive smartInputF.value
pif
( ptraceIfFalse
"Tx mint doesn't match the reclaim mint"
Expand Down
2 changes: 1 addition & 1 deletion test/SmartHandlesSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Test.Tasty.QuickCheck (Gen, Property, chooseInt, chooseInteger, forAll, s
import BatchValidator (SmartRedeemer (..), smartHandleRouteValidatorW)
import Compilation
import Debug.Trace (trace)
import SingleValidator (ReclaimMint (..), SmartHandleDatum (..))
import SingleValidator (RequiredMint (..), SmartHandleDatum (..))
import Specialized.Minswap
import StakingValidator (RouterRedeemer (..), puniqueOrdered)

Expand Down

0 comments on commit fe30aef

Please sign in to comment.