From 7c50b10309e5afd98e102f2ba7a19be4709c711d Mon Sep 17 00:00:00 2001 From: fanghr Date: Thu, 21 Apr 2022 22:15:48 +0800 Subject: [PATCH] allow GST has a custom name --- agora/Agora/Governor.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/agora/Agora/Governor.hs b/agora/Agora/Governor.hs index 52db026..fa06ce7 100644 --- a/agora/Agora/Governor.hs +++ b/agora/Agora/Governor.hs @@ -12,7 +12,6 @@ module Agora.Governor ( GovernorDatum (..), GovernorRedeemer (..), Governor (..), - governorStateTokenName, -- * Plutarch-land PGovernorDatum (..), @@ -163,13 +162,11 @@ PlutusTx.makeIsDataIndexed -- | Parameters for creating Governor scripts. data Governor = Governor - { stORef :: TxOutRef + { stORef :: TxOutRef, -- ^ 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. @@ -216,7 +213,7 @@ deriving via (DerivePConstantViaData GovernorRedeemer PGovernorRedeemer) instanc - The utxo specified in the Governor parameter is spent. - Only one token is minted. - - Ensure the token name is "". + - Ensure the token name is 'stName'. -} governorPolicy :: Governor -> ClosedTerm PMintingPolicy governorPolicy params = @@ -224,6 +221,7 @@ governorPolicy params = ctx <- pletFields @'["txInfo", "purpose"] ctx' let oref = pconstant params.stORef ownSymbol = pownCurrencySymbol # ctx' + ownAssetClass = passetClass # ownSymbol # pconstant params.stName mintValue <- plet $ pownMintValue # ctx' @@ -538,7 +536,7 @@ governorValidator params = -------------------------------------------------------------------------------- governorStateTokenAssetClass :: Governor -> AssetClass -governorStateTokenAssetClass gov = AssetClass (symbol, governorStateTokenName) +governorStateTokenAssetClass gov = AssetClass (symbol, gov.stName) where policy :: MintingPolicy policy = mkMintingPolicy $ governorPolicy gov