Skip to content

Commit

Permalink
introduce ApiScript
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Oct 22, 2020
1 parent 12ba6d8 commit d85a752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/core/src/Cardano/Wallet/Api.hs
Expand Up @@ -109,8 +109,6 @@ module Cardano.Wallet.Api

import Prelude

import Cardano.Address.Script
( Script )
import Cardano.Wallet
( WalletLayer (..), WalletLog )
import Cardano.Wallet.Api.Types
Expand All @@ -127,6 +125,7 @@ import Cardano.Wallet.Api.Types
, ApiPoolId
, ApiPostRandomAddressData
, ApiPutAddressesDataT
, ApiScript
, ApiSelectCoinsDataT
, ApiT
, ApiTransactionT
Expand Down Expand Up @@ -315,7 +314,7 @@ type InspectAddress = "addresses"

-- | https://input-output-hk.github.io/cardano-wallet/api/#operation/postScriptAddress
type PostScriptAddress n = "addresses"
:> ReqBody '[JSON] (ApiT Script)
:> ReqBody '[JSON] ApiScript
:> PostCreated '[JSON] (ApiAddressT n)

{-------------------------------------------------------------------------------
Expand Down
13 changes: 9 additions & 4 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Expand Up @@ -42,6 +42,7 @@ module Cardano.Wallet.Api.Types

-- * API Types
, ApiAddress (..)
, ApiScript (..)
, ApiCertificate (..)
, ApiEpochInfo (..)
, ApiSelectCoinsData (..)
Expand Down Expand Up @@ -377,6 +378,10 @@ data ApiAddress (n :: NetworkDiscriminant) = ApiAddress
, state :: !(ApiT AddressState)
} deriving (Eq, Generic, Show)

newtype ApiScript = ApiScript
{ script :: ApiT Script
} deriving (Eq, Generic, Show)

data ApiEpochInfo = ApiEpochInfo
{ epochNumber :: !(ApiT EpochNo)
, epochStartTime :: !UTCTime
Expand Down Expand Up @@ -1255,10 +1260,10 @@ instance (PassphraseMaxLength purpose, PassphraseMinLength purpose)
instance ToJSON (ApiT (Passphrase purpose)) where
toJSON = toJSON . toText . getApiT

instance FromJSON (ApiT Script) where
parseJSON = fmap ApiT . parseJSON
instance ToJSON (ApiT Script) where
toJSON (ApiT script) = toJSON script
instance FromJSON ApiScript where
parseJSON = fmap (ApiScript . ApiT) . parseJSON
instance ToJSON ApiScript where
toJSON (ApiScript (ApiT script')) = toJSON script'

instance MkSomeMnemonic sizes => FromJSON (ApiMnemonicT sizes)
where
Expand Down

0 comments on commit d85a752

Please sign in to comment.