Merge pull request #214 from Liqwid-Labs/connor/bump-lpe

This commit is contained in:
方泓睿 2022-12-02 00:00:30 +08:00 committed by GitHub
commit 76b3e8f197
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 20 deletions

View file

@ -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

View file

@ -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

View file

@ -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" #) ->

6
flake.lock generated
View file

@ -692,11 +692,11 @@
]
},
"locked": {
"lastModified": 1668121695,
"narHash": "sha256-2ltW7mvn14zm9f67OmxXIPJHAXR6vxBdN/6Q6nRh7a8=",
"lastModified": 1669819820,
"narHash": "sha256-D+WLcMDL8iPb05XnD8C7ay2azV3ImJgaJjjzJpSDokw=",
"owner": "Liqwid-Labs",
"repo": "liqwid-plutarch-extra",
"rev": "0cb63aa7d4fd2006cf590edc7fca0f3fcdb71a55",
"rev": "e68f7449b54865de3a59540a19702147ef5fbf67",
"type": "github"
},
"original": {