Skip to content

Commit

Permalink
add getWalletKey to api link
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Oct 13, 2020
1 parent cc98a3b commit 4b29f53
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/core/src/Cardano/Wallet/Api/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ module Cardano.Wallet.Api.Link
, getMigrationInfo
, migrateWallet

-- * WalletKeys
, getWalletKey

-- * Addresses
, postRandomAddress
, putRandomAddresses
Expand Down Expand Up @@ -104,7 +107,14 @@ import Cardano.Wallet.Api.Types
import Cardano.Wallet.Primitive.AddressDerivation
( NetworkDiscriminant (..) )
import Cardano.Wallet.Primitive.Types
( AddressState, Coin (..), Hash, PoolId, SortOrder, WalletId (..) )
( AddressState
, Coin (..)
, DerivationIndex
, Hash
, PoolId
, SortOrder
, WalletId (..)
)
import Data.Function
( (&) )
import Data.Generics.Internal.VL.Lens
Expand Down Expand Up @@ -255,6 +265,22 @@ getMigrationInfo w = discriminate @style
where
wid = w ^. typed @(ApiT WalletId)

--
-- WalletKeys
--

getWalletKey
:: forall w.
( HasType (ApiT WalletId) w
)
=> w
-> ApiT DerivationIndex
-> (Method, Text)
getWalletKey w index =
endpoint @Api.GetWalletKey (\mk -> mk wid index)
where
wid = w ^. typed @(ApiT WalletId)

--
-- Addresses
--
Expand Down
3 changes: 3 additions & 0 deletions lib/core/src/Cardano/Wallet/Primitive/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ instance NFData DerivationIndex
instance FromText DerivationIndex where
fromText = fmap DerivationIndex . fromText

instance ToText DerivationIndex where
toText (DerivationIndex index) = toText index

{-------------------------------------------------------------------------------
Coin
-------------------------------------------------------------------------------}
Expand Down

0 comments on commit 4b29f53

Please sign in to comment.