From ca951031dc0b50b037faeaf5d32dc3fff8c16e83 Mon Sep 17 00:00:00 2001 From: Hongrui Fang Date: Wed, 30 Nov 2022 23:02:25 +0800 Subject: [PATCH] fix compilation errors; rename stuff --- agora/Agora/Proposal/Scripts.hs | 12 ++++++------ agora/Agora/Proposal/Time.hs | 16 ++++++++-------- agora/Agora/Stake/Redeemers.hs | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/agora/Agora/Proposal/Scripts.hs b/agora/Agora/Proposal/Scripts.hs index 1d42121..32be0d3 100644 --- a/agora/Agora/Proposal/Scripts.hs +++ b/agora/Agora/Proposal/Scripts.hs @@ -83,7 +83,7 @@ import "liqwid-plutarch-extra" Plutarch.Extra.TermCont ( pmatchC, ptryFromC, ) -import Plutarch.Extra.Time (PCurrentTime) +import Plutarch.Extra.Time (PFullyBoundedTimeRange) import Plutarch.Extra.Traversable (pfoldMap) import Plutarch.Extra.Value (psymbolValueOf') import Plutarch.Unsafe (punsafeCoerce) @@ -310,18 +310,18 @@ proposalValidator = currentTime <- pletC $ pcurrentProposalTime # txInfoF.validRange - let withCurrentTime :: + let withBoundedValidTimeRange :: forall (a :: PType). - Term _ (PCurrentTime :--> a) -> + Term _ (PFullyBoundedTimeRange :--> a) -> Term _ a - withCurrentTime f = + withBoundedValidTimeRange f = pmatch currentTime $ \case PJust currentTime -> f # currentTime PNothing -> ptraceError "Unable to resolve current time" getTimingRelation' <- pletC $ - withCurrentTime $ + withBoundedValidTimeRange $ pgetRelation # proposalInputDatumF.timingConfig # proposalInputDatumF.startingTime @@ -511,7 +511,7 @@ proposalValidator = pisWithin # getTimingRelation PVotingPeriod pguardC "Width of time should meet maximum requirement" $ - withCurrentTime $ + withBoundedValidTimeRange $ psatisfyMaximumWidth #$ pfield @"votingTimeRangeMaxWidth" # proposalInputDatumF.timingConfig diff --git a/agora/Agora/Proposal/Time.hs b/agora/Agora/Proposal/Time.hs index 38b5691..df0415f 100644 --- a/agora/Agora/Proposal/Time.hs +++ b/agora/Agora/Proposal/Time.hs @@ -51,9 +51,9 @@ import Plutarch.Extra.IsData (PlutusTypeEnumData) import Plutarch.Extra.Maybe (pjust, pmaybe, pnothing) import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pletC, pmatchC) import Plutarch.Extra.Time ( - PCurrentTime (PCurrentTime), - pcurrentTimeDuration, - pisWithinCurrentTime, + PFullyBoundedTimeRange (PFullyBoundedTimeRange), + pisWithinTimeRange, + ptimeRangeDuration, ) import Plutarch.Lift ( DerivePConstantViaNewtype (DerivePConstantViaNewtype), @@ -173,7 +173,7 @@ PlutusTx.makeIsDataIndexed 'ProposalTimingConfig [('ProposalTimingConfig, 0)] @since 0.1.0 -} -type PProposalTime = PCurrentTime +type PProposalTime = PFullyBoundedTimeRange -- | Plutarch-level version of 'ProposalStartingTime'. newtype PProposalStartingTime (s :: S) = PProposalStartingTime (Term s PPOSIXTime) @@ -362,7 +362,7 @@ pvalidateProposalStartingTime = phoistAcyclic $ isInCurrentTimeRange = ptraceIfFalse "createProposalStartingTime: starting time should be in current time range" - $ pisWithinCurrentTime # st # ct + $ pisWithinTimeRange # st # ct in isTightEnough #&& isInCurrentTimeRange ) # (pcurrentProposalTime # iv) @@ -406,7 +406,7 @@ pcurrentProposalTime = phoistAcyclic $ passert "Upper bound bigger than lower bound" (lb #< ub) - (pcon $ PCurrentTime lb ub) + (pcon $ PFullyBoundedTimeRange lb ub) pure $ pliftA2 # mkTime # lowerBound # upperBound @@ -495,7 +495,7 @@ pgetRelation = phoistAcyclic $ configF <- pletAllC config PProposalStartingTime s <- pmatchC startingTime - PCurrentTime lb ub <- pmatchC currentTime + PFullyBoundedTimeRange lb ub <- pmatchC currentTime dub <- pletC $ s + configF.draftTime vub <- pletC $ dub + configF.votingTime @@ -531,6 +531,6 @@ psatisfyMaximumWidth :: ) psatisfyMaximumWidth = phoistAcyclic $ plam $ \maxWidth time -> - let width = pcurrentTimeDuration # time + let width = ptimeRangeDuration # time max = pto maxWidth in width #<= max diff --git a/agora/Agora/Stake/Redeemers.hs b/agora/Agora/Stake/Redeemers.hs index 3c0dd37..63eba7d 100644 --- a/agora/Agora/Stake/Redeemers.hs +++ b/agora/Agora/Stake/Redeemers.hs @@ -62,7 +62,7 @@ import "liqwid-plutarch-extra" Plutarch.Extra.List ( import Plutarch.Extra.Maybe (pdjust, pdnothing, pmaybeData) import Plutarch.Extra.Record (mkRecordConstr, (.&), (.=)) import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC) -import Plutarch.Extra.Time (PCurrentTime (PCurrentTime)) +import Plutarch.Extra.Time (PFullyBoundedTimeRange (PFullyBoundedTimeRange)) -- | A wrapper which ensures that no proposal is presented in the transaction. pwithoutProposal :: @@ -229,7 +229,7 @@ ppermitVote = pvoteHelper #$ phoistAcyclic $ pguardC "Owner or delegatee signs the transaction" $ pisSignedBy # pconstant True # ctx - PCurrentTime _ upperBound <- pmatchC currentTime + PFullyBoundedTimeRange _ upperBound <- pmatchC currentTime let action = mkRecordConstr @@ -286,7 +286,7 @@ premoveLocks = plam $ \proposalId unlockCooldown currentTime mode -> unTermCont $ do shouldRemoveAllLocks <- pletC $ mode #== pcon PRemoveAllLocks - PCurrentTime lowerBound _ <- pmatchC currentTime + PFullyBoundedTimeRange lowerBound _ <- pmatchC currentTime let handleVoter ( (pfield @"createdAt" #) ->