-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCP-3079 basic support for balanced Marlowe transactions
1. Builds various flavors of Marlowe transactions from script, datum, redeemer. 2. Corrects error in `Cardano.Api.makeTransactionBodyAutoBalance`, which ignores the situation where computing the change increases the execution units, also making the actual fee larger than the computed fee. 3. Needs haddock documentation. 4. Needs revisions to man pages, examples, and tutorial.
- Loading branch information
Showing
8 changed files
with
980 additions
and
79 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,61 @@ | ||
----------------------------------------------------------------------------- | ||
-- | ||
-- Module : $Headers | ||
-- License : Apache 2.0 | ||
-- | ||
-- Stability : Experimental | ||
-- Portability : Portable | ||
-- | ||
-- | Input/output functions for Marlowe CLI tool. | ||
-- | ||
----------------------------------------------------------------------------- | ||
|
||
|
||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
|
||
module Language.Marlowe.CLI.IO ( | ||
-- * IO | ||
decodeFileStrict | ||
, decodeFileBuiltinData | ||
) where | ||
|
||
|
||
import Cardano.Api (ScriptDataJsonSchema (..), scriptDataFromJson) | ||
import Cardano.Api.Shelley (toPlutusData) | ||
import Control.Monad.Except (MonadError, MonadIO, liftEither, liftIO) | ||
import Data.Aeson (FromJSON (..), eitherDecodeFileStrict) | ||
import Data.Bifunctor (first) | ||
import Language.Marlowe.CLI.Types (CliError (..), liftCli) | ||
import Plutus.V1.Ledger.Api (BuiltinData) | ||
import PlutusTx (dataToBuiltinData) | ||
|
||
|
||
-- | Decode a JSON file in an error monad. | ||
decodeFileStrict :: MonadError CliError m | ||
=> MonadIO m | ||
=> FromJSON a | ||
=> FilePath -- ^ The JSON file. | ||
-> m a -- ^ Action to decode the file. | ||
decodeFileStrict filePath = | ||
do | ||
result <- liftIO $ eitherDecodeFileStrict filePath | ||
liftEither $ first CliError result | ||
|
||
|
||
decodeFileBuiltinData :: MonadError CliError m | ||
=> MonadIO m | ||
=> FilePath | ||
-> m BuiltinData | ||
decodeFileBuiltinData file = | ||
do | ||
value <- decodeFileStrict file | ||
liftCli | ||
. fmap (dataToBuiltinData . toPlutusData) | ||
$ scriptDataFromJson ScriptDataJsonDetailedSchema value |
Oops, something went wrong.