Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
olgaklimenko
committed
Nov 30, 2021
1 parent
8ef04e7
commit 8d86c74
Showing
9 changed files
with
322 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE DoAndIfThenElse #-} | ||
|
||
import qualified Cardano.Api as C | ||
import Data.Default (Default (..)) | ||
import Data.Monoid (Sum (..)) | ||
import Ledger.Index (ValidatorMode (..)) | ||
import Options.Applicative | ||
import Plutus.Contract.Wallet (ExportTx (..)) | ||
import Plutus.Trace (Command (..), ScriptsConfig (..), showStats, writeScriptsTo) | ||
import qualified Marketplace.Spec.Start as Marketplace | ||
import qualified Marketplace.Spec.CreateNft as CreateNft | ||
import qualified Marketplace.Spec.Bundles as Bundles | ||
import qualified Marketplace.Spec.Sale as Sale | ||
import qualified Marketplace.Spec.Auction as Auction | ||
import Control.Monad (void) | ||
|
||
writeWhat :: Command -> String | ||
writeWhat (Scripts FullyAppliedValidators) = "scripts (fully applied)" | ||
writeWhat (Scripts UnappliedValidators) = "scripts (unapplied)" | ||
writeWhat Transactions{} = "transactions" | ||
|
||
pathParser :: Parser FilePath | ||
pathParser = strArgument (metavar "SCRIPT_PATH" <> help "output path") | ||
|
||
protocolParamsParser :: Parser FilePath | ||
protocolParamsParser = strOption (long "protocol-parameters" <> short 'p' <> help "Path to protocol parameters JSON file" <> showDefault <> value "protocol-parameters.json") | ||
|
||
networkIdParser :: Parser C.NetworkId | ||
networkIdParser = | ||
let p = C.Testnet . C.NetworkMagic <$> option auto (long "network-magic" <> short 'n' <> help "Cardano network magic. If none is specified, mainnet addresses are generated.") | ||
in p <|> pure C.Mainnet | ||
|
||
commandParser :: Parser Command | ||
commandParser = hsubparser $ mconcat [scriptsParser, transactionsParser] | ||
|
||
scriptsParser :: Mod CommandFields Command | ||
scriptsParser = | ||
command "scripts" $ | ||
info | ||
(Scripts <$> flag FullyAppliedValidators UnappliedValidators (long "unapplied-validators" <> short 'u' <> help "Write the unapplied validator scripts" <> showDefault)) | ||
(fullDesc <> progDesc "Write fully applied validator scripts") | ||
|
||
transactionsParser :: Mod CommandFields Command | ||
transactionsParser = | ||
command "transactions" $ | ||
info | ||
(Transactions <$> networkIdParser <*> protocolParamsParser) | ||
(fullDesc <> progDesc "Write partial transactions") | ||
|
||
progParser :: ParserInfo ScriptsConfig | ||
progParser = | ||
let p = ScriptsConfig <$> pathParser <*> commandParser | ||
in info | ||
(p <**> helper) | ||
(fullDesc | ||
<> progDesc "Run a number of emulator traces and write all validator scripts and/or partial transactions to SCRIPT_PATH" | ||
<> header "plutus-use-cases-scripts - extract validators and partial transactions from emulator traces" | ||
) | ||
|
||
main :: IO () | ||
main = execParser progParser >>= writeScripts | ||
|
||
writeScripts :: ScriptsConfig -> IO () | ||
writeScripts config = do | ||
putStrLn $ "Writing " <> writeWhat (scCommand config) <> " to: " <> scPath config | ||
(Sum size, exBudget) <- foldMap (uncurry3 (writeScriptsTo config)) | ||
[ ("marketplace-start", Marketplace.startTrace, def) | ||
, ("create-nft-with-hidden-issuer", void CreateNft.createNftTrace, def) | ||
|
||
, ("bundle", void Bundles.bundleTrace, def) | ||
, ("unbundle", Bundles.unbundleTrace, def) | ||
|
||
, ("open-sale", void Sale.openSaleTrace, def) | ||
, ("close-sale", Sale.closeSaleTrace, def) | ||
, ("buy-item", Sale.buyItemTrace, def) | ||
|
||
, ("start-auction", void Auction.startAnAuctionTrace, def) | ||
, ("complete-auction", Auction.completeAnAuctionTrace, def) | ||
, ("bid-on-auction", void Auction.bidOnAuctionTrace, def) | ||
, ("buy-on-auction", Auction.buyOnAuctionTrace, def) | ||
, ("cancel-auction-with-bids", Auction.cancelAuctionWithBidsTrace, def) | ||
] | ||
if size > 0 then | ||
putStrLn $ "Total " <> showStats size exBudget | ||
else pure () | ||
|
||
-- | `uncurry3` converts a curried function to a function on triples. | ||
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d | ||
uncurry3 f (a, b, c) = f a b c |
136 changes: 136 additions & 0 deletions
136
MetaLamp/nft-marketplace/script-analyzer/protocol-parameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"txFeePerByte": 44, | ||
"minUTxOValue": null, | ||
"stakePoolDeposit": 500000000, | ||
"utxoCostPerWord": 1, | ||
"decentralization": 0.6, | ||
"poolRetireMaxEpoch": 18, | ||
"extraPraosEntropy": null, | ||
"collateralPercentage": 1, | ||
"stakePoolTargetNum": 150, | ||
"maxBlockBodySize": 65536, | ||
"maxTxSize": 16384, | ||
"treasuryCut": 0.2, | ||
"minPoolCost": 340000000, | ||
"maxCollateralInputs": 5, | ||
"maxValueSize": 5000, | ||
"maxBlockExecutionUnits": { | ||
"memory": 500000000000, | ||
"steps": 500000000000 | ||
}, | ||
"maxBlockHeaderSize": 1100, | ||
"costModels": { | ||
"PlutusScriptV1": { | ||
"cek_startup_cost-_ex_budget_cpu": 1000000, | ||
"cek_force_cost-_ex_budget_cpu": 39000, | ||
"cek_var_cost-_ex_budget_cpu": 39000, | ||
"multiply_integer-memory-arguments-intercept": 0, | ||
"remainder_integer-memory-arguments-intercept": 0, | ||
"cek_builtin_cost-_ex_budget_memory": 10, | ||
"remainder_integer-cpu-arguments-model_split_const_intercept": 330895, | ||
"sha3-cpu-arguments-intercept": 1260296, | ||
"subtract_integer-memory-arguments-slope": 1, | ||
"cek_apply_cost-_ex_budget_memory": 10, | ||
"gt_byte_string-cpu-arguments-intercept": 204537, | ||
"less_than_eq_integer-cpu-arguments-slope": 699, | ||
"concatenate-cpu-arguments-slope": 515, | ||
"less_than_integer-cpu-arguments-intercept": 187278, | ||
"quotient_integer-memory-arguments-slope": 1, | ||
"greater_than_integer-cpu-arguments-slope": 980, | ||
"if_then_else-cpu-arguments": 0, | ||
"quotient_integer-cpu-arguments-model_split_const_slope": 427, | ||
"lt_byte_string-cpu-arguments-slope": 227, | ||
"mod_integer-cpu-arguments-model_split_const_slope": 427, | ||
"eq_byte_string-cpu-arguments-intercept": 188562, | ||
"eq_integer-cpu-arguments-slope": 867, | ||
"multiply_integer-cpu-arguments-slope": 11464, | ||
"cek_builtin_cost-_ex_budget_cpu": 39000, | ||
"cek_startup_cost-_ex_budget_memory": 0, | ||
"sha3-memory-arguments": 4, | ||
"divide_integer-memory-arguments-intercept": 0, | ||
"subtract_integer-cpu-arguments-intercept": 251934, | ||
"cek_var_cost-_ex_budget_memory": 10, | ||
"divide_integer-cpu-arguments-model_split_const_intercept": 330895, | ||
"cek_force_cost-_ex_budget_memory": 10, | ||
"less_than_integer-memory-arguments": 1, | ||
"mod_integer-memory-arguments-minimum": 1, | ||
"gt_byte_string-memory-arguments": 1, | ||
"eq_byte_string-cpu-arguments-slope": 246, | ||
"mod_integer-cpu-arguments-model_split_const_intercept": 330895, | ||
"greater_than_eq_integer-cpu-arguments-slope": 699, | ||
"add_integer-memory-arguments-intercept": 1, | ||
"eq_byte_string-memory-arguments": 1, | ||
"verify_signature-cpu-arguments": 5082989, | ||
"take_byte_string-cpu-arguments": 3420288, | ||
"remainder_integer-cpu-arguments-model_split_const_slope": 427, | ||
"cek_const_cost-_ex_budget_cpu": 39000, | ||
"sha3-cpu-arguments-slope": 81356, | ||
"cek_delay_cost-_ex_budget_cpu": 39000, | ||
"drop_byte_string-memory-arguments": 2, | ||
"remainder_integer-memory-arguments-slope": 1, | ||
"subtract_integer-memory-arguments-intercept": 1, | ||
"eq_integer-memory-arguments": 1, | ||
"multiply_integer-memory-arguments-slope": 1, | ||
"add_integer-memory-arguments-slope": 1, | ||
"sha2-memory-arguments": 4, | ||
"greater_than_eq_integer-cpu-arguments-intercept": 216015, | ||
"less_than_eq_integer-memory-arguments": 1, | ||
"if_then_else-memory-arguments": 0, | ||
"add_integer-cpu-arguments-slope": 1722, | ||
"concatenate-memory-arguments-slope": 1, | ||
"lt_byte_string-memory-arguments": 1, | ||
"sha2-cpu-arguments-slope": 28904, | ||
"mod_integer-memory-arguments-slope": 1, | ||
"cek_apply_cost-_ex_budget_cpu": 39000, | ||
"greater_than_integer-memory-arguments": 1, | ||
"divide_integer-memory-arguments-slope": 1, | ||
"subtract_integer-cpu-arguments-slope": 1194, | ||
"divide_integer-cpu-arguments-model_split_const_slope": 427, | ||
"eq_integer-cpu-arguments-intercept": 211716, | ||
"cek_const_cost-_ex_budget_memory": 10, | ||
"cek_delay_cost-_ex_budget_memory": 10, | ||
"multiply_integer-cpu-arguments-intercept": 78642, | ||
"drop_byte_string-cpu-arguments": 3418326, | ||
"divide_integer-memory-arguments-minimum": 1, | ||
"cek_lam_cost-_ex_budget_memory": 10, | ||
"greater_than_eq_integer-memory-arguments": 1, | ||
"take_byte_string-memory-arguments": 20, | ||
"add_integer-cpu-arguments-intercept": 235735, | ||
"sha2-cpu-arguments-intercept": 2267819, | ||
"mod_integer-memory-arguments-intercept": 0, | ||
"verify_signature-memory-arguments": 1, | ||
"concatenate-memory-arguments-intercept": 0, | ||
"less_than_integer-cpu-arguments-slope": 980, | ||
"lt_byte_string-cpu-arguments-intercept": 204537, | ||
"less_than_eq_integer-cpu-arguments-intercept": 216015, | ||
"concatenate-cpu-arguments-intercept": 420084, | ||
"cek_lam_cost-_ex_budget_cpu": 39000, | ||
"quotient_integer-cpu-arguments-model_split_const_intercept": 330895, | ||
"quotient_integer-memory-arguments-intercept": 0, | ||
"greater_than_integer-cpu-arguments-intercept": 187278, | ||
"gt_byte_string-cpu-arguments-slope": 227 | ||
} | ||
}, | ||
"maxTxExecutionUnits": { | ||
"memory": 500000000000, | ||
"steps": 500000000000 | ||
}, | ||
"protocolVersion": { | ||
"minor": 0, | ||
"major": 5 | ||
}, | ||
"txFeeFixed": 155381, | ||
"stakeAddressDeposit": 2000000, | ||
"monetaryExpansion": 3.0e-3, | ||
"poolPledgeInfluence": 0.3, | ||
"executionUnitPrices": { | ||
"priceSteps": { | ||
"numerator": 1, | ||
"denominator": 1 | ||
}, | ||
"priceMemory": { | ||
"numerator": 1, | ||
"denominator": 1 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters