Skip to content

Commit

Permalink
Web fixes (#693)
Browse files Browse the repository at this point in the history
* add 'BETA' label

* revert k: default account

* wrap header button text for ... mobile users

* add DisplayError class for better error msgs on mnemonic failures

Co-authored-by: jmininger <none>
  • Loading branch information
jmininger authored Oct 15, 2021
1 parent 228e28e commit 1b9d9c8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 7 deletions.
5 changes: 5 additions & 0 deletions backend/sass/common.blocks/_main-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ $main-header-wallet-btn-bg: #ececec;
font-size: $secondary-font-size;
line-height: 0;
height: $main-header-std-height;
// For mobile users
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;


&.main-header__primary-button {
@extend .main-header__button;
Expand Down
7 changes: 7 additions & 0 deletions desktop/src/Desktop/Crypto/BIP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ data BIP39PhraseError
| BIP39PhraseError_PhraseIncomplete
deriving (Show)

instance DisplayError BIP39PhraseError where
displayError e = case e of
BIP39PhraseError_Dictionary dictError -> tshow dictError
BIP39PhraseError_MnemonicWordsErr mnemWordErr -> tshow mnemWordErr
BIP39PhraseError_InvalidPhrase -> "Invalid Phrase"
BIP39PhraseError_PhraseIncomplete -> ""

instance BIP39Mnemonic (Crypto.MnemonicSentence 12) where
type BIP39MnemonicError (Crypto.MnemonicSentence 12)= BIP39PhraseError

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Frontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ loaderMarkup = divClass "spinner" $ do

newHead :: (Prerender js t m, DomBuilder t m) => (R BackendRoute -> Text) -> m (Event t ())
newHead routeText = do
el "title" $ text "Kadena Chainweaver: Wallet & IDE"
el "title" $ text "(BETA) Kadena Chainweaver: Wallet & IDE"
elAttr "link" ("rel" =: "icon" <> "type" =: "image/png" <> "href" =: static @"img/favicon/favicon-96x96.png") blank
meta ("name" =: "description" <> "content" =: "Write, test, and deploy safe smart contracts using Pact, Kadena's programming language")
meta ("name" =: "keywords" <> "content" =: "kadena, pact, pact testnet, pact language, pact programming language, smart contracts, safe smart contracts, smart contract language, blockchain, learn blockchain programming, chainweb")
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/Frontend/Crypto/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ data MnemonicError =
| MnemonicError_NotEnoughWords
deriving (Show)

class (Show (BIP39MnemonicError mnem)) => BIP39Mnemonic mnem where
class DisplayError e where
displayError :: e -> Text

instance DisplayError MnemonicError where
displayError MnemonicError_InvalidPhrase = "Invalid Mnemonic Phrase"
displayError MnemonicError_NotEnoughWords = ""


class (DisplayError (BIP39MnemonicError mnem)) => BIP39Mnemonic mnem where
type BIP39MnemonicError mnem
generateMnemonic :: MonadJSM m => m (Either Text mnem)
toMnemonic :: MonadJSM m => [Text] -> m (Either (BIP39MnemonicError mnem) mnem)
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/Frontend/Setup/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,12 @@ restoreBipWallet backWF eBack = Workflow $ do
onPhraseMapUpdate <- passphraseWidget dPhraseMap (pure Recover) True

sentenceOrError <- performEvent $ ffor (updated dPhraseMap) $ \pMap ->
toMnemonic $ Map.elems pMap
let wList = filter (not . T.null) $ Map.elems pMap
in toMnemonic wList
widgetHold_ blank $ ffor sentenceOrError $ \case
Right _ -> blank
Left e -> setupDiv "phrase-error-message-wrapper" $ setupDiv "phrase-error-message" $
text $ tshow e
text $ displayError e
let
ePhraseUpdated = fmapMaybe hush sentenceOrError

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Frontend/Setup/Widgets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ kadenaWalletLogo :: DomBuilder t m => m ()
kadenaWalletLogo = divClass "logo" $ do
elAttr "img" ("src" =: static @"img/kadena_blue_logo.png" <> "class" =: setupClass "kadena-logo") blank
elClass "div" "chainweaver" $ text "Chainweaver"
elClass "div" "by-kadena" $ text "by Kadena"
elClass "div" "by-kadena" $ text "by Kadena (BETA)"
8 changes: 6 additions & 2 deletions frontend/src/Frontend/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,12 @@ makeWallet mChangePassword model conf = do
addStarterAccount net ks ad =
case IntMap.toList ks of
[(i,k)] -> if Map.size (ad ^. _AccountData . ix net) == 0
then let accName = (AccountName $ "k:" <> (keyToText $ _keyPair_publicKey $ _key_pair k))
in ad <> (AccountData $ net =: accName =: mempty)
then ad <> (AccountData $ net =: (AccountName $ keyToText $ _keyPair_publicKey $ _key_pair k) =: mempty)
-- k: syntax, We use pubkey syntax as default account name for now `until we have
-- a better community migration plan

-- then let accName = (AccountName $ "k:" <> (keyToText $ _keyPair_publicKey $ _key_pair k))
-- in ad <> (AccountData $ net =: accName =: mempty)
else ad
_ -> ad

Expand Down

0 comments on commit 1b9d9c8

Please sign in to comment.