Use liqwid-script-export
commit ec70bfd539fe2e27fd48f5f76395400287ac72d7
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Tue Oct 18 18:58:59 2022 -0500
use LSE
commit 25fff9b3ad1f2dde4cd7cf36977530b06a87d23c
Merge: 01cd3aa 1821dd6
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Tue Oct 18 18:17:45 2022 -0500
Merge branch 'staging' into seungheonoh/ply
commit 01cd3aa7a235e6fe6658246ca1026fa26dc71a83
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 12:02:03 2022 +0800
update benchmark
commit a8513244892ce33cfdc9edf8cd501c4985ae8008
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 11:59:22 2022 +0800
fix tests
commit 20ca40823485c2e2f78253643cf4453ac7b7ddd5
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 11:57:37 2022 +0800
better import
commit a19fe49424210891bd03db71e4083fc1e0edfd98
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 11:08:20 2022 +0800
update flake inputs
commit c93b21f1f9441e5c6f54525bf7c6a54757ec36cc
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 12:54:12 2022 -0500
tried to make tests pass
commit 1046ae1237299a33c58b48661bdb6d325a22147e
Merge: 2bf4e36 363bd83
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 12:18:48 2022 -0500
Merge branch 'staging' into seungheonoh/ply
commit 2bf4e3627c1b229f58078695082da85c80efd560
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 10:48:36 2022 -0500
remove junkpile
commit a1dbc9ad9e531fe0d0a0480c4aef9cf9ffa90f1d
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 10:47:25 2022 -0500
versions
commit 4542a06ac733858297d3a48c53368fad19dedc43
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Thu Oct 6 22:57:48 2022 -0500
script exporting interface
commit 6bd8c1a1d57e4bf9dc25c3068a9c8eae6bf6a19d
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Thu Oct 6 22:58:41 2022 -0500
fixed tests
commit d3ce2cf95633d336f3e621833677bd5bf10ee2c8
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sun Oct 2 00:55:18 2022 -0500
fixed tests
commit 1ae64c9f692652b77b0506013853b2ba44267c65
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sat Oct 1 13:28:20 2022 -0500
linker
commit db88cb75c7b74843141ad8ab4e6522b66d0dcfbc
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sat Oct 1 01:03:50 2022 -0500
exporting scripts
commit 6389fce28e885a8a7f8669629c266f59c0edb51f
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sat Oct 1 00:51:49 2022 -0500
made scripts parameterized on the script level
commit aea1e518a8890550bdebd0e5251da11d915c53a9
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Wed Sep 28 19:53:29 2022 -0500
Use `TypedScriptEnvelope` for `Agora.Bootstrap`
This commit is contained in:
parent
1821dd6a88
commit
d2018afd4d
38 changed files with 8614 additions and 2330 deletions
|
|
@ -9,153 +9,16 @@
|
|||
module Main (main) where
|
||||
|
||||
import Agora.Bootstrap qualified as Bootstrap
|
||||
import Agora.Governor (Governor (Governor))
|
||||
import Agora.SafeMoney (GTTag)
|
||||
import Agora.Scripts qualified as Scripts
|
||||
import Agora.Utils (CompiledMintingPolicy (getCompiledMintingPolicy), CompiledValidator (getCompiledValidator))
|
||||
import Data.Aeson qualified as Aeson
|
||||
import Agora.Linker
|
||||
import Data.Default (def)
|
||||
import Data.Function ((&))
|
||||
import Data.Tagged (Tagged)
|
||||
import Data.Text (Text)
|
||||
import Development.GitRev (gitBranch, gitHash)
|
||||
import GHC.Generics qualified as GHC
|
||||
import Plutarch (Config (Config, tracingMode), TracingMode (DoTracing, NoTracing))
|
||||
import PlutusLedgerApi.V1 (
|
||||
MintingPolicy (getMintingPolicy),
|
||||
TxOutRef,
|
||||
Validator (getValidator),
|
||||
)
|
||||
import PlutusLedgerApi.V1.Value (AssetClass)
|
||||
import ScriptExport.API (runServer)
|
||||
import ScriptExport.Options (parseOptions)
|
||||
import ScriptExport.ScriptInfo (ScriptInfo, mkPolicyInfo, mkScriptInfo, mkValidatorInfo)
|
||||
import ScriptExport.Types (Builders, insertBuilder)
|
||||
import ScriptExport.Export
|
||||
import ScriptExport.Types
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
parseOptions >>= runServer revision builders
|
||||
where
|
||||
-- This encodes the git revision of the server. It's useful for the caller
|
||||
-- to be able to ensure they are compatible with it.
|
||||
revision :: Text
|
||||
revision = $(gitBranch) <> "@" <> $(gitHash)
|
||||
main = exportMain builders
|
||||
|
||||
{- | Builders for Agora scripts.
|
||||
|
||||
@since 0.2.0
|
||||
-}
|
||||
builders :: Builders
|
||||
builders =
|
||||
def
|
||||
-- Agora scripts
|
||||
& insertBuilder "governorPolicy" ((.governorPolicyInfo) . agoraScripts)
|
||||
& insertBuilder "governorValidator" ((.governorValidatorInfo) . agoraScripts)
|
||||
& insertBuilder "stakePolicy" ((.stakePolicyInfo) . agoraScripts)
|
||||
& insertBuilder "stakeValidator" ((.stakeValidatorInfo) . agoraScripts)
|
||||
& insertBuilder "proposalPolicy" ((.proposalPolicyInfo) . agoraScripts)
|
||||
& insertBuilder "proposalValidator" ((.proposalValidatorInfo) . agoraScripts)
|
||||
& insertBuilder "treasuryValidator" ((.treasuryValidatorInfo) . agoraScripts)
|
||||
& insertBuilder "authorityTokenPolicy" ((.authorityTokenPolicyInfo) . agoraScripts)
|
||||
-- Trivial scripts. These are useful for testing, but they likely aren't useful
|
||||
-- to you if you are actually interested in deploying to mainnet.
|
||||
& insertBuilder
|
||||
"alwaysSucceedsPolicy"
|
||||
(\() -> mkPolicyInfo $ plam $ \_ _ -> popaque (pconstant ()))
|
||||
& insertBuilder
|
||||
"alwaysSucceedsValidator"
|
||||
(\() -> mkValidatorInfo $ plam $ \_ _ _ -> popaque (pconstant ()))
|
||||
& insertBuilder
|
||||
"neverSucceedsPolicy"
|
||||
(\() -> mkPolicyInfo $ plam $ \_ _ -> perror)
|
||||
& insertBuilder
|
||||
"neverSucceedsValidator"
|
||||
(\() -> mkValidatorInfo $ plam $ \_ _ _ -> perror)
|
||||
-- Provided Effect scripts
|
||||
& insertBuilder "treasuryWithdrawalEffect" ((.treasuryWithdrawalEffectInfo) . agoraScripts)
|
||||
|
||||
{- | Create scripts from params.
|
||||
|
||||
@since 0.2.0
|
||||
-}
|
||||
agoraScripts :: ScriptParams -> AgoraScripts
|
||||
agoraScripts params =
|
||||
AgoraScripts
|
||||
{ governorPolicyInfo = mkPolicyInfo' scripts.compiledGovernorPolicy
|
||||
, governorValidatorInfo = mkValidatorInfo' scripts.compiledGovernorValidator
|
||||
, stakePolicyInfo = mkPolicyInfo' scripts.compiledStakePolicy
|
||||
, stakeValidatorInfo = mkValidatorInfo' scripts.compiledStakeValidator
|
||||
, proposalPolicyInfo = mkPolicyInfo' scripts.compiledProposalPolicy
|
||||
, proposalValidatorInfo = mkValidatorInfo' scripts.compiledProposalValidator
|
||||
, treasuryValidatorInfo = mkValidatorInfo' scripts.compiledTreasuryValidator
|
||||
, authorityTokenPolicyInfo = mkPolicyInfo' scripts.compiledAuthorityTokenPolicy
|
||||
, treasuryWithdrawalEffectInfo = mkValidatorInfo' scripts.compiledTreasuryWithdrawalEffect
|
||||
}
|
||||
where
|
||||
governor =
|
||||
Agora.Governor.Governor
|
||||
params.governorInitialSpend
|
||||
params.gtClassRef
|
||||
params.maximumCosigners
|
||||
|
||||
scripts = Bootstrap.agoraScripts plutarchConfig governor
|
||||
|
||||
plutarchConfig :: Config
|
||||
plutarchConfig = Config {tracingMode = if params.tracing then DoTracing else NoTracing}
|
||||
|
||||
{- | Params required for creating script export.
|
||||
|
||||
@since 1.0.0
|
||||
-}
|
||||
data ScriptParams = ScriptParams
|
||||
{ governorInitialSpend :: TxOutRef
|
||||
, gtClassRef :: Tagged GTTag AssetClass
|
||||
, maximumCosigners :: Integer
|
||||
, tracing :: Bool
|
||||
}
|
||||
deriving anyclass (Aeson.ToJSON, Aeson.FromJSON)
|
||||
deriving stock (Show, Eq, GHC.Generic, Ord)
|
||||
|
||||
{- | Scripts that get exported.
|
||||
|
||||
@since 0.2.0
|
||||
-}
|
||||
data AgoraScripts = AgoraScripts
|
||||
{ governorPolicyInfo :: ScriptInfo
|
||||
, governorValidatorInfo :: ScriptInfo
|
||||
, stakePolicyInfo :: ScriptInfo
|
||||
, stakeValidatorInfo :: ScriptInfo
|
||||
, proposalPolicyInfo :: ScriptInfo
|
||||
, proposalValidatorInfo :: ScriptInfo
|
||||
, treasuryValidatorInfo :: ScriptInfo
|
||||
, authorityTokenPolicyInfo :: ScriptInfo
|
||||
, treasuryWithdrawalEffectInfo :: ScriptInfo
|
||||
}
|
||||
deriving anyclass
|
||||
( -- | @since 0.2.0
|
||||
Aeson.ToJSON
|
||||
, -- | @since 0.2.0
|
||||
Aeson.FromJSON
|
||||
)
|
||||
deriving stock
|
||||
( -- | @since 0.2.0
|
||||
Show
|
||||
, -- | @since 0.2.0
|
||||
Eq
|
||||
, -- | @since 0.2.0
|
||||
GHC.Generic
|
||||
)
|
||||
|
||||
{- | Turn a precompiled minting policy to a 'ScriptInfo'.
|
||||
|
||||
@since 0.2.0
|
||||
-}
|
||||
mkPolicyInfo' :: forall redeemer. CompiledMintingPolicy redeemer -> ScriptInfo
|
||||
mkPolicyInfo' = mkScriptInfo . getMintingPolicy . (.getCompiledMintingPolicy)
|
||||
|
||||
{- | Turn a precompiled validator to a 'ScriptInfo'.
|
||||
|
||||
@since 0.2.0
|
||||
-}
|
||||
mkValidatorInfo' :: forall redeemer datum. CompiledValidator datum redeemer -> ScriptInfo
|
||||
mkValidatorInfo' = mkScriptInfo . getValidator . (.getCompiledValidator)
|
||||
mconcat
|
||||
[ insertScriptExportWithLinker "agora" (Bootstrap.agoraScripts def) linker
|
||||
]
|
||||
|
|
|
|||
7
agora-scripts/sampleGov.json
Normal file
7
agora-scripts/sampleGov.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{ "gstOutRef":
|
||||
{"txOutRefId":"f28cd7145c24e66fd5bcd2796837aeb19a48a2656e7833c88c62a2d0450bd00d"
|
||||
,"txOutRefIdx":0
|
||||
}
|
||||
,"gtClassRef":["da8c30857834c6ae7203935b89278c532b3995245295456f993e1d24","4c51"]
|
||||
,"maximumCosigners":20
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue