allow GST has a custom name

This commit is contained in:
fanghr 2022-04-21 22:15:48 +08:00
parent 8ec958646c
commit 12a0e3046e

View file

@ -12,7 +12,6 @@ module Agora.Governor (
GovernorDatum (..), GovernorDatum (..),
GovernorRedeemer (..), GovernorRedeemer (..),
Governor (..), Governor (..),
governorStateTokenName,
-- * Plutarch-land -- * Plutarch-land
PGovernorDatum (..), PGovernorDatum (..),
@ -163,13 +162,11 @@ PlutusTx.makeIsDataIndexed
-- | Parameters for creating Governor scripts. -- | Parameters for creating Governor scripts.
data Governor = Governor data Governor = Governor
{ stORef :: TxOutRef { stORef :: TxOutRef,
-- ^ An utxo, which will be spent to mint the state token for the governor validator. -- ^ An utxo, which will be spent to mint the state token for the governor validator.
stName :: TokenName
} }
governorStateTokenName :: TokenName
governorStateTokenName = TokenName ""
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Plutarch-level datum for the Governor script. -- | Plutarch-level datum for the Governor script.
@ -216,7 +213,7 @@ deriving via (DerivePConstantViaData GovernorRedeemer PGovernorRedeemer) instanc
- The utxo specified in the Governor parameter is spent. - The utxo specified in the Governor parameter is spent.
- Only one token is minted. - Only one token is minted.
- Ensure the token name is "". - Ensure the token name is 'stName'.
-} -}
governorPolicy :: Governor -> ClosedTerm PMintingPolicy governorPolicy :: Governor -> ClosedTerm PMintingPolicy
governorPolicy params = governorPolicy params =
@ -224,6 +221,7 @@ governorPolicy params =
ctx <- pletFields @'["txInfo", "purpose"] ctx' ctx <- pletFields @'["txInfo", "purpose"] ctx'
let oref = pconstant params.stORef let oref = pconstant params.stORef
ownSymbol = pownCurrencySymbol # ctx' ownSymbol = pownCurrencySymbol # ctx'
ownAssetClass = passetClass # ownSymbol # pconstant params.stName
mintValue <- plet $ pownMintValue # ctx' mintValue <- plet $ pownMintValue # ctx'
@ -538,7 +536,7 @@ governorValidator params =
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
governorStateTokenAssetClass :: Governor -> AssetClass governorStateTokenAssetClass :: Governor -> AssetClass
governorStateTokenAssetClass gov = AssetClass (symbol, governorStateTokenName) governorStateTokenAssetClass gov = AssetClass (symbol, gov.stName)
where where
policy :: MintingPolicy policy :: MintingPolicy
policy = mkMintingPolicy $ governorPolicy gov policy = mkMintingPolicy $ governorPolicy gov