agora-0.1.0
Maintaineremi@haskell.fyi
Safe HaskellSafe-Inferred
LanguageHaskell2010

Agora.Proposal.Time

Description

Time functions for proposal phases.

Synopsis

Haskell-land

data ProposalTimingConfig Source #

Constructors

ProposalTimingConfig 

Fields

Instances

Instances details
Generic ProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Rep ProposalTimingConfig :: Type -> Type Source #

Show ProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Eq ProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PConstantDecl ProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

FromData ProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

ToData ProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

UnsafeFromData ProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep ProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep ProposalTimingConfig = D1 ('MetaData "ProposalTimingConfig" "Agora.Proposal.Time" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) (C1 ('MetaCons "ProposalTimingConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "draftTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime) :*: S1 ('MetaSel ('Just "votingTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime)) :*: (S1 ('MetaSel ('Just "lockingTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime) :*: S1 ('MetaSel ('Just "executingTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime))))
type PConstantRepr ProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PConstanted ProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

newtype ProposalStartingTime Source #

Represents the starting time of the proposal.

Since: 0.1.0

Instances

Instances details
Generic ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Rep ProposalStartingTime :: Type -> Type Source #

Show ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

Eq ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

PConstantDecl ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

FromData ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

ToData ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

UnsafeFromData ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

type Rep ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

type Rep ProposalStartingTime = D1 ('MetaData "ProposalStartingTime" "Agora.Proposal.Time" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'True) (C1 ('MetaCons "ProposalStartingTime" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProposalStartingTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime)))
type PConstantRepr ProposalStartingTime Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PConstanted ProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

newtype MaxTimeRangeWidth Source #

Represents the maximum width of a POSIXTimeRange.

Constructors

MaxTimeRangeWidth 

Instances

Instances details
Generic MaxTimeRangeWidth Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Rep MaxTimeRangeWidth :: Type -> Type Source #

Show MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Eq MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Ord MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PConstantDecl MaxTimeRangeWidth Source # 
Instance details

Defined in Agora.Proposal.Time

FromData MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

ToData MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

UnsafeFromData MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep MaxTimeRangeWidth = D1 ('MetaData "MaxTimeRangeWidth" "Agora.Proposal.Time" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'True) (C1 ('MetaCons "MaxTimeRangeWidth" 'PrefixI 'True) (S1 ('MetaSel ('Just "getMaxWidth") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime)))
type PConstantRepr MaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PConstanted MaxTimeRangeWidth Source # 
Instance details

Defined in Agora.Proposal.Time

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

Instances

Instances details
PEq PProposalTime Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Methods

(#==) :: forall (s :: S). Term s PProposalTime -> Term s PProposalTime -> Term s PBool Source #

PlutusType PProposalTime Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type PInner PProposalTime b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PProposalTime s -> Term s (PInner PProposalTime b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PProposalTime b) -> (PProposalTime s -> Term s b) -> Term s b Source #

Generic (PProposalTime s) Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Rep (PProposalTime s) :: Type -> Type Source #

Generic (PProposalTime s) Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Code (PProposalTime s) :: [[Type]] Source #

HasDatatypeInfo (PProposalTime s) Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type DatatypeInfoOf (PProposalTime s) :: DatatypeInfo Source #

type PInner PProposalTime b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PInner PProposalTime b' = ScottFn (ScottList 'SI (ToPType2 (Code (PProposalTime 'SI))) b') b'
type Rep (PProposalTime s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep (PProposalTime s) = D1 ('MetaData "PProposalTime" "Agora.Proposal.Time" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) (C1 ('MetaCons "PProposalTime" 'PrefixI 'True) (S1 ('MetaSel ('Just "lowerBound") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s PPOSIXTime)) :*: S1 ('MetaSel ('Just "upperBound") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s PPOSIXTime))))
type Code (PProposalTime s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type DatatypeInfoOf (PProposalTime s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

newtype PProposalTimingConfig (s :: S) Source #

Plutarch-level version of ProposalTimingConfig.

Since: 0.1.0

Constructors

PProposalTimingConfig 

Fields

Instances

Instances details
PIsData PProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PIsDataRepr PProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

PDataFields PProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

PlutusType PProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type PInner PProposalTimingConfig b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PProposalTimingConfig s -> Term s (PInner PProposalTimingConfig b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PProposalTimingConfig b) -> (PProposalTimingConfig s -> Term s b) -> Term s b Source #

PUnsafeLiftDecl PProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Associated Types

type PLifted PProposalTimingConfig = (r :: Type) Source #

PTryFrom PData (PAsData PProposalTimingConfig) Source # 
Instance details

Defined in Agora.Proposal.Time

Generic (PProposalTimingConfig s) Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Rep (PProposalTimingConfig s) :: Type -> Type Source #

Generic (PProposalTimingConfig s) Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type Code (PProposalTimingConfig s) :: [[Type]] Source #

type PIsDataReprRepr PProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PFields PProposalTimingConfig Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PLifted PProposalTimingConfig Source # 
Instance details

Defined in Agora.Proposal.Time

type PInner PProposalTimingConfig b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PTryFromExcess PData (PAsData PProposalTimingConfig) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep (PProposalTimingConfig s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type Rep (PProposalTimingConfig s) = D1 ('MetaData "PProposalTimingConfig" "Agora.Proposal.Time" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'True) (C1 ('MetaCons "PProposalTimingConfig" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProposalTimingConfig") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PDataRecord '["draftTime" := PPOSIXTime, "votingTime" := PPOSIXTime, "lockingTime" := PPOSIXTime, "executingTime" := PPOSIXTime])))))
type Code (PProposalTimingConfig s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

newtype PProposalStartingTime (s :: S) Source #

Plutarch-level version of ProposalStartingTime.

Instances

Instances details
PEq PProposalStartingTime Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

POrd PProposalStartingTime Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PIsData PProposalStartingTime Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PlutusType PProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type PInner PProposalStartingTime b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PProposalStartingTime s -> Term s (PInner PProposalStartingTime b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PProposalStartingTime b) -> (PProposalStartingTime s -> Term s b) -> Term s b Source #

PUnsafeLiftDecl PProposalStartingTime Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Associated Types

type PLifted PProposalStartingTime = (r :: Type) Source #

PTryFrom PData (PAsData PProposalStartingTime) Source # 
Instance details

Defined in Agora.Proposal.Time

type PLifted PProposalStartingTime Source # 
Instance details

Defined in Agora.Proposal.Time

type PInner PProposalStartingTime b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PTryFromExcess PData (PAsData PProposalStartingTime) Source # 
Instance details

Defined in Agora.Proposal.Time

newtype PMaxTimeRangeWidth (s :: S) Source #

Plutarch-level version of MaxTimeRangeWidth.

Instances

Instances details
PEq PMaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Methods

(#==) :: forall (s :: S). Term s PMaxTimeRangeWidth -> Term s PMaxTimeRangeWidth -> Term s PBool Source #

POrd PMaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PIsData PMaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

PlutusType PMaxTimeRangeWidth Source # 
Instance details

Defined in Agora.Proposal.Time

Associated Types

type PInner PMaxTimeRangeWidth b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PMaxTimeRangeWidth s -> Term s (PInner PMaxTimeRangeWidth b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PMaxTimeRangeWidth b) -> (PMaxTimeRangeWidth s -> Term s b) -> Term s b Source #

PUnsafeLiftDecl PMaxTimeRangeWidth Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

Associated Types

type PLifted PMaxTimeRangeWidth = (r :: Type) Source #

PTryFrom PData (PAsData PMaxTimeRangeWidth) Source # 
Instance details

Defined in Agora.Proposal.Time

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PMaxTimeRangeWidth), Reduce (PTryFromExcess PData (PAsData PMaxTimeRangeWidth) s)) -> Term s r) -> Term s r Source #

type PLifted PMaxTimeRangeWidth Source # 
Instance details

Defined in Agora.Proposal.Time

type PInner PMaxTimeRangeWidth b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

type PTryFromExcess PData (PAsData PMaxTimeRangeWidth) Source #

Since: 0.1.0

Instance details

Defined in Agora.Proposal.Time

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