Skip to content

Commit

Permalink
add postSharedWallet skeleton and multisig api layer in shelley
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Apr 15, 2021
1 parent ce846f9 commit 12ac979
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
28 changes: 28 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -81,6 +81,7 @@ module Cardano.Wallet.Api.Server
, selectCoinsForQuit
, signMetadata
, postAccountPublicKey
, postSharedWallet

-- * Server error responses
, IsServerError(..)
Expand Down Expand Up @@ -198,6 +199,8 @@ import Cardano.Wallet.Api.Types
, ApiPutAddressesData (..)
, ApiRawMetadata (..)
, ApiSelectCoinsPayments
, ApiSharedWallet
, ApiSharedWalletPostData
, ApiSlotId (..)
, ApiSlotReference (..)
, ApiT (..)
Expand Down Expand Up @@ -289,6 +292,8 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Sequential
, mkSeqStateFromRootXPrv
, purposeCIP1852
)
import Cardano.Wallet.Primitive.AddressDiscovery.SharedState
( SharedState (..) )
import Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobin
( SelectionError (..)
, SelectionInsufficientError (..)
Expand Down Expand Up @@ -799,6 +804,29 @@ mkShelleyWallet ctx wid cp meta pending progress = do
}


--------------------- Shared Wallet
postSharedWallet
:: forall ctx s k n.
( s ~ SharedState n k
, ctx ~ ApiLayer s k
, SoftDerivation k
, MkKeyFingerprint k (Proxy n, k 'AddressK XPub)
, MkKeyFingerprint k Address
, WalletKey k
, Bounded (Index (AddressIndexDerivationType k) 'AddressK)
, HasDBFactory s k ctx
, HasWorkerRegistry s k ctx
, Typeable s
, Typeable n
)
=> ctx
-> ((SomeMnemonic, Maybe SomeMnemonic) -> Passphrase "encryption" -> k 'RootK XPrv)
-> (XPub -> k 'AccountK XPub)
-> ApiSharedWalletPostData
-> Handler ApiSharedWallet
postSharedWallet _ctx _generateKey _liftKey _body = undefined


--------------------- Legacy

postLegacyWallet
Expand Down
10 changes: 8 additions & 2 deletions lib/shelley/src/Cardano/Wallet/Shelley.hs
Expand Up @@ -100,6 +100,8 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Random
( RndState )
import Cardano.Wallet.Primitive.AddressDiscovery.Sequential
( SeqState )
import Cardano.Wallet.Primitive.AddressDiscovery.SharedState
( SharedState )
import Cardano.Wallet.Primitive.Slotting
( neverFails )
import Cardano.Wallet.Primitive.SyncProgress
Expand Down Expand Up @@ -286,6 +288,8 @@ serveWallet
Server.idleWorker
shelleyApi <- apiLayer (newTransactionLayer net) nl
(Server.manageRewardBalance proxy)
multisigApi <- apiLayer (newTransactionLayer net) nl
Server.idleWorker

withPoolsMonitoring databaseDir np nl $ \spl -> do
startServer
Expand All @@ -294,6 +298,7 @@ serveWallet
randomApi
icarusApi
shelleyApi
multisigApi
spl
ntpClient
pure ExitSuccess
Expand Down Expand Up @@ -321,15 +326,16 @@ serveWallet
-> ApiLayer (RndState n) ByronKey
-> ApiLayer (SeqState n IcarusKey) IcarusKey
-> ApiLayer (SeqState n ShelleyKey) ShelleyKey
-> ApiLayer (SharedState n ShelleyKey) ShelleyKey
-> StakePoolLayer
-> NtpClient
-> IO ()
startServer _proxy socket byron icarus shelley spl ntp = do
startServer _proxy socket byron icarus shelley multisig spl ntp = do
sockAddr <- getSocketName socket
let serverSettings = Warp.defaultSettings & setBeforeMainLoop
(beforeMainLoop sockAddr)
let application = Server.serve (Proxy @(ApiV2 n ApiStakePool)) $
server byron icarus shelley spl ntp
server byron icarus shelley multisig spl ntp
Server.start serverSettings apiServerTracer tlsConfig socket application

withPoolsMonitoring
Expand Down
9 changes: 6 additions & 3 deletions lib/shelley/src/Cardano/Wallet/Shelley/Api/Server.hs
Expand Up @@ -90,6 +90,7 @@ import Cardano.Wallet.Api.Server
, postRandomAddress
, postRandomWallet
, postRandomWalletFromXPrv
, postSharedWallet
, postTransaction
, postTransactionFee
, postTrezorWallet
Expand Down Expand Up @@ -142,6 +143,8 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Random
( RndState )
import Cardano.Wallet.Primitive.AddressDiscovery.Sequential
( SeqState )
import Cardano.Wallet.Primitive.AddressDiscovery.SharedState
( SharedState )
import Cardano.Wallet.Primitive.Types
( PoolMetadataSource (..), SmashServer (..), poolMetadataSource )
import Cardano.Wallet.Shelley.Compatibility
Expand Down Expand Up @@ -204,10 +207,11 @@ server
=> ApiLayer (RndState n) ByronKey
-> ApiLayer (SeqState n IcarusKey) IcarusKey
-> ApiLayer (SeqState n ShelleyKey) ShelleyKey
-> ApiLayer (SharedState n ShelleyKey) ShelleyKey
-> StakePoolLayer
-> NtpClient
-> Server (Api n ApiStakePool)
server byron icarus shelley spl ntp =
server byron icarus shelley multisig spl ntp =
wallets
:<|> walletKeys
:<|> assets
Expand Down Expand Up @@ -488,13 +492,12 @@ server byron icarus shelley spl ntp =

sharedWallets :: Server SharedWallets
sharedWallets =
postSharedWallet
postSharedWallet multisig generateKeyFromSeed ShelleyKey
:<|> getSharedWallet
:<|> patchSharedWalletInPayment
:<|> patchSharedWalletInDelegation
:<|> deleteSharedWallet
where
postSharedWallet = pure $ throwError err501
getSharedWallet = pure $ throwError err501
patchSharedWalletInPayment _ = pure $ throwError err501
patchSharedWalletInDelegation _ = pure $ throwError err501
Expand Down

0 comments on commit 12ac979

Please sign in to comment.