fix compilation errors; rename stuff

This commit is contained in:
Hongrui Fang 2022-11-30 23:02:25 +08:00
parent ba6d2611d7
commit eb4d9a2bf9
3 changed files with 17 additions and 17 deletions

View file

@ -83,7 +83,7 @@ import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (
pmatchC, pmatchC,
ptryFromC, ptryFromC,
) )
import Plutarch.Extra.Time (PCurrentTime) import Plutarch.Extra.Time (PFullyBoundedTimeRange)
import Plutarch.Extra.Traversable (pfoldMap) import Plutarch.Extra.Traversable (pfoldMap)
import Plutarch.Extra.Value (psymbolValueOf') import Plutarch.Extra.Value (psymbolValueOf')
import Plutarch.Unsafe (punsafeCoerce) import Plutarch.Unsafe (punsafeCoerce)
@ -310,18 +310,18 @@ proposalValidator =
currentTime <- pletC $ pcurrentProposalTime # txInfoF.validRange currentTime <- pletC $ pcurrentProposalTime # txInfoF.validRange
let withCurrentTime :: let withBoundedValidTimeRange ::
forall (a :: PType). forall (a :: PType).
Term _ (PCurrentTime :--> a) -> Term _ (PFullyBoundedTimeRange :--> a) ->
Term _ a Term _ a
withCurrentTime f = withBoundedValidTimeRange f =
pmatch currentTime $ \case pmatch currentTime $ \case
PJust currentTime -> f # currentTime PJust currentTime -> f # currentTime
PNothing -> ptraceError "Unable to resolve current time" PNothing -> ptraceError "Unable to resolve current time"
getTimingRelation' <- getTimingRelation' <-
pletC $ pletC $
withCurrentTime $ withBoundedValidTimeRange $
pgetRelation pgetRelation
# proposalInputDatumF.timingConfig # proposalInputDatumF.timingConfig
# proposalInputDatumF.startingTime # proposalInputDatumF.startingTime
@ -511,7 +511,7 @@ proposalValidator =
pisWithin # getTimingRelation PVotingPeriod pisWithin # getTimingRelation PVotingPeriod
pguardC "Width of time should meet maximum requirement" $ pguardC "Width of time should meet maximum requirement" $
withCurrentTime $ withBoundedValidTimeRange $
psatisfyMaximumWidth psatisfyMaximumWidth
#$ pfield @"votingTimeRangeMaxWidth" #$ pfield @"votingTimeRangeMaxWidth"
# proposalInputDatumF.timingConfig # proposalInputDatumF.timingConfig

View file

@ -51,9 +51,9 @@ import Plutarch.Extra.IsData (PlutusTypeEnumData)
import Plutarch.Extra.Maybe (pjust, pmaybe, pnothing) import Plutarch.Extra.Maybe (pjust, pmaybe, pnothing)
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pletC, pmatchC) import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pletC, pmatchC)
import Plutarch.Extra.Time ( import Plutarch.Extra.Time (
PCurrentTime (PCurrentTime), PFullyBoundedTimeRange (PFullyBoundedTimeRange),
pcurrentTimeDuration, pisWithinTimeRange,
pisWithinCurrentTime, ptimeRangeDuration,
) )
import Plutarch.Lift ( import Plutarch.Lift (
DerivePConstantViaNewtype (DerivePConstantViaNewtype), DerivePConstantViaNewtype (DerivePConstantViaNewtype),
@ -173,7 +173,7 @@ PlutusTx.makeIsDataIndexed 'ProposalTimingConfig [('ProposalTimingConfig, 0)]
@since 0.1.0 @since 0.1.0
-} -}
type PProposalTime = PCurrentTime type PProposalTime = PFullyBoundedTimeRange
-- | Plutarch-level version of 'ProposalStartingTime'. -- | Plutarch-level version of 'ProposalStartingTime'.
newtype PProposalStartingTime (s :: S) = PProposalStartingTime (Term s PPOSIXTime) newtype PProposalStartingTime (s :: S) = PProposalStartingTime (Term s PPOSIXTime)
@ -362,7 +362,7 @@ pvalidateProposalStartingTime = phoistAcyclic $
isInCurrentTimeRange = isInCurrentTimeRange =
ptraceIfFalse ptraceIfFalse
"createProposalStartingTime: starting time should be in current time range" "createProposalStartingTime: starting time should be in current time range"
$ pisWithinCurrentTime # st # ct $ pisWithinTimeRange # st # ct
in isTightEnough #&& isInCurrentTimeRange in isTightEnough #&& isInCurrentTimeRange
) )
# (pcurrentProposalTime # iv) # (pcurrentProposalTime # iv)
@ -406,7 +406,7 @@ pcurrentProposalTime = phoistAcyclic $
passert passert
"Upper bound bigger than lower bound" "Upper bound bigger than lower bound"
(lb #< ub) (lb #< ub)
(pcon $ PCurrentTime lb ub) (pcon $ PFullyBoundedTimeRange lb ub)
pure $ pliftA2 # mkTime # lowerBound # upperBound pure $ pliftA2 # mkTime # lowerBound # upperBound
@ -495,7 +495,7 @@ pgetRelation = phoistAcyclic $
configF <- pletAllC config configF <- pletAllC config
PProposalStartingTime s <- pmatchC startingTime PProposalStartingTime s <- pmatchC startingTime
PCurrentTime lb ub <- pmatchC currentTime PFullyBoundedTimeRange lb ub <- pmatchC currentTime
dub <- pletC $ s + configF.draftTime dub <- pletC $ s + configF.draftTime
vub <- pletC $ dub + configF.votingTime vub <- pletC $ dub + configF.votingTime
@ -531,6 +531,6 @@ psatisfyMaximumWidth ::
) )
psatisfyMaximumWidth = phoistAcyclic $ psatisfyMaximumWidth = phoistAcyclic $
plam $ \maxWidth time -> plam $ \maxWidth time ->
let width = pcurrentTimeDuration # time let width = ptimeRangeDuration # time
max = pto maxWidth max = pto maxWidth
in width #<= max in width #<= max

View file

@ -62,7 +62,7 @@ import "liqwid-plutarch-extra" Plutarch.Extra.List (
import Plutarch.Extra.Maybe (pdjust, pdnothing, pmaybeData) import Plutarch.Extra.Maybe (pdjust, pdnothing, pmaybeData)
import Plutarch.Extra.Record (mkRecordConstr, (.&), (.=)) import Plutarch.Extra.Record (mkRecordConstr, (.&), (.=))
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC) 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. -- | A wrapper which ensures that no proposal is presented in the transaction.
pwithoutProposal :: pwithoutProposal ::
@ -229,7 +229,7 @@ ppermitVote = pvoteHelper #$ phoistAcyclic $
pguardC "Owner or delegatee signs the transaction" $ pguardC "Owner or delegatee signs the transaction" $
pisSignedBy # pconstant True # ctx pisSignedBy # pconstant True # ctx
PCurrentTime _ upperBound <- pmatchC currentTime PFullyBoundedTimeRange _ upperBound <- pmatchC currentTime
let action = let action =
mkRecordConstr mkRecordConstr
@ -286,7 +286,7 @@ premoveLocks =
plam $ \proposalId unlockCooldown currentTime mode -> unTermCont $ do plam $ \proposalId unlockCooldown currentTime mode -> unTermCont $ do
shouldRemoveAllLocks <- pletC $ mode #== pcon PRemoveAllLocks shouldRemoveAllLocks <- pletC $ mode #== pcon PRemoveAllLocks
PCurrentTime lowerBound _ <- pmatchC currentTime PFullyBoundedTimeRange lowerBound _ <- pmatchC currentTime
let handleVoter let handleVoter
( (pfield @"createdAt" #) -> ( (pfield @"createdAt" #) ->