module Michelson.Runtime.TxData
( TxData (..)
, TxParam(..)
, tdSenderAddressL
, tdParameterL
, tdEntrypointL
, tdAmountL
) where
import Control.Lens (makeLensesWith)
import Data.Aeson (ToJSON(toJSON))
import Data.Aeson.TH (deriveToJSON)
import Michelson.Typed (ParameterScope)
import qualified Michelson.Typed as T
import Michelson.Untyped (EpName)
import qualified Michelson.Untyped as U
import Tezos.Address (Address)
import Tezos.Core (Mutez)
import Util.Aeson (morleyAesonOptions)
import Util.Lens (postfixLFields)
data TxParam where
TxTypedParam :: forall t. ParameterScope t => T.Value t -> TxParam
TxUntypedParam :: U.Value -> TxParam
deriving stock instance Show TxParam
instance ToJSON TxParam where
toJSON :: TxParam -> Value
toJSON (TxTypedParam val :: Value t
val) = Value -> Value
forall a. ToJSON a => a -> Value
toJSON (Value -> Value) -> Value -> Value
forall a b. (a -> b) -> a -> b
$ Value t -> Value
forall (t :: T). (SingI t, HasNoOp t) => Value' Instr t -> Value
T.untypeValue Value t
val
toJSON (TxUntypedParam val :: Value
val) = Value -> Value
forall a. ToJSON a => a -> Value
toJSON Value
val
data TxData = TxData
{ TxData -> Address
tdSenderAddress :: Address
, TxData -> TxParam
tdParameter :: TxParam
, TxData -> EpName
tdEntrypoint :: EpName
, TxData -> Mutez
tdAmount :: Mutez
} deriving stock Int -> TxData -> ShowS
[TxData] -> ShowS
TxData -> String
(Int -> TxData -> ShowS)
-> (TxData -> String) -> ([TxData] -> ShowS) -> Show TxData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TxData] -> ShowS
$cshowList :: [TxData] -> ShowS
show :: TxData -> String
$cshow :: TxData -> String
showsPrec :: Int -> TxData -> ShowS
$cshowsPrec :: Int -> TxData -> ShowS
Show
makeLensesWith postfixLFields ''TxData
deriveToJSON morleyAesonOptions ''TxData