From f9a1e3b87f19ca27df25cfdfcc5a498e20f98c31 Mon Sep 17 00:00:00 2001 From: Hongrui Fang Date: Thu, 10 Nov 2022 18:24:52 +0800 Subject: [PATCH] improve doc string and naming as suggested by auditors --- agora-specs/Property/Governor.hs | 4 ++-- agora-specs/Sample/Effect/GovernorMutation.hs | 6 +++--- agora-specs/Sample/Governor/Initialize.hs | 4 ++-- agora-specs/Sample/Governor/Mutate.hs | 4 ++-- agora-specs/Sample/Proposal/Advance.hs | 4 ++-- agora-specs/Sample/Proposal/Create.hs | 6 +++--- agora/Agora/Governor.hs | 7 +++---- agora/Agora/Governor/Scripts.hs | 6 +++--- agora/Agora/Proposal.hs | 2 +- agora/Agora/Stake.hs | 4 ++-- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/agora-specs/Property/Governor.hs b/agora-specs/Property/Governor.hs index 5e5547c..1c85e6e 100644 --- a/agora-specs/Property/Governor.hs +++ b/agora-specs/Property/Governor.hs @@ -15,7 +15,7 @@ import Agora.Governor ( GovernorDatum ( GovernorDatum, createProposalTimeRangeMaxWidth, - maximumProposalsPerStake, + maximumCreatedProposalsPerStake, nextProposalId, proposalThresholds, proposalTimings @@ -274,7 +274,7 @@ mkGovMintingCasePropertyTest name case' positiveCaseName negativeCaseName = , nextProposalId = ProposalId 0 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } gst = assetClassValue governorAssetClass 1 diff --git a/agora-specs/Sample/Effect/GovernorMutation.hs b/agora-specs/Sample/Effect/GovernorMutation.hs index 7739d80..dd25bed 100644 --- a/agora-specs/Sample/Effect/GovernorMutation.hs +++ b/agora-specs/Sample/Effect/GovernorMutation.hs @@ -114,7 +114,7 @@ mkEffectTxInfo newGovDatum = , nextProposalId = ProposalId 0 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } governorInputDatum :: Datum governorInputDatum = Datum $ toBuiltinData governorInputDatum' @@ -186,7 +186,7 @@ validNewGovernorDatum = , nextProposalId = ProposalId 42 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } invalidNewGovernorDatum :: GovernorDatum @@ -199,5 +199,5 @@ invalidNewGovernorDatum = , nextProposalId = ProposalId 42 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } diff --git a/agora-specs/Sample/Governor/Initialize.hs b/agora-specs/Sample/Governor/Initialize.hs index e07117d..ec7cce6 100644 --- a/agora-specs/Sample/Governor/Initialize.hs +++ b/agora-specs/Sample/Governor/Initialize.hs @@ -72,7 +72,7 @@ data Parameters = Parameters -- ^ Whether the 'GovernorDatum.proposalThresholds' field of the output -- governor datum is valid or not. , datumMaxTimeRangeWidthValid :: Bool - -- ^ Whether the 'GovernorDatum.maximumProposalsPerStake'field of the + -- ^ Whether the 'GovernorDatum.maximumCreatedProposalsPerStake'field of the -- output governor datum is valid or not. , datumTimingConfigValid :: Bool -- ^ Whether the 'GovernorDatum.proposalTimings'field of the output @@ -96,7 +96,7 @@ validGovernorOutputDatum = , nextProposalId = ProposalId 0 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } invalidProposalThresholds :: ProposalThresholds diff --git a/agora-specs/Sample/Governor/Mutate.hs b/agora-specs/Sample/Governor/Mutate.hs index a2ca582..11577f7 100644 --- a/agora-specs/Sample/Governor/Mutate.hs +++ b/agora-specs/Sample/Governor/Mutate.hs @@ -105,7 +105,7 @@ governorInputDatum = , nextProposalId = ProposalId 0 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } mkGovernorOutputDatum :: @@ -115,7 +115,7 @@ mkGovernorOutputDatum DatumValid = Just $ toData $ governorInputDatum - { maximumProposalsPerStake = 4 + { maximumCreatedProposalsPerStake = 4 } mkGovernorOutputDatum ValueInvalid = let invalidProposalThresholds = diff --git a/agora-specs/Sample/Proposal/Advance.hs b/agora-specs/Sample/Proposal/Advance.hs index e7e427a..38232e9 100644 --- a/agora-specs/Sample/Proposal/Advance.hs +++ b/agora-specs/Sample/Proposal/Advance.hs @@ -426,14 +426,14 @@ governorInputDatum = , nextProposalId = ProposalId 42 , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = 3 + , maximumCreatedProposalsPerStake = 3 } -- | Create the output governor datum given the parameters. mkGovernorOutputDatum :: GovernorParameters -> GovernorDatum mkGovernorOutputDatum ps = if ps.invalidGovernorOutputDatum - then governorInputDatum {maximumProposalsPerStake = 15} + then governorInputDatum {maximumCreatedProposalsPerStake = 15} else governorInputDatum -- | Reference to the governor UTXO. diff --git a/agora-specs/Sample/Proposal/Create.hs b/agora-specs/Sample/Proposal/Create.hs index 94fec7a..04d4486 100644 --- a/agora-specs/Sample/Proposal/Create.hs +++ b/agora-specs/Sample/Proposal/Create.hs @@ -136,7 +136,7 @@ data Parameters = Parameters -------------------------------------------------------------------------------- --- | See 'GovernorDatum.maximumProposalsPerStake'. +-- | See 'GovernorDatum.maximumCreatedProposalsPerStake'. maxProposalPerStake :: Integer maxProposalPerStake = 3 @@ -181,7 +181,7 @@ governorInputDatum = , nextProposalId = thisProposalId , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = maxProposalPerStake + , maximumCreatedProposalsPerStake = maxProposalPerStake } -- | Create governor output datum given the parameters. @@ -196,7 +196,7 @@ mkGovernorOutputDatum ps = , nextProposalId = nextPid , proposalTimings = def , createProposalTimeRangeMaxWidth = def - , maximumProposalsPerStake = maxProposalPerStake + , maximumCreatedProposalsPerStake = maxProposalPerStake } -------------------------------------------------------------------------------- diff --git a/agora/Agora/Governor.hs b/agora/Agora/Governor.hs index a8ced77..d536cc2 100644 --- a/agora/Agora/Governor.hs +++ b/agora/Agora/Governor.hs @@ -87,9 +87,8 @@ data GovernorDatum = GovernorDatum -- Will get copied over upon the creation of proposals. , createProposalTimeRangeMaxWidth :: MaxTimeRangeWidth -- ^ The maximum valid duration of a transaction that creats a proposal. - , maximumProposalsPerStake :: Integer - -- ^ The maximum number of unfinished proposals that a stake is allowed to be - -- associated to. + , maximumCreatedProposalsPerStake :: Integer + -- ^ The maximum number of proposals created by any given stakes. } deriving stock ( -- | @since 0.1.0 @@ -183,7 +182,7 @@ newtype PGovernorDatum (s :: S) = PGovernorDatum , "nextProposalId" ':= PProposalId , "proposalTimings" ':= PProposalTimingConfig , "createProposalTimeRangeMaxWidth" ':= PMaxTimeRangeWidth - , "maximumProposalsPerStake" ':= PInteger + , "maximumCreatedProposalsPerStake" ':= PInteger ] ) } diff --git a/agora/Agora/Governor/Scripts.hs b/agora/Agora/Governor/Scripts.hs index 8dfe72e..6c5c0ab 100644 --- a/agora/Agora/Governor/Scripts.hs +++ b/agora/Agora/Governor/Scripts.hs @@ -380,8 +380,8 @@ governorValidator = .= governorInputDatumF.proposalTimings .& #createProposalTimeRangeMaxWidth .= governorInputDatumF.createProposalTimeRangeMaxWidth - .& #maximumProposalsPerStake - .= governorInputDatumF.maximumProposalsPerStake + .& #maximumCreatedProposalsPerStake + .= governorInputDatumF.maximumCreatedProposalsPerStake ) pguardC "Only next proposal id gets advanced" $ @@ -410,7 +410,7 @@ governorValidator = pguardC "Proposals created by the stake must not exceed the limit" $ pnumCreatedProposals # stakeInputDatumF.lockedBy - #< governorInputDatumF.maximumProposalsPerStake + #< governorInputDatumF.maximumCreatedProposalsPerStake let gtThreshold = pfromData $ diff --git a/agora/Agora/Proposal.hs b/agora/Agora/Proposal.hs index 19a86e8..b84f549 100644 --- a/agora/Agora/Proposal.hs +++ b/agora/Agora/Proposal.hs @@ -162,7 +162,7 @@ newtype ResultTag = ResultTag {getResultTag :: Integer} data ProposalStatus = -- | A draft proposal represents a proposal that has yet to be realized. -- - -- In effect, this means one which didn't have enough LQ to be a full + -- In effect, this means one which didn't have enough GT to be a full -- proposal, and needs cosigners to enable that to happen. This is -- similar to a "temperature check", but only useful if multiple people -- want to pool governance tokens together. If the proposal doesn't get to diff --git a/agora/Agora/Stake.hs b/agora/Agora/Stake.hs index 25dcc72..714c440 100644 --- a/agora/Agora/Stake.hs +++ b/agora/Agora/Stake.hs @@ -160,7 +160,7 @@ data StakeRedeemer = -- | Deposit or withdraw a discrete amount of the staked governance token. -- Stake must be unlocked. DepositWithdraw (Tagged GTTag Integer) - | -- | Destroy a stake, retrieving its LQ, the minimum ADA and any other assets. + | -- | Destroy a stake, retrieving its GT, the minimum ADA and any other assets. -- Stake must be unlocked. Destroy | -- | Permit a Vote to be added onto a 'Agora.Proposal.Proposal'. @@ -291,7 +291,7 @@ instance PTryFrom PData (PAsData PStakeDatum) data PStakeRedeemer (s :: S) = -- | Deposit or withdraw a discrete amount of the staked governance token. PDepositWithdraw (Term s (PDataRecord '["delta" ':= PTagged GTTag PInteger])) - | -- | Destroy a stake, retrieving its LQ, the minimum ADA and any other assets. + | -- | Destroy a stake, retrieving its GT, the minimum ADA and any other assets. PDestroy (Term s (PDataRecord '[])) | PPermitVote (Term s (PDataRecord '[])) | PRetractVotes (Term s (PDataRecord '[]))