File tree Expand file tree Collapse file tree 3 files changed +16
-15
lines changed Expand file tree Collapse file tree 3 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 1
1
module Core.Types.Mnemonics.Options
2
2
( mnemonicsParser
3
3
, walletPassphraseCommon
4
+ , walletFileOption
4
5
) where
5
6
6
7
import Core.Encryption (decryptText )
@@ -60,7 +61,7 @@ walletFileOption =
60
61
setting
61
62
[ env " ANTI_WALLET_FILE"
62
63
, metavar " FILEPATH"
63
- , help " The file path to the wallet secrets"
64
+ , help " The file path to the wallet secrets mnemonics "
64
65
, reader str
65
66
]
66
67
Original file line number Diff line number Diff line change @@ -30,17 +30,20 @@ instance (ToJSON m a, Monad m) => ToJSON m (Either WalletError a) where
30
30
data WalletInfo = WalletInfo
31
31
{ address :: Address
32
32
, owner :: Owner
33
+ , filePath :: FilePath
33
34
}
34
35
35
36
instance Monad m => ToJSON m WalletInfo where
36
- toJSON WalletInfo {address, owner} =
37
+ toJSON WalletInfo {address, owner, filePath } =
37
38
object
38
39
[ " address" .= address
39
40
, " owner" .= owner
41
+ , " filePath" .= filePath
40
42
]
41
43
42
44
data WalletCommand a where
43
- Info :: Wallet -> WalletCommand (Either WalletError WalletInfo )
45
+ Info
46
+ :: Wallet -> FilePath -> WalletCommand (Either WalletError WalletInfo )
44
47
Create
45
48
:: FilePath
46
49
-> Maybe Text
@@ -50,12 +53,13 @@ deriving instance Show (WalletCommand a)
50
53
deriving instance Eq (WalletCommand a )
51
54
52
55
walletCmd :: WalletCommand a -> IO a
53
- walletCmd (Info wallet) =
56
+ walletCmd (Info wallet filePath ) =
54
57
pure
55
58
$ Right
56
59
$ WalletInfo
57
60
{ address = wallet. address
58
61
, owner = wallet. owner
62
+ , filePath = filePath
59
63
}
60
64
walletCmd (Create walletFile passphrase) = do
61
65
w12 <- replicateM 12 $ element englishWords
@@ -68,6 +72,7 @@ walletCmd (Create walletFile passphrase) = do
68
72
$ WalletInfo
69
73
{ address = wallet. address
70
74
, owner = wallet. owner
75
+ , filePath = walletFile
71
76
}
72
77
73
78
element :: [a ] -> IO a
Original file line number Diff line number Diff line change @@ -5,21 +5,15 @@ module Wallet.Options
5
5
) where
6
6
7
7
import Core.Options (walletOption )
8
- import Core.Types.Mnemonics.Options (walletPassphraseCommon )
8
+ import Core.Types.Mnemonics.Options
9
+ ( walletFileOption
10
+ , walletPassphraseCommon
11
+ )
9
12
import Data.Text (Text )
10
13
import Lib.Box (Box (.. ))
11
14
import OptEnvConf
12
15
import Wallet.Cli (WalletCommand (.. ))
13
16
14
- walletFileOption :: Parser FilePath
15
- walletFileOption =
16
- setting
17
- [ help " File to store the wallet mnemonic"
18
- , metavar " MNEMONICS"
19
- , env " ANTI_WALLET_FILE"
20
- , reader str
21
- ]
22
-
23
17
walletCommandParser :: Parser (Box WalletCommand )
24
18
walletCommandParser =
25
19
commands
@@ -32,8 +26,9 @@ walletCommandParser =
32
26
, command
33
27
" info"
34
28
" Get the wallet information"
35
- $ Box . Info
29
+ $ fmap Box . Info
36
30
<$> walletOption
31
+ <*> walletFileOption
37
32
]
38
33
39
34
passphraseOption :: Parser (Maybe Text )
You can’t perform that action at this time.
0 commit comments