-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
15267d2
commit 0c34b0c
Showing
4 changed files
with
54 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
{-# LANGUAGE RecordWildCards #-} | ||
|
||
module Main where | ||
|
||
import Control.Exception (throw) | ||
import Data.String (IsString (fromString)) | ||
import qualified Data.Text as T | ||
import Ext.Plutarch.Extra.Run (evalWithArgsT) | ||
import Mixer.Datum.Plutus (MixerConfig (..)) | ||
import Mixer.Script (validatorLogic) | ||
import Options (MixerOpts (..), mixerOpts) | ||
import Options.Applicative (execParser) | ||
import PlutusLedgerApi.V1.Bytes (LedgerBytes (..), fromHex) | ||
import PlutusLedgerApi.V1.Value (CurrencySymbol (CurrencySymbol), TokenName, assetClass) | ||
import PlutusLedgerApi.V2 (toData) | ||
|
||
main :: IO () | ||
main = do | ||
putStrLn "Hello, Haskell!" | ||
MixerOpts {..} <- execParser mixerOpts | ||
let ledgerTokenName :: TokenName = fromString tokenName | ||
ledgerCurrSymbol :: CurrencySymbol <- either throw (pure . CurrencySymbol . getLedgerBytes) $ fromHex currencySymbol | ||
let config = | ||
toData | ||
MixerConfig | ||
{ protocolToken = assetClass ledgerCurrSymbol ledgerTokenName | ||
, poolNominal = poolNominal | ||
} | ||
let (script, budget, log) = either (error . T.unpack) id $ evalWithArgsT validatorLogic [config] | ||
putStrLn $ "Script budget: " <> show budget | ||
putStrLn $ "Compilation log: " <> show log |
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,19 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Mixer.Datum.Plutus where | ||
|
||
import GHC.Generics (Generic) | ||
import PlutusLedgerApi.V1.Value (AssetClass) | ||
import qualified PlutusTx | ||
|
||
data MixerConfig = MixerConfig | ||
{ protocolToken :: AssetClass | ||
, poolNominal :: Integer | ||
} | ||
deriving stock (Generic, Show, Eq) | ||
|
||
PlutusTx.makeLift ''MixerConfig | ||
|
||
PlutusTx.makeIsDataIndexed | ||
''MixerConfig | ||
[('MixerConfig, 0)] |
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