-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add very preliminary interface/structure for wallet getter and creation #62
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DuplicateRecordFields #-} | ||
|
||
-- | | ||
-- Copyright: © 2018-2019 IOHK | ||
-- License: MIT | ||
-- | ||
-- | Module provides wallet layer api that is used by API layer | ||
-- | and uses both DB and Networking layer to realize its role | ||
-- | as being intermediary between the three. | ||
|
||
|
||
module Cardano.WalletLayer where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet | ||
( Wallet ) | ||
import Cardano.Wallet.AddressDerivation | ||
( Depth (..), Key, Passphrase, XPub ) | ||
import Cardano.Wallet.AddressDiscovery | ||
( AddressPoolGap ) | ||
import Cardano.Wallet.Mnemonic | ||
( Mnemonic ) | ||
import Control.Monad.Except | ||
( ExceptT ) | ||
import Data.Text | ||
( Text ) | ||
import Data.Time.Units | ||
( Microsecond ) | ||
import GHC.Generics | ||
( Generic ) | ||
|
||
|
||
|
||
-- | Errors | ||
data CreateWalletError | ||
|
||
data GetWalletError | ||
|
||
-- | Types | ||
data WalletLayer m s = WalletLayer | ||
{ createWallet :: CreateWallet -> ExceptT CreateWalletError m (Wallet s) | ||
, getWallet :: WalletId -> ExceptT GetWalletError m (Wallet s) | ||
} | ||
|
||
data CreateWallet = | ||
CreateWallet NewWallet | ||
| ImportWallet (Key 'AccountK XPub) | ||
|
||
data NewWallet = NewWallet | ||
{ | ||
mnemonicSentence | ||
:: !(Mnemonic 15) | ||
, mnemonicSentencePassphrase | ||
:: !(Maybe (Mnemonic 9)) | ||
, name | ||
:: !WalletName | ||
, passphrase | ||
:: !(Passphrase "encryption") | ||
, addressPoolGap | ||
:: !AddressPoolGap | ||
} deriving (Show, Generic) | ||
|
||
newtype WalletName = WalletName Text | ||
deriving (Eq, Show) | ||
|
||
newtype WalletId = WalletId Text | ||
deriving (Eq, Show) | ||
|
||
newtype WalletTimestamp = WalletTimestamp Microsecond | ||
deriving (Eq, Ord, Show) | ||
|
||
data WalletMode = Ready | Restoring deriving (Eq, Show) | ||
|
||
data Delegation = Delegated | NotDelegated deriving (Eq, Show) | ||
|
||
newtype PassphraseInfo = PassphraseInfo { lastUpdated :: WalletTimestamp } | ||
deriving (Eq, Show) | ||
|
||
data WalletMetadata = WalletMetadata { | ||
id | ||
:: !WalletId | ||
, name | ||
:: !WalletName | ||
, addressPoolGap | ||
:: !AddressPoolGap | ||
, passphraseInfo | ||
:: !PassphraseInfo | ||
, state | ||
:: !WalletMode | ||
, delegation | ||
:: !Delegation | ||
} deriving (Eq, Show, Generic) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have separate error types for the different functions. I am not expecting
getWallet
to throw anything related to the creation of a wallet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done