improve doc string and naming as suggested by auditors

This commit is contained in:
Hongrui Fang 2022-11-10 18:24:52 +08:00
parent eacec0a10b
commit f9a1e3b87f
No known key found for this signature in database
GPG key ID: F10AB2CCE24113DD
10 changed files with 23 additions and 24 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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
]
)
}

View file

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

View file

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

View file

@ -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 '[]))