From 1b9d9c8f6c504f5b89019c730ab82b78c3e615a5 Mon Sep 17 00:00:00 2001 From: jmininger <20273200+jmininger@users.noreply.github.com> Date: Fri, 15 Oct 2021 15:06:03 -0400 Subject: [PATCH] Web fixes (#693) * 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 --- backend/sass/common.blocks/_main-header.scss | 5 +++++ desktop/src/Desktop/Crypto/BIP.hs | 7 +++++++ frontend/src/Frontend.hs | 2 +- frontend/src/Frontend/Crypto/Class.hs | 10 +++++++++- frontend/src/Frontend/Setup/Common.hs | 5 +++-- frontend/src/Frontend/Setup/Widgets.hs | 2 +- frontend/src/Frontend/Wallet.hs | 8 ++++++-- 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/backend/sass/common.blocks/_main-header.scss b/backend/sass/common.blocks/_main-header.scss index c58ed3cfc..0b52bed93 100644 --- a/backend/sass/common.blocks/_main-header.scss +++ b/backend/sass/common.blocks/_main-header.scss @@ -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; diff --git a/desktop/src/Desktop/Crypto/BIP.hs b/desktop/src/Desktop/Crypto/BIP.hs index 79a1c16bc..4b431ef70 100644 --- a/desktop/src/Desktop/Crypto/BIP.hs +++ b/desktop/src/Desktop/Crypto/BIP.hs @@ -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 diff --git a/frontend/src/Frontend.hs b/frontend/src/Frontend.hs index c4385f702..f63a64252 100644 --- a/frontend/src/Frontend.hs +++ b/frontend/src/Frontend.hs @@ -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") diff --git a/frontend/src/Frontend/Crypto/Class.hs b/frontend/src/Frontend/Crypto/Class.hs index 9e4fe4af1..07949004b 100644 --- a/frontend/src/Frontend/Crypto/Class.hs +++ b/frontend/src/Frontend/Crypto/Class.hs @@ -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) diff --git a/frontend/src/Frontend/Setup/Common.hs b/frontend/src/Frontend/Setup/Common.hs index f64f15b59..dd858c7a2 100644 --- a/frontend/src/Frontend/Setup/Common.hs +++ b/frontend/src/Frontend/Setup/Common.hs @@ -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 diff --git a/frontend/src/Frontend/Setup/Widgets.hs b/frontend/src/Frontend/Setup/Widgets.hs index 27624e1f4..d43de8c66 100644 --- a/frontend/src/Frontend/Setup/Widgets.hs +++ b/frontend/src/Frontend/Setup/Widgets.hs @@ -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)" diff --git a/frontend/src/Frontend/Wallet.hs b/frontend/src/Frontend/Wallet.hs index 632a023e3..6be3b330f 100644 --- a/frontend/src/Frontend/Wallet.hs +++ b/frontend/src/Frontend/Wallet.hs @@ -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