AgoraScriptInfo for linker informations
This commit is contained in:
parent
d2018afd4d
commit
ead3467d57
2 changed files with 25 additions and 96 deletions
|
|
@ -5,6 +5,7 @@ module Agora.Aeson.Orphans (AsBase16Bytes (..)) where
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
import Data.Coerce (Coercible, coerce)
|
||||
import Plutarch.Orphans ()
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -19,7 +20,6 @@ import Data.Text.Encoding qualified as T
|
|||
|
||||
import PlutusLedgerApi.V1 qualified as Plutus
|
||||
import PlutusLedgerApi.V1.Bytes qualified as Plutus
|
||||
import PlutusLedgerApi.V1.Scripts qualified as Plutus
|
||||
import PlutusLedgerApi.V1.Value qualified as Plutus
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
@ -37,16 +37,6 @@ deriving via
|
|||
instance
|
||||
Aeson.FromJSON Plutus.AssetClass
|
||||
|
||||
deriving via
|
||||
AsBase16Bytes Plutus.TxId
|
||||
instance
|
||||
Aeson.FromJSON Plutus.TxId
|
||||
|
||||
deriving via
|
||||
AsBase16Bytes Plutus.TxId
|
||||
instance
|
||||
Aeson.ToJSON Plutus.TxId
|
||||
|
||||
instance (Coercible a Plutus.LedgerBytes) => Aeson.ToJSON (AsBase16Bytes a) where
|
||||
toJSON =
|
||||
Aeson.String
|
||||
|
|
@ -76,86 +66,3 @@ instance (Codec.Serialise a) => Aeson.FromJSON (AsBase16Codec a) where
|
|||
. Codec.deserialiseOrFail
|
||||
. Lazy.fromStrict
|
||||
. T.encodeUtf8
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.CurrencySymbol)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.CurrencySymbol)
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.CurrencySymbol)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.CurrencySymbol)
|
||||
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.TokenName)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.TokenName)
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.TokenName)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.TokenName)
|
||||
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.ValidatorHash)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.ValidatorHash)
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.ValidatorHash)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.ValidatorHash)
|
||||
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.ScriptHash)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.ScriptHash)
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.ScriptHash)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.ScriptHash)
|
||||
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.BuiltinByteString)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.BuiltinByteString)
|
||||
deriving via
|
||||
(AsBase16Bytes Plutus.BuiltinByteString)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.BuiltinByteString)
|
||||
|
||||
deriving via
|
||||
(AsBase16Codec Plutus.Validator)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.Validator)
|
||||
deriving via
|
||||
(AsBase16Codec Plutus.Validator)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.Validator)
|
||||
|
||||
deriving via
|
||||
(AsBase16Codec Plutus.MintingPolicy)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.MintingPolicy)
|
||||
deriving via
|
||||
(AsBase16Codec Plutus.MintingPolicy)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.MintingPolicy)
|
||||
|
||||
deriving via
|
||||
(AsBase16Codec Plutus.Script)
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.Script)
|
||||
deriving via
|
||||
(AsBase16Codec Plutus.Script)
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.Script)
|
||||
|
||||
deriving via
|
||||
Integer
|
||||
instance
|
||||
(Aeson.ToJSON Plutus.POSIXTime)
|
||||
deriving via
|
||||
Integer
|
||||
instance
|
||||
(Aeson.FromJSON Plutus.POSIXTime)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ module Agora.Linker (linker) where
|
|||
|
||||
import Agora.Governor (Governor (gstOutRef, gtClassRef, maximumCosigners))
|
||||
import Agora.Utils (validatorHashToAddress, validatorHashToTokenName)
|
||||
import Data.Aeson qualified as Aeson
|
||||
import Data.Map (fromList)
|
||||
import Data.Tagged (untag)
|
||||
import Plutarch.Api.V2 (mintingPolicySymbol, validatorHash)
|
||||
|
|
@ -24,11 +25,25 @@ import ScriptExport.ScriptInfo (
|
|||
)
|
||||
import Prelude hiding ((#))
|
||||
|
||||
{- | Additional information provided after linking.
|
||||
|
||||
@since 1.0.0
|
||||
-}
|
||||
data AgoraScriptInfo = AgoraScriptInfo
|
||||
{ governorAssetClass :: AssetClass
|
||||
, authorityTokenSymbol :: CurrencySymbol
|
||||
, proposalAssetClass :: AssetClass
|
||||
, stakeAssetClass :: AssetClass
|
||||
, governor :: Governor
|
||||
}
|
||||
deriving stock (Generic, Show)
|
||||
deriving anyclass (Aeson.FromJSON, Aeson.ToJSON)
|
||||
|
||||
{- | Links parameterized Agora scripts given parameters.
|
||||
|
||||
@since 1.0.0
|
||||
-}
|
||||
linker :: Linker Governor (ScriptExport Governor)
|
||||
linker :: Linker Governor (ScriptExport AgoraScriptInfo)
|
||||
linker = do
|
||||
govPol <- fetchTS @MintingPolicyRole @'[TxOutRef] "agora:governorPolicy"
|
||||
govVal <- fetchTS @ValidatorRole @'[Address, CurrencySymbol, CurrencySymbol, CurrencySymbol, CurrencySymbol] "agora:governorValidator"
|
||||
|
|
@ -105,5 +120,12 @@ linker = do
|
|||
, ("agora:treasuryWithdrawalValidator", toScript treaWithdrawalVal')
|
||||
, ("agora:mutateGovernorValidator", toScript mutateGovVal')
|
||||
]
|
||||
, information = governor
|
||||
, information =
|
||||
AgoraScriptInfo
|
||||
{ governorAssetClass = gstAssetClass
|
||||
, authorityTokenSymbol = atSymbol
|
||||
, proposalAssetClass = pstAssetClass
|
||||
, stakeAssetClass = sstAssetClass
|
||||
, governor = governor
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue