From aca2807a8b401a8a0991975374750ae90431d708 Mon Sep 17 00:00:00 2001 From: udaybansal19 Date: Sun, 28 Jul 2024 18:29:59 +0530 Subject: [PATCH] Web3 UI fixes and signer error handling --- .../page/ping_doc_signer/utils/pdf_signer.tsx | 8 +++-- .../browser/brave_wallet_prefs.cc | 4 +-- .../views/portfolio/portfolio-overview.tsx | 6 ++-- .../brave_wallet_ui/options/nav-options.ts | 36 +++++++++---------- .../tab-header/tab-header.tsx | 4 +-- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/components/brave_rewards/resources/page/ping_doc_signer/utils/pdf_signer.tsx b/components/brave_rewards/resources/page/ping_doc_signer/utils/pdf_signer.tsx index f99885ac04cf..3da809d2bec2 100644 --- a/components/brave_rewards/resources/page/ping_doc_signer/utils/pdf_signer.tsx +++ b/components/brave_rewards/resources/page/ping_doc_signer/utils/pdf_signer.tsx @@ -226,13 +226,17 @@ export const signPdf = async ( const toSign = buf.toString('hex') - return new Promise((resolve) => { + return new Promise((resolve, reject) => { ; (chrome as any).pkcs11.getSignature( hsmPath, pin, toSign, (sig: string) => { - getPkcs11ErrorHandler(sig) + try { + getPkcs11ErrorHandler(sig) + } catch (error) { + reject(error) + } let signature = Buffer.from(sig, 'hex').toString('binary') resolve(signature) } diff --git a/components/brave_wallet/browser/brave_wallet_prefs.cc b/components/brave_wallet/browser/brave_wallet_prefs.cc index 2534117f30eb..5e9986a2647f 100644 --- a/components/brave_wallet/browser/brave_wallet_prefs.cc +++ b/components/brave_wallet/browser/brave_wallet_prefs.cc @@ -169,8 +169,8 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { kDefaultSolanaWallet, static_cast( brave_wallet::mojom::DefaultWallet::BraveWalletPreferExtension)); - registry->RegisterStringPref(kDefaultBaseCurrency, "USD"); - registry->RegisterStringPref(kDefaultBaseCryptocurrency, "BTC"); + registry->RegisterStringPref(kDefaultBaseCurrency, "INR"); + registry->RegisterStringPref(kDefaultBaseCryptocurrency, "SOL"); registry->RegisterBooleanPref(kShowWalletIconOnToolbar, true); registry->RegisterDictionaryPref(kBraveWalletTransactions); registry->RegisterDictionaryPref(kBraveWalletP3AActiveWalletDict); diff --git a/components/brave_wallet_ui/components/desktop/views/portfolio/portfolio-overview.tsx b/components/brave_wallet_ui/components/desktop/views/portfolio/portfolio-overview.tsx index a5866d643f89..0afa4dcf2bc5 100644 --- a/components/brave_wallet_ui/components/desktop/views/portfolio/portfolio-overview.tsx +++ b/components/brave_wallet_ui/components/desktop/views/portfolio/portfolio-overview.tsx @@ -98,7 +98,7 @@ import { BackgroundWatermark, BalanceAndLineChartWrapper } from './style' -import { Column, Row, HorizontalSpace } from '../../../shared/style' +import { Column, Row } from '../../../shared/style' // Queries import { @@ -618,7 +618,7 @@ export const PortfolioOverview = () => { ) : ( <> - @@ -626,7 +626,7 @@ export const PortfolioOverview = () => { + /> */} )} diff --git a/components/brave_wallet_ui/options/nav-options.ts b/components/brave_wallet_ui/options/nav-options.ts index be9a54a0b306..901474b608b4 100644 --- a/components/brave_wallet_ui/options/nav-options.ts +++ b/components/brave_wallet_ui/options/nav-options.ts @@ -43,24 +43,24 @@ export const isValidPanelNavigationOption = ( } export const BuySendSwapDepositOptions: NavOption[] = [ - { - id: 'buy', - name: 'braveWalletBuy', - icon: 'coins-alt1', - route: WalletRoutes.FundWalletPageStart - }, + // { + // id: 'buy', + // name: 'braveWalletBuy', + // icon: 'coins-alt1', + // route: WalletRoutes.FundWalletPageStart + // }, { id: 'send', name: 'braveWalletSend', icon: 'send', route: WalletRoutes.Send }, - { - id: 'swap', - name: 'braveWalletSwap', - icon: 'currency-exchange', - route: WalletRoutes.Swap - }, + // { + // id: 'swap', + // name: 'braveWalletSwap', + // icon: 'currency-exchange', + // route: WalletRoutes.Swap + // }, { id: 'deposit', name: 'braveWalletDepositCryptoButton', @@ -112,12 +112,12 @@ export const NavOptions: NavOption[] = [ icon: 'user-accounts', route: WalletRoutes.Accounts }, - { - id: 'market', - name: 'braveWalletTopNavMarket', - icon: 'discover', - route: WalletRoutes.Market - } + // { + // id: 'market', + // name: 'braveWalletTopNavMarket', + // icon: 'discover', + // route: WalletRoutes.Market + // } ] export const AllNavOptions: NavOption[] = [ diff --git a/components/brave_wallet_ui/page/screens/shared-screen-components/tab-header/tab-header.tsx b/components/brave_wallet_ui/page/screens/shared-screen-components/tab-header/tab-header.tsx index 48623508dc46..09918c82dce3 100644 --- a/components/brave_wallet_ui/page/screens/shared-screen-components/tab-header/tab-header.tsx +++ b/components/brave_wallet_ui/page/screens/shared-screen-components/tab-header/tab-header.tsx @@ -11,7 +11,7 @@ import { useOnClickOutside } from '../../../../common/hooks/useOnClickOutside' // Styled Components import { HeaderWrapper, - BraveLogo, + // BraveLogo, SettingsButton, SettingsIcon, SettingsWrapper @@ -50,7 +50,7 @@ export const TabHeader = (props: Props) => { rowHeight='full' verticalAlign='center' > - + {/* */} {!hideHeaderMenu && (