store starting time of the proposal in its datum
... hardcoded to 0 upon creation for now
This commit is contained in:
parent
d44fe083da
commit
fc48709c07
7 changed files with 26 additions and 2 deletions
|
|
@ -80,6 +80,7 @@ import Sample.Shared (
|
||||||
stake,
|
stake,
|
||||||
stakeAddress,
|
stakeAddress,
|
||||||
stakeAssetClass,
|
stakeAssetClass,
|
||||||
|
tmpProposalStartingTime,
|
||||||
)
|
)
|
||||||
import Test.Util (datumPair, toDatumHash)
|
import Test.Util (datumPair, toDatumHash)
|
||||||
|
|
||||||
|
|
@ -236,6 +237,7 @@ createProposal =
|
||||||
, thresholds = defaultProposalThresholds
|
, thresholds = defaultProposalThresholds
|
||||||
, votes = emptyVotesFor effects
|
, votes = emptyVotesFor effects
|
||||||
, timingConfig = proposalTimingConfig
|
, timingConfig = proposalTimingConfig
|
||||||
|
, startingTime = tmpProposalStartingTime
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
proposalOutput :: TxOut
|
proposalOutput :: TxOut
|
||||||
|
|
@ -411,6 +413,7 @@ mintGATs =
|
||||||
, thresholds = defaultProposalThresholds
|
, thresholds = defaultProposalThresholds
|
||||||
, votes = proposalVotes
|
, votes = proposalVotes
|
||||||
, timingConfig = proposalTimingConfig
|
, timingConfig = proposalTimingConfig
|
||||||
|
, startingTime = tmpProposalStartingTime
|
||||||
}
|
}
|
||||||
proposalInputDatum :: Datum
|
proposalInputDatum :: Datum
|
||||||
proposalInputDatum = Datum $ toBuiltinData proposalInputDatum'
|
proposalInputDatum = Datum $ toBuiltinData proposalInputDatum'
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ proposalCreation =
|
||||||
, thresholds = defaultProposalThresholds
|
, thresholds = defaultProposalThresholds
|
||||||
, votes = emptyVotesFor effects
|
, votes = emptyVotesFor effects
|
||||||
, timingConfig = proposalTimingConfig
|
, timingConfig = proposalTimingConfig
|
||||||
|
, startingTime = tmpProposalStartingTime
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -169,6 +170,7 @@ cosignProposal newSigners =
|
||||||
, thresholds = defaultProposalThresholds
|
, thresholds = defaultProposalThresholds
|
||||||
, votes = emptyVotesFor effects
|
, votes = emptyVotesFor effects
|
||||||
, timingConfig = proposalTimingConfig
|
, timingConfig = proposalTimingConfig
|
||||||
|
, startingTime = tmpProposalStartingTime
|
||||||
}
|
}
|
||||||
stakeDatum :: StakeDatum
|
stakeDatum :: StakeDatum
|
||||||
stakeDatum = StakeDatum (Tagged 50_000_000) signer2 []
|
stakeDatum = StakeDatum (Tagged 50_000_000) signer2 []
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ module Sample.Shared (
|
||||||
proposalValidatorHash,
|
proposalValidatorHash,
|
||||||
proposalValidatorAddress,
|
proposalValidatorAddress,
|
||||||
proposalTimingConfig,
|
proposalTimingConfig,
|
||||||
|
tmpProposalStartingTime,
|
||||||
|
|
||||||
-- ** Authority
|
-- ** Authority
|
||||||
authorityToken,
|
authorityToken,
|
||||||
|
|
@ -76,6 +77,7 @@ import Agora.Proposal (
|
||||||
ProposalThresholds (..),
|
ProposalThresholds (..),
|
||||||
)
|
)
|
||||||
import Agora.Proposal.Time (
|
import Agora.Proposal.Time (
|
||||||
|
ProposalStartingTime (..),
|
||||||
ProposalTimingConfig (..),
|
ProposalTimingConfig (..),
|
||||||
)
|
)
|
||||||
import Agora.Stake (Stake (..))
|
import Agora.Stake (Stake (..))
|
||||||
|
|
@ -197,6 +199,10 @@ proposalTimingConfig =
|
||||||
, executingTime = 3000
|
, executingTime = 3000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- FIXME: should be removed.
|
||||||
|
tmpProposalStartingTime :: ProposalStartingTime
|
||||||
|
tmpProposalStartingTime = ProposalStartingTime 0
|
||||||
|
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
|
|
||||||
treasuryOut :: TxOut
|
treasuryOut :: TxOut
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ tests =
|
||||||
, (ResultTag 1, AssocMap.empty)
|
, (ResultTag 1, AssocMap.empty)
|
||||||
]
|
]
|
||||||
, timingConfig = Shared.proposalTimingConfig
|
, timingConfig = Shared.proposalTimingConfig
|
||||||
|
, startingTime = Shared.tmpProposalStartingTime
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(Cosign [signer2])
|
(Cosign [signer2])
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ import Plutarch.TryFrom (ptryFrom)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Agora.Proposal.Time (ProposalTimingConfig (..))
|
import Agora.Proposal.Time (ProposalStartingTime (..), ProposalTimingConfig (..))
|
||||||
import Plutus.V1.Ledger.Api (
|
import Plutus.V1.Ledger.Api (
|
||||||
CurrencySymbol (..),
|
CurrencySymbol (..),
|
||||||
MintingPolicy,
|
MintingPolicy,
|
||||||
|
|
@ -579,6 +579,8 @@ governorValidator gov =
|
||||||
.& #votes .= proposalInputDatumF.votes
|
.& #votes .= proposalInputDatumF.votes
|
||||||
-- FIXME: copy from the governor datum
|
-- FIXME: copy from the governor datum
|
||||||
.& #timingConfig .= pdata (pconstant tmpTimingConfig)
|
.& #timingConfig .= pdata (pconstant tmpTimingConfig)
|
||||||
|
-- FIXME: calculate from 'txInfoValidRange'
|
||||||
|
.& #startingTime .= pdata (pconstant tmpProposalStartingTime)
|
||||||
)
|
)
|
||||||
|
|
||||||
tcassert "Unexpected output proposal datum" $
|
tcassert "Unexpected output proposal datum" $
|
||||||
|
|
@ -740,6 +742,10 @@ governorValidator gov =
|
||||||
, executingTime = 3000
|
, executingTime = 3000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- TODO: remove this.
|
||||||
|
tmpProposalStartingTime :: ProposalStartingTime
|
||||||
|
tmpProposalStartingTime = ProposalStartingTime 0
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- | Get the 'CurrencySymbol' of GST.
|
-- | Get the 'CurrencySymbol' of GST.
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ import PlutusTx.AssocMap qualified as AssocMap
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Agora.Proposal.Time (PProposalTimingConfig, ProposalTimingConfig)
|
import Agora.Proposal.Time (PProposalStartingTime, PProposalTimingConfig, ProposalStartingTime, ProposalTimingConfig)
|
||||||
import Agora.SafeMoney (GTTag)
|
import Agora.SafeMoney (GTTag)
|
||||||
import Agora.Utils (pkeysEqual, pnotNull)
|
import Agora.Utils (pkeysEqual, pnotNull)
|
||||||
import Control.Applicative (Const)
|
import Control.Applicative (Const)
|
||||||
|
|
@ -190,6 +190,8 @@ data ProposalDatum = ProposalDatum
|
||||||
-- ^ Vote tally on the proposal
|
-- ^ Vote tally on the proposal
|
||||||
, timingConfig :: ProposalTimingConfig
|
, timingConfig :: ProposalTimingConfig
|
||||||
-- ^ Timing configuration copied over on initialization.
|
-- ^ Timing configuration copied over on initialization.
|
||||||
|
, startingTime :: ProposalStartingTime
|
||||||
|
-- ^ The time upon the creation of the proposal.
|
||||||
}
|
}
|
||||||
deriving stock (Eq, Show, GHC.Generic)
|
deriving stock (Eq, Show, GHC.Generic)
|
||||||
|
|
||||||
|
|
@ -359,6 +361,7 @@ newtype PProposalDatum (s :: S) = PProposalDatum
|
||||||
, "thresholds" ':= PProposalThresholds
|
, "thresholds" ':= PProposalThresholds
|
||||||
, "votes" ':= PProposalVotes
|
, "votes" ':= PProposalVotes
|
||||||
, "timingConfig" ':= PProposalTimingConfig
|
, "timingConfig" ':= PProposalTimingConfig
|
||||||
|
, "startingTime" ':= PProposalStartingTime
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ proposalValidator proposal =
|
||||||
, "thresholds"
|
, "thresholds"
|
||||||
, "votes"
|
, "votes"
|
||||||
, "timingConfig"
|
, "timingConfig"
|
||||||
|
, "startingTime"
|
||||||
]
|
]
|
||||||
proposalDatum
|
proposalDatum
|
||||||
|
|
||||||
|
|
@ -255,6 +256,7 @@ proposalValidator proposal =
|
||||||
.& #thresholds .= proposalF.thresholds
|
.& #thresholds .= proposalF.thresholds
|
||||||
.& #votes .= pdata expectedNewVotes
|
.& #votes .= pdata expectedNewVotes
|
||||||
.& #timingConfig .= proposalF.timingConfig
|
.& #timingConfig .= proposalF.timingConfig
|
||||||
|
.& #startingTime .= proposalF.startingTime
|
||||||
)
|
)
|
||||||
|
|
||||||
tcassert "Invalid output proposal" $ proposalOut #== expectedProposalOut
|
tcassert "Invalid output proposal" $ proposalOut #== expectedProposalOut
|
||||||
|
|
@ -345,6 +347,7 @@ proposalValidator proposal =
|
||||||
.& #thresholds .= proposalF.thresholds
|
.& #thresholds .= proposalF.thresholds
|
||||||
.& #votes .= proposalF.votes
|
.& #votes .= proposalF.votes
|
||||||
.& #timingConfig .= proposalF.timingConfig
|
.& #timingConfig .= proposalF.timingConfig
|
||||||
|
.& #startingTime .= proposalF.startingTime
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
in foldr1
|
in foldr1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue