diff --git a/src/SingleValidator.hs b/src/SingleValidator.hs index 2776105..74edeef 100644 --- a/src/SingleValidator.hs +++ b/src/SingleValidator.hs @@ -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 @@ -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 @@ -97,7 +97,7 @@ data PSmartHandleDatum (s :: S) '[ "mOwner" ':= PMaybeData PAddress , "routerFee" ':= PInteger , "reclaimRouterFee" ':= PInteger - , "reclaimMint" ':= PReclaimMint + , "requiredMint" ':= PRequiredMint , "extraInfo" ':= PData ] ) @@ -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" diff --git a/src/StakingValidator.hs b/src/StakingValidator.hs index ebd7e5b..64deafc 100644 --- a/src/StakingValidator.hs +++ b/src/StakingValidator.hs @@ -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) @@ -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 @@ -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" diff --git a/test/SmartHandlesSpec.hs b/test/SmartHandlesSpec.hs index cf128af..7787423 100644 --- a/test/SmartHandlesSpec.hs +++ b/test/SmartHandlesSpec.hs @@ -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)