diff --git a/lib/core/src/Cardano/Wallet.hs b/lib/core/src/Cardano/Wallet.hs index 4aca1c5722a..d70fa93dc3a 100644 --- a/lib/core/src/Cardano/Wallet.hs +++ b/lib/core/src/Cardano/Wallet.hs @@ -173,7 +173,8 @@ import qualified Data.Text.IO as TIO data WalletLayer s t = WalletLayer { createWallet - :: WalletId + :: (Show s, NFData s, IsOurs s, TxId t) + => WalletId -> WalletName -> s -> ExceptT ErrWalletAlreadyExists IO WalletId @@ -218,7 +219,8 @@ data WalletLayer s t = WalletLayer -- apply remaining blocks until failure or, the target slot is reached. , listAddresses - :: WalletId + :: (IsOurs s, CompareDiscovery s, KnownAddresses s) + => WalletId -> ExceptT ErrNoSuchWallet IO [(Address, AddressState)] -- ^ List all addresses of a wallet with their metadata. Addresses -- are ordered from the most recently discovered to the oldest known. @@ -234,7 +236,8 @@ data WalletLayer s t = WalletLayer -- sign) an actual transaction, have a look at 'signTx'. , signTx - :: WalletId + :: (Show s, NFData s, IsOwned s, GenChange s) + => WalletId -> Passphrase "encryption" -> CoinSelection -> ExceptT ErrSignTx IO (Tx, TxMeta, [TxWitness]) @@ -245,7 +248,8 @@ data WalletLayer s t = WalletLayer -- 'submitTx'. , submitTx - :: WalletId + :: (TxId t) + => WalletId -> (Tx, TxMeta, [TxWitness]) -> ExceptT ErrSubmitTx IO () -- ^ Broadcast a (signed) transaction to the network. @@ -327,15 +331,7 @@ cancelWorker (WorkerRegistry mvar) wid = -- | Create a new instance of the wallet layer. newWalletLayer - :: forall s t. - ( IsOwned s - , GenChange s - , KnownAddresses s - , CompareDiscovery s - , NFData s - , Show s - , TxId t - ) + :: forall s t. () => DBLayer IO s t -> NetworkLayer t IO -> TransactionLayer t @@ -362,7 +358,8 @@ newWalletLayer db nw tl = do ---------------------------------------------------------------------------} _createWallet - :: WalletId + :: (Show s, NFData s, IsOurs s, TxId t) + => WalletId -> WalletName -> s -> ExceptT ErrWalletAlreadyExists IO WalletId @@ -532,7 +529,8 @@ newWalletLayer db nw tl = do -- This implementation is rather inneficient and not intented for frequent -- use, in particular for exchanges or "big-players". _listAddresses - :: WalletId + :: (IsOurs s, CompareDiscovery s, KnownAddresses s) + => WalletId -> ExceptT ErrNoSuchWallet IO [(Address, AddressState)] _listAddresses wid = do (s, txs) <- DB.withLock db $ (,) @@ -573,7 +571,8 @@ newWalletLayer db nw tl = do adjustForFee feeOpts utxo' sel _signTx - :: WalletId + :: (Show s, NFData s, IsOwned s, GenChange s) + => WalletId -> Passphrase "encryption" -> CoinSelection -> ExceptT ErrSignTx IO (Tx, TxMeta, [TxWitness]) @@ -606,7 +605,8 @@ newWalletLayer db nw tl = do throwE $ ErrSignTx e _submitTx - :: WalletId + :: (TxId t) + => WalletId -> (Tx, TxMeta, [TxWitness]) -> ExceptT ErrSubmitTx IO () _submitTx wid (tx, meta, wit) = do diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index 0d264098b5e..3d10673aceb 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -189,7 +189,10 @@ withListeningSocket mport = bracket acquire release Wallets -------------------------------------------------------------------------------} -wallets :: KeyToAddress t => WalletLayer (SeqState t) t -> Server Wallets +wallets + :: (TxId t, KeyToAddress t) + => WalletLayer (SeqState t) t + -> Server Wallets wallets w = deleteWallet w :<|> getWallet w @@ -250,7 +253,7 @@ listWallets w = do mapM (getWalletWithCreationTime w) (ApiT <$> wids) postWallet - :: KeyToAddress t + :: (KeyToAddress t, TxId t) => WalletLayer (SeqState t) t -> WalletPostData -> Handler ApiWallet @@ -295,11 +298,14 @@ putWalletPassphrase w (ApiT wid) body = do Addresses -------------------------------------------------------------------------------} -addresses :: WalletLayer (SeqState t) t -> Server (Addresses t) +addresses + :: KeyToAddress t + => WalletLayer (SeqState t) t + -> Server (Addresses t) addresses = listAddresses listAddresses - :: forall t. () + :: forall t. (KeyToAddress t) => WalletLayer (SeqState t) t -> ApiT WalletId -> Maybe (ApiT AddressState) @@ -318,11 +324,14 @@ listAddresses w (ApiT wid) stateFilter = do Transactions -------------------------------------------------------------------------------} -transactions :: TxId t => WalletLayer (SeqState t) t -> Server (Transactions t) +transactions + :: (TxId t, KeyToAddress t) + => WalletLayer (SeqState t) t + -> Server (Transactions t) transactions = createTransaction createTransaction - :: forall t. (TxId t) + :: forall t. (TxId t, KeyToAddress t) => WalletLayer (SeqState t) t -> ApiT WalletId -> PostTransactionData t