Skip to content

Commit

Permalink
Merge #1809
Browse files Browse the repository at this point in the history
1809: More mnemonics for icarus/random wallets r=paweljakubas a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#1803 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have enabled more mnemonics lengths for random/icarus wallets
- [x] I have updated swagger and Malformed in core unit tests
- [x] I have updated byron integration scenarios


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Pawel Jakubas <[email protected]>
  • Loading branch information
iohk-bors[bot] and paweljakubas authored Jun 27, 2020
2 parents 1af1c49 + 8e2abff commit d1d635f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,17 @@ spec = do

it' "random" (genMnemonics @9) scenarioFailure --
it' "random" (genMnemonics @12) scenarioSuccess -- ✔️
it' "random" (genMnemonics @15) scenarioFailure --
it' "random" (genMnemonics @18) scenarioFailure --
it' "random" (genMnemonics @21) scenarioFailure --
it' "random" (genMnemonics @24) scenarioFailure --
it' "random" (genMnemonics @15) scenarioSuccess -- ✔️
it' "random" (genMnemonics @18) scenarioSuccess -- ✔️
it' "random" (genMnemonics @21) scenarioSuccess -- ✔️
it' "random" (genMnemonics @24) scenarioSuccess -- ✔️

it' "icarus" (genMnemonics @9) scenarioFailure --
it' "icarus" (genMnemonics @12) scenarioFailure --
it' "icarus" (genMnemonics @12) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @15) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @18) scenarioFailure --
it' "icarus" (genMnemonics @21) scenarioFailure --
it' "icarus" (genMnemonics @24) scenarioFailure --
it' "icarus" (genMnemonics @18) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @21) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @24) scenarioSuccess -- ✔️

it' "trezor" (genMnemonics @9) scenarioFailure --
it' "trezor" (genMnemonics @12) scenarioSuccess -- ✔️
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ spec = do

it' "random" (genMnemonics @9) scenarioFailure --
it' "random" (genMnemonics @12) scenarioSuccess -- ✔️
it' "random" (genMnemonics @15) scenarioFailure --
it' "random" (genMnemonics @18) scenarioFailure --
it' "random" (genMnemonics @21) scenarioFailure --
it' "random" (genMnemonics @24) scenarioFailure --
it' "random" (genMnemonics @15) scenarioSuccess -- ✔️
it' "random" (genMnemonics @18) scenarioSuccess -- ✔️
it' "random" (genMnemonics @21) scenarioSuccess -- ✔️
it' "random" (genMnemonics @24) scenarioSuccess -- ✔️

it' "icarus" (genMnemonics @9) scenarioFailure --
it' "icarus" (genMnemonics @12) scenarioFailure --
it' "icarus" (genMnemonics @12) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @15) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @18) scenarioFailure --
it' "icarus" (genMnemonics @21) scenarioFailure --
it' "icarus" (genMnemonics @24) scenarioFailure --
it' "icarus" (genMnemonics @18) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @21) scenarioSuccess -- ✔️
it' "icarus" (genMnemonics @24) scenarioSuccess -- ✔️

it' "trezor" (genMnemonics @9) scenarioFailure --
it' "trezor" (genMnemonics @12) scenarioSuccess -- ✔️
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ postRandomWallet
, k ~ ByronKey
)
=> ctx
-> ByronWalletPostData '[12]
-> ByronWalletPostData '[12,15,18,21,24]
-> Handler ApiByronWallet
postRandomWallet ctx body = do
s <- liftIO $ mkRndState rootXPrv <$> getStdRandom random
Expand Down Expand Up @@ -776,7 +776,7 @@ postIcarusWallet
, PaymentAddress n IcarusKey
)
=> ctx
-> ByronWalletPostData '[15]
-> ByronWalletPostData '[12,15,18,21,24]
-> Handler ApiByronWallet
postIcarusWallet ctx body = do
postLegacyWallet ctx (rootXPrv, pwd) $ \wrk wid ->
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ type family StyleSymbol (style :: ByronWalletStyle) :: Symbol where

type family AllowedMnemonics (style :: k) :: [Nat]

type instance AllowedMnemonics 'Random = '[12]
type instance AllowedMnemonics 'Icarus = '[15]
type instance AllowedMnemonics 'Random = '[12,15,18,21,24]
type instance AllowedMnemonics 'Icarus = '[12,15,18,21,24]
type instance AllowedMnemonics 'Trezor = '[12,15,18,21,24]
type instance AllowedMnemonics 'Ledger = '[12,15,18,21,24]
type instance AllowedMnemonics 'Shelley = '[15,18,21,24]
Expand Down
12 changes: 6 additions & 6 deletions lib/core/test/unit/Cardano/Wallet/Api/Malformed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,18 @@ instance Malformed (BodyParam SomeByronWalletPostData) where
, ( [aesonQQ|
{ "style": "random"
, "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "mnemonic_sentence": #{mnemonics9}
, "passphrase": #{wPassphrase}
}|]
, "Error in $['mnemonic_sentence']: Invalid number of words: 12 words are expected."
, "Error in $['mnemonic_sentence']: Invalid number of words: 12, 15, 18, 21 or 24 words are expected."
)
, ( [aesonQQ|
{ "style": "icarus"
, "name": #{wName}
, "mnemonic_sentence": #{mnemonics12}
, "mnemonic_sentence": #{mnemonics9}
, "passphrase": #{wPassphrase}
}|]
, "Error in $['mnemonic_sentence']: Invalid number of words: 15 words are expected."
, "Error in $['mnemonic_sentence']: Invalid number of words: 12, 15, 18, 21 or 24 words are expected."
)
, ( [aesonQQ|
{ "style": "trezor"
Expand All @@ -241,10 +241,10 @@ instance Malformed (BodyParam SomeByronWalletPostData) where
, ( [aesonQQ|
{ "style": "random"
, "name": #{wName}
, "mnemonic_sentence": #{mnemonics15}
, "mnemonic_sentence": #{invalidMnemonics15}
, "passphrase": #{wPassphrase}
}|]
, "Error in $['mnemonic_sentence']: Invalid number of words: 12 words are expected."
, "Error in $['mnemonic_sentence']: Invalid entropy checksum: please double-check the last word of your mnemonic sentence."
)
, ( [aesonQQ|
{ "style": "icarus"
Expand Down
6 changes: 3 additions & 3 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ components:
mnemonic_sentence:
<<: *walletMnemonicSentence
minItems: 12
maxItems: 12
maxItems: 24

ApiByronWalletRandomXPrvPostData: &ApiByronWalletRandomXPrvPostData
type: object
Expand Down Expand Up @@ -1134,8 +1134,8 @@ components:
passphrase: *walletPassphrase
mnemonic_sentence:
<<: *walletMnemonicSentence
minItems: 15
maxItems: 15
minItems: 12
maxItems: 24

ApiByronWalletTrezorPostData: &ApiByronWalletTrezorPostData
type: object
Expand Down

0 comments on commit d1d635f

Please sign in to comment.