improve doc string and naming as suggested by auditors
This commit is contained in:
parent
7c3d66f365
commit
ae72d0ae6d
10 changed files with 23 additions and 24 deletions
|
|
@ -15,7 +15,7 @@ import Agora.Governor (
|
||||||
GovernorDatum (
|
GovernorDatum (
|
||||||
GovernorDatum,
|
GovernorDatum,
|
||||||
createProposalTimeRangeMaxWidth,
|
createProposalTimeRangeMaxWidth,
|
||||||
maximumProposalsPerStake,
|
maximumCreatedProposalsPerStake,
|
||||||
nextProposalId,
|
nextProposalId,
|
||||||
proposalThresholds,
|
proposalThresholds,
|
||||||
proposalTimings
|
proposalTimings
|
||||||
|
|
@ -274,7 +274,7 @@ mkGovMintingCasePropertyTest name case' positiveCaseName negativeCaseName =
|
||||||
, nextProposalId = ProposalId 0
|
, nextProposalId = ProposalId 0
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
gst = assetClassValue governorAssetClass 1
|
gst = assetClassValue governorAssetClass 1
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ mkEffectTxInfo newGovDatum =
|
||||||
, nextProposalId = ProposalId 0
|
, nextProposalId = ProposalId 0
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
governorInputDatum :: Datum
|
governorInputDatum :: Datum
|
||||||
governorInputDatum = Datum $ toBuiltinData governorInputDatum'
|
governorInputDatum = Datum $ toBuiltinData governorInputDatum'
|
||||||
|
|
@ -186,7 +186,7 @@ validNewGovernorDatum =
|
||||||
, nextProposalId = ProposalId 42
|
, nextProposalId = ProposalId 42
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidNewGovernorDatum :: GovernorDatum
|
invalidNewGovernorDatum :: GovernorDatum
|
||||||
|
|
@ -199,5 +199,5 @@ invalidNewGovernorDatum =
|
||||||
, nextProposalId = ProposalId 42
|
, nextProposalId = ProposalId 42
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ data Parameters = Parameters
|
||||||
-- ^ Whether the 'GovernorDatum.proposalThresholds' field of the output
|
-- ^ Whether the 'GovernorDatum.proposalThresholds' field of the output
|
||||||
-- governor datum is valid or not.
|
-- governor datum is valid or not.
|
||||||
, datumMaxTimeRangeWidthValid :: Bool
|
, datumMaxTimeRangeWidthValid :: Bool
|
||||||
-- ^ Whether the 'GovernorDatum.maximumProposalsPerStake'field of the
|
-- ^ Whether the 'GovernorDatum.maximumCreatedProposalsPerStake'field of the
|
||||||
-- output governor datum is valid or not.
|
-- output governor datum is valid or not.
|
||||||
, datumTimingConfigValid :: Bool
|
, datumTimingConfigValid :: Bool
|
||||||
-- ^ Whether the 'GovernorDatum.proposalTimings'field of the output
|
-- ^ Whether the 'GovernorDatum.proposalTimings'field of the output
|
||||||
|
|
@ -96,7 +96,7 @@ validGovernorOutputDatum =
|
||||||
, nextProposalId = ProposalId 0
|
, nextProposalId = ProposalId 0
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidProposalThresholds :: ProposalThresholds
|
invalidProposalThresholds :: ProposalThresholds
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ governorInputDatum =
|
||||||
, nextProposalId = ProposalId 0
|
, nextProposalId = ProposalId 0
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
mkGovernorOutputDatum ::
|
mkGovernorOutputDatum ::
|
||||||
|
|
@ -115,7 +115,7 @@ mkGovernorOutputDatum DatumValid =
|
||||||
Just $
|
Just $
|
||||||
toData $
|
toData $
|
||||||
governorInputDatum
|
governorInputDatum
|
||||||
{ maximumProposalsPerStake = 4
|
{ maximumCreatedProposalsPerStake = 4
|
||||||
}
|
}
|
||||||
mkGovernorOutputDatum ValueInvalid =
|
mkGovernorOutputDatum ValueInvalid =
|
||||||
let invalidProposalThresholds =
|
let invalidProposalThresholds =
|
||||||
|
|
|
||||||
|
|
@ -426,14 +426,14 @@ governorInputDatum =
|
||||||
, nextProposalId = ProposalId 42
|
, nextProposalId = ProposalId 42
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = 3
|
, maximumCreatedProposalsPerStake = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Create the output governor datum given the parameters.
|
-- | Create the output governor datum given the parameters.
|
||||||
mkGovernorOutputDatum :: GovernorParameters -> GovernorDatum
|
mkGovernorOutputDatum :: GovernorParameters -> GovernorDatum
|
||||||
mkGovernorOutputDatum ps =
|
mkGovernorOutputDatum ps =
|
||||||
if ps.invalidGovernorOutputDatum
|
if ps.invalidGovernorOutputDatum
|
||||||
then governorInputDatum {maximumProposalsPerStake = 15}
|
then governorInputDatum {maximumCreatedProposalsPerStake = 15}
|
||||||
else governorInputDatum
|
else governorInputDatum
|
||||||
|
|
||||||
-- | Reference to the governor UTXO.
|
-- | Reference to the governor UTXO.
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ data Parameters = Parameters
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- | See 'GovernorDatum.maximumProposalsPerStake'.
|
-- | See 'GovernorDatum.maximumCreatedProposalsPerStake'.
|
||||||
maxProposalPerStake :: Integer
|
maxProposalPerStake :: Integer
|
||||||
maxProposalPerStake = 3
|
maxProposalPerStake = 3
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ governorInputDatum =
|
||||||
, nextProposalId = thisProposalId
|
, nextProposalId = thisProposalId
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = maxProposalPerStake
|
, maximumCreatedProposalsPerStake = maxProposalPerStake
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Create governor output datum given the parameters.
|
-- | Create governor output datum given the parameters.
|
||||||
|
|
@ -196,7 +196,7 @@ mkGovernorOutputDatum ps =
|
||||||
, nextProposalId = nextPid
|
, nextProposalId = nextPid
|
||||||
, proposalTimings = def
|
, proposalTimings = def
|
||||||
, createProposalTimeRangeMaxWidth = def
|
, createProposalTimeRangeMaxWidth = def
|
||||||
, maximumProposalsPerStake = maxProposalPerStake
|
, maximumCreatedProposalsPerStake = maxProposalPerStake
|
||||||
}
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,8 @@ data GovernorDatum = GovernorDatum
|
||||||
-- Will get copied over upon the creation of proposals.
|
-- Will get copied over upon the creation of proposals.
|
||||||
, createProposalTimeRangeMaxWidth :: MaxTimeRangeWidth
|
, createProposalTimeRangeMaxWidth :: MaxTimeRangeWidth
|
||||||
-- ^ The maximum valid duration of a transaction that creats a proposal.
|
-- ^ The maximum valid duration of a transaction that creats a proposal.
|
||||||
, maximumProposalsPerStake :: Integer
|
, maximumCreatedProposalsPerStake :: Integer
|
||||||
-- ^ The maximum number of unfinished proposals that a stake is allowed to be
|
-- ^ The maximum number of proposals created by any given stakes.
|
||||||
-- associated to.
|
|
||||||
}
|
}
|
||||||
deriving stock
|
deriving stock
|
||||||
( -- | @since 0.1.0
|
( -- | @since 0.1.0
|
||||||
|
|
@ -183,7 +182,7 @@ newtype PGovernorDatum (s :: S) = PGovernorDatum
|
||||||
, "nextProposalId" ':= PProposalId
|
, "nextProposalId" ':= PProposalId
|
||||||
, "proposalTimings" ':= PProposalTimingConfig
|
, "proposalTimings" ':= PProposalTimingConfig
|
||||||
, "createProposalTimeRangeMaxWidth" ':= PMaxTimeRangeWidth
|
, "createProposalTimeRangeMaxWidth" ':= PMaxTimeRangeWidth
|
||||||
, "maximumProposalsPerStake" ':= PInteger
|
, "maximumCreatedProposalsPerStake" ':= PInteger
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -380,8 +380,8 @@ governorValidator =
|
||||||
.= governorInputDatumF.proposalTimings
|
.= governorInputDatumF.proposalTimings
|
||||||
.& #createProposalTimeRangeMaxWidth
|
.& #createProposalTimeRangeMaxWidth
|
||||||
.= governorInputDatumF.createProposalTimeRangeMaxWidth
|
.= governorInputDatumF.createProposalTimeRangeMaxWidth
|
||||||
.& #maximumProposalsPerStake
|
.& #maximumCreatedProposalsPerStake
|
||||||
.= governorInputDatumF.maximumProposalsPerStake
|
.= governorInputDatumF.maximumCreatedProposalsPerStake
|
||||||
)
|
)
|
||||||
|
|
||||||
pguardC "Only next proposal id gets advanced" $
|
pguardC "Only next proposal id gets advanced" $
|
||||||
|
|
@ -410,7 +410,7 @@ governorValidator =
|
||||||
pguardC "Proposals created by the stake must not exceed the limit" $
|
pguardC "Proposals created by the stake must not exceed the limit" $
|
||||||
pnumCreatedProposals
|
pnumCreatedProposals
|
||||||
# stakeInputDatumF.lockedBy
|
# stakeInputDatumF.lockedBy
|
||||||
#< governorInputDatumF.maximumProposalsPerStake
|
#< governorInputDatumF.maximumCreatedProposalsPerStake
|
||||||
|
|
||||||
let gtThreshold =
|
let gtThreshold =
|
||||||
pfromData $
|
pfromData $
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ newtype ResultTag = ResultTag {getResultTag :: Integer}
|
||||||
data ProposalStatus
|
data ProposalStatus
|
||||||
= -- | A draft proposal represents a proposal that has yet to be realized.
|
= -- | 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
|
-- proposal, and needs cosigners to enable that to happen. This is
|
||||||
-- similar to a "temperature check", but only useful if multiple people
|
-- similar to a "temperature check", but only useful if multiple people
|
||||||
-- want to pool governance tokens together. If the proposal doesn't get to
|
-- want to pool governance tokens together. If the proposal doesn't get to
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ data StakeRedeemer
|
||||||
= -- | Deposit or withdraw a discrete amount of the staked governance token.
|
= -- | Deposit or withdraw a discrete amount of the staked governance token.
|
||||||
-- Stake must be unlocked.
|
-- Stake must be unlocked.
|
||||||
DepositWithdraw (Tagged GTTag Integer)
|
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.
|
-- Stake must be unlocked.
|
||||||
Destroy
|
Destroy
|
||||||
| -- | Permit a Vote to be added onto a 'Agora.Proposal.Proposal'.
|
| -- | Permit a Vote to be added onto a 'Agora.Proposal.Proposal'.
|
||||||
|
|
@ -291,7 +291,7 @@ instance PTryFrom PData (PAsData PStakeDatum)
|
||||||
data PStakeRedeemer (s :: S)
|
data PStakeRedeemer (s :: S)
|
||||||
= -- | Deposit or withdraw a discrete amount of the staked governance token.
|
= -- | Deposit or withdraw a discrete amount of the staked governance token.
|
||||||
PDepositWithdraw (Term s (PDataRecord '["delta" ':= PTagged GTTag PInteger]))
|
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 '[]))
|
PDestroy (Term s (PDataRecord '[]))
|
||||||
| PPermitVote (Term s (PDataRecord '[]))
|
| PPermitVote (Term s (PDataRecord '[]))
|
||||||
| PRetractVotes (Term s (PDataRecord '[]))
|
| PRetractVotes (Term s (PDataRecord '[]))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue