| Maintainer | emi@haskell.fyi |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Agora.Proposal.Time
Description
Time functions for proposal phases.
Synopsis
- data ProposalTimingConfig = ProposalTimingConfig {}
- newtype ProposalStartingTime = ProposalStartingTime {}
- newtype MaxTimeRangeWidth = MaxTimeRangeWidth {}
- data PProposalTime (s :: S) = PProposalTime {
- lowerBound :: Term s PPOSIXTime
- upperBound :: Term s PPOSIXTime
- newtype PProposalTimingConfig (s :: S) = PProposalTimingConfig {
- getProposalTimingConfig :: Term s (PDataRecord '["draftTime" := PPOSIXTime, "votingTime" := PPOSIXTime, "lockingTime" := PPOSIXTime, "executingTime" := PPOSIXTime])
- newtype PProposalStartingTime (s :: S) = PProposalStartingTime (Term s PPOSIXTime)
- newtype PMaxTimeRangeWidth (s :: S) = PMaxTimeRangeWidth (Term s PPOSIXTime)
- createProposalStartingTime :: forall (s :: S). Term s (PMaxTimeRangeWidth :--> (PPOSIXTimeRange :--> PProposalStartingTime))
- currentProposalTime :: forall (s :: S). Term s (PPOSIXTimeRange :--> PProposalTime)
- isDraftPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool)))
- isVotingPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool)))
- isLockingPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool)))
- isExecutionPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool)))
Haskell-land
data ProposalTimingConfig Source #
Configuration of proposal timings.
Since: 0.1.0
Constructors
| ProposalTimingConfig | |
Fields
| |
Instances
newtype ProposalStartingTime Source #
Represents the starting time of the proposal.
Since: 0.1.0
Constructors
| ProposalStartingTime | |
Fields | |
Instances
newtype MaxTimeRangeWidth Source #
Represents the maximum width of a POSIXTimeRange.
Constructors
| MaxTimeRangeWidth | |
Fields | |
Instances
Plutarch-land
data PProposalTime (s :: S) Source #
Establishing timing in Proposal interactions.
In Plutus, it's impossible to determine time exactly. It's also impossible to get a single point in time, yet often we need to check various constraints on time.
For the purposes of proposals, there's a single most important feature: The ability to determine if we can perform an action. In order to correctly determine if we are able to perform certain actions, we need to know what time it roughly is, compared to when the proposal was created.
PProposalTime represents "the time according to the proposal".
Its representation is opaque, and doesn't matter.
Various functions work simply on PProposalTime and ProposalTimingConfig.
In particular, currentProposalTime is useful for extracting the time
from the txInfoValidPeriod field
of TxInfo.
We avoid PPOSIXTimeRange where we can in order to save on operations.
Note: PProposalTime doesn't need a Haskell-level equivalent because it
is only used in scripts, and does not go in datums. It is also scott-encoded
which is more efficient in usage.
Since: 0.1.0
Constructors
| PProposalTime | |
Fields
| |
Instances
newtype PProposalTimingConfig (s :: S) Source #
Plutarch-level version of ProposalTimingConfig.
Since: 0.1.0
Constructors
| PProposalTimingConfig | |
Fields
| |
Instances
newtype PProposalStartingTime (s :: S) Source #
Plutarch-level version of ProposalStartingTime.
Constructors
| PProposalStartingTime (Term s PPOSIXTime) |
Instances
newtype PMaxTimeRangeWidth (s :: S) Source #
Plutarch-level version of MaxTimeRangeWidth.
Constructors
| PMaxTimeRangeWidth (Term s PPOSIXTime) |
Instances
Compute periods given config and starting time.
createProposalStartingTime :: forall (s :: S). Term s (PMaxTimeRangeWidth :--> (PPOSIXTimeRange :--> PProposalStartingTime)) Source #
Get the starting time of a proposal, from the txInfoValidPeriod field.
For every proposal, this is only meant to run once upon creation. Given time range should be
tight enough, meaning that the width of the time range should be less than the maximum value.
Since: 0.1.0
currentProposalTime :: forall (s :: S). Term s (PPOSIXTimeRange :--> PProposalTime) Source #
Get the current proposal time, from the txInfoValidPeriod field.
If it's impossible to get a fully-bounded time, (e.g. either end of the PPOSIXTimeRange is
an infinity) then we error out.
Since: 0.1.0
isDraftPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool))) Source #
True if the PProposalTime is in the draft period.
Since: 0.1.0
isVotingPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool))) Source #
True if the PProposalTime is in the voting period.
Since: 0.1.0
isLockingPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool))) Source #
True if the PProposalTime is in the locking period.
Since: 0.1.0
isExecutionPeriod :: forall (s :: S). Term s (PProposalTimingConfig :--> (PProposalStartingTime :--> (PProposalTime :--> PBool))) Source #
True if the PProposalTime is in the execution period.
Since: 0.1.0