module TD.Data.TonWalletTransactionType
(TonWalletTransactionType(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.TonNft as TonNft
data TonWalletTransactionType
= TonWalletTransactionTypeOnRampDeposit
{ TonWalletTransactionType -> Maybe Int
amount :: Maybe Int
, TonWalletTransactionType -> Maybe Text
provider_name :: Maybe T.Text
}
| TonWalletTransactionTypeTransfer
{ amount :: Maybe Int
, TonWalletTransactionType -> Maybe Bool
is_gasless :: Maybe Bool
, :: Maybe T.Text
, :: Maybe Bool
}
| TonWalletTransactionTypeNftTransfer
{ TonWalletTransactionType -> Maybe TonNft
nft :: Maybe TonNft.TonNft
, TonWalletTransactionType -> Maybe Bool
is_outgoing :: Maybe Bool
, :: Maybe T.Text
, :: Maybe Bool
}
| TonWalletTransactionTypeKeyChange
deriving (TonWalletTransactionType -> TonWalletTransactionType -> Bool
(TonWalletTransactionType -> TonWalletTransactionType -> Bool)
-> (TonWalletTransactionType -> TonWalletTransactionType -> Bool)
-> Eq TonWalletTransactionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
== :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
$c/= :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
/= :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
Eq, Int -> TonWalletTransactionType -> ShowS
[TonWalletTransactionType] -> ShowS
TonWalletTransactionType -> String
(Int -> TonWalletTransactionType -> ShowS)
-> (TonWalletTransactionType -> String)
-> ([TonWalletTransactionType] -> ShowS)
-> Show TonWalletTransactionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TonWalletTransactionType -> ShowS
showsPrec :: Int -> TonWalletTransactionType -> ShowS
$cshow :: TonWalletTransactionType -> String
show :: TonWalletTransactionType -> String
$cshowList :: [TonWalletTransactionType] -> ShowS
showList :: [TonWalletTransactionType] -> ShowS
Show)
instance I.ShortShow TonWalletTransactionType where
shortShow :: TonWalletTransactionType -> String
shortShow TonWalletTransactionTypeOnRampDeposit
{ amount :: TonWalletTransactionType -> Maybe Int
amount = Maybe Int
amount_
, provider_name :: TonWalletTransactionType -> Maybe Text
provider_name = Maybe Text
provider_name_
}
= String
"TonWalletTransactionTypeOnRampDeposit"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"provider_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
provider_name_
]
shortShow TonWalletTransactionTypeTransfer
{ amount :: TonWalletTransactionType -> Maybe Int
amount = Maybe Int
amount_
, is_gasless :: TonWalletTransactionType -> Maybe Bool
is_gasless = Maybe Bool
is_gasless_
, comment :: TonWalletTransactionType -> Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: TonWalletTransactionType -> Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
= String
"TonWalletTransactionTypeTransfer"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"is_gasless" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_gasless_
, String
"comment" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
comment_
, String
"is_comment_encrypted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_comment_encrypted_
]
shortShow TonWalletTransactionTypeNftTransfer
{ nft :: TonWalletTransactionType -> Maybe TonNft
nft = Maybe TonNft
nft_
, is_outgoing :: TonWalletTransactionType -> Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, comment :: TonWalletTransactionType -> Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: TonWalletTransactionType -> Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
= String
"TonWalletTransactionTypeNftTransfer"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"nft" String -> Maybe TonNft -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TonNft
nft_
, String
"is_outgoing" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_outgoing_
, String
"comment" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
comment_
, String
"is_comment_encrypted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_comment_encrypted_
]
shortShow TonWalletTransactionType
TonWalletTransactionTypeKeyChange
= String
"TonWalletTransactionTypeKeyChange"
instance AT.FromJSON TonWalletTransactionType where
parseJSON :: Value -> Parser TonWalletTransactionType
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"tonWalletTransactionTypeOnRampDeposit" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeOnRampDeposit Value
v
String
"tonWalletTransactionTypeTransfer" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeTransfer Value
v
String
"tonWalletTransactionTypeNftTransfer" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeNftTransfer Value
v
String
"tonWalletTransactionTypeKeyChange" -> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TonWalletTransactionType
TonWalletTransactionTypeKeyChange
String
_ -> Parser TonWalletTransactionType
forall a. Monoid a => a
mempty
where
parseTonWalletTransactionTypeOnRampDeposit :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeOnRampDeposit :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeOnRampDeposit = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeOnRampDeposit" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Text
provider_name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"provider_name"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeOnRampDeposit
{ amount :: Maybe Int
amount = Maybe Int
amount_
, provider_name :: Maybe Text
provider_name = Maybe Text
provider_name_
}
parseTonWalletTransactionTypeTransfer :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeTransfer :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeTransfer = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeTransfer" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Bool
is_gasless_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_gasless"
Maybe Text
comment_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"comment"
Maybe Bool
is_comment_encrypted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_comment_encrypted"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeTransfer
{ amount :: Maybe Int
amount = Maybe Int
amount_
, is_gasless :: Maybe Bool
is_gasless = Maybe Bool
is_gasless_
, comment :: Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
parseTonWalletTransactionTypeNftTransfer :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeNftTransfer :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeNftTransfer = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeNftTransfer" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe TonNft
nft_ <- Object
o Object -> Key -> Parser (Maybe TonNft)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"nft"
Maybe Bool
is_outgoing_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_outgoing"
Maybe Text
comment_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"comment"
Maybe Bool
is_comment_encrypted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_comment_encrypted"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeNftTransfer
{ nft :: Maybe TonNft
nft = Maybe TonNft
nft_
, is_outgoing :: Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, comment :: Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
parseJSON Value
_ = Parser TonWalletTransactionType
forall a. Monoid a => a
mempty