Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Merge branch 'CO-335' into Squad1/CO-334/implement-v0-endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Jul 25, 2018
2 parents 7bfe0c5 + c54ed1d commit 5ff10f7
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 92 deletions.
2 changes: 2 additions & 0 deletions wallet-new/cardano-sl-wallet-new.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ library
Cardano.Wallet.API.V1.Handlers.Wallets
Cardano.Wallet.API.V1.Info
Cardano.Wallet.API.V1.Internal
Cardano.Wallet.API.V1.Internal.Update
Cardano.Wallet.API.V1.LegacyHandlers
Cardano.Wallet.API.V1.LegacyHandlers.Accounts
Cardano.Wallet.API.V1.LegacyHandlers.Addresses
Cardano.Wallet.API.V1.LegacyHandlers.Info
Cardano.Wallet.API.V1.LegacyHandlers.Internal.Update
Cardano.Wallet.API.V1.LegacyHandlers.Settings
Cardano.Wallet.API.V1.LegacyHandlers.Transactions
Cardano.Wallet.API.V1.LegacyHandlers.Wallets
Expand Down
63 changes: 2 additions & 61 deletions wallet-new/src/Cardano/Wallet/API/V1/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,10 @@
-- Daedalus client, and aren't useful for wallets, exchanges, and other users.
module Cardano.Wallet.API.V1.Internal where

import Universum

import Servant

import Cardano.Wallet.API.Response

-- migrate everything except for import/export
import qualified Cardano.Wallet.API.V1.Internal.Update as Update

type API =
"internal"
:> ( "update"
:> ( "apply"
:> Post '[ValidJSON] NoContent
:<|> "postpone"
:> Post '[ValidJSON] NoContent
)
)

newtype Seed = Seed Text
deriving (Eq, Show, Generic)

-- redeemAda
-- ProtocolMagic -> (TxAux -> m Bool) -> PassPhrase -> CWalletRedeem -> m CTx
--
-- -- | Query data for redeem
-- data CWalletRedeem = CWalletRedeem
-- { crWalletId :: !CAccountId
-- , crSeed :: !Text -- TODO: newtype!
-- } deriving (Show, Generic)

-- redeemAdaPaperVend
-- :: MonadWalletTxFull ctx m
-- => ProtocolMagic
-- -> (TxAux -> m Bool)
-- -> PassPhrase
-- -> CPaperVendWalletRedeem
-- -> m CTx
-- data CPaperVendWalletRedeem = CPaperVendWalletRedeem
-- { pvWalletId :: !CAccountId
-- , pvSeed :: !Text -- TODO: newtype!
-- , pvBackupPhrase :: !(CBackupPhrase 9)
-- } deriving (Show, Generic)

-- The redemption datatypes differ only by the backup phrase. Otherwise the
-- wallet ID and seed are both present. Potentially we can unify these into the
-- same endpoint. Seems like a query parameter like `paper_vend_passphrase=...`
-- would do nicely.

-- update postpone
-- -- | Postpone next update after restart
-- postponeUpdate :: (MonadIO m, WalletDbReader ctx m) => m NoContent
-- postponeUpdate = askWalletDB >>= removeNextUpdate >> return NoContent
--

-- update apply
--
-- -- | Delete next update info and restart immediately
-- applyUpdate :: ( MonadIO m
-- , WalletDbReader ctx m
-- , MonadUpdates m
-- )
-- => m NoContent
-- applyUpdate = askWalletDB >>= removeNextUpdate
-- >> applyLastUpdate >> return NoContent
--
--
:> Update.API
13 changes: 13 additions & 0 deletions wallet-new/src/Cardano/Wallet/API/V1/Internal/Update.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Cardano.Wallet.API.V1.Internal.Update where

import Servant

import Cardano.Wallet.API.Response (ValidJSON)

type API =
"update"
:> ( "apply"
:> Post '[ValidJSON] NoContent
:<|> "postpone"
:> Post '[ValidJSON] NoContent
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Cardano.Wallet.API.V1.LegacyHandlers.Internal.Update where

import Servant

import qualified Pos.Wallet.Web.Methods.Misc as V0

import qualified Cardano.Wallet.API.V1.Internal.Update as Update
import Cardano.Wallet.API.V1.Migration (MonadV1)

handlers :: ServerT Update.API MonadV1
handlers = applyUpdate :<|> postponeUpdate

applyUpdate :: MonadV1 NoContent
applyUpdate = V0.applyUpdate

postponeUpdate :: MonadV1 NoContent
postponeUpdate = V0.postponeUpdate
31 changes: 0 additions & 31 deletions wallet-new/src/Cardano/Wallet/API/V1/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -263,37 +263,6 @@ instance ByteArray.ByteArrayAccess a => ByteArray.ByteArrayAccess (V1 a) where
length (V1 a) = ByteArray.length a
withByteArray (V1 a) callback = ByteArray.withByteArray a callback

-- instance
-- ( n ~ EntropySize mw
-- , mw ~ MnemonicWords n
-- , ValidChecksumSize n csz
-- , ValidEntropySize n
-- , ValidMnemonicSentence mw
-- , Arbitrary (Entropy n)
-- ) => Arbitrary (V1 (Mnemonic mw)) where
-- arbitrary =
-- V1 <$> arbitrary
--
-- instance
-- ( n ~ EntropySize mw
-- , mw ~ MnemonicWords n
-- , ValidChecksumSize n csz
-- , ValidEntropySize n
-- , ValidMnemonicSentence mw
-- ) => ToJSON (V1 (Mnemonic mw)) where
-- toJSON =
-- toJSON . unV1
--
-- instance
-- ( n ~ EntropySize mw
-- , mw ~ MnemonicWords n
-- , ValidChecksumSize n csz
-- , ValidEntropySize n
-- , ValidMnemonicSentence mw
-- ) => FromJSON (V1 (Mnemonic mw)) where
-- parseJSON =
-- fmap V1 . parseJSON

mkPassPhrase :: Text -> Either Text Core.PassPhrase
mkPassPhrase text =
case Base16.decode text of
Expand Down
13 changes: 13 additions & 0 deletions wallet/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
help: ## Print documentation
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

ghcid: ## Run ghcid with the wallet-new project
ghcid \
--command "stack ghci cardano-sl-wallet --ghci-options=-fno-code"

ghcid-test: ## Have ghcid run the test suite for the wallet-new-specs on successful recompile
ghcid \
--command "stack ghci cardano-sl-wallet:lib cardano-sl-wallet:test:cardano-wallet-test --ghci-options=-fobject-code" \
--test "main"

.PHONY: ghcid ghcid-test help

0 comments on commit 5ff10f7

Please sign in to comment.