From 47bbae06f4633331e2aba97ae5aa4fbed6571a52 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 21 Oct 2024 13:20:04 +0300 Subject: [PATCH 001/133] ff 5.4.277 --- packages/yoroi-extension/package-lock.json | 4 ++-- packages/yoroi-extension/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/package-lock.json b/packages/yoroi-extension/package-lock.json index 7fbeb74263..6dd115e85a 100644 --- a/packages/yoroi-extension/package-lock.json +++ b/packages/yoroi-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "yoroi", - "version": "5.3.310", + "version": "5.4.277", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yoroi", - "version": "5.3.310", + "version": "5.4.277", "license": "MIT", "dependencies": { "@amplitude/analytics-browser": "^2.1.3", diff --git a/packages/yoroi-extension/package.json b/packages/yoroi-extension/package.json index 721116800f..c1fb43c761 100644 --- a/packages/yoroi-extension/package.json +++ b/packages/yoroi-extension/package.json @@ -1,6 +1,6 @@ { "name": "yoroi", - "version": "5.3.310", + "version": "5.4.277", "description": "Cardano ADA wallet", "scripts": { "dev-mv2": "rimraf dev/ && NODE_OPTIONS=--openssl-legacy-provider babel-node scripts-mv2/build --type=debug --env 'mainnet'", From 45f14ee2054474b5b6d508588d4753ee5a9bacd4 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Wed, 30 Oct 2024 19:50:15 +0300 Subject: [PATCH 002/133] Version bump: 5.4.278 (ff) --- packages/yoroi-extension/package-lock.json | 4 ++-- packages/yoroi-extension/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/package-lock.json b/packages/yoroi-extension/package-lock.json index 6dd115e85a..0cc1e2c3e0 100644 --- a/packages/yoroi-extension/package-lock.json +++ b/packages/yoroi-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "yoroi", - "version": "5.4.277", + "version": "5.4.278", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yoroi", - "version": "5.4.277", + "version": "5.4.278", "license": "MIT", "dependencies": { "@amplitude/analytics-browser": "^2.1.3", diff --git a/packages/yoroi-extension/package.json b/packages/yoroi-extension/package.json index c1fb43c761..91792b23d0 100644 --- a/packages/yoroi-extension/package.json +++ b/packages/yoroi-extension/package.json @@ -1,6 +1,6 @@ { "name": "yoroi", - "version": "5.4.277", + "version": "5.4.278", "description": "Cardano ADA wallet", "scripts": { "dev-mv2": "rimraf dev/ && NODE_OPTIONS=--openssl-legacy-provider babel-node scripts-mv2/build --type=debug --env 'mainnet'", From 60082d12b01bdf70a64db71001e50fbaee9720cb Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Wed, 30 Oct 2024 12:47:25 +0100 Subject: [PATCH 003/133] update tx colors --- .../wallet/transactions/TransactionRevamp.js | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js b/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js index a876326bd7..0c86b8aef9 100644 --- a/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js +++ b/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js @@ -18,8 +18,7 @@ import { intlShape } from 'react-intl'; import moment from 'moment'; import classnames from 'classnames'; import BigNumber from 'bignumber.js'; -import { Button, Grid, Typography } from '@mui/material'; -import { Box } from '@mui/system'; +import { Button, Grid, Typography, useTheme, styled, Box } from '@mui/material'; import { ReactComponent as AddMemoSvg } from '../../../assets/images/revamp/add-memo.inline.svg'; import { ReactComponent as EditSvg } from '../../../assets/images/edit.inline.svg'; import { ReactComponent as SendIcon } from '../../../assets/images/transaction/send.inline.svg'; @@ -1057,7 +1056,40 @@ const icons = { stake: StakeIcon, }; +const getColors = (ds, type) => { + const colorsByType = { + send: { bg: ds.primary_100, icon: ds.primary_600 }, + receive: { bg: ds.secondary_100, icon: ds.secondary_600 }, + reward: { bg: ds.secondary_100, icon: ds.secondary_600 }, + error: { bg: ds.magenta_100, icon: ds.magenta_500 }, + stake: { bg: ds.secondary_100, icon: ds.secondary_600 }, + }; + + return colorsByType[type] || { bg: ds.primary_100, icon: ds.primary_600 }; +}; + +const IconWrapper = styled(Box)(({ isDark, colors, theme }) => ({ + '& svg': { + '& rect': { + fill: isDark && colors.bg, + }, + '& path': { + fill: isDark && colors.icon, + }, + }, +})); + const TypeIcon = ({ type }) => { const Icon = icons[type]; - return {Icon && }; + const theme = useTheme(); + const colors = getColors(theme.palette.ds, type); + const isDark = theme.name === 'dark-theme'; + + return ( + + + {Icon && } + + + ); }; From 0985cc25bb00484f85105d1f91e495bd378c6666 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Mon, 4 Nov 2024 14:34:06 +0100 Subject: [PATCH 004/133] add pt name --- .../common/components/PortfolioHeader.tsx | 13 +++++++---- .../common/hooks/usePortfolioTokenChart.ts | 6 ++--- .../useCases/Dapps/LiquidityTable.tsx | 23 +++++++++---------- .../portfolio/useCases/Dapps/OrderTable.tsx | 22 +++++++++--------- .../TransactionTable.tsx | 5 ++-- .../TokenDetails/HeaderDetails/Header.tsx | 10 +++++--- .../useCases/TokensTable/TableColumnsChip.tsx | 2 +- .../useCases/TokensTable/useProcentage.tsx | 3 ++- 8 files changed, 45 insertions(+), 39 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx b/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx index c9f59dcb1f..bab80ab733 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx @@ -45,10 +45,10 @@ const PortfolioHeader = ({ walletBalance, setKeyword, isLoading, tooltipTitle }: const { changeValue, changePercent, variantPnl } = priceChange(open, ptPrice); - const showADA = accountPair?.from.name === 'ADA'; + const showADA = accountPair?.from.name === primaryTokenInfo.name; const totalTokenPrice = React.useMemo(() => { - const showingAda = accountPair?.from.name !== 'ADA'; + const showingAda = accountPair?.from.name !== primaryTokenInfo.name; const currency = showingAda ? primaryTokenInfo.ticker : unitOfAccount; if (ptPrice == null) return `... ${currency}`; @@ -61,10 +61,13 @@ const PortfolioHeader = ({ walletBalance, setKeyword, isLoading, tooltipTitle }: const handleCurrencyChange = async () => { const pair = { from: { - name: showADA ? unitOfAccount ?? DEFAULT_FIAT_PAIR : 'ADA', + name: showADA ? unitOfAccount ?? DEFAULT_FIAT_PAIR : primaryTokenInfo.name, value: showADA ? totalTokenPrice ?? '0' : walletBalance.ada, }, - to: { name: showADA ? 'ADA' : unitOfAccount ?? DEFAULT_FIAT_PAIR, value: showADA ? walletBalance.ada : totalTokenPrice }, + to: { + name: showADA ? primaryTokenInfo.name : unitOfAccount ?? DEFAULT_FIAT_PAIR, + value: showADA ? walletBalance.ada : totalTokenPrice, + }, }; localStorageApi.setSetPortfolioFiatPair(pair); changeUnitOfAccountPair(pair); @@ -77,7 +80,7 @@ const PortfolioHeader = ({ walletBalance, setKeyword, isLoading, tooltipTitle }: const portfolioStoragePairObj = portfolioStoragePair && JSON.parse(portfolioStoragePair); const pair = { - from: { name: 'ADA', value: walletBalance?.ada || '0' }, + from: { name: primaryTokenInfo.name, value: walletBalance?.ada || '0' }, to: { name: unitOfAccount || DEFAULT_FIAT_PAIR, value: !showADA ? walletBalance.ada : totalTokenPrice || '0' }, }; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts index 0761c14ac3..1d96031eed 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts @@ -72,8 +72,6 @@ type TokenChartData = { // return chartData; // } -const ptTicker = 'ADA'; - export const useGetPortfolioTokenChart = ( timeInterval = TOKEN_CHART_INTERVAL.DAY as TokenChartInterval, tokenInfo, @@ -85,7 +83,7 @@ export const useGetPortfolioTokenChart = ( > = {} ) => { // const { currency } = useCurrencyPairing(); - const { unitOfAccount } = usePortfolio(); + const { unitOfAccount, primaryTokenInfo } = usePortfolio(); const currency = unitOfAccount; @@ -109,7 +107,7 @@ export const useGetPortfolioTokenChart = ( const tickers = response.value.data.tickers; // @ts-ignore - const validCurrency = currency === ptTicker ? supportedCurrencies.USD : currency ?? supportedCurrencies.USD; + const validCurrency = currency === primaryTokenInfo.name ? supportedCurrencies.USD : currency ?? supportedCurrencies.USD; const initialPrice = tickers[0]?.prices[validCurrency]; const records = tickers diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/LiquidityTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/LiquidityTable.tsx index fccc29121d..e9b49d49ea 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/LiquidityTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/LiquidityTable.tsx @@ -1,18 +1,17 @@ -import React from 'react'; -import { useMemo, useState } from 'react'; -import { TableCell, TableRow, Typography, Stack, Box } from '@mui/material'; +import { Box, Stack, TableCell, TableRow, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; -import { usePortfolio } from '../../module/PortfolioContextProvider'; +import React, { useMemo, useState } from 'react'; import adaPng from '../../../../../assets/images/ada.png'; +import { Skeleton } from '../../../../components'; import hoskyPng from '../../common/assets/images/hosky-token.png'; import minswapPng from '../../common/assets/images/minswap-dex.png'; -import { Skeleton } from '../../../../components'; +import Table from '../../common/components/Table'; +import { formatNumber } from '../../common/helpers/formatHelper'; import { useStrings } from '../../common/hooks/useStrings'; import useTableSort, { ISortState } from '../../common/hooks/useTableSort'; -import Table from '../../common/components/Table'; -import { IHeadCell } from '../../common/types/table'; import { LiquidityItemType } from '../../common/types/index'; -import { formatNumber } from '../../common/helpers/formatHelper'; +import { IHeadCell } from '../../common/types/table'; +import { usePortfolio } from '../../module/PortfolioContextProvider'; const TableRowSkeleton = ({ theme, ...props }) => ( { const theme: any = useTheme(); const strings = useStrings(); - const { unitOfAccount } = usePortfolio(); + const { unitOfAccount, primaryTokenInfo } = usePortfolio(); const [{ order, orderBy }, setSortState] = useState({ order: null, orderBy: null, @@ -183,7 +182,7 @@ const LiquidityTable = ({ data, isLoading }: Props): JSX.Element => { {formatNumber(row.firstTokenValue)} {row.firstToken.name} - {row.firstToken.name === 'ADA' && unitOfAccount === 'ADA' ? null : ( + {row.firstToken.name === primaryTokenInfo.name && unitOfAccount === primaryTokenInfo.name ? null : ( {formatNumber(row.firstTokenValueUsd)} {unitOfAccount} @@ -196,7 +195,7 @@ const LiquidityTable = ({ data, isLoading }: Props): JSX.Element => { {formatNumber(row.secondTokenValue)} {row.secondToken.name} - {row.secondToken.name === 'ADA' && unitOfAccount === 'ADA' ? null : ( + {row.secondToken.name === primaryTokenInfo.name && unitOfAccount === primaryTokenInfo.name ? null : ( {formatNumber(row.secondTokenValueUsd)} {unitOfAccount} @@ -213,7 +212,7 @@ const LiquidityTable = ({ data, isLoading }: Props): JSX.Element => { {formatNumber(row.totalValue)} {row.firstToken.name} - {unitOfAccount === 'ADA' && row.firstToken.name === 'ADA' ? null : ( + {unitOfAccount === primaryTokenInfo.name && row.firstToken.name === primaryTokenInfo.name ? null : ( {formatNumber(row.totalValueUsd)} {unitOfAccount} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/OrderTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/OrderTable.tsx index aab0ad4c2b..c39f015884 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/OrderTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Dapps/OrderTable.tsx @@ -1,18 +1,18 @@ -import React, { useMemo, useState } from 'react'; -import { TableCell, TableRow, Typography, Stack, Box } from '@mui/material'; +import { Box, Stack, TableCell, TableRow, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; -import { useStrings } from '../../common/hooks/useStrings'; +import React, { useMemo, useState } from 'react'; import adaPng from '../../../../../assets/images/ada.png'; +import { truncateAddressShort } from '../../../../../utils/formatters'; +import { Skeleton } from '../../../../components'; import hoskyPng from '../../common/assets/images/hosky-token.png'; import minswapPng from '../../common/assets/images/minswap-dex.png'; -import { Skeleton } from '../../../../components'; -import { truncateAddressShort } from '../../../../../utils/formatters'; -import { usePortfolio } from '../../module/PortfolioContextProvider'; -import useTableSort, { ISortState } from '../../common/hooks/useTableSort'; import Table from '../../common/components/Table'; -import { IHeadCell } from '../../common/types/table'; -import { OrderItemType } from '../../common/types/index'; import { formatNumber } from '../../common/helpers/formatHelper'; +import { useStrings } from '../../common/hooks/useStrings'; +import useTableSort, { ISortState } from '../../common/hooks/useTableSort'; +import { OrderItemType } from '../../common/types/index'; +import { IHeadCell } from '../../common/types/table'; +import { usePortfolio } from '../../module/PortfolioContextProvider'; const TableRowSkeleton = ({ theme, ...props }) => ( { const theme = useTheme(); const strings = useStrings(); - const { unitOfAccount } = usePortfolio(); + const { unitOfAccount, primaryTokenInfo } = usePortfolio(); const [{ order, orderBy }, setSortState] = useState({ order: null, orderBy: null, @@ -197,7 +197,7 @@ const OrderTable = ({ data, isLoading }: Props): JSX.Element => { {formatNumber(row.totalValue)} {row.firstToken.name} - {row.firstToken.name === 'ADA' && unitOfAccount === 'ADA' ? null : ( + {row.firstToken.name === primaryTokenInfo.name && unitOfAccount === primaryTokenInfo.name ? null : ( {formatNumber(row.totalValueUsd)} {unitOfAccount} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/AssetTransactionDetails/TransactionTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/AssetTransactionDetails/TransactionTable.tsx index b4e97d4758..295f833169 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/AssetTransactionDetails/TransactionTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/AssetTransactionDetails/TransactionTable.tsx @@ -122,6 +122,7 @@ const TransactionTable = ({ history, tokenName }: { history: TransactionItemType const TransactionHistoryItem = ({ index, row, theme, strings, unitOfAccount, headCells, tokenName }) => { const [isExpanded, setIsExpanded] = useState(false); + const { primaryTokenInfo } = usePortfolio(); return ( @@ -177,7 +178,7 @@ const TransactionHistoryItem = ({ index, row, theme, strings, unitOfAccount, hea {row.feeValue ? `${row.feeValue.toFixed(2)} ADA` : '-'} {isExpanded && - (unitOfAccount === 'ADA' ? null : ( + (unitOfAccount === primaryTokenInfo.name ? null : ( {row.feeValueUsd ? `${row.feeValueUsd.toFixed(2)} ${unitOfAccount}` : '-'} @@ -204,7 +205,7 @@ const TransactionHistoryItem = ({ index, row, theme, strings, unitOfAccount, hea {isExpanded ? ( - {unitOfAccount === 'ADA' ? null : ( + {unitOfAccount === primaryTokenInfo.name ? null : ( {(row.type === HistoryItemType.RECEIVED || row.type === HistoryItemType.WITHDRAW || diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx index a0dc6b0ef2..43c9278fd3 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx @@ -18,7 +18,7 @@ interface Props { const HeaderSection = ({ tokenInfo }: Props): JSX.Element => { const theme: any = useTheme(); const strings = useStrings(); - const { unitOfAccount, walletBalance, accountPair } = usePortfolio(); + const { unitOfAccount, walletBalance, accountPair, primaryTokenInfo } = usePortfolio(); const isPrimaryToken: boolean = tokenInfo.id === '-'; const tokenTotalAmount = isPrimaryToken ? walletBalance?.ada : tokenInfo.formatedAmount; if (tokenInfo.quantity === null) { @@ -72,8 +72,12 @@ const HeaderSection = ({ tokenInfo }: Props): JSX.Element => { - {isPrimaryToken ? (accountPair?.from.name === 'ADA' ? accountPair?.to.value : accountPair?.from.value) : totaPriceCalc}{' '} - {isPrimaryToken && unitOfAccount === 'ADA' ? DEFAULT_FIAT_PAIR : unitOfAccount} + {isPrimaryToken + ? accountPair?.from.name === primaryTokenInfo.name + ? accountPair?.to.value + : accountPair?.from.value + : totaPriceCalc}{' '} + {isPrimaryToken && unitOfAccount === primaryTokenInfo.name ? DEFAULT_FIAT_PAIR : unitOfAccount} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index dacd85ed5f..cf47cb15d9 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -121,7 +121,7 @@ export const TokenPriceTotal = ({ token, secondaryToken24Activity }) => { const tokenPrice = secondaryToken24Activity && secondaryToken24Activity[1].price?.close; const tokenQuantityAsBigInt = bigNumberToBigInt(token.quantity); - const showingAda = accountPair?.from.name === 'ADA'; + const showingAda = accountPair?.from.name === primaryTokenInfo.name; const currency = accountPair?.from.name; const decimals = isPrimary ? primaryTokenInfo.decimals : token.info.numberOfDecimals; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx index 6261d5dc0c..b285f502e5 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx @@ -29,7 +29,8 @@ export const useProcessedTokenData = ({ data, ptActivity, data24h }) => { const primaryTokenFiatTotalAmount = formatValue(primaryTokenInfo.quantity.multipliedBy(String(ptActivity?.close))); const totalTokenPrice = isPrimaryToken ? primaryTokenFiatTotalAmount : totalValue; - const unitPrice = accountPair?.from.name === 'ADA' ? tokenPrice : Number(totalTokenPrice) / Number(token.shiftedAmount); + const unitPrice = + accountPair?.from.name === primaryTokenInfo.name ? tokenPrice : Number(totalTokenPrice) / Number(token.shiftedAmount); return { totalValue: totalTokenPrice, unitPrice }; }; From 70de4484dd43ec5bf053938d02c037c557c5203f Mon Sep 17 00:00:00 2001 From: yushi Date: Tue, 5 Nov 2024 14:34:37 +0800 Subject: [PATCH 005/133] git ignore generated .d.ts files --- packages/yoroi-extension/.gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/.gitignore b/packages/yoroi-extension/.gitignore index e5f88b3bce..fad4529c33 100644 --- a/packages/yoroi-extension/.gitignore +++ b/packages/yoroi-extension/.gitignore @@ -45,4 +45,6 @@ Yoroi Shelley Testnet .netlify # SSL overrides for DEV -scripts/sslOverrides.js \ No newline at end of file +scripts/sslOverrides.js + +app/UI/**/*.d.ts From 43b3d81a28b9da052be981642f0fe13276b4c99b Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 7 Nov 2024 15:12:26 +0800 Subject: [PATCH 006/133] pop up analaytics consent after installation on Firefox --- .../app/stores/base/BaseProfileStore.js | 4 ++++ .../app/stores/toplevel/ProfileStore.js | 24 +++++++++++-------- .../chrome/extension/background.js | 6 +++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 437b5f3fea..82c6d302ff 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -573,6 +573,10 @@ export default class BaseProfileStore this.getIsAnalyticsAllowed.patch(_ => isAnalyticsAllowed); this.api.localStorage.saveIsAnalysticsAllowed(isAnalyticsAllowed); ampli.client.setOptOut(!isAnalyticsAllowed); + if (environment.userAgentInfo.isFirefox() && window.document.location.search === '?installed') { + // This is the mandatory data collection consent pop up of Firefox on installation. + window.close(); + } } @computed get isAnalyticsOpted(): boolean { diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index 3b9d2d69eb..acbc2dc69a 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -21,9 +21,22 @@ export default class ProfileStore extends BaseProfileStore this.isAnalyticsOpted, + action: async () => { + const route = ROUTES.PROFILE.OPT_FOR_ANALYTICS; + if (this.stores.app.currentRoute === route) { + return; + } + this.actions.router.goToRoute.trigger({ route }); + }, + }; + /** Linear list of steps that need to be completed before app start */ @observable SETUP_STEPS: Array<{| isDone: void => boolean | Promise, action: void => Promise |}> = [ + // Firefox policy requires this to be the first + ...(environment.userAgentInfo.isFirefox() ? [this._analyticsStep] : []), { isDone: () => this.isCurrentLocaleSet, action: async () => { @@ -46,16 +59,7 @@ export default class ProfileStore extends BaseProfileStore this.isAnalyticsOpted, - action: async () => { - const route = ROUTES.PROFILE.OPT_FOR_ANALYTICS; - if (this.stores.app.currentRoute === route) { - return; - } - this.actions.router.goToRoute.trigger({ route }); - }, - }, + ...(environment.userAgentInfo.isFirefox() ? [] : [this._analyticsStep]), { isDone: () => this.isComplexityLevelSelected, action: async () => { diff --git a/packages/yoroi-extension/chrome/extension/background.js b/packages/yoroi-extension/chrome/extension/background.js index e50148e3e6..deeab412d8 100644 --- a/packages/yoroi-extension/chrome/extension/background.js +++ b/packages/yoroi-extension/chrome/extension/background.js @@ -1816,3 +1816,9 @@ function handleExchangeRedirectMessage(message, sender) { chrome.tabs.create({ url: extensionUrl }); } } + +if (environment.userAgentInfo.isFirefox()) { + browser.runtime.onInstalled.addListener(() => { + chrome.tabs.create({ url: 'main_window.html?installed' }); + }); +} From afaee492d62f2173cbdbb959bbfbf057872dcbba Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 7 Nov 2024 15:34:12 +0800 Subject: [PATCH 007/133] re-show consent for all users --- .../yoroi-extension/app/api/localStorage/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/localStorage/index.js b/packages/yoroi-extension/app/api/localStorage/index.js index 93c12eaf98..38e868b7e5 100644 --- a/packages/yoroi-extension/app/api/localStorage/index.js +++ b/packages/yoroi-extension/app/api/localStorage/index.js @@ -338,8 +338,17 @@ export default class LocalStorageApi { unsetAcceptedTosVersion: void => Promise = () => removeLocalItem(storageKeys.ACCEPTED_TOS_VERSION); + // Firefox demands us to re-show the data collection consent screen, so change the key for Firefox + _getIsAnalyticsAllowedKey: () => string = () => { + let key = storageKeys.IS_ANALYTICS_ALLOWED; + if (environment.userAgentInfo.isFirefox()) { + key += '-firefox'; + } + return key; + } + loadIsAnalyticsAllowed: () => Promise = async () => { - const json = await getLocalItem(storageKeys.IS_ANALYTICS_ALLOWED); + const json = await getLocalItem(this._getIsAnalyticsAllowedKey()); if (!json) { return undefined; } @@ -347,7 +356,7 @@ export default class LocalStorageApi { } saveIsAnalysticsAllowed: (flag: boolean) => Promise = async (flag) => { - await setLocalItem(storageKeys.IS_ANALYTICS_ALLOWED, JSON.stringify(flag)); + await setLocalItem(this._getIsAnalyticsAllowedKey(), JSON.stringify(flag)); } unsetIsAnalyticsAllowed: void => Promise = @@ -495,4 +504,4 @@ export function createFlagStorage(): StorageAPI { get: async s => (await getLocalItem(s)) ?? null, set: setLocalItem, }; -} \ No newline at end of file +} From 56c7c8a78e24f6dffe378f2ba3fe233491c891d8 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 7 Nov 2024 18:40:27 +0800 Subject: [PATCH 008/133] auto launch and continue, instead of just launch the consent dialog --- packages/yoroi-extension/app/stores/base/BaseProfileStore.js | 4 ---- packages/yoroi-extension/chrome/extension/background.js | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 82c6d302ff..437b5f3fea 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -573,10 +573,6 @@ export default class BaseProfileStore this.getIsAnalyticsAllowed.patch(_ => isAnalyticsAllowed); this.api.localStorage.saveIsAnalysticsAllowed(isAnalyticsAllowed); ampli.client.setOptOut(!isAnalyticsAllowed); - if (environment.userAgentInfo.isFirefox() && window.document.location.search === '?installed') { - // This is the mandatory data collection consent pop up of Firefox on installation. - window.close(); - } } @computed get isAnalyticsOpted(): boolean { diff --git a/packages/yoroi-extension/chrome/extension/background.js b/packages/yoroi-extension/chrome/extension/background.js index deeab412d8..e896594c9a 100644 --- a/packages/yoroi-extension/chrome/extension/background.js +++ b/packages/yoroi-extension/chrome/extension/background.js @@ -1818,7 +1818,5 @@ function handleExchangeRedirectMessage(message, sender) { } if (environment.userAgentInfo.isFirefox()) { - browser.runtime.onInstalled.addListener(() => { - chrome.tabs.create({ url: 'main_window.html?installed' }); - }); + browser.runtime.onInstalled.addListener(onYoroiIconClicked); } From 8effff33efc01b8d54f62562e8862a0bfc254829 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 7 Nov 2024 19:30:02 +0800 Subject: [PATCH 009/133] fix message passing in Firefox --- packages/yoroi-extension/app/api/thunk.js | 11 ++++++++++- .../extension/background/subscriptionManager.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 8bdd30e91f..d6b35cd7fa 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -408,8 +408,17 @@ const callbacks = Object.freeze({ serverStatusUpdate: [], coinPriceUpdate: [], }); -chrome.runtime.onMessage.addListener(async (message, _sender, _sendResponse) => { +chrome.runtime.onMessage.addListener(async (serializedMessage, _sender, _sendResponse) => { //fixme: verify sender.id/origin + let message; + try { + message = JSON.parse(serializedMessage); + } catch { + return; + } + if (typeof message !== 'object') { + return; + } Logger.debug('get message from background:', JSON.stringify(sanitizeForLog(message))); if (message.type === 'wallet-state-update') { diff --git a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js index a04d09943b..6f87855b40 100644 --- a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js +++ b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js @@ -68,6 +68,6 @@ declare var chrome; */ export function emitUpdateToSubscriptions(data: Object): void { for (const { tabId } of getSubscriptions()) { - chrome.tabs.sendMessage(tabId, data); + chrome.tabs.sendMessage(tabId, JSON.stringify(data)); } } From 8f1329cc046b3c4a50552f421ba2e72daf5accd6 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 21 Oct 2024 00:22:45 +0300 Subject: [PATCH 010/133] messaging serialization fix --- packages/yoroi-extension/app/api/thunk.js | 9 ++++++--- .../chrome/extension/background/handlers/yoroi/index.js | 1 + .../chrome/extension/background/handlers/yoroi/wallet.js | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index d6b35cd7fa..5a5efe1718 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -110,6 +110,8 @@ declare var chrome; export function callBackground(message: T): Promise { return new Promise((resolve, reject) => { window.chrome.runtime.sendMessage(message, response => { + // $FlowIgnore + console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); if (window.chrome.runtime.lastError) { // eslint-disable-next-line prefer-promise-reject-errors reject(`Error ${window.chrome.runtime.lastError} when calling the background with: ${JSON.stringify(sanitizeForLog(message)) ?? 'undefined'}`); @@ -306,11 +308,12 @@ function deserializeTx(tx: any): ?WalletTransaction { } export const refreshTransactions: GetEntryFuncType = async (request) => { - const txs = await callBackground({ type: 'refresh-transactions', request }); - if (txs.error) { - console.error('Failed to refresh transactions!', txs.error); + const resp = await callBackground({ type: RefreshTransactions.typeTag, request }); + if (resp.error) { + console.error('Failed to refresh transactions!', resp.error); return []; } + const txs = JSON.parse(resp); return txs.map(tx => { try { return deserializeTx(tx); diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js index f935d3711a..b312ad4db3 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js @@ -107,6 +107,7 @@ export function getHandler(typeTag: string): ?Handler { return async (request, send, sendResponse) => { try { const result = await handler(request.request); + console.debug(`BACKGROUND [${typeTag}] sending result: `, JSON.stringify(result)); sendResponse(result); } catch (error) { sendResponse({ error: error.message }); diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js index 3bdce74838..9090ecc164 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js @@ -354,6 +354,7 @@ export const RefreshTransactions: HandlerType< // initial transaction list loading txs = await adaApi.refreshTransactions(refreshTxRequest); } - return txs; + // $FlowIgnore + return JSON.stringify(txs); }, }); From a8db8087cbbc7ed3e3d3a1c6cd67442d0c0a5ab9 Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 23 Oct 2024 21:11:46 +0800 Subject: [PATCH 011/133] fix serialization --- packages/yoroi-extension/app/api/thunk.js | 10 +++++++--- .../background/handlers/yoroi/protocolParameters.js | 2 +- .../extension/background/handlers/yoroi/wallet.js | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 5a5efe1718..6fae34f1e8 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -292,7 +292,8 @@ export async function removeAllTransactions( } } -export const popAddress: GetEntryFuncType = async ({ publicDeriverId }) => { +type PopAddressType = ({ publicDeriverId: number, ...}) => ReturnType>; +export const popAddress: PopAddressType = async ({ publicDeriverId }) => { await callBackground({ type: PopAddress.typeTag, request: { publicDeriverId } }); } @@ -401,8 +402,11 @@ export const getConnectedSites: GetEntryFuncType = asy return await callBackground({ type: GetConnectedSites.typeTag }); } -export const getProtocolParameters: GetEntryFuncType = async (request) => { - return await callBackground({ type: GetProtocolParameters.typeTag, request }); +type GetProtocolParametersType = ({ networkId: number, ... }) => ReturnType>; +export const getProtocolParameters: GetProtocolParametersType = async ( + { networkId } +) => { + return await callBackground({ type: GetProtocolParameters.typeTag, request: { networkId } }); } // Background -> UI notifications: diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js index 93e4cdb8c0..109f64594b 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js @@ -206,7 +206,7 @@ class ProcolParameterApi { } export const GetProtocolParameters: HandlerType< - { networkId: number, ... }, + {| networkId: number |}, ProtocolParameters > = Object.freeze({ typeTag: 'get-protocol-parameters', diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js index 9090ecc164..bd9b23d1e8 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js @@ -250,7 +250,7 @@ export const GetPrivateStakingKey: HandlerType< }); export const RemoveAllTransactions: HandlerType< - { publicDeriverId: number, ... }, + {| publicDeriverId: number |}, void > = Object.freeze({ typeTag: 'remove-all-transactions', @@ -275,7 +275,7 @@ export const RemoveAllTransactions: HandlerType< }); export const PopAddress: HandlerType< - { publicDeriverId: number, ... }, + {| publicDeriverId: number |}, void > = Object.freeze({ typeTag: 'pop-address', From 2559f7563bd01f161db9369fb37bd90cce66df1d Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 23 Oct 2024 21:26:21 +0800 Subject: [PATCH 012/133] serialize request data from frontend to the background --- packages/yoroi-extension/app/api/thunk.js | 5 +++-- .../yoroi-extension/chrome/extension/background/index.js | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 6fae34f1e8..baad0098f9 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -107,9 +107,10 @@ declare var chrome; // UI -> background queries: -export function callBackground(message: T): Promise { +export function callBackground(message: {| type: string, request?: Object |}): Promise { return new Promise((resolve, reject) => { - window.chrome.runtime.sendMessage(message, response => { + const serializedMessage = { type: message.type, request: JSON.stringify(message.request || null) }; + window.chrome.runtime.sendMessage(serializedMessage, response => { // $FlowIgnore console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); if (window.chrome.runtime.lastError) { diff --git a/packages/yoroi-extension/chrome/extension/background/index.js b/packages/yoroi-extension/chrome/extension/background/index.js index 9df389ca06..ab35d1d8d7 100644 --- a/packages/yoroi-extension/chrome/extension/background/index.js +++ b/packages/yoroi-extension/chrome/extension/background/index.js @@ -36,7 +36,11 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { } const handler = getHandler(message.type); if (handler) { - handler(message, sender, sendResponse); + const deserializedMessage = { + type: message.type, + request: JSON.parse(message.request), + }; + handler(deserializedMessage, sender, sendResponse); // Returning `true` is required by Firefox, see: // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage return true; From 961c7360f5258d089d713f3b5119939be4147405 Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 23 Oct 2024 21:31:56 +0800 Subject: [PATCH 013/133] add error log --- packages/yoroi-extension/app/api/thunk.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index baad0098f9..0579b29bc4 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -422,9 +422,11 @@ chrome.runtime.onMessage.addListener(async (serializedMessage, _sender, _sendRes try { message = JSON.parse(serializedMessage); } catch { + Logger.error('underializable message'); return; } if (typeof message !== 'object') { + Logger.error('unrecognizable message'); return; } Logger.debug('get message from background:', JSON.stringify(sanitizeForLog(message))); From 9070b9a36d510a41df830a03a65fa4ccf2f58b48 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 25 Oct 2024 18:20:54 +0800 Subject: [PATCH 014/133] fix FF connector pop out window could not get response for API call to the background when the main extension window is open --- packages/yoroi-extension/app/api/thunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 0579b29bc4..09414672d5 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -416,7 +416,7 @@ const callbacks = Object.freeze({ serverStatusUpdate: [], coinPriceUpdate: [], }); -chrome.runtime.onMessage.addListener(async (serializedMessage, _sender, _sendResponse) => { +chrome.runtime.onMessage.addListener((serializedMessage, _sender, _sendResponse) => { //fixme: verify sender.id/origin let message; try { From 60c103171baaaffb1c8b529f846512247a6c2504 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 25 Oct 2024 21:06:21 +0800 Subject: [PATCH 015/133] parvum melius --- packages/yoroi-extension/app/api/thunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 09414672d5..f535bcc100 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -109,7 +109,7 @@ declare var chrome; export function callBackground(message: {| type: string, request?: Object |}): Promise { return new Promise((resolve, reject) => { - const serializedMessage = { type: message.type, request: JSON.stringify(message.request || null) }; + const serializedMessage = { type: message.type, request: JSON.stringify(message.request ?? null) }; window.chrome.runtime.sendMessage(serializedMessage, response => { // $FlowIgnore console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); From 510834518b2a7291cae819b42721761635337e88 Mon Sep 17 00:00:00 2001 From: yushi Date: Tue, 29 Oct 2024 16:46:17 +0800 Subject: [PATCH 016/133] lint --- packages/yoroi-extension/app/api/thunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index f535bcc100..b88b7ce072 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -107,7 +107,7 @@ declare var chrome; // UI -> background queries: -export function callBackground(message: {| type: string, request?: Object |}): Promise { +export function callBackground(message: {| type: string, request?: Object |}): Promise { return new Promise((resolve, reject) => { const serializedMessage = { type: message.type, request: JSON.stringify(message.request ?? null) }; window.chrome.runtime.sendMessage(serializedMessage, response => { From a8d65217e91a422d78e8bafd6e6c24eeba5e025c Mon Sep 17 00:00:00 2001 From: yushi Date: Tue, 5 Nov 2024 16:16:42 +0800 Subject: [PATCH 017/133] log error when UI gets unserializable message --- packages/yoroi-extension/app/api/thunk.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index b88b7ce072..c29a7a9932 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -421,12 +421,12 @@ chrome.runtime.onMessage.addListener((serializedMessage, _sender, _sendResponse) let message; try { message = JSON.parse(serializedMessage); - } catch { - Logger.error('underializable message'); + } catch (error) { + Logger.error('unserializable message: ' + serializedMessage + ' | Error: ' + stringifyError(error)); return; } if (typeof message !== 'object') { - Logger.error('unrecognizable message'); + Logger.error('unrecognizable message type: ' + (typeof message) + ' (expected object); Original message: ' + serializedMessage); return; } Logger.debug('get message from background:', JSON.stringify(sanitizeForLog(message))); From 26c367d9bebfe22fea9f9b90fe07e081f5269249 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 7 Nov 2024 13:37:46 +0200 Subject: [PATCH 018/133] update table sort and styles --- .../common/components/SortableTableHead.tsx | 4 +- .../portfolio/common/hooks/useTableSort.ts | 27 +++--- .../useCases/TokensTable/StatsTable.tsx | 23 +++--- .../useCases/TokensTable/TableColumnsChip.tsx | 25 ++---- .../useCases/TokensTable/useProcentage.tsx | 82 +++++++++++-------- .../useCases/Wallet/PortfolioWallet.tsx | 4 +- 6 files changed, 79 insertions(+), 86 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/components/SortableTableHead.tsx b/packages/yoroi-extension/app/UI/features/portfolio/common/components/SortableTableHead.tsx index ea3cce86b7..ca1bf08cdf 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/components/SortableTableHead.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/components/SortableTableHead.tsx @@ -1,7 +1,7 @@ +import { Stack, TableCell, TableHead, TableRow, Typography } from '@mui/material'; +import { useTheme } from '@mui/material/styles'; import React from 'react'; -import { TableHead, TableRow, TableCell, Stack, Typography } from '@mui/material'; import { Sort as SortIcon } from '../../../../components/icons/Sort'; -import { useTheme } from '@mui/material/styles'; import { IHeadCell } from '../types/table'; interface Props { diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts index 309019b4e7..8ee3101fbd 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts @@ -1,4 +1,4 @@ -import { useCallback } from 'react'; +import React from 'react'; import { IHeadCell, TableSortType } from '../types/table'; export interface ISortState { @@ -13,7 +13,6 @@ interface Props { headCells: IHeadCell[]; data: any[]; } - const useTableSort = ({ order, orderBy, setSortState, headCells, data }: Props) => { const handleRequestSort = (property: string) => { let direction: string | null = 'asc'; @@ -21,7 +20,7 @@ const useTableSort = ({ order, orderBy, setSortState, headCells, data }: Props) if (order === 'asc') { direction = 'desc'; } else if (order === 'desc') { - direction = null; + direction = 'asc'; } } setSortState({ @@ -34,32 +33,26 @@ const useTableSort = ({ order, orderBy, setSortState, headCells, data }: Props) if (!orderBy || !order) return 0; switch (sortType) { case 'numeric': - if (parseFloat(b[orderBy]) < parseFloat(a[orderBy])) { - return -1; - } else { - return 1; - } + const aValue = Number(a[orderBy]); + const bValue = Number(b[orderBy]); + return bValue === aValue ? 0 : bValue < aValue ? -1 : 1; case 'character': - return String(a[orderBy]).localeCompare(b[orderBy]); + return String(a.info[orderBy]).localeCompare(b.info[orderBy]); default: - if (b[orderBy] < a[orderBy]) { - return -1; - } else { - return 1; - } + return b[orderBy] === a[orderBy] ? 0 : b[orderBy] < a[orderBy] ? -1 : 1; } }; - const getSortedData = useCallback( + const getSortedData = React.useCallback( (arr: any[]) => { if (!orderBy || !order) return data; const sortColumn = headCells.find(cell => cell.id === orderBy); const sortType = sortColumn?.sortType ?? 'character'; - return arr.sort((a, b) => { + return [...arr].sort((a, b) => { return order === 'desc' ? descendingComparator(a, b, sortType) : -descendingComparator(a, b, sortType); }); }, - [order, orderBy, headCells] + [order, orderBy, headCells, data] ); return { getSortedData, handleRequestSort }; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx index 73462ba739..f14e7494db 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx @@ -58,21 +58,24 @@ const StatsTable = ({ data }: Props): JSX.Element => { }, ]; - const assetFormatedList = useProcessedTokenData({ data: list, ptActivity, data24h }); + const assetFormatedList = useProcessedTokenData({ data: list, ptActivity, data24h, data7d, data30d }); + // console.log('assetFormatedList', assetFormatedList); const { getSortedData, handleRequestSort } = useTableSort({ order, orderBy, setSortState, headCells, data: assetFormatedList }); + + const sortedData = useMemo(() => getSortedData(assetFormatedList), [getSortedData, assetFormatedList]); return ( } > - {getSortedData(assetFormatedList).map((row: any) => ( + {sortedData.map((row: any) => ( navigateTo.portfolioDetail(row.id)} @@ -86,15 +89,15 @@ const StatsTable = ({ data }: Props): JSX.Element => { }, }} > - + - + - + { /> - + { /> - + { /> - + - + diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index cf47cb15d9..f1b0e04377 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -134,32 +134,20 @@ export const TokenPriceTotal = ({ token, secondaryToken24Activity }) => { .times(showingAda ? 1 : new BigNumber(ptPrice)) .toFormat(decimals); - // if (token.info.name === 'SHIBA') { - // console.log('Token CALC DETAILS', { - // ptPrice, - // tokenQuantityAsBigInt, - // tokenPrice, - // name: token.info.name, - // decimals, - // confff: config.decimals, - // showingAda, - // }); - - // console.log('totaPrice', totaPrice); - // } const totalTicker = isPrimary && showingAda ? accountPair?.to.name : accountPair?.from.name; const totalTokenPrice = isPrimary && showingAda ? '' : `${totaPrice} ${totalTicker || DEFAULT_FIAT_PAIR}`; return ( - - {isPrimary ? walletBalance?.ada : token.formatedAmount} {token.info.name} + + {isPrimary ? walletBalance?.ada : token.formatedAmount} + {token.info.name} {token.name === accountPair?.to.name ? ( - + ) : ( - + {totalTokenPrice} )} @@ -174,10 +162,11 @@ export const TokenPrice = ({ secondaryToken24Activity, ptActivity, token }) => { const tokenPrice = secondaryToken24Activity && secondaryToken24Activity[1].price?.close; const ptPrice = ptActivity?.close; const ptUnitPrice = tokenPrice * ptPrice; + const priceDisplay = parseFloat(isPrimaryToken ? ptPrice : ptUnitPrice).toFixed(4); return ( - {parseFloat(isPrimaryToken ? ptPrice : ptUnitPrice).toFixed(4)} {unitOfAccount} + {priceDisplay} {unitOfAccount} ); }; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx index b285f502e5..37fb040cdf 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/useProcentage.tsx @@ -2,71 +2,81 @@ import { atomicBreakdown } from '@yoroi/common'; import BigNumber from 'bignumber.js'; import { useMemo } from 'react'; import { formatValue } from '../../common/components/PortfolioHeader'; +import { priceChange } from '../../common/helpers/priceChange'; import { usePortfolio } from '../../module/PortfolioContextProvider'; import { bigNumberToBigInt } from './TableColumnsChip'; -export const useProcessedTokenData = ({ data, ptActivity, data24h }) => { - const { accountPair, primaryTokenInfo } = usePortfolio(); +export const useProcessedTokenData = ({ data, ptActivity, data24h, data7d, data30d }) => { + const { primaryTokenInfo } = usePortfolio(); - // Helper function to calculate total fiat value for each token + // Helper to calculate fiat value and unit price for a token const calculateTotalFiatForToken = token => { const isPrimaryToken = token.id === '-'; - const secondaryToken24Activity = data24h && data24h[token.info.id]; + const secondaryToken24Activity = data24h?.[token.info.id]; const tokenPrice = - isPrimaryToken && secondaryToken24Activity === undefined - ? ptActivity?.close - : secondaryToken24Activity && secondaryToken24Activity[1].price?.close; - const tokenPriceFiat = tokenPrice ? new BigNumber(tokenPrice) : 1; - const tokenQuantityAsBigInt = bigNumberToBigInt(token.quantity); - const decimals = isPrimaryToken ? primaryTokenInfo.decimals : token.info.numberOfDecimals; + isPrimaryToken && !secondaryToken24Activity ? ptActivity?.close : secondaryToken24Activity?.[1].price?.close || 1; - const totalValue = atomicBreakdown(tokenQuantityAsBigInt, decimals) - .bn.times(tokenPriceFiat) - .times(new BigNumber(ptActivity?.close)) + const tokenQuantity = atomicBreakdown( + bigNumberToBigInt(token.quantity), + isPrimaryToken ? primaryTokenInfo.decimals : token.info.numberOfDecimals + ); + const totalValue = tokenQuantity.bn + .times(new BigNumber(tokenPrice)) + .times(new BigNumber(ptActivity?.close || 1)) .toNumber(); + const unitPrice = parseFloat((tokenPrice * ptActivity?.close || 1).toFixed(4)); const primaryTokenFiatTotalAmount = formatValue(primaryTokenInfo.quantity.multipliedBy(String(ptActivity?.close))); - const totalTokenPrice = isPrimaryToken ? primaryTokenFiatTotalAmount : totalValue; - const unitPrice = - accountPair?.from.name === primaryTokenInfo.name ? tokenPrice : Number(totalTokenPrice) / Number(token.shiftedAmount); + return { totalValue: isPrimaryToken ? primaryTokenFiatTotalAmount : totalValue, unitPrice }; + }; - return { totalValue: totalTokenPrice, unitPrice }; + const getTokenActivityChange = (tokenId, activityData, isPrimaryToken) => { + const activity = activityData?.[tokenId]; + return isPrimaryToken + ? { open: ptActivity?.open, close: ptActivity?.close } + : { open: activity?.[1].price?.open, close: activity?.[1].price?.close }; }; - // Use useMemo to calculate fiat values, percentages, and sort by percentage + // Memoized data processing const processedData = useMemo(() => { - // Calculate total fiat values for all tokens const tokenFiatValues = data.reduce((acc, token) => { - const totalFiat = calculateTotalFiatForToken(token); - - acc[token.info.id] = totalFiat; + acc[token.info.id] = calculateTotalFiatForToken(token); return acc; }, {}); - // Calculate total portfolio value - const totalPortfolioValue: any = Object.values(tokenFiatValues).reduce((sum, value: any) => { - return Number(sum) + Number(value?.totalValue); - }, 0); + const totalPortfolioValue = Object.values(tokenFiatValues).reduce( + (sum: number, { totalValue }: any) => sum + Number(totalValue), + 0 + ); - // Calculate percentages for each token and then sort by percentage - const sortedData = data + return data .map(token => { - const { totalValue, unitPrice } = tokenFiatValues[token.info.id] || 0; - const percentage = totalPortfolioValue > 0 ? (totalValue / totalPortfolioValue) * 100 : 0; + const { totalValue, unitPrice } = tokenFiatValues[token.info.id] || {}; + const percentage = totalPortfolioValue ? (totalValue / Number(totalPortfolioValue)) * 100 : 0; + const isPrimaryToken = token.id === '-'; + + const { open: open24, close: close24 } = getTokenActivityChange(token.info.id, data24h, isPrimaryToken); + const { open: open7d, close: close7d } = getTokenActivityChange(token.info.id, data7d, isPrimaryToken); + const { open: open30d, close: close30d } = getTokenActivityChange(token.info.id, data30d, isPrimaryToken); + + const changePercent24 = priceChange(open24, close24).changePercent; + const changePercent7d = priceChange(open7d, close7d).changePercent; + const changePercent30d = priceChange(open30d, close30d).changePercent; return { ...token, - totalValue, percentage, - unitPrice, + totalAmount: totalValue, + price: unitPrice, + '24h': changePercent24, + '1W': Number(changePercent7d), + '1M': changePercent30d, }; }) - .sort((a, b) => b.percentage - a.percentage); // Sort by percentage in ascending order - - return sortedData; - }, [data, ptActivity, data24h, accountPair, primaryTokenInfo]); + .sort((a, b) => b.percentage - a.percentage); + }, [data, ptActivity, data24h, data7d, data30d, primaryTokenInfo]); return processedData; }; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx index 6b2f21de7a..020759b343 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx @@ -26,9 +26,7 @@ const PortfolioWallet = (): JSX.Element => { const temp = ftAssetList.filter(item => { return ( - item.info.name.toLowerCase().includes(lowercaseKeyword) || - item.info.id.toLowerCase().includes(lowercaseKeyword) || - item.info.policyId.toLowerCase().includes(lowercaseKeyword) + item.info.name.toLowerCase().includes(lowercaseKeyword) || item.info.policyId.toLowerCase().includes(lowercaseKeyword) ); }); if (temp && temp.length > 0) { From accf66b1ca98caf14395a2b85387dbafc006b5a3 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 17:02:06 +0300 Subject: [PATCH 019/133] check for analytics flag when firefox reload --- packages/yoroi-extension/chrome/extension/background.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/chrome/extension/background.js b/packages/yoroi-extension/chrome/extension/background.js index e896594c9a..399ba3c367 100644 --- a/packages/yoroi-extension/chrome/extension/background.js +++ b/packages/yoroi-extension/chrome/extension/background.js @@ -1818,5 +1818,10 @@ function handleExchangeRedirectMessage(message, sender) { } if (environment.userAgentInfo.isFirefox()) { - browser.runtime.onInstalled.addListener(onYoroiIconClicked); + browser.runtime.onInstalled.addListener(async () => { + const analyticsFlag = await new LocalStorageApi().loadIsAnalyticsAllowed(); + if (analyticsFlag == null) { + onYoroiIconClicked(); + } + }); } From d09b5f03de75f162e24a2d0d71c82b0e42892296 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 19:56:40 +0300 Subject: [PATCH 020/133] firefox external privacy policy link --- .../profile/language-selection/LanguageSelectionForm.js | 9 ++++++++- .../app/containers/profile/LanguageSelectionPage.js | 1 + packages/yoroi-extension/app/environment.js | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js b/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js index 6692a51a2d..83a0546d5e 100644 --- a/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js +++ b/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js @@ -29,6 +29,7 @@ type Props = {| +error?: ?LocalizableError, +localizedTermsOfUse: string, +localizedPrivacyNotice: string, + +externalPrivacyPolicyURL: ?string, |}; type State = {| @@ -82,7 +83,13 @@ class LanguageSelectionForm extends Component ); diff --git a/packages/yoroi-extension/app/environment.js b/packages/yoroi-extension/app/environment.js index ce035f74ed..c78d4f6eaa 100644 --- a/packages/yoroi-extension/app/environment.js +++ b/packages/yoroi-extension/app/environment.js @@ -16,6 +16,8 @@ function getVersion(): string { return content.version; } +const FIREFOX_PRIVACY_POLICY_URL = 'https://addons.mozilla.org/en-US/firefox/addon/yoroi/privacy'; + export const environment = (( { ...process.env, @@ -41,6 +43,12 @@ export const environment = (( getWalletRefreshInterval: () => CONFIG.app.walletRefreshInterval, getServerStatusRefreshInterval: () => CONFIG.app.serverStatusRefreshInterval, userAgentInfo, + externalPrivacyPolicyURL: (): ?string => { + if (userAgentInfo.isFirefox()) { + return FIREFOX_PRIVACY_POLICY_URL; + } + return null; + } } ): { getNetworkName: void => Network, From 15773aa3b7dbb268280dcd4e840c3fd07790cf1f Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 20:23:25 +0300 Subject: [PATCH 021/133] added analytics no rejection impact --- .../components/profile/terms-of-use/OptForAnalyticsForm.js | 5 +++++ packages/yoroi-extension/app/i18n/locales/en-US.json | 1 + 2 files changed, 6 insertions(+) diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js index da66df3060..ebfd63720e 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js @@ -48,6 +48,10 @@ const messages = defineMessages({ id: 'profile.analytics.learnMore', defaultMessage: '!!!Learn more about user insights', }, + rejectionImpact: { + id: 'profile.analytics.rejectionImpact', + defaultMessage: '!!!Opting out won’t impact your experience', + }, accept: { id: 'profile.analytics.accept', defaultMessage: '!!!Accept', @@ -91,6 +95,7 @@ export default class OptForAnalyticsForm extends Component { const analyticsDetails = [ [YesIcon, messages.line1], [YesIcon, messages.line2], + [YesIcon, messages.rejectionImpact], [NoIcon, messages.line3], [NoIcon, messages.line4], [NoIcon, messages.line5], diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index dbd9f29c7d..d0e499bf95 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -222,6 +222,7 @@ "profile.analytics.accept": "Accept", "profile.analytics.allow": "Allow Yoroi analytics", "profile.analytics.learnMore": "Learn more about user insights", + "profile.analytics.rejectionImpact": "Opting out won’t impact your experience", "profile.analytics.line1": "Anonymous analytics data", "profile.analytics.line2": "You can always opt-out via Settings", "profile.analytics.line3": "We can not access private keys", From e2d5d5b596d764a72be74be2c176efc8458be979 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 21:33:59 +0300 Subject: [PATCH 022/133] added analytics listing collected data --- .../terms-of-use/OptForAnalyticsForm.js | 32 +++++++++++++++++-- .../app/i18n/locales/en-US.json | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js index ebfd63720e..35e584142f 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js @@ -13,6 +13,7 @@ import { ReactComponent as YesIcon } from '../../../assets/images/yes.inline.svg import { ReactComponent as NoIcon } from '../../../assets/images/no.inline.svg'; import { Box, Typography } from '@mui/material'; import { RevampSwitch } from '../../widgets/Switch'; +import environment from '../../../environment'; const messages = defineMessages({ title: { @@ -48,6 +49,10 @@ const messages = defineMessages({ id: 'profile.analytics.learnMore', defaultMessage: '!!!Learn more about user insights', }, + collectedData: { + id: 'profile.analytics.collectedData', + defaultMessage: '!!!Collected data includes: visited pages, browser version, selected language, time of analytical events', + }, rejectionImpact: { id: 'profile.analytics.rejectionImpact', defaultMessage: '!!!Opting out won’t impact your experience', @@ -92,16 +97,19 @@ export default class OptForAnalyticsForm extends Component { const isStartupScreen = variant === 'startup'; const isSettingsScreen = variant === 'settings'; + const isFirefox = environment.userAgentInfo.isFirefox(); + const analyticsDetails = [ [YesIcon, messages.line1], [YesIcon, messages.line2], - [YesIcon, messages.rejectionImpact], + (isFirefox ? [YesIcon, messages.rejectionImpact] : null), [NoIcon, messages.line3], [NoIcon, messages.line4], [NoIcon, messages.line5], - ]; + ].filter(Boolean); return ( + <>
{isSettingsScreen && ( @@ -141,6 +149,25 @@ export default class OptForAnalyticsForm extends Component { ))} +
+
+ + {isFirefox ? ( + + {intl.formatMessage(messages.collectedData)} + + ) : null} + + +
{ )}
+ ); } } diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index d0e499bf95..20c1ff5235 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -223,6 +223,7 @@ "profile.analytics.allow": "Allow Yoroi analytics", "profile.analytics.learnMore": "Learn more about user insights", "profile.analytics.rejectionImpact": "Opting out won’t impact your experience", + "profile.analytics.collectedData": "Collected data includes: visited pages, browser version, selected language, time of analytical events", "profile.analytics.line1": "Anonymous analytics data", "profile.analytics.line2": "You can always opt-out via Settings", "profile.analytics.line3": "We can not access private keys", From 07779df7a431bd25438861971d0830ca266c0c72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 03:54:07 +0000 Subject: [PATCH 023/133] Bump chromedriver from 130.0.1 to 130.0.4 in /packages/e2e-tests Bumps [chromedriver](https://github.com/giggio/node-chromedriver) from 130.0.1 to 130.0.4. - [Commits](https://github.com/giggio/node-chromedriver/compare/130.0.1...130.0.4) --- updated-dependencies: - dependency-name: chromedriver dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/e2e-tests/package-lock.json | 8 ++++---- packages/e2e-tests/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/e2e-tests/package-lock.json b/packages/e2e-tests/package-lock.json index 284e8c0295..0b44c711a7 100644 --- a/packages/e2e-tests/package-lock.json +++ b/packages/e2e-tests/package-lock.json @@ -41,7 +41,7 @@ "@emurgo/cardano-serialization-lib-nodejs": "^12.0.0-alpha.26", "bignumber.js": "^9.1.2", "chai": "^4.3.10", - "chromedriver": "130.0.1", + "chromedriver": "130.0.4", "cross-env": "^7.0.3", "json-server": "^0.17.4", "mocha": "^10.2.0", @@ -450,9 +450,9 @@ } }, "node_modules/chromedriver": { - "version": "130.0.1", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-130.0.1.tgz", - "integrity": "sha512-JH+OxDZ7gVv02r9oXwj4mQ8JCtj62g0fCD1LMUUYdB/4mPxn/E2ys+1IzXItoE7vXM9fGVc9R1akvXLqwwuSww==", + "version": "130.0.4", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-130.0.4.tgz", + "integrity": "sha512-lpR+PWXszij1k4Ig3t338Zvll9HtCTiwoLM7n4pCCswALHxzmgwaaIFBh3rt9+5wRk9D07oFblrazrBxwaYYAQ==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 7498dade11..02930995f0 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -47,7 +47,7 @@ "@emurgo/cardano-serialization-lib-nodejs": "^12.0.0-alpha.26", "bignumber.js": "^9.1.2", "chai": "^4.3.10", - "chromedriver": "130.0.1", + "chromedriver": "130.0.4", "cross-env": "^7.0.3", "json-server": "^0.17.4", "mocha": "^10.2.0", From ebfde9df6324d5c27cb5fe7e0d0512e924eba7cf Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 8 Nov 2024 12:35:07 +0200 Subject: [PATCH 024/133] add hover state on table row --- .../useCases/TokensTable/StatsTable.tsx | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx index f14e7494db..f190d64281 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx @@ -1,4 +1,4 @@ -import { TableCell, TableRow } from '@mui/material'; +import { TableCell, TableRow, styled } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import React, { useMemo, useState } from 'react'; import { useCurrencyPairing } from '../../../../context/CurrencyContext'; @@ -16,6 +16,16 @@ import { usePortfolioTokenActivity } from '../../module/PortfolioTokenActivityPr import { TokenDisplay, TokenPrice, TokenPriceChangeChip, TokenPriceTotal, TokenProcentage } from './TableColumnsChip'; import { useProcessedTokenData } from './useProcentage'; +const STableRow = styled(TableRow)(({ theme }: any) => ({ + cursor: 'pointer', + transition: 'all 0.3s ease-in-out', + borderRadius: `${theme.shape.borderRadius}px`, + '& td': { border: 0 }, + '&:hover': { + backgroundColor: theme.palette.ds.bg_color_min, + }, +})); + interface Props { data: TokenType[]; isLoading: boolean; @@ -58,46 +68,31 @@ const StatsTable = ({ data }: Props): JSX.Element => { }, ]; - const assetFormatedList = useProcessedTokenData({ data: list, ptActivity, data24h, data7d, data30d }); + const assetFormatedList = useProcessedTokenData({ data: list, ptActivity, data24h }); - // console.log('assetFormatedList', assetFormatedList); const { getSortedData, handleRequestSort } = useTableSort({ order, orderBy, setSortState, headCells, data: assetFormatedList }); - - const sortedData = useMemo(() => getSortedData(assetFormatedList), [getSortedData, assetFormatedList]); return (
} > - {sortedData.map((row: any) => ( - navigateTo.portfolioDetail(row.id)} - sx={{ - cursor: 'pointer', - transition: 'all 0.3s ease-in-out', - borderRadius: `${theme.shape.borderRadius}px`, - '& td': { border: 0 }, - '&:hover': { - backgroundColor: theme.palette.ds.gray_c50, - }, - }} - > - + {getSortedData(assetFormatedList).map((row: any) => ( + navigateTo.portfolioDetail(row.id)} sx={{}}> + - + - + { /> - + { /> - + { /> - + - + - + ))}
); From 38aa6a24da4b2e327a7931611e8c8392954c50d1 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 8 Nov 2024 14:06:20 +0300 Subject: [PATCH 025/133] flow fixes --- packages/yoroi-extension/app/environment.js | 3 ++- packages/yoroi-extension/app/stores/toplevel/ProfileStore.js | 2 +- packages/yoroi-extension/chrome/extension/background.js | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/environment.js b/packages/yoroi-extension/app/environment.js index c78d4f6eaa..34ba0ed748 100644 --- a/packages/yoroi-extension/app/environment.js +++ b/packages/yoroi-extension/app/environment.js @@ -43,7 +43,7 @@ export const environment = (( getWalletRefreshInterval: () => CONFIG.app.walletRefreshInterval, getServerStatusRefreshInterval: () => CONFIG.app.serverStatusRefreshInterval, userAgentInfo, - externalPrivacyPolicyURL: (): ?string => { + externalPrivacyPolicyURL: () => { if (userAgentInfo.isFirefox()) { return FIREFOX_PRIVACY_POLICY_URL; } @@ -64,6 +64,7 @@ export const environment = (( isProduction: void => boolean, getWalletRefreshInterval: void => number, getServerStatusRefreshInterval: void => number, + externalPrivacyPolicyURL: void => ?string, userAgentInfo: UserAgentInfo, isLight: boolean, ... diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index acbc2dc69a..c3ae70f127 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -21,7 +21,7 @@ export default class ProfileStore extends BaseProfileStore boolean | Promise, action: void => Promise |} = { isDone: () => this.isAnalyticsOpted, action: async () => { const route = ROUTES.PROFILE.OPT_FOR_ANALYTICS; diff --git a/packages/yoroi-extension/chrome/extension/background.js b/packages/yoroi-extension/chrome/extension/background.js index 399ba3c367..02fb41cc6b 100644 --- a/packages/yoroi-extension/chrome/extension/background.js +++ b/packages/yoroi-extension/chrome/extension/background.js @@ -85,6 +85,7 @@ import { addressHexToBech32 } from '../../app/api/ada/lib/cardanoCrypto/utils'; /*:: declare var chrome; +declare var browser; */ const onYoroiIconClicked = () => { From a0c4665d0b11712844a8bb9efbcba569e7f82b65 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 8 Nov 2024 14:14:08 +0300 Subject: [PATCH 026/133] Version bump: 5.4.279 --- packages/yoroi-extension/package-lock.json | 4 ++-- packages/yoroi-extension/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/package-lock.json b/packages/yoroi-extension/package-lock.json index 0cc1e2c3e0..0a688b6e04 100644 --- a/packages/yoroi-extension/package-lock.json +++ b/packages/yoroi-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "yoroi", - "version": "5.4.278", + "version": "5.4.279", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yoroi", - "version": "5.4.278", + "version": "5.4.279", "license": "MIT", "dependencies": { "@amplitude/analytics-browser": "^2.1.3", diff --git a/packages/yoroi-extension/package.json b/packages/yoroi-extension/package.json index 91792b23d0..40954db013 100644 --- a/packages/yoroi-extension/package.json +++ b/packages/yoroi-extension/package.json @@ -1,6 +1,6 @@ { "name": "yoroi", - "version": "5.4.278", + "version": "5.4.279", "description": "Cardano ADA wallet", "scripts": { "dev-mv2": "rimraf dev/ && NODE_OPTIONS=--openssl-legacy-provider babel-node scripts-mv2/build --type=debug --env 'mainnet'", From 4f83c088e453ca19d8f0864a159dea2eb3574e51 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 8 Nov 2024 14:08:09 +0200 Subject: [PATCH 027/133] update filters --- .../features/portfolio/useCases/Wallet/PortfolioWallet.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx index 020759b343..eddb007961 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/Wallet/PortfolioWallet.tsx @@ -23,10 +23,11 @@ const PortfolioWallet = (): JSX.Element => { } const lowercaseKeyword = keyword.toLowerCase(); - const temp = ftAssetList.filter(item => { return ( - item.info.name.toLowerCase().includes(lowercaseKeyword) || item.info.policyId.toLowerCase().includes(lowercaseKeyword) + item.info.name.toLowerCase().includes(lowercaseKeyword) || + item.info.policyId.toLowerCase() === lowercaseKeyword || + item.info.fingerprint.toLowerCase() === lowercaseKeyword ); }); if (temp && temp.length > 0) { From 1aa4c7a6fec97703148a65828ab13a1429b91919 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 8 Nov 2024 14:08:24 +0200 Subject: [PATCH 028/133] update page title --- packages/yoroi-extension/app/UI/pages/portfolio/layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/pages/portfolio/layout.tsx b/packages/yoroi-extension/app/UI/pages/portfolio/layout.tsx index e66fa6c756..a0090ac8ca 100644 --- a/packages/yoroi-extension/app/UI/pages/portfolio/layout.tsx +++ b/packages/yoroi-extension/app/UI/pages/portfolio/layout.tsx @@ -35,7 +35,7 @@ const PortfolioLayout = ({ stores, actions, children }: Props): JSX.Element => { } + title={} // menu={menu} /> } From 5cfa3cd31ed174b1a21f713974859b895abd0de3 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 8 Nov 2024 14:08:37 +0200 Subject: [PATCH 029/133] fix no data display --- .../portfolio/useCases/TokensTable/StatsTable.tsx | 2 +- .../portfolio/useCases/TokensTable/TableColumnsChip.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx index f190d64281..0f74b9b264 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx @@ -68,7 +68,7 @@ const StatsTable = ({ data }: Props): JSX.Element => { }, ]; - const assetFormatedList = useProcessedTokenData({ data: list, ptActivity, data24h }); + const assetFormatedList = useProcessedTokenData({ data: list, ptActivity, data24h, data30d, data7d }); const { getSortedData, handleRequestSort } = useTableSort({ order, orderBy, setSortState, headCells, data: assetFormatedList }); return ( diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index f1b0e04377..9658e10264 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -69,9 +69,11 @@ export const TokenPriceChangeChip = ({ - {formatPriceChange( - isPrimaryToken && timeInterval !== undefined ? ptTokenDataInterval?.[50]?.changePercent ?? 0 : changePercent ?? 0 - )} + {Number.isNaN(changePercent) + ? '-' + : formatPriceChange( + isPrimaryToken && timeInterval !== undefined ? ptTokenDataInterval?.[50]?.changePercent ?? 0 : changePercent ?? 0 + )} % From 3eee5e9e3876ba07e2531899a5fc766a89632386 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 8 Nov 2024 14:14:56 +0200 Subject: [PATCH 030/133] add on mouse hover for graph info --- .../useCases/TokenDetails/ChartDetails/TokenChartInterval.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/TokenChartInterval.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/TokenChartInterval.tsx index c27f098d7d..61854aa483 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/TokenChartInterval.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/TokenChartInterval.tsx @@ -101,7 +101,7 @@ export const TokenChartInterval = ({ tokenInfo }: Props): JSX.Element => { Date: Thu, 7 Nov 2024 15:12:26 +0800 Subject: [PATCH 031/133] pop up analaytics consent after installation on Firefox --- .../app/stores/base/BaseProfileStore.js | 4 ++++ .../app/stores/toplevel/ProfileStore.js | 24 +++++++++++-------- .../chrome/extension/background/index.js | 6 +++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index 5284176e1c..dd1dab09bd 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -512,6 +512,10 @@ export default class BaseProfileStore this.getIsAnalyticsAllowed.patch(_ => isAnalyticsAllowed); this.api.localStorage.saveIsAnalysticsAllowed(isAnalyticsAllowed); ampli.client.setOptOut(!isAnalyticsAllowed); + if (environment.userAgentInfo.isFirefox() && window.document.location.search === '?installed') { + // This is the mandatory data collection consent pop up of Firefox on installation. + window.close(); + } } @computed get isAnalyticsOpted(): boolean { diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index 6d431d8368..f26c62c3b0 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -22,9 +22,22 @@ export default class ProfileStore extends BaseProfileStore this.isAnalyticsOpted, + action: async () => { + const route = ROUTES.PROFILE.OPT_FOR_ANALYTICS; + if (this.stores.app.currentRoute === route) { + return; + } + this.actions.router.goToRoute.trigger({ route }); + }, + }; + /** Linear list of steps that need to be completed before app start */ @observable SETUP_STEPS: Array<{| isDone: void => boolean | Promise, action: void => Promise |}> = [ + // Firefox policy requires this to be the first + ...(environment.userAgentInfo.isFirefox() ? [this._analyticsStep] : []), { isDone: () => this.isCurrentLocaleSet, action: async () => { @@ -47,16 +60,7 @@ export default class ProfileStore extends BaseProfileStore this.isAnalyticsOpted, - action: async () => { - const route = ROUTES.PROFILE.OPT_FOR_ANALYTICS; - if (this.stores.app.currentRoute === route) { - return; - } - this.actions.router.goToRoute.trigger({ route }); - }, - }, + ...(environment.userAgentInfo.isFirefox() ? [] : [this._analyticsStep]), { isDone: () => this.isComplexityLevelSelected, action: async () => { diff --git a/packages/yoroi-extension/chrome/extension/background/index.js b/packages/yoroi-extension/chrome/extension/background/index.js index 9df389ca06..bdccca3a91 100644 --- a/packages/yoroi-extension/chrome/extension/background/index.js +++ b/packages/yoroi-extension/chrome/extension/background/index.js @@ -47,3 +47,9 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { init().catch(console.error); startMonitorServerStatus(); startPoll(); + +if (environment.userAgentInfo.isFirefox()) { + browser.runtime.onInstalled.addListener(() => { + chrome.tabs.create({ url: 'main_window.html?installed' }); + }); +} From a903579484bf7d2b7a0b2b2e24009b2f92b7e7c4 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 8 Nov 2024 21:10:14 +0800 Subject: [PATCH 032/133] re-show consent for all users --- .../app/api/localStorage/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/api/localStorage/index.js b/packages/yoroi-extension/app/api/localStorage/index.js index 078842ac68..6ae6675e3b 100644 --- a/packages/yoroi-extension/app/api/localStorage/index.js +++ b/packages/yoroi-extension/app/api/localStorage/index.js @@ -303,17 +303,26 @@ export default class LocalStorageApi { unsetAcceptedTosVersion: void => Promise = () => removeLocalItem(storageKeys.ACCEPTED_TOS_VERSION); + // Firefox demands us to re-show the data collection consent screen, so change the key for Firefox + _getIsAnalyticsAllowedKey: () => string = () => { + let key = storageKeys.IS_ANALYTICS_ALLOWED; + if (environment.userAgentInfo.isFirefox()) { + key += '-firefox'; + } + return key; + } + loadIsAnalyticsAllowed: () => Promise = async () => { - const json = await getLocalItem(storageKeys.IS_ANALYTICS_ALLOWED); + const json = await getLocalItem(this._getIsAnalyticsAllowedKey()); if (!json) { return undefined; } return JSON.parse(json); }; - saveIsAnalysticsAllowed: (flag: boolean) => Promise = async flag => { - await setLocalItem(storageKeys.IS_ANALYTICS_ALLOWED, JSON.stringify(flag)); - }; + saveIsAnalysticsAllowed: (flag: boolean) => Promise = async (flag) => { + await setLocalItem(this._getIsAnalyticsAllowedKey(), JSON.stringify(flag)); + } unsetIsAnalyticsAllowed: void => Promise = () => removeLocalItem(storageKeys.IS_ANALYTICS_ALLOWED); From 54f2a2c4bb770c4bbecf8150692cc5de2da088db Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 8 Nov 2024 21:11:38 +0800 Subject: [PATCH 033/133] auto launch and continue, instead of just launch the consent dialog --- packages/yoroi-extension/app/stores/base/BaseProfileStore.js | 4 ---- packages/yoroi-extension/chrome/extension/background/index.js | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js index dd1dab09bd..5284176e1c 100644 --- a/packages/yoroi-extension/app/stores/base/BaseProfileStore.js +++ b/packages/yoroi-extension/app/stores/base/BaseProfileStore.js @@ -512,10 +512,6 @@ export default class BaseProfileStore this.getIsAnalyticsAllowed.patch(_ => isAnalyticsAllowed); this.api.localStorage.saveIsAnalysticsAllowed(isAnalyticsAllowed); ampli.client.setOptOut(!isAnalyticsAllowed); - if (environment.userAgentInfo.isFirefox() && window.document.location.search === '?installed') { - // This is the mandatory data collection consent pop up of Firefox on installation. - window.close(); - } } @computed get isAnalyticsOpted(): boolean { diff --git a/packages/yoroi-extension/chrome/extension/background/index.js b/packages/yoroi-extension/chrome/extension/background/index.js index bdccca3a91..07d4358847 100644 --- a/packages/yoroi-extension/chrome/extension/background/index.js +++ b/packages/yoroi-extension/chrome/extension/background/index.js @@ -49,7 +49,5 @@ startMonitorServerStatus(); startPoll(); if (environment.userAgentInfo.isFirefox()) { - browser.runtime.onInstalled.addListener(() => { - chrome.tabs.create({ url: 'main_window.html?installed' }); - }); + browser.runtime.onInstalled.addListener(onYoroiIconClicked); } From df2226244c0908295bad37a070d4e6c279e69057 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 8 Nov 2024 21:12:19 +0800 Subject: [PATCH 034/133] check for analytics flag when firefox reload --- .../yoroi-extension/chrome/extension/background/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/chrome/extension/background/index.js b/packages/yoroi-extension/chrome/extension/background/index.js index 07d4358847..73993229e0 100644 --- a/packages/yoroi-extension/chrome/extension/background/index.js +++ b/packages/yoroi-extension/chrome/extension/background/index.js @@ -49,5 +49,10 @@ startMonitorServerStatus(); startPoll(); if (environment.userAgentInfo.isFirefox()) { - browser.runtime.onInstalled.addListener(onYoroiIconClicked); + browser.runtime.onInstalled.addListener(async () => { + const analyticsFlag = await new LocalStorageApi().loadIsAnalyticsAllowed(); + if (analyticsFlag == null) { + onYoroiIconClicked(); + } + }); } From 6a68c7e528a77feac3ab102fb67c133ef7ae420c Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 19:56:40 +0300 Subject: [PATCH 035/133] firefox external privacy policy link --- .../profile/language-selection/LanguageSelectionForm.js | 9 ++++++++- .../app/containers/profile/LanguageSelectionPage.js | 1 + packages/yoroi-extension/app/environment.js | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js b/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js index 6692a51a2d..83a0546d5e 100644 --- a/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js +++ b/packages/yoroi-extension/app/components/profile/language-selection/LanguageSelectionForm.js @@ -29,6 +29,7 @@ type Props = {| +error?: ?LocalizableError, +localizedTermsOfUse: string, +localizedPrivacyNotice: string, + +externalPrivacyPolicyURL: ?string, |}; type State = {| @@ -82,7 +83,13 @@ class LanguageSelectionForm extends Component ); diff --git a/packages/yoroi-extension/app/environment.js b/packages/yoroi-extension/app/environment.js index ce035f74ed..c78d4f6eaa 100644 --- a/packages/yoroi-extension/app/environment.js +++ b/packages/yoroi-extension/app/environment.js @@ -16,6 +16,8 @@ function getVersion(): string { return content.version; } +const FIREFOX_PRIVACY_POLICY_URL = 'https://addons.mozilla.org/en-US/firefox/addon/yoroi/privacy'; + export const environment = (( { ...process.env, @@ -41,6 +43,12 @@ export const environment = (( getWalletRefreshInterval: () => CONFIG.app.walletRefreshInterval, getServerStatusRefreshInterval: () => CONFIG.app.serverStatusRefreshInterval, userAgentInfo, + externalPrivacyPolicyURL: (): ?string => { + if (userAgentInfo.isFirefox()) { + return FIREFOX_PRIVACY_POLICY_URL; + } + return null; + } } ): { getNetworkName: void => Network, From 36e6dfa655e0a60cb6419c5fc2e481273a171033 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 20:23:25 +0300 Subject: [PATCH 036/133] added analytics no rejection impact --- .../components/profile/terms-of-use/OptForAnalyticsForm.js | 5 +++++ packages/yoroi-extension/app/i18n/locales/en-US.json | 1 + 2 files changed, 6 insertions(+) diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js index da66df3060..ebfd63720e 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js @@ -48,6 +48,10 @@ const messages = defineMessages({ id: 'profile.analytics.learnMore', defaultMessage: '!!!Learn more about user insights', }, + rejectionImpact: { + id: 'profile.analytics.rejectionImpact', + defaultMessage: '!!!Opting out won’t impact your experience', + }, accept: { id: 'profile.analytics.accept', defaultMessage: '!!!Accept', @@ -91,6 +95,7 @@ export default class OptForAnalyticsForm extends Component { const analyticsDetails = [ [YesIcon, messages.line1], [YesIcon, messages.line2], + [YesIcon, messages.rejectionImpact], [NoIcon, messages.line3], [NoIcon, messages.line4], [NoIcon, messages.line5], diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index 1354e9f4e1..a6d3c5cb77 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -226,6 +226,7 @@ "profile.analytics.accept": "Accept", "profile.analytics.allow": "Allow Yoroi analytics", "profile.analytics.learnMore": "Learn more about user insights", + "profile.analytics.rejectionImpact": "Opting out won’t impact your experience", "profile.analytics.line1": "Anonymous analytics data", "profile.analytics.line2": "You can always opt-out via Settings", "profile.analytics.line3": "We can not access private keys", From 4eb05bf9dc59aadec9716a95f5bcc567f5b3434b Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 7 Nov 2024 21:33:59 +0300 Subject: [PATCH 037/133] added analytics listing collected data --- .../terms-of-use/OptForAnalyticsForm.js | 32 +++++++++++++++++-- .../app/i18n/locales/en-US.json | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js index ebfd63720e..35e584142f 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js @@ -13,6 +13,7 @@ import { ReactComponent as YesIcon } from '../../../assets/images/yes.inline.svg import { ReactComponent as NoIcon } from '../../../assets/images/no.inline.svg'; import { Box, Typography } from '@mui/material'; import { RevampSwitch } from '../../widgets/Switch'; +import environment from '../../../environment'; const messages = defineMessages({ title: { @@ -48,6 +49,10 @@ const messages = defineMessages({ id: 'profile.analytics.learnMore', defaultMessage: '!!!Learn more about user insights', }, + collectedData: { + id: 'profile.analytics.collectedData', + defaultMessage: '!!!Collected data includes: visited pages, browser version, selected language, time of analytical events', + }, rejectionImpact: { id: 'profile.analytics.rejectionImpact', defaultMessage: '!!!Opting out won’t impact your experience', @@ -92,16 +97,19 @@ export default class OptForAnalyticsForm extends Component { const isStartupScreen = variant === 'startup'; const isSettingsScreen = variant === 'settings'; + const isFirefox = environment.userAgentInfo.isFirefox(); + const analyticsDetails = [ [YesIcon, messages.line1], [YesIcon, messages.line2], - [YesIcon, messages.rejectionImpact], + (isFirefox ? [YesIcon, messages.rejectionImpact] : null), [NoIcon, messages.line3], [NoIcon, messages.line4], [NoIcon, messages.line5], - ]; + ].filter(Boolean); return ( + <>
{isSettingsScreen && ( @@ -141,6 +149,25 @@ export default class OptForAnalyticsForm extends Component { ))} +
+
+ + {isFirefox ? ( + + {intl.formatMessage(messages.collectedData)} + + ) : null} + + +
{ )}
+ ); } } diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index a6d3c5cb77..92daa7ce63 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -227,6 +227,7 @@ "profile.analytics.allow": "Allow Yoroi analytics", "profile.analytics.learnMore": "Learn more about user insights", "profile.analytics.rejectionImpact": "Opting out won’t impact your experience", + "profile.analytics.collectedData": "Collected data includes: visited pages, browser version, selected language, time of analytical events", "profile.analytics.line1": "Anonymous analytics data", "profile.analytics.line2": "You can always opt-out via Settings", "profile.analytics.line3": "We can not access private keys", From cff4cd405605380abfd86adc6334297c6dbad362 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 8 Nov 2024 21:15:30 +0800 Subject: [PATCH 038/133] flow fixes --- packages/yoroi-extension/app/environment.js | 3 ++- packages/yoroi-extension/app/stores/toplevel/ProfileStore.js | 2 +- packages/yoroi-extension/chrome/extension/background/index.js | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/environment.js b/packages/yoroi-extension/app/environment.js index c78d4f6eaa..34ba0ed748 100644 --- a/packages/yoroi-extension/app/environment.js +++ b/packages/yoroi-extension/app/environment.js @@ -43,7 +43,7 @@ export const environment = (( getWalletRefreshInterval: () => CONFIG.app.walletRefreshInterval, getServerStatusRefreshInterval: () => CONFIG.app.serverStatusRefreshInterval, userAgentInfo, - externalPrivacyPolicyURL: (): ?string => { + externalPrivacyPolicyURL: () => { if (userAgentInfo.isFirefox()) { return FIREFOX_PRIVACY_POLICY_URL; } @@ -64,6 +64,7 @@ export const environment = (( isProduction: void => boolean, getWalletRefreshInterval: void => number, getServerStatusRefreshInterval: void => number, + externalPrivacyPolicyURL: void => ?string, userAgentInfo: UserAgentInfo, isLight: boolean, ... diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index f26c62c3b0..a92c0d0928 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -22,7 +22,7 @@ export default class ProfileStore extends BaseProfileStore boolean | Promise, action: void => Promise |} = { isDone: () => this.isAnalyticsOpted, action: async () => { const route = ROUTES.PROFILE.OPT_FOR_ANALYTICS; diff --git a/packages/yoroi-extension/chrome/extension/background/index.js b/packages/yoroi-extension/chrome/extension/background/index.js index 73993229e0..b750de1a2f 100644 --- a/packages/yoroi-extension/chrome/extension/background/index.js +++ b/packages/yoroi-extension/chrome/extension/background/index.js @@ -9,11 +9,13 @@ import { environment } from '../../../app/environment'; import axios from 'axios'; import fetchAdapter from '@vespaiach/axios-fetch-adapter'; import { sanitizeForLog } from '../../../app/coreUtils'; +import LocalStorageApi from '../../../app/api/localStorage/index'; axios.defaults.adapter = fetchAdapter; /*:: declare var chrome; +declare var browser; */ const onYoroiIconClicked = () => { From c7cd8302e3bac8670b2be8471b961deab9c41b5e Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 8 Nov 2024 16:24:16 +0200 Subject: [PATCH 039/133] add explorer store --- .../module/PortfolioContextProvider.tsx | 3 ++- .../app/UI/features/portfolio/module/state.ts | 2 ++ .../OverviewPerformanceDetails/Overview.tsx | 24 ++++++++----------- .../app/UI/types/currrentWallet.ts | 1 + .../app/UI/utils/createCurrentWalletInfo.ts | 8 +++++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/module/PortfolioContextProvider.tsx b/packages/yoroi-extension/app/UI/features/portfolio/module/PortfolioContextProvider.tsx index 34772bf9fc..dbd61d0056 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/module/PortfolioContextProvider.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/module/PortfolioContextProvider.tsx @@ -43,7 +43,7 @@ export const PortfolioContextProvider = ({ currentWallet, openDialogWrapper, }: PortfolioProviderProps) => { - const { walletBalance, ftAssetList, selectedWallet, networkId, primaryTokenInfo, backendServiceZero } = currentWallet; + const { walletBalance, ftAssetList, selectedWallet, networkId, primaryTokenInfo, backendServiceZero, explorer } = currentWallet; if (selectedWallet === undefined) { return <>; } @@ -83,6 +83,7 @@ export const PortfolioContextProvider = ({ openBuyDialog: () => openDialogWrapper(BuySellDialog), showWelcomeBanner: ftAssetList.length === 1, backendServiceZero: backendServiceZero, + explorer, }), [state, actions, ftAssetList] ); diff --git a/packages/yoroi-extension/app/UI/features/portfolio/module/state.ts b/packages/yoroi-extension/app/UI/features/portfolio/module/state.ts index 73a86bd9a8..032b0d1dfa 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/module/state.ts +++ b/packages/yoroi-extension/app/UI/features/portfolio/module/state.ts @@ -43,6 +43,7 @@ export type PortfolioState = { primaryTokenInfo: any; openBuyDialog: () => void; backendServiceZero: string; + explorer: { tokenInfo: { name: string; baseUrl: string } }; }; // Define default state @@ -60,6 +61,7 @@ export const defaultPortfolioState: PortfolioState = { showWelcomeBanner: false, openBuyDialog: () => {}, backendServiceZero: '', + explorer: { tokenInfo: { name: '', baseUrl: '' } }, }; // Define action handlers diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx index 6e0c4ed7c3..2f7cfb5344 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx @@ -2,7 +2,6 @@ import { Box, Link as LinkMui, Stack, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; import React from 'react'; import { CopyButton } from '../../../../../components'; -import { getNetworkUrl } from '../../../../../utils/getNetworkUrl'; import tokenPng from '../../../common/assets/images/token.png'; import { isPrimaryToken } from '../../../common/helpers/isPrimary'; import { useStrings } from '../../../common/hooks/useStrings'; @@ -56,7 +55,7 @@ const Overview = ({ tokenInfo }: Props): JSX.Element => { @@ -87,8 +86,7 @@ const TokenOverviewSection = ({ return <>; } - const { networkId } = usePortfolio(); - const networkUrl = networkId !== null ? getNetworkUrl(networkId) : ''; + const { explorer } = usePortfolio(); const theme: any = useTheme(); return ( @@ -101,19 +99,17 @@ const TokenOverviewSection = ({ - Cardanoscan - - - Adaex + {explorer.tokenInfo.name} ) : isExternalLink ? ( diff --git a/packages/yoroi-extension/app/UI/types/currrentWallet.ts b/packages/yoroi-extension/app/UI/types/currrentWallet.ts index 04fc518820..100ede892a 100644 --- a/packages/yoroi-extension/app/UI/types/currrentWallet.ts +++ b/packages/yoroi-extension/app/UI/types/currrentWallet.ts @@ -42,4 +42,5 @@ export type CurrentWalletType = { primaryTokenInfo: PrimaryTokenInfo; walletBalance: WalletBalance; ftAssetList: any[]; + explorer: { tokenInfo: { name: string; baseUrl: string } }; }; diff --git a/packages/yoroi-extension/app/UI/utils/createCurrentWalletInfo.ts b/packages/yoroi-extension/app/UI/utils/createCurrentWalletInfo.ts index f619304c7c..a715ae54f2 100644 --- a/packages/yoroi-extension/app/UI/utils/createCurrentWalletInfo.ts +++ b/packages/yoroi-extension/app/UI/utils/createCurrentWalletInfo.ts @@ -141,7 +141,7 @@ const groupTransactionsByDay = transactions => { }; export const createCurrrentWalletInfo = (stores: any): CurrentWalletType | undefined => { - const { wallets, delegation, tokenInfoStore } = stores; + const { wallets, delegation, tokenInfoStore, explorers } = stores; try { const walletCurrentPoolInfo = getStakePoolMeta(stores); @@ -173,11 +173,14 @@ export const createCurrrentWalletInfo = (stores: any): CurrentWalletType | undef const isHardware: boolean = selectedWallet.isHardware; - // Asset List + // FT Asset List const ftAssetList = getAssetWalletAssetList(stores); const groupedTx = groupTransactionsByDay(stores.transactions.recent); + const selectedExplorer = explorers.selectedExplorer.get(networkId); + const explorerTransactionInfo = selectedExplorer.getOrDefault('token'); + return { currentPool: walletCurrentPoolInfo, networkId, @@ -197,6 +200,7 @@ export const createCurrrentWalletInfo = (stores: any): CurrentWalletType | undef ada: `${beforeDecimalRewards}${afterDecimalRewards}`, }, ftAssetList: ftAssetList, + explorer: { tokenInfo: explorerTransactionInfo }, }; } catch (error) { console.warn('ERROR trying to create wallet info', error); From 55cc2e62f07cd908755a6d0f021ce4255e7bdcd5 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 8 Nov 2024 23:33:38 +0300 Subject: [PATCH 040/133] sanitized --- packages/yoroi-extension/app/api/thunk.js | 2 +- packages/yoroi-extension/app/coreUtils.js | 8 +++++--- .../chrome/extension/background/handlers/yoroi/index.js | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index c29a7a9932..9ac5be3c09 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -112,7 +112,7 @@ export function callBackground(message: {| type: string, request?: Object |}) const serializedMessage = { type: message.type, request: JSON.stringify(message.request ?? null) }; window.chrome.runtime.sendMessage(serializedMessage, response => { // $FlowIgnore - console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); + console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(sanitizeForLog(response))); if (window.chrome.runtime.lastError) { // eslint-disable-next-line prefer-promise-reject-errors reject(`Error ${window.chrome.runtime.lastError} when calling the background with: ${JSON.stringify(sanitizeForLog(message)) ?? 'undefined'}`); diff --git a/packages/yoroi-extension/app/coreUtils.js b/packages/yoroi-extension/app/coreUtils.js index 1d60daf755..be0a53c946 100644 --- a/packages/yoroi-extension/app/coreUtils.js +++ b/packages/yoroi-extension/app/coreUtils.js @@ -225,11 +225,13 @@ export function timeCached(fun: () => R, ttl: number): () => R { * @return same value or a copy in case the value is an object */ export function sanitizeForLog(v: any): any { + const fields: Array = ['password']; if (v != null && typeof v === 'object') { let r = Object.keys(v).reduce((o, k) => ({ ...o, [k]: sanitizeForLog(v[k]) }) , {}) - // $FlowIgnore[incompatible-use] - if (r.password != null) { - r = { ...r, password: '[sanitized]' }; + for (const f of fields) { + if (r[f] != null) { + r = { ...r, [f]: '[sanitized]' }; + } } return r; } diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js index b312ad4db3..4b88c7b783 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js @@ -43,6 +43,7 @@ import { } from './connector'; import { GetProtocolParameters } from './protocolParameters'; import { subscribe } from '../../subscriptionManager'; +import { sanitizeForLog } from '../../../../../app/coreUtils'; const handlerMap = Object.freeze({ [GetHistoricalCoinPrices.typeTag]: GetHistoricalCoinPrices.handle, @@ -107,7 +108,7 @@ export function getHandler(typeTag: string): ?Handler { return async (request, send, sendResponse) => { try { const result = await handler(request.request); - console.debug(`BACKGROUND [${typeTag}] sending result: `, JSON.stringify(result)); + console.debug(`BACKGROUND [${typeTag}] sending result: `, JSON.stringify(sanitizeForLog(result))); sendResponse(result); } catch (error) { sendResponse({ error: error.message }); From 04dfbbc47d0efb93aa5f2ec115bbec35d4d50190 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 10 Nov 2024 00:19:14 +0300 Subject: [PATCH 041/133] filter message passing --- packages/yoroi-extension/app/api/thunk.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 9ac5be3c09..b8516b9719 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -416,13 +416,22 @@ const callbacks = Object.freeze({ serverStatusUpdate: [], coinPriceUpdate: [], }); -chrome.runtime.onMessage.addListener((serializedMessage, _sender, _sendResponse) => { - //fixme: verify sender.id/origin +const APP_ORIGIN = window.location.origin || null; +chrome.runtime.onMessage.addListener((serializedMessage, { origin }, _sendResponse) => { + if (APP_ORIGIN != null && origin !== APP_ORIGIN) { + Logger.debug('ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(serializedMessage))); + return; + } + const messageType = typeof serializedMessage; + if (messageType !== 'string') { + Logger.error('unexpected message type (' + messageType + ') a JSON string is expected, but received: ' + JSON.stringify(sanitizeForLog(serializedMessage))); + return; + } let message; try { message = JSON.parse(serializedMessage); } catch (error) { - Logger.error('unserializable message: ' + serializedMessage + ' | Error: ' + stringifyError(error)); + Logger.error('unparsable message: ' + serializedMessage + ' | Error: ' + stringifyError(error)); return; } if (typeof message !== 'object') { From 13252a8948b3dbdf6a73877593e33f1f02f1fdfb Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 11 Nov 2024 10:17:55 +0300 Subject: [PATCH 042/133] message type checking --- packages/yoroi-extension/app/api/thunk.js | 12 +++++++++--- .../extension/background/subscriptionManager.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index b8516b9719..1eba037b8a 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -417,14 +417,20 @@ const callbacks = Object.freeze({ coinPriceUpdate: [], }); const APP_ORIGIN = window.location.origin || null; -chrome.runtime.onMessage.addListener((serializedMessage, { origin }, _sendResponse) => { +const EXPECTED_MESSAGE_TYPE = 'yoroi-emit-update'; +chrome.runtime.onMessage.addListener((rawMessage, { origin }, _sendResponse) => { if (APP_ORIGIN != null && origin !== APP_ORIGIN) { - Logger.debug('ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(serializedMessage))); + Logger.debug('[client] ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(rawMessage))); return; } + if (rawMessage.type !== EXPECTED_MESSAGE_TYPE) { + Logger.debug('[client] ignoring unknown type message (' + rawMessage.type + '/' + EXPECTED_MESSAGE_TYPE + '):' + JSON.stringify(sanitizeForLog(rawMessage))); + return; + } + const serializedMessage = rawMessage.data; const messageType = typeof serializedMessage; if (messageType !== 'string') { - Logger.error('unexpected message type (' + messageType + ') a JSON string is expected, but received: ' + JSON.stringify(sanitizeForLog(serializedMessage))); + Logger.error('[client] unexpected message type (' + messageType + ') a JSON string is expected, but received: ' + JSON.stringify(sanitizeForLog(serializedMessage))); return; } let message; diff --git a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js index 6f87855b40..bd69ca4799 100644 --- a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js +++ b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js @@ -68,6 +68,6 @@ declare var chrome; */ export function emitUpdateToSubscriptions(data: Object): void { for (const { tabId } of getSubscriptions()) { - chrome.tabs.sendMessage(tabId, JSON.stringify(data)); + chrome.tabs.sendMessage(tabId, { type: 'yoroi-emit-update', data: JSON.stringify(data) }); } } From 8d4f16d3f373ff6be009046a5e11a31763bb7d5b Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 11 Nov 2024 13:30:17 +0300 Subject: [PATCH 043/133] trace logging fix --- packages/yoroi-extension/app/api/thunk.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 1eba037b8a..aab033a4cf 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -420,11 +420,11 @@ const APP_ORIGIN = window.location.origin || null; const EXPECTED_MESSAGE_TYPE = 'yoroi-emit-update'; chrome.runtime.onMessage.addListener((rawMessage, { origin }, _sendResponse) => { if (APP_ORIGIN != null && origin !== APP_ORIGIN) { - Logger.debug('[client] ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(rawMessage))); + Logger.debug('[client] ignoring non-origin message (' + origin + '/' + APP_ORIGIN + ')'); return; } if (rawMessage.type !== EXPECTED_MESSAGE_TYPE) { - Logger.debug('[client] ignoring unknown type message (' + rawMessage.type + '/' + EXPECTED_MESSAGE_TYPE + '):' + JSON.stringify(sanitizeForLog(rawMessage))); + Logger.debug('[client] ignoring unknown type message (' + rawMessage.type + '/' + EXPECTED_MESSAGE_TYPE + ')'); return; } const serializedMessage = rawMessage.data; From a12a7ee625d1150723e3e3b4ac0a13f1615776f4 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Mon, 11 Nov 2024 12:39:51 +0200 Subject: [PATCH 044/133] update styles for overview section --- .../OverviewPerformanceDetails/Overview.tsx | 2 +- .../OverviewPerformance.tsx | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx index 2f7cfb5344..f660d8117a 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx @@ -90,7 +90,7 @@ const TokenOverviewSection = ({ const theme: any = useTheme(); return ( - + {label} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/OverviewPerformance.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/OverviewPerformance.tsx index 82333bdaa5..65d89f9e05 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/OverviewPerformance.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/OverviewPerformance.tsx @@ -1,8 +1,7 @@ -import { Box, Divider } from '@mui/material'; +import { Box, Typography } from '@mui/material'; import { styled, useTheme } from '@mui/material/styles'; import React, { useState } from 'react'; import { Card } from '../../../../../components'; -import Menu from '../../../common/components/Menu'; import { useStrings } from '../../../common/hooks/useStrings'; import { SubMenuOption } from '../../../common/types/index'; import TokenDetailOverview from './Overview'; @@ -33,22 +32,25 @@ const OverviewPerformance = ({ tokenInfo }: Props): JSX.Element => { // }, ]; - const [selectedTab, setSelectedTab] = useState(subMenuOptions[0]?.route); + const [selectedTab, _] = useState(subMenuOptions[0]?.route); - const isActiveItem = (route: string) => { - if (route === selectedTab) { - return true; - } else { - return false; - } - }; + // const isActiveItem = (route: string) => { + // if (route === selectedTab) { + // return true; + // } else { + // return false; + // } + // }; return ( - + + {strings.overview} + + {/* setSelectedTab(route)} isActiveItem={isActiveItem} /> - + */} {selectedTab === subMenuOptions[0]?.route ? ( From 2e5c30e3f21a6ee8bcce0e14eb9a5c43d8cdc406 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Mon, 11 Nov 2024 13:26:26 +0200 Subject: [PATCH 045/133] update design - add switch icon --- .../app/UI/components/icons/Switch.tsx | 16 ++++++++ .../app/UI/components/icons/index.ts | 22 ++++++----- .../common/components/PortfolioHeader.tsx | 38 +++++++++---------- 3 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 packages/yoroi-extension/app/UI/components/icons/Switch.tsx diff --git a/packages/yoroi-extension/app/UI/components/icons/Switch.tsx b/packages/yoroi-extension/app/UI/components/icons/Switch.tsx new file mode 100644 index 0000000000..3983cb88e7 --- /dev/null +++ b/packages/yoroi-extension/app/UI/components/icons/Switch.tsx @@ -0,0 +1,16 @@ +import React from 'react'; + +export const Switch = () => { + return ( + + + + + ); +}; diff --git a/packages/yoroi-extension/app/UI/components/icons/index.ts b/packages/yoroi-extension/app/UI/components/icons/index.ts index c70a9049fe..c7d598b40b 100644 --- a/packages/yoroi-extension/app/UI/components/icons/index.ts +++ b/packages/yoroi-extension/app/UI/components/icons/index.ts @@ -1,17 +1,18 @@ +import { Cancel } from './Cancel'; +import { ChevronDown } from './ChevronDown'; +import { ChevronUp } from './ChevronUp'; +import { ChipArrowDown } from './ChipArrowDown'; +import { ChipArrowUp } from './ChipArrowUp'; import { CloseIcon } from './CloseIcon'; -import { VisibilityOff } from './VisibilityOff'; -import { VisibilityOn } from './VisibilityOn'; -import { Copy } from './Copy'; import { Copied } from './Copied'; -import { ChipArrowUp } from './ChipArrowUp'; -import { ChipArrowDown } from './ChipArrowDown'; -import { Send } from './Send'; -import { Cancel } from './Cancel'; -import { Staking } from './Staking'; +import { Copy } from './Copy'; import { Expand } from './Expand'; -import { ChevronUp } from './ChevronUp'; -import { ChevronDown } from './ChevronDown'; import { Search } from './Search'; +import { Send } from './Send'; +import { Staking } from './Staking'; +import { Switch } from './Switch'; +import { VisibilityOff } from './VisibilityOff'; +import { VisibilityOn } from './VisibilityOn'; export const Icon = { CloseIcon, @@ -28,4 +29,5 @@ export const Icon = { ChevronDown, ChevronUp, Search, + Switch, }; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx b/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx index bab80ab733..da588c26f3 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/components/PortfolioHeader.tsx @@ -1,8 +1,9 @@ -import { Box, Skeleton, Stack, Typography, useTheme } from '@mui/material'; +import { Box, IconButton, Skeleton, Stack, styled, Typography, useTheme } from '@mui/material'; import BigNumber from 'bignumber.js'; import React from 'react'; import LocalStorageApi from '../../../../../api/localStorage/index'; import { SearchInput, Tooltip } from '../../../../components'; +import { Switch } from '../../../../components/icons/Switch'; import { useCurrencyPairing } from '../../../../context/CurrencyContext'; import { WalletBalance } from '../../../../types/currrentWallet'; import { usePortfolio } from '../../module/PortfolioContextProvider'; @@ -13,6 +14,14 @@ import { useStrings } from '../hooks/useStrings'; import { HeaderPrice } from './HeaderPrice'; import PnlTag from './PlnTag'; +const IconWrapper: any = styled(IconButton)(({ theme }: any) => ({ + '& svg': { + '& path': { + fill: theme.palette.ds.el_gray_medium, + }, + }, +})); + export function formatValue(value: BigNumber): string { if (value.isZero()) { return '0'; @@ -114,11 +123,7 @@ const PortfolioHeader = ({ walletBalance, setKeyword, isLoading, tooltipTitle }: {String(accountPair?.from.value)} )} - + @@ -157,22 +162,15 @@ const LoadingSkeleton = () => ( ); -const CurrencyDisplay = ({ from, to, handleCurrencyChange }) => ( - - +const CurrencyDisplay = ({ from, handleCurrencyChange }) => ( + + {from} - - /{to} - - + + + + ); const Skeletons = ({ theme }) => ( From 1433530c8dbbd9d5ebfb780f22e44a3e2ca02d93 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Mon, 11 Nov 2024 13:31:38 +0200 Subject: [PATCH 046/133] hide asset tab --- .../app/stores/stateless/sidebarCategories.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js index 23125e88d5..f994979861 100644 --- a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js +++ b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js @@ -131,13 +131,6 @@ export const allCategoriesRevamp: Array = [ label: globalMessages.sidebarSwap, isVisible: ({ selected }) => !selected?.isTestnet, }, - { - className: 'assets', - route: ROUTES.ASSETS.ROOT, - icon: assetsIcon, - label: globalMessages.sidebarAssets, - isVisible: () => environment.isProduction() || environment.isDev(), - }, { className: 'portfolio', route: ROUTES.PORTFOLIO.ROOT, From cc7d8ba0852debffd091f241098d9fb0c8e08a71 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Mon, 11 Nov 2024 15:15:49 +0200 Subject: [PATCH 047/133] fix lint --- .../app/components/wallet/transactions/TransactionRevamp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js b/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js index 0c86b8aef9..6df1a05048 100644 --- a/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js +++ b/packages/yoroi-extension/app/components/wallet/transactions/TransactionRevamp.js @@ -1068,7 +1068,7 @@ const getColors = (ds, type) => { return colorsByType[type] || { bg: ds.primary_100, icon: ds.primary_600 }; }; -const IconWrapper = styled(Box)(({ isDark, colors, theme }) => ({ +const IconWrapper = styled(Box)(({ isDark, colors }) => ({ '& svg': { '& rect': { fill: isDark && colors.bg, From 1022691da9363c6146bc4c5d8ba94c06f9689a87 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Mon, 11 Nov 2024 15:15:58 +0200 Subject: [PATCH 048/133] fix lint --- .../yoroi-extension/app/stores/stateless/sidebarCategories.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js index f994979861..524bd54c57 100644 --- a/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js +++ b/packages/yoroi-extension/app/stores/stateless/sidebarCategories.js @@ -17,7 +17,6 @@ import environment from '../../environment'; import globalMessages, { connectorMessages } from '../../i18n/global-messages'; import { ROUTES } from '../../routes-config'; import type { WalletState } from '../../../chrome/extension/background/types'; -import { ReactComponent as assetsIcon } from '../../assets/images/sidebar/revamp/assets.inline.svg'; export type SidebarCategory = {| +className: string, From 8a1f509c8b4ca599d0afdd7a39c3fbee23136b98 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Tue, 12 Nov 2024 11:44:05 +0200 Subject: [PATCH 049/133] update design --- .../useCases/TokensTable/TableColumnsChip.tsx | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 9658e10264..98f9cbebc1 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -65,11 +65,31 @@ export const TokenPriceChangeChip = ({ const { changePercent, variantPnl } = priceChange(tokenPriceOpen, tokenPriceClose); + const noDataToDisplay = Number.isNaN(changePercent); + + if (noDataToDisplay) { + return ( + + + - + + + % + + + ); + } + return ( - {Number.isNaN(changePercent) + {noDataToDisplay ? '-' : formatPriceChange( isPrimaryToken && timeInterval !== undefined ? ptTokenDataInterval?.[50]?.changePercent ?? 0 : changePercent ?? 0 From 50997c35f44a5189f5d38a7f396258df57fce3cc Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Tue, 12 Nov 2024 12:34:08 +0200 Subject: [PATCH 050/133] updates --- .../portfolio/useCases/TokensTable/TableColumnsChip.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 98f9cbebc1..5012bf3a2c 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -186,9 +186,11 @@ export const TokenPrice = ({ secondaryToken24Activity, ptActivity, token }) => { const ptUnitPrice = tokenPrice * ptPrice; const priceDisplay = parseFloat(isPrimaryToken ? ptPrice : ptUnitPrice).toFixed(4); + const noDataToDisplay = priceDisplay === 'NaN'; + return ( - {priceDisplay} {unitOfAccount} + {noDataToDisplay ? '-' : `${priceDisplay} ${unitOfAccount}`} ); }; From f91aa8c7d3768edbd4c7c5533f9eb72d05c73f8f Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Tue, 12 Nov 2024 13:47:11 +0200 Subject: [PATCH 051/133] fix table cell width --- .../useCases/TokensTable/StatsTable.tsx | 33 ++++++++++--------- .../useCases/TokensTable/TableColumnsChip.tsx | 3 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx index 0f74b9b264..33d5ab94f8 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx @@ -25,6 +25,9 @@ const STableRow = styled(TableRow)(({ theme }: any) => ({ backgroundColor: theme.palette.ds.bg_color_min, }, })); +const STableCell = styled(TableCell)(() => ({ + width: '15%', +})); interface Props { data: TokenType[]; @@ -83,48 +86,48 @@ const StatsTable = ({ data }: Props): JSX.Element => { TableRowSkeleton={} > {getSortedData(assetFormatedList).map((row: any) => ( - navigateTo.portfolioDetail(row.id)} sx={{}}> - + navigateTo.portfolioDetail(row.id)}> + - + - + - + - + - + - + - + - + - + - + - + - + - + ))} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 5012bf3a2c..0bad23c88a 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -13,6 +13,7 @@ import { usePortfolio } from '../../module/PortfolioContextProvider'; export const TokenDisplay = ({ token }: { token: TokenInfoType }) => { const theme = useTheme(); + return ( { borderRadius: `${theme.shape.borderRadius}px`, }} component="img" - src={token.info.image || tokenPng} + src={token.info.image ?? tokenPng} > From 7dce676dc87176e83adea08cf80b5c7a820dca8f Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Tue, 12 Nov 2024 13:54:04 +0200 Subject: [PATCH 052/133] fix sorting --- .../app/UI/features/portfolio/common/hooks/useTableSort.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts index 8ee3101fbd..8c64f1fbde 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useTableSort.ts @@ -37,7 +37,7 @@ const useTableSort = ({ order, orderBy, setSortState, headCells, data }: Props) const bValue = Number(b[orderBy]); return bValue === aValue ? 0 : bValue < aValue ? -1 : 1; case 'character': - return String(a.info[orderBy]).localeCompare(b.info[orderBy]); + return String(b.info[orderBy]).localeCompare(a.info[orderBy]); default: return b[orderBy] === a[orderBy] ? 0 : b[orderBy] < a[orderBy] ? -1 : 1; } From 1db0c6d56a3f23a4517799c0fc94a32acdd9505c Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Wed, 13 Nov 2024 14:29:34 +0200 Subject: [PATCH 053/133] add delta price --- .../TokenDetails/ChartDetails/MarketPriceOverview.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx index 17bdad9564..f1f0503580 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx @@ -33,13 +33,12 @@ export const TokenMarketPriceOverview = ({ chartData, detailInfo, tokenInfo, isD tokenActivity: { data24h }, } = usePortfolioTokenActivity(); - const priceChangeProcent = isPrimaryToken - ? detailInfo?.changePercent || changePercent - : !isEmpty(data24h) && data24h[tokenInfo?.info?.id][1].price.change; + const deltaPriceChange = + !isPrimaryToken && data24h[tokenInfo?.info?.id][1].price.close - data24h[tokenInfo?.info?.id][1].price.open; + const priceChangeProcent = isPrimaryToken ? detailInfo?.changePercent || changePercent : !isEmpty(data24h) && deltaPriceChange; const priceChangeValue = isPrimaryToken ? detailInfo?.changeValue || changeValue : !isEmpty(data24h) && data24h[tokenInfo?.info?.id][1].price.close; - return ( From 4ae9586a588483e0e0d7d3460d86f60510c8c992 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Wed, 13 Nov 2024 15:07:30 +0200 Subject: [PATCH 054/133] updates --- .../TokenDetails/ChartDetails/MarketPriceOverview.tsx | 5 ++++- .../TokenDetails/OverviewPerformanceDetails/Overview.tsx | 6 ++---- .../features/portfolio/useCases/TokensTable/StatsTable.tsx | 4 ++-- .../portfolio/useCases/TokensTable/TableColumnsChip.tsx | 7 ++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx index f1f0503580..f813715d41 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx @@ -34,7 +34,10 @@ export const TokenMarketPriceOverview = ({ chartData, detailInfo, tokenInfo, isD } = usePortfolioTokenActivity(); const deltaPriceChange = - !isPrimaryToken && data24h[tokenInfo?.info?.id][1].price.close - data24h[tokenInfo?.info?.id][1].price.open; + !isPrimaryToken && + !isEmpty(data24h) && + data24h[tokenInfo?.info?.id][1].price.close - data24h[tokenInfo?.info?.id][1].price.open; + const priceChangeProcent = isPrimaryToken ? detailInfo?.changePercent || changePercent : !isEmpty(data24h) && deltaPriceChange; const priceChangeValue = isPrimaryToken ? detailInfo?.changeValue || changeValue diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx index f660d8117a..24f0bd0497 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx @@ -37,9 +37,7 @@ const Overview = ({ tokenInfo }: Props): JSX.Element => { - {tokenInfo.info.metadata.website && ( - - )} + {} {isPrimary && } @@ -114,7 +112,7 @@ const TokenOverviewSection = ({ ) : isExternalLink ? ( - {value} + {value || '-'} ) : ( {value} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx index 33d5ab94f8..f091161656 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/StatsTable.tsx @@ -95,7 +95,7 @@ const StatsTable = ({ data }: Props): JSX.Element => { - + { /> - + diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 0bad23c88a..465a295dc2 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -66,9 +66,11 @@ export const TokenPriceChangeChip = ({ const { changePercent, variantPnl } = priceChange(tokenPriceOpen, tokenPriceClose); + // console.log('ptTokenDataInterval?.[50]?.changePercent', ptTokenDataInterval?.[50]?.changePercent); + const noDataToDisplay = Number.isNaN(changePercent); - if (noDataToDisplay) { + if (noDataToDisplay || changePercent === undefined) { return ( ); } - return ( - + {noDataToDisplay ? '-' : formatPriceChange( From 98b4a002a4a742e136ecc1d07bc431c41ebe7c82 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Wed, 13 Nov 2024 15:21:40 +0200 Subject: [PATCH 055/133] update overview --- .../OverviewPerformanceDetails/Overview.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx index 24f0bd0497..62bd9d0712 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx @@ -37,7 +37,7 @@ const Overview = ({ tokenInfo }: Props): JSX.Element => { - {} + {isPrimary && } @@ -80,9 +80,9 @@ const TokenOverviewSection = ({ withCopy, isPrimary, }: TokenOverviewSectionTypes) => { - if (!value && !isPrimary) { - return <>; - } + // if (!value && !isPrimary) { + // return <>; + // } const { explorer } = usePortfolio(); const theme: any = useTheme(); @@ -115,7 +115,7 @@ const TokenOverviewSection = ({ {value || '-'} ) : ( - {value} + {value || '-'} )} {withCopy && } From 7b289923b103c6651140db39cff0e1917c6f33e2 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Wed, 13 Nov 2024 16:00:52 +0200 Subject: [PATCH 056/133] fix search and website --- .../app/UI/components/Input/SearchInput.tsx | 24 ++++++++++--------- .../OverviewPerformanceDetails/Overview.tsx | 8 ++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx b/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx index 4901b59a8c..15b9fc8077 100644 --- a/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx +++ b/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx @@ -1,17 +1,19 @@ -import React from 'react'; -import { Input, InputAdornment, InputProps, styled, useTheme } from '@mui/material'; -import { useRef } from 'react'; +import { InputAdornment, InputProps, OutlinedInput, styled, useTheme } from '@mui/material'; +import React, { useRef } from 'react'; import { Icon } from './../icons/index'; -const StyledInput = styled(Input)(({ theme }: any) => ({ - borderRadius: `${theme.shape.borderRadius}px`, - width: '320px', +const StyledInput = styled(OutlinedInput)(({ theme }: any) => ({ + width: '370px', height: '40px', - padding: `${theme.spacing(1)} ${theme.spacing(2)} ${theme.spacing(1)} ${theme.spacing(1)}`, - border: '1px solid', - borderColor: theme.palette.ds.gray_400, - 'input::placeholder': { - color: theme.palette.ds.gray_600, + padding: '10px 12px', + '& svg': { + '& path': { + fill: theme.palette.ds.el_gray_low, + }, + }, + '& input::placeholder': { + color: theme.palette.ds.el_gray_low, + opacity: 1, }, })); diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx index 62bd9d0712..e9d263aae4 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/OverviewPerformanceDetails/Overview.tsx @@ -37,9 +37,11 @@ const Overview = ({ tokenInfo }: Props): JSX.Element => { - - - {isPrimary && } + {isPrimary ? ( <> From 217deca3918fb86e21c0d8fbbfc7990bc3bb64f3 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Wed, 13 Nov 2024 16:35:48 +0200 Subject: [PATCH 057/133] add reusable back button --- .../app/UI/components/BackButton.tsx | 26 ++++++++++++++++ .../app/UI/components/Input/SearchInput.tsx | 4 +-- .../app/UI/components/index.ts | 3 +- .../portfolio/common/hooks/useStrings.ts | 4 +-- .../useCases/TokenDetails/TokenDetails.tsx | 30 +++++-------------- .../components/wallet/assets/NFTDetails.js | 6 ++-- 6 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 packages/yoroi-extension/app/UI/components/BackButton.tsx diff --git a/packages/yoroi-extension/app/UI/components/BackButton.tsx b/packages/yoroi-extension/app/UI/components/BackButton.tsx new file mode 100644 index 0000000000..7f50212dbb --- /dev/null +++ b/packages/yoroi-extension/app/UI/components/BackButton.tsx @@ -0,0 +1,26 @@ +import { Button, Typography } from '@mui/material'; +import { styled } from '@mui/material/styles'; +import React from 'react'; +import { ReactComponent as BackIcon } from '../../assets/images/assets-page/back-arrow.inline.svg'; + +const SButton = styled(Button)(({ theme }: any) => ({ + color: theme.palette.ds.el_gray_medium, + '&.MuiButton-sizeMedium': { + padding: '13px 16px', + }, + '& svg': { + '& path': { + fill: theme.palette.ds.el_gray_medium, + }, + }, +})); + +export const BackButton = ({ label, onAction }: { label: string; onAction: () => void }) => { + return ( + }> + + {label} + + + ); +}; diff --git a/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx b/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx index 15b9fc8077..9be0e5b39d 100644 --- a/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx +++ b/packages/yoroi-extension/app/UI/components/Input/SearchInput.tsx @@ -3,9 +3,9 @@ import React, { useRef } from 'react'; import { Icon } from './../icons/index'; const StyledInput = styled(OutlinedInput)(({ theme }: any) => ({ - width: '370px', + width: '320px', height: '40px', - padding: '10px 12px', + padding: '8px', '& svg': { '& path': { fill: theme.palette.ds.el_gray_low, diff --git a/packages/yoroi-extension/app/UI/components/index.ts b/packages/yoroi-extension/app/UI/components/index.ts index dc48700ddb..32e85462b9 100644 --- a/packages/yoroi-extension/app/UI/components/index.ts +++ b/packages/yoroi-extension/app/UI/components/index.ts @@ -1,3 +1,4 @@ +export * from './BackButton'; export * from './buttons/CopyButton'; export * from './Card'; export * from './Chip'; @@ -10,5 +11,5 @@ export * from './Skeleton'; export * from './Tooltip'; export * from './TransactionFailed/TransactionFailed'; export * from './TransactionSubmitted/TransactionSubmitted'; -export * from './wrappers/IconButtonWrapper'; export * from './wrappers/GradientBgBox'; +export * from './wrappers/IconButtonWrapper'; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useStrings.ts b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useStrings.ts index 82622a5c9a..a538de9ed1 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useStrings.ts +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/useStrings.ts @@ -70,8 +70,8 @@ export const messages = Object.freeze( defaultMessage: '!!!in 24 hours', }, backToPortfolio: { - id: 'portfolio.button.backToPortfolio', - defaultMessage: '!!!Back to portfolio', + id: 'global.labels.back', + defaultMessage: '!!!Back', }, swap: { id: 'portfolio.button.swap', diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx index 62d40dc7fb..6b69aac13f 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx @@ -1,8 +1,7 @@ -import { Box, Divider, Stack, Typography } from '@mui/material'; +import { Box, Button, Divider, Stack } from '@mui/material'; import { styled, useTheme } from '@mui/material/styles'; import React from 'react'; -import { ReactComponent as BackIcon } from '../../../../../assets/images/assets-page/back-arrow.inline.svg'; -import { Card } from '../../../../components'; +import { BackButton, Card } from '../../../../components'; import NavigationButton from '../../common/components/NavigationButton'; import { useNavigateTo } from '../../common/hooks/useNavigateTo'; import { useStrings } from '../../common/hooks/useStrings'; @@ -23,7 +22,11 @@ interface Props { tokenInfo: TokenInfoType; } -const IconWrapper = styled(Box)(({ theme }: any) => ({ +const SButton = styled(Button)(({ theme }: any) => ({ + color: theme.palette.ds.el_gray_medium, + '&.MuiButton-sizeMedium': { + padding: '13px 16px', + }, '& svg': { '& path': { fill: theme.palette.ds.el_gray_medium, @@ -40,24 +43,7 @@ const TokenDetails = ({ tokenInfo }: Props): JSX.Element => { return (
- navigateTo.portfolio()} - sx={{ - color: theme.palette.ds.black_static, - display: 'flex', - gap: theme.spacing(2), - alignItems: 'center', - cursor: 'pointer', - }} - > - - - - - {strings.backToPortfolio} - - + navigateTo.portfolio()} /> navigateTo.swapPage(tokenInfo.info.id)} label={strings.swap} /> navigateTo.sendPage()} label={strings.send} /> diff --git a/packages/yoroi-extension/app/components/wallet/assets/NFTDetails.js b/packages/yoroi-extension/app/components/wallet/assets/NFTDetails.js index bbc0e9c07f..442e9deadf 100644 --- a/packages/yoroi-extension/app/components/wallet/assets/NFTDetails.js +++ b/packages/yoroi-extension/app/components/wallet/assets/NFTDetails.js @@ -121,7 +121,7 @@ const SImageButton = styled(IconButton)(({ theme }) => ({ })); const STypography = styled(Typography)(({ theme }) => ({ - color: theme.palette.ds.el_gray_medium + color: theme.palette.ds.el_gray_medium, })); function NFTDetails({ nftInfo, network, intl, nextNftId, prevNftId, tab }: Props & Intl): Node { @@ -172,7 +172,9 @@ function NFTDetails({ nftInfo, network, intl, nextNftId, prevNftId, tab }: Props return ( }> - {intl.formatMessage(messages.back)} + + {intl.formatMessage(messages.back)} + Date: Thu, 14 Nov 2024 00:04:17 +0300 Subject: [PATCH 058/133] use browser info API for browser detection --- .../app/api/localStorage/index.js | 2 +- .../app/api/localStorage/primitives.js | 12 +-- .../terms-of-use/OptForAnalyticsForm.js | 2 +- .../app/components/widgets/Support.js | 4 +- .../categories/BlockchainSettingsPage.js | 4 +- .../containers/wallet/staking/SeizaFetcher.js | 6 +- packages/yoroi-extension/app/environment.js | 79 ++++++++++++++++++- .../app/stores/ada/AdaStateFetchStore.js | 4 +- .../app/stores/lib/TrezorWrapper.js | 2 +- .../app/stores/toplevel/ProfileStore.js | 6 +- .../app/stores/toplevel/StateFetchStore.js | 4 +- packages/yoroi-extension/app/uri-protocols.js | 2 +- .../app/utils/userAgentInfo.js | 48 ----------- .../chrome/extension/background.js | 6 +- 14 files changed, 105 insertions(+), 76 deletions(-) diff --git a/packages/yoroi-extension/app/api/localStorage/index.js b/packages/yoroi-extension/app/api/localStorage/index.js index 38e868b7e5..92324034c3 100644 --- a/packages/yoroi-extension/app/api/localStorage/index.js +++ b/packages/yoroi-extension/app/api/localStorage/index.js @@ -341,7 +341,7 @@ export default class LocalStorageApi { // Firefox demands us to re-show the data collection consent screen, so change the key for Firefox _getIsAnalyticsAllowedKey: () => string = () => { let key = storageKeys.IS_ANALYTICS_ALLOWED; - if (environment.userAgentInfo.isFirefox()) { + if (environment.isFirefox()) { key += '-firefox'; } return key; diff --git a/packages/yoroi-extension/app/api/localStorage/primitives.js b/packages/yoroi-extension/app/api/localStorage/primitives.js index a39af38800..ef525349b6 100644 --- a/packages/yoroi-extension/app/api/localStorage/primitives.js +++ b/packages/yoroi-extension/app/api/localStorage/primitives.js @@ -47,7 +47,7 @@ const getStorageItemInWeb = async ( /** passing undefined gives you the whole storage as a JSON string */ export async function getLocalItem(key: string | void): Promise { - const isExtension = environment.userAgentInfo.isExtension(); + const isExtension = environment.isExtension(); if (isExtension) { return await getStorageItemInExtension(key); } @@ -59,7 +59,7 @@ export async function getLocalItem(key: string | void): Promise { // ===== export async function setLocalItem(key: string, value: string): Promise { - const isExtension = environment.userAgentInfo.isExtension(); + const isExtension = environment.isExtension(); if (isExtension) { await new Promise((resolve, reject) => { chrome.storage.local.set( @@ -80,7 +80,7 @@ export async function setLocalItem(key: string, value: string): Promise { // ======== export async function removeLocalItem(key: string): Promise { - const isExtension = environment.userAgentInfo.isExtension(); + const isExtension = environment.isExtension(); if (isExtension) { await new Promise((resolve, reject) => { @@ -98,7 +98,7 @@ export async function removeLocalItem(key: string): Promise { } export async function clear(): Promise { - const isExtension = environment.userAgentInfo.isExtension(); + const isExtension = environment.isExtension(); if (isExtension) { await new Promise((resolve, reject) => { chrome.storage.local.clear( @@ -136,7 +136,7 @@ type StorageChange = { [key: string]: {| export function addListener( listener: StorageChange => void, ): void { - const isExtension = environment.userAgentInfo.isExtension(); + const isExtension = environment.isExtension(); if (isExtension) { chrome.storage.onChanged.addListener((changes, _area) => { listener(changes); @@ -168,7 +168,7 @@ export function addListener( // ======= export async function isEmptyStorage(): Promise { - const isExtension = environment.userAgentInfo.isExtension(); + const isExtension = environment.isExtension(); if (isExtension) { const isEmpty = await getStorageItemInExtension().then( (data: Object) => Object.keys(data).length === 0 diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js index 35e584142f..4047cbac9b 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js @@ -97,7 +97,7 @@ export default class OptForAnalyticsForm extends Component { const isStartupScreen = variant === 'startup'; const isSettingsScreen = variant === 'settings'; - const isFirefox = environment.userAgentInfo.isFirefox(); + const isFirefox = environment.isFirefox(); const analyticsDetails = [ [YesIcon, messages.line1], diff --git a/packages/yoroi-extension/app/components/widgets/Support.js b/packages/yoroi-extension/app/components/widgets/Support.js index 37e0df0313..abdccd642c 100644 --- a/packages/yoroi-extension/app/components/widgets/Support.js +++ b/packages/yoroi-extension/app/components/widgets/Support.js @@ -35,8 +35,8 @@ export default class Support extends Component { } getUrl(): string | null { - if (!environment.userAgentInfo.isExtension()) return null; - const agent = environment.userAgentInfo.isFirefox() ? 'firefox' : 'chrome'; + if (!environment.isExtension()) return null; + const agent = environment.isFirefox() ? 'firefox' : 'chrome'; return `https://emurgo.github.io/yoroi-support/?source=${agent}&extensionId=${window.location.hostname}`; } diff --git a/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js index 6d5a5345e5..5718cddb54 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/BlockchainSettingsPage.js @@ -34,10 +34,10 @@ export default class BlockchainSettingsPage extends Component registerProtocols()} - isFirefox={environment.userAgentInfo.isFirefox()} + isFirefox={environment.isFirefox()} /> ) : null; diff --git a/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js b/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js index a56ea7016b..9fb4297698 100644 --- a/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js +++ b/packages/yoroi-extension/app/containers/wallet/staking/SeizaFetcher.js @@ -201,8 +201,8 @@ class SeizaFetcher extends Component { _getBrowserReplacement(): string { // 1) handle Yoroi running as an extension - if (environment.userAgentInfo.isExtension()) { - if (environment.userAgentInfo.isFirefox()) { + if (environment.isExtension()) { + if (environment.isFirefox()) { return 'firefox&mozId=' + location.hostname; } // otherwise assume Chrome @@ -211,7 +211,7 @@ class SeizaFetcher extends Component { } // 2) Handle Yoroi running as a website - if (environment.userAgentInfo.isFirefox()) { + if (environment.isFirefox()) { return 'firefox&host' + location.host; } // otherwise assume Chrome diff --git a/packages/yoroi-extension/app/environment.js b/packages/yoroi-extension/app/environment.js index 34ba0ed748..b645433b12 100644 --- a/packages/yoroi-extension/app/environment.js +++ b/packages/yoroi-extension/app/environment.js @@ -7,6 +7,75 @@ import userAgentInfo from './utils/userAgentInfo'; // populated by ConfigWebpackPlugin declare var CONFIG: ConfigType; +declare var browser; + +const IS_FIREFOX_BROWSER_INFO: [boolean | null] = [null]; +if (typeof browser !== 'undefined') { + browser.runtime.getBrowserInfo().then(({ name }) => { + const isFirefox = name === 'Firefox'; + console.debug(`isFirefox = ${String(isFirefox)} / defined by browser info API`) + IS_FIREFOX_BROWSER_INFO[0] = isFirefox; + }); +} + +function isChromeProtocol(): boolean { + return location.protocol === 'chrome-extension:'; +} + +function isMozProtocol(): boolean { + return location.protocol === 'moz-extension:'; +} + +function isExtension(): boolean { + return isChromeProtocol() || isMozProtocol(); +} + +function isFirefox(): boolean { + if (IS_FIREFOX_BROWSER_INFO[0] != null) { + return IS_FIREFOX_BROWSER_INFO[0]; + } + + if (isMozProtocol()) { + return true; + } + // if an extension type that isn't Firefox, return false + if (isExtension()) { + return false; + } + + // $FlowExpectedError[cannot-resolve-name] InstallTrigger is a global from the browser + return typeof InstallTrigger !== 'undefined'; +} + +function isChrome(): boolean { + /** + * This method returns true for all browser that uses `chrome-extension:` protocol, + *hence it will return true for browsers like Google Chrome, Brave + */ + if (isChromeProtocol()) { + return true; + } + // if an extension type that isn't Chrome-based, return false + if (isExtension()) { + return false; + } + + return !!window.chrome + && (!!window.chrome.webstore || !!window.chrome.runtime) + && !isFirefox(); +} + +function canRegisterProtocol(): boolean { + // Moz-Extension specify the protocol in the manifest not at runtime + if (isExtension() && isFirefox()) { + return false; + } + // Can only register a protocol to a website if it's https + if (!isExtension() && window.location.protocol !== 'https:') { + return false; + } + return true; +} function getVersion(): string { const genManifest = require('../chrome/manifest.' + CONFIG.network.name); @@ -43,8 +112,12 @@ export const environment = (( getWalletRefreshInterval: () => CONFIG.app.walletRefreshInterval, getServerStatusRefreshInterval: () => CONFIG.app.serverStatusRefreshInterval, userAgentInfo, + isFirefox, + isChrome, + isExtension, + canRegisterProtocol, externalPrivacyPolicyURL: () => { - if (userAgentInfo.isFirefox()) { + if (isFirefox()) { return FIREFOX_PRIVACY_POLICY_URL; } return null; @@ -64,6 +137,10 @@ export const environment = (( isProduction: void => boolean, getWalletRefreshInterval: void => number, getServerStatusRefreshInterval: void => number, + isExtension: void => boolean, + isFirefox: void => boolean, + isChrome: void => boolean, + canRegisterProtocol: void => boolean, externalPrivacyPolicyURL: void => ?string, userAgentInfo: UserAgentInfo, isLight: boolean, diff --git a/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js b/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js index 1b7493ca6c..a7b407e77e 100644 --- a/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js +++ b/packages/yoroi-extension/app/stores/ada/AdaStateFetchStore.js @@ -25,10 +25,10 @@ export default class AdaStateFetchStore< () => environment.getVersion(), () => this.stores.profile.currentLocale, () => { - if (environment.userAgentInfo.isFirefox()) { + if (environment.isFirefox()) { return 'firefox'; } - if (environment.userAgentInfo.isChrome()) { + if (environment.isChrome()) { return 'chrome'; } return '-'; diff --git a/packages/yoroi-extension/app/stores/lib/TrezorWrapper.js b/packages/yoroi-extension/app/stores/lib/TrezorWrapper.js index 7e158467a9..ca1f4be7f2 100644 --- a/packages/yoroi-extension/app/stores/lib/TrezorWrapper.js +++ b/packages/yoroi-extension/app/stores/lib/TrezorWrapper.js @@ -29,7 +29,7 @@ export function getTrezorManifest(): Manifest { const trezorManifest: Manifest = { email: manifest.EMAIL, appUrl: (() => { - if (environment.userAgentInfo.isFirefox()) { + if (environment.isFirefox()) { // Set appUrl for `moz-extension:` protocol using browser (like Firefox) return manifest.appURL.FIREFOX; } diff --git a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js index c3ae70f127..e610ec0fa5 100644 --- a/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/ProfileStore.js @@ -36,7 +36,7 @@ export default class ProfileStore extends BaseProfileStore boolean | Promise, action: void => Promise |}> = [ // Firefox policy requires this to be the first - ...(environment.userAgentInfo.isFirefox() ? [this._analyticsStep] : []), + ...(environment.isFirefox() ? [this._analyticsStep] : []), { isDone: () => this.isCurrentLocaleSet, action: async () => { @@ -59,7 +59,7 @@ export default class ProfileStore extends BaseProfileStore this.isComplexityLevelSelected, action: async () => { @@ -81,7 +81,7 @@ export default class ProfileStore extends BaseProfileStore !environment.userAgentInfo.canRegisterProtocol() || this.isUriSchemeAccepted, + isDone: () => !environment.canRegisterProtocol() || this.isUriSchemeAccepted, action: async () => { const route = ROUTES.PROFILE.URI_PROMPT; if (this.stores.app.currentRoute === route) { diff --git a/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js b/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js index 4069caec18..3e0b46b8eb 100644 --- a/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js +++ b/packages/yoroi-extension/app/stores/toplevel/StateFetchStore.js @@ -26,10 +26,10 @@ export default class StateFetchStore< () => environment.getVersion(), () => this.stores.profile.currentLocale, () => { - if (environment.userAgentInfo.isFirefox()) { + if (environment.isFirefox()) { return 'firefox'; } - if (environment.userAgentInfo.isChrome()) { + if (environment.isChrome()) { return 'chrome'; } return '-'; diff --git a/packages/yoroi-extension/app/uri-protocols.js b/packages/yoroi-extension/app/uri-protocols.js index 22d52917e6..d04cf3c1e4 100644 --- a/packages/yoroi-extension/app/uri-protocols.js +++ b/packages/yoroi-extension/app/uri-protocols.js @@ -12,7 +12,7 @@ const cardanoURI = { }; const registerProtocols = () => { - if (!environment.userAgentInfo.canRegisterProtocol()) { + if (!environment.canRegisterProtocol()) { Logger.error(`uri-protocols:registerProtocols cannot use registerProtocolHandler on this page`); return; } diff --git a/packages/yoroi-extension/app/utils/userAgentInfo.js b/packages/yoroi-extension/app/utils/userAgentInfo.js index cfa0156b3b..c39dba82ba 100644 --- a/packages/yoroi-extension/app/utils/userAgentInfo.js +++ b/packages/yoroi-extension/app/utils/userAgentInfo.js @@ -5,57 +5,9 @@ import UAParser from 'ua-parser-js'; export class UserAgentInfo { // Refer: https://www.npmjs.com/package/ua-parser-js ua: { ... }; - - isChrome: void => boolean = () => { - /** - * This method returns true for all browser that uses `chrome-extension:` protocol, - *hence it will return true for browsers like Google Chrome, Brave - */ - if (location.protocol === 'chrome-extension:') { - return true; - } - // if an extension type that isn't Chrome-based, return false - if (this.isExtension()) { - return false; - } - - return !!window.chrome && - (!!window.chrome.webstore || !!window.chrome.runtime) && - !this.isFirefox(); - }; - isFirefox: void => boolean = () => { - if (location.protocol === 'moz-extension:') { - return true; - } - // if an extension type that isn't Firefox, return false - if (this.isExtension()) { - return false; - } - - // $FlowExpectedError[cannot-resolve-name] InstallTrigger is a global from the browser - return typeof InstallTrigger !== 'undefined'; - } - isExtension: void => boolean = () => { - return ( - location.protocol === 'chrome-extension:' || location.protocol === 'moz-extension:' - ); - } - constructor() { this.ua = (new UAParser()).getResult(); } - - canRegisterProtocol: (() => boolean) = () => { - // Moz-Extension specify the protocol in the manifest not at runtime - if (this.isExtension() && this.isFirefox()) { - return false; - } - // Can only register a protocol to a website if it's https - if (!this.isExtension() && window.location.protocol !== 'https:') { - return false; - } - return true; - } } export default (new UserAgentInfo(): UserAgentInfo); diff --git a/packages/yoroi-extension/chrome/extension/background.js b/packages/yoroi-extension/chrome/extension/background.js index 02fb41cc6b..95d60fa653 100644 --- a/packages/yoroi-extension/chrome/extension/background.js +++ b/packages/yoroi-extension/chrome/extension/background.js @@ -326,10 +326,10 @@ async function createFetcher( () => environment.getVersion(), () => locale, () => { - if (environment.userAgentInfo.isFirefox()) { + if (environment.isFirefox()) { return 'firefox'; } - if (environment.userAgentInfo.isChrome()) { + if (environment.isChrome()) { return 'chrome'; } return '-'; @@ -1818,7 +1818,7 @@ function handleExchangeRedirectMessage(message, sender) { } } -if (environment.userAgentInfo.isFirefox()) { +if (environment.isFirefox()) { browser.runtime.onInstalled.addListener(async () => { const analyticsFlag = await new LocalStorageApi().loadIsAnalyticsAllowed(); if (analyticsFlag == null) { From c8e53d8b135fbbde607fd7d734e6e2f810c3aed6 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 14 Nov 2024 00:21:29 +0300 Subject: [PATCH 059/133] privacy policy link added to analytics consent page for FF. Data collection wording updated. --- .../terms-of-use/OptForAnalyticsForm.js | 46 ++++++++++++++----- .../app/i18n/locales/en-US.json | 3 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js index 4047cbac9b..a8b5021921 100644 --- a/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js +++ b/packages/yoroi-extension/app/components/profile/terms-of-use/OptForAnalyticsForm.js @@ -49,9 +49,13 @@ const messages = defineMessages({ id: 'profile.analytics.learnMore', defaultMessage: '!!!Learn more about user insights', }, + privacyNotice: { + id: 'profile.analytics.seePrivacyNotice', + defaultMessage: '!!!See Privacy Notice', + }, collectedData: { id: 'profile.analytics.collectedData', - defaultMessage: '!!!Collected data includes: visited pages, browser version, selected language, time of analytical events', + defaultMessage: '!!!Collected data includes: visited Yoroi extension pages, browser version, selected language, time of analytical events', }, rejectionImpact: { id: 'profile.analytics.rejectionImpact', @@ -153,16 +157,36 @@ export default class OptForAnalyticsForm extends Component { {isFirefox ? ( - - {intl.formatMessage(messages.collectedData)} + + + {intl.formatMessage(messages.collectedData)} + + + + + {intl.formatMessage(messages.privacyNotice)} + + ) : null} diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index 20c1ff5235..91ce931d76 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -222,8 +222,9 @@ "profile.analytics.accept": "Accept", "profile.analytics.allow": "Allow Yoroi analytics", "profile.analytics.learnMore": "Learn more about user insights", + "profile.analytics.seePrivacyNotice": "See Privacy Notice", "profile.analytics.rejectionImpact": "Opting out won’t impact your experience", - "profile.analytics.collectedData": "Collected data includes: visited pages, browser version, selected language, time of analytical events", + "profile.analytics.collectedData": "Collected data includes: visited Yoroi extension pages, browser version, selected language, time of analytical events", "profile.analytics.line1": "Anonymous analytics data", "profile.analytics.line2": "You can always opt-out via Settings", "profile.analytics.line3": "We can not access private keys", From 727d8c6b5218dcf40f10d4f98e71021503bc602d Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 14 Nov 2024 00:23:30 +0300 Subject: [PATCH 060/133] Version bump: ff/5.4.280 --- packages/yoroi-extension/package-lock.json | 4 ++-- packages/yoroi-extension/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/package-lock.json b/packages/yoroi-extension/package-lock.json index 0a688b6e04..40e076ab95 100644 --- a/packages/yoroi-extension/package-lock.json +++ b/packages/yoroi-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "yoroi", - "version": "5.4.279", + "version": "5.4.280", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "yoroi", - "version": "5.4.279", + "version": "5.4.280", "license": "MIT", "dependencies": { "@amplitude/analytics-browser": "^2.1.3", diff --git a/packages/yoroi-extension/package.json b/packages/yoroi-extension/package.json index 40954db013..60480d288f 100644 --- a/packages/yoroi-extension/package.json +++ b/packages/yoroi-extension/package.json @@ -1,6 +1,6 @@ { "name": "yoroi", - "version": "5.4.279", + "version": "5.4.280", "description": "Cardano ADA wallet", "scripts": { "dev-mv2": "rimraf dev/ && NODE_OPTIONS=--openssl-legacy-provider babel-node scripts-mv2/build --type=debug --env 'mainnet'", From 1bcc36dd3ad47bd9081aca584436cb69c70d4564 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Thu, 14 Nov 2024 01:17:35 +0300 Subject: [PATCH 061/133] eslint fixes --- packages/yoroi-extension/app/environment.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/environment.js b/packages/yoroi-extension/app/environment.js index b645433b12..e2191559a9 100644 --- a/packages/yoroi-extension/app/environment.js +++ b/packages/yoroi-extension/app/environment.js @@ -12,9 +12,12 @@ declare var browser; const IS_FIREFOX_BROWSER_INFO: [boolean | null] = [null]; if (typeof browser !== 'undefined') { browser.runtime.getBrowserInfo().then(({ name }) => { - const isFirefox = name === 'Firefox'; - console.debug(`isFirefox = ${String(isFirefox)} / defined by browser info API`) - IS_FIREFOX_BROWSER_INFO[0] = isFirefox; + const isff = name === 'Firefox'; + console.debug(`isFirefox = ${String(isff)} / defined by browser info API`) + IS_FIREFOX_BROWSER_INFO[0] = isff; + return null; + }).catch(e => { + console.error('failed to call browser info API', e); }); } From 456387768f1ae38b4a392a5474fa59b73ff31282 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 14 Nov 2024 09:32:22 +0200 Subject: [PATCH 062/133] change refech interval --- .../features/portfolio/common/hooks/usePortfolioTokenChart.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts index 1d96031eed..b4a0ab586c 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/hooks/usePortfolioTokenChart.ts @@ -92,7 +92,7 @@ export const useGetPortfolioTokenChart = ( cacheTime: time.oneHour, retryDelay: time.oneSecond, optimisticResults: true, - refetchInterval: time.halfHour, + refetchInterval: time.oneMinute, useErrorBoundary: true, refetchOnMount: false, enabled: tokenInfo && tokenInfo.info?.id.length === 0, From 86123a09bc55324da3e0c72c97b10a76424be6b8 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 14 Nov 2024 09:38:52 +0200 Subject: [PATCH 063/133] refactor pln tag --- .../app/UI/features/portfolio/common/components/PlnTag.tsx | 3 +++ .../portfolio/useCases/TokensTable/TableColumnsChip.tsx | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/components/PlnTag.tsx b/packages/yoroi-extension/app/UI/features/portfolio/common/components/PlnTag.tsx index 9d2a580ce9..8ba1598467 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/components/PlnTag.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/components/PlnTag.tsx @@ -38,6 +38,9 @@ const PnlTag = ({ children, withIcon = false, variant = 'neutral' }: Props) => { {children} + + % + ); }; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 465a295dc2..3ab69c0cdb 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -90,13 +90,12 @@ export const TokenPriceChangeChip = ({ return ( - + {noDataToDisplay ? '-' : formatPriceChange( isPrimaryToken && timeInterval !== undefined ? ptTokenDataInterval?.[50]?.changePercent ?? 0 : changePercent ?? 0 )} - % From f6be6538601bed1f7985d66ddf7353c6c48b1525 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 14 Nov 2024 16:15:19 +0800 Subject: [PATCH 064/133] fix ttl deserialization --- .../yoroi-extension/app/domain/CardanoShelleyTransaction.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js b/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js index 4beaca3ff4..f4f3fa1322 100644 --- a/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js +++ b/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js @@ -219,7 +219,11 @@ export function deserializeTransactionCtorData( state: serializedData.state, errorMsg: serializedData.errorMsg, certificates: serializedData.certificates, - ttl: serializedData.ttl && new BigNumber(serializedData.ttl), + ttl: serializedData.ttl && new BigNumber( + typeof serializedData.ttl === 'object' + ? { ...serializedData.ttl, _isBigNumber: true } + : serializedData.ttl + ), metadata: serializedData.metadata, withdrawals: serializedData.withdrawals.map(({ address, value }) => ({ address, From f3be1f0fbf4be19b213d9c8db1b2b8ac4f66b57a Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 14 Nov 2024 12:04:46 +0200 Subject: [PATCH 065/133] update UI to new requirements --- .../TokenDetails/ChartDetails/MarketPriceOverview.tsx | 10 ++++++++-- .../useCases/TokenDetails/HeaderDetails/Header.tsx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx index f813715d41..5601e79fd2 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/ChartDetails/MarketPriceOverview.tsx @@ -43,9 +43,15 @@ export const TokenMarketPriceOverview = ({ chartData, detailInfo, tokenInfo, isD ? detailInfo?.changeValue || changeValue : !isEmpty(data24h) && data24h[tokenInfo?.info?.id][1].price.close; return ( - + - {tokenInfo.info.name} {strings.marketPrice} + {strings.marketPrice} diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx index 43c9278fd3..6cc7e50a8c 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/HeaderDetails/Header.tsx @@ -51,7 +51,7 @@ const HeaderSection = ({ tokenInfo }: Props): JSX.Element => { return ( - {`${tokenInfo.info.name} ${strings.balance}`} + {strings.balance} From a0d9123f863abc80e7847a128c28712e497e59f3 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 14 Nov 2024 02:15:35 +0800 Subject: [PATCH 066/133] connector returns user reject when user closes signing popup --- .../app/connector/containers/SignTxContainer.js | 4 ++-- .../yoroi-extension/app/connector/stores/ConnectorStore.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js index 9355a8ddba..a5941aeac0 100644 --- a/packages/yoroi-extension/app/connector/containers/SignTxContainer.js +++ b/packages/yoroi-extension/app/connector/containers/SignTxContainer.js @@ -51,10 +51,10 @@ export default class SignTxContainer extends Component< // will throw a WrongPasswordError if password is wrong await getPrivateStakingKey({ publicDeriverId: deriver.publicDeriverId, password }); } + await this.props.actions.connector.confirmSignInTx.trigger(password); window.removeEventListener('beforeunload', this.onUnload); window.removeEventListener('unload', this.onUnload); - - await this.props.actions.connector.confirmSignInTx.trigger(password); + window.close(); }; onCancel: () => void = () => { window.removeEventListener('beforeunload', this.onUnload); diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index b5fb9e2bff..5c7b730e80 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -361,7 +361,6 @@ export default class ConnectorStore extends Store { this.actions.connector.cancelSignInTx.remove(this._cancelSignInTx); await ampli.dappPopupSignTransactionSubmitted(); - this._closeWindow(); }; @action _cancelSignInTx: void => void = () => { From bf4786adff7c0047cf5ba0f55311f2933e8ccff8 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 14 Nov 2024 14:55:47 +0200 Subject: [PATCH 067/133] fix flow --- .../features/portfolio/common/components/Table.tsx | 8 ++++---- .../useCases/TokenDetails/TokenDetails.tsx | 14 +------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/common/components/Table.tsx b/packages/yoroi-extension/app/UI/features/portfolio/common/components/Table.tsx index 105f4681aa..fe9edac014 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/common/components/Table.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/common/components/Table.tsx @@ -1,10 +1,10 @@ -import React, { ReactElement, ReactNode, cloneElement } from 'react'; -import { Table as MuiTable, TableBody, Stack, Box, Typography } from '@mui/material'; +import { Box, Table as MuiTable, Stack, TableBody, Typography } from '@mui/material'; import { useTheme } from '@mui/material/styles'; -import { useStrings } from '../hooks/useStrings'; +import React, { ReactElement, ReactNode, cloneElement } from 'react'; import noResultsPng from '../assets/illustrations/no-results.png'; -import SortableTableHead from './SortableTableHead'; +import { useStrings } from '../hooks/useStrings'; import { IHeadCell } from '../types/table'; +import SortableTableHead from './SortableTableHead'; interface Props { name: string; diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx index 6b69aac13f..b5da8d1ba5 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokenDetails/TokenDetails.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Divider, Stack } from '@mui/material'; +import { Box, Divider, Stack } from '@mui/material'; import { styled, useTheme } from '@mui/material/styles'; import React from 'react'; import { BackButton, Card } from '../../../../components'; @@ -22,18 +22,6 @@ interface Props { tokenInfo: TokenInfoType; } -const SButton = styled(Button)(({ theme }: any) => ({ - color: theme.palette.ds.el_gray_medium, - '&.MuiButton-sizeMedium': { - padding: '13px 16px', - }, - '& svg': { - '& path': { - fill: theme.palette.ds.el_gray_medium, - }, - }, -})); - const TokenDetails = ({ tokenInfo }: Props): JSX.Element => { const theme: any = useTheme(); const navigateTo = useNavigateTo(); From 6b647e607e05f423e21575c4660312fa24eeb076 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 14 Nov 2024 15:40:37 +0200 Subject: [PATCH 068/133] fix string --- packages/yoroi-extension/app/i18n/locales/en-US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index 6d6485a998..85d8c67666 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -1119,7 +1119,7 @@ "portfolio.button.liquidityPool": "Liquidity pool", "portfolio.button.openOrders": "Open orders", "portfolio.button.lendAndBorrow": "Lend & Borrow", - "portfolio.tokenInfo.balance": "balance", + "portfolio.tokenInfo.balance": "Balance", "portfolio.tokenInfo.marketPrice": "Market price", "portfolio.tokenInfo.menuLabel.overview": "Overview", "portfolio.tokenInfo.menuLabel.performance": "Performance", From 6c1495e6ee9ecb3c22091be470bf1795899b69c1 Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Thu, 14 Nov 2024 17:57:42 +0200 Subject: [PATCH 069/133] update overflow for main layout --- packages/yoroi-extension/app/components/layout/TopBarLayout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/layout/TopBarLayout.js b/packages/yoroi-extension/app/components/layout/TopBarLayout.js index f4e254bbc4..01f536b7ed 100644 --- a/packages/yoroi-extension/app/components/layout/TopBarLayout.js +++ b/packages/yoroi-extension/app/components/layout/TopBarLayout.js @@ -74,7 +74,7 @@ function TopBarLayout({ flex: '0 1 auto', height: '100%', }), - overflow: isRevamp ? 'auto' : 'unset', + overflow: 'scroll', }} > {isRevamp ? ( From 77bf3f3017b16e22503b959fd7fecf7392832158 Mon Sep 17 00:00:00 2001 From: Patriciu Nista Date: Tue, 5 Nov 2024 10:27:17 +0100 Subject: [PATCH 070/133] add paper wallet page on settings --- packages/yoroi-extension/app/Routes.js | 7 +++ .../categories/PaperWalletSettings.js | 31 ++++++++++ .../components/settings/menu/SettingsMenu.js | 25 ++++---- .../transfer/cards/TransferCards.scss | 2 +- .../categories/PaperWalletSettingsPage.js | 15 +++++ .../app/containers/transfer/Transfer.js | 57 +++++-------------- .../containers/transfer/WalletTransferPage.js | 20 +++---- .../app/i18n/locales/en-US.json | 1 + packages/yoroi-extension/app/routes-config.js | 1 + 9 files changed, 89 insertions(+), 70 deletions(-) create mode 100644 packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js create mode 100644 packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index e4a4a73a8c..860fc2ecd1 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -79,6 +79,8 @@ const SupportSettingsPagePromise = () => import('./containers/settings/categorie const SupportSettingsPage = React.lazy(SupportSettingsPagePromise); const AnalyticsSettingsPagePromise = () => import('./containers/settings/categories/AnalyticsSettingsPage'); const AnalyticsSettingsPage = React.lazy(AnalyticsSettingsPagePromise); +const PaperWalletSettingsPagePromise = () => import('./containers/settings/categories/PaperWalletSettingsPage'); +const PaperWalletSettingsPage = React.lazy(PaperWalletSettingsPagePromise); const NightlyPagePromise = () => import('./containers/profile/NightlyPage'); const NightlyPage = React.lazy(NightlyPagePromise); @@ -425,6 +427,11 @@ const SettingsSubpages = (stores, actions) => ( path={ROUTES.SETTINGS.ANALYTICS} component={props => } /> + } + /> ); diff --git a/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js b/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js new file mode 100644 index 0000000000..f1aa5ed13b --- /dev/null +++ b/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js @@ -0,0 +1,31 @@ +// @flow +import type { Node, ComponentType } from 'react'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import { Component } from 'react'; +import { observer } from 'mobx-react'; +import { defineMessages, intlShape } from 'react-intl'; +import { Button } from '@mui/material'; + +type Props = {| + onRedirect(): void, +|}; + +@observer +class PaperWalletSettings extends Component { + static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { + intl: intlShape.isRequired, + }; + + render(): Node { + const { onRedirect } = this.props; + return ( +
+ +
+ ); + } +} + +export default PaperWalletSettings; diff --git a/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js b/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js index 6d69743fdb..d02cc092ed 100644 --- a/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js +++ b/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js @@ -33,6 +33,10 @@ export const settingsMenuMessages: Object = defineMessages({ id: 'settings.menu.analytics.link.label', defaultMessage: '!!!Analytics', }, + paperWallet: { + id: 'settings.menu.paperWallet.link.label', + defaultMessage: '!!!Paper Wallet', + }, }); type Props = {| @@ -47,7 +51,7 @@ class SettingsMenu extends Component { render(): Node { const { intl } = this.context; - const { onItemClick, isActiveItem, isRevampLayout } = this.props; + const { onItemClick, isActiveItem } = this.props; const isProduction = environmnent.isProduction(); const settingOptions: Array = [ { @@ -72,9 +76,7 @@ class SettingsMenu extends Component { hidden: isProduction, }, { - label: intl.formatMessage( - isRevampLayout ? globalMessages.termsOfService : globalMessages.termsOfUse - ), + label: intl.formatMessage(globalMessages.termsOfService), route: ROUTES.SETTINGS.TERMS_OF_USE, className: 'termsOfUse', }, @@ -92,18 +94,15 @@ class SettingsMenu extends Component { label: intl.formatMessage(settingsMenuMessages.analytics), route: ROUTES.SETTINGS.ANALYTICS, className: 'analytics', - hidden: !isRevampLayout, + }, + { + label: intl.formatMessage(settingsMenuMessages.paperWallet), + route: ROUTES.SETTINGS.PAPER_WALLET, + className: 'paperWallet', }, ]; - return ( - - ); + return ; } } diff --git a/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss b/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss index 86fb38fe15..737783f665 100644 --- a/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss +++ b/packages/yoroi-extension/app/components/transfer/cards/TransferCards.scss @@ -22,7 +22,7 @@ } .tooltipSize { - width: 500px; + max-width: 500px; overflow-wrap: break-word; white-space: normal; } diff --git a/packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js new file mode 100644 index 0000000000..073e970d8e --- /dev/null +++ b/packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js @@ -0,0 +1,15 @@ +// @flow +import type { Node } from 'react'; +import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; +import { Component } from 'react'; +import { observer } from 'mobx-react'; +import { ROUTES } from '../../../routes-config'; +import PaperWalletSettings from '../../../components/settings/categories/PaperWalletSettings'; + +@observer +export default class PaperWalletSettingsPage extends Component { + render(): Node { + const { actions } = this.props; + return actions.router.redirect.trigger({ route: ROUTES.TRANSFER.ROOT })} />; + } +} diff --git a/packages/yoroi-extension/app/containers/transfer/Transfer.js b/packages/yoroi-extension/app/containers/transfer/Transfer.js index ef2293064b..47995a805e 100644 --- a/packages/yoroi-extension/app/containers/transfer/Transfer.js +++ b/packages/yoroi-extension/app/containers/transfer/Transfer.js @@ -1,22 +1,17 @@ // @flow -import type { ComponentType, Node } from 'react'; +import type { Node } from 'react'; +import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import { Component, lazy, Suspense } from 'react'; import { observer } from 'mobx-react'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; import { intlShape } from 'react-intl'; -import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import TopBarLayout from '../../components/layout/TopBarLayout'; import BannerContainer from '../banners/BannerContainer'; import SidebarContainer from '../SidebarContainer'; -import BackgroundColoredLayout from '../../components/layout/BackgroundColoredLayout'; import NoWalletMessage from '../wallet/NoWalletMessage'; -import UnsupportedWallet from '../wallet/UnsupportedWallet'; import NavBarTitle from '../../components/topbar/NavBarTitle'; -import NavBarContainer from '../NavBarContainer'; import globalMessages from '../../i18n/global-messages'; -import HorizontalLine from '../../components/widgets/HorizontalLine'; -import type { LayoutComponentMap } from '../../styles/context/layout'; -import { withLayout } from '../../styles/context/layout'; +import NavBarContainerRevamp from '../NavBarContainerRevamp'; export const WalletTransferPagePromise: void => Promise = () => import('./WalletTransferPage'); const WalletTransferPage = lazy(WalletTransferPagePromise); @@ -26,11 +21,8 @@ type Props = {| +children?: Node, |}; -type InjectedLayoutProps = {| +renderLayoutComponent: LayoutComponentMap => Node |}; -type AllProps = {| ...Props, ...InjectedLayoutProps |}; - @observer -class Transfer extends Component { +class Transfer extends Component { static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -41,26 +33,17 @@ class Transfer extends Component { render(): Node { const { actions, stores } = this.props; - if (this.props.stores.profile.isRevampTheme) { - return null; - } const sidebarContainer = ; const navbar = ( - - } + title={} /> ); + return ( - } - navbar={navbar} - sidebar={sidebarContainer} - showInContainer - > + } navbar={navbar} sidebar={sidebarContainer}> {this.getContent()} ); @@ -72,24 +55,12 @@ class Transfer extends Component { if (wallet == null) { return ; } - // temporary solution: will need to handle more cases later for different currencies - if (wallet.isCardanoHaskell) { - return ; - } + return ( - <> - - - - - - - + + + ); }; } -export default (withLayout(Transfer): ComponentType); +export default Transfer; diff --git a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js index 8189738564..7e50f5c9b8 100644 --- a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js @@ -10,7 +10,7 @@ import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import TransferTypeSelect from '../../components/transfer/cards/TransferTypeSelect'; import { PublicDeriver } from '../../api/ada/lib/storage/models/PublicDeriver'; import YoroiTransferPage from './YoroiTransferPage'; -import { genLookupOrFail, getTokenName, } from '../../stores/stateless/tokenHelpers'; +import { genLookupOrFail, getTokenName } from '../../stores/stateless/tokenHelpers'; import { truncateToken } from '../../utils/formatters'; type Props = {| @@ -20,7 +20,7 @@ type Props = {| @observer export default class WalletTransferPage extends Component { - static contextTypes: {|intl: $npm$ReactIntl$IntlFormat|} = { + static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { intl: intlShape.isRequired, }; @@ -31,21 +31,15 @@ export default class WalletTransferPage extends Component { // paper startTransferYoroiPaperFunds: void => void = () => { this.props.actions.yoroiTransfer.startTransferFunds.trigger(); - } + }; render(): Node { - const { actions, stores } = this.props; - const defaultToken = this.props.publicDeriver.getParent().getDefaultToken(); - const defaultTokenInfo = genLookupOrFail(this.props.stores.tokenInfoStore.tokenInfo)({ - identifier: defaultToken.defaultIdentifier, - networkId: defaultToken.defaultNetworkId, - }); + const { actions, stores, publicDeriver } = this.props; + const defaultTokenInfo = stores.tokenInfoStore.getDefaultTokenInfo(publicDeriver.networkId); + return ( <> - + ); diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index 1354e9f4e1..26ac435dbb 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -295,6 +295,7 @@ "settings.general.translation.contributors": "_", "settings.general.theme.light": "Light Theme", "settings.general.theme.dark": "Dark Theme", + "settings.menu.paperWallet.link.label": "Paper Wallet", "settings.menu.analytics.link.label": "Analytics", "settings.menu.assetDeposit.link.label": "Locked assets deposit", "settings.menu.blockchain.link.label": "Blockchain", diff --git a/packages/yoroi-extension/app/routes-config.js b/packages/yoroi-extension/app/routes-config.js index 8f35cd6939..b03d5abeca 100644 --- a/packages/yoroi-extension/app/routes-config.js +++ b/packages/yoroi-extension/app/routes-config.js @@ -42,6 +42,7 @@ export const ROUTES = { SUPPORT: '/settings/support', LEVEL_OF_COMPLEXITY: '/settings/level-of-complexity', ANALYTICS: '/settings/analytics', + PAPER_WALLET: '/settings/paper-wallet', }, TRANSFER: { ROOT: '/transfer', From 379d5a1dff022644b57202ab51b6156616ca4f13 Mon Sep 17 00:00:00 2001 From: Patriciu Nista Date: Tue, 5 Nov 2024 10:45:21 +0100 Subject: [PATCH 071/133] fix eslint & flow errors --- .../categories/PaperWalletSettings.js | 8 +---- .../app/containers/transfer/Transfer.js | 2 +- .../containers/transfer/WalletTransferPage.js | 33 +++++++------------ 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js b/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js index f1aa5ed13b..0907a18efc 100644 --- a/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js @@ -1,9 +1,7 @@ // @flow -import type { Node, ComponentType } from 'react'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; +import type { Node } from 'react'; import { Component } from 'react'; import { observer } from 'mobx-react'; -import { defineMessages, intlShape } from 'react-intl'; import { Button } from '@mui/material'; type Props = {| @@ -12,10 +10,6 @@ type Props = {| @observer class PaperWalletSettings extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - render(): Node { const { onRedirect } = this.props; return ( diff --git a/packages/yoroi-extension/app/containers/transfer/Transfer.js b/packages/yoroi-extension/app/containers/transfer/Transfer.js index 47995a805e..fa1262add8 100644 --- a/packages/yoroi-extension/app/containers/transfer/Transfer.js +++ b/packages/yoroi-extension/app/containers/transfer/Transfer.js @@ -58,7 +58,7 @@ class Transfer extends Component { return ( - + ); }; diff --git a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js index 7e50f5c9b8..6d5b9008f7 100644 --- a/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js +++ b/packages/yoroi-extension/app/containers/transfer/WalletTransferPage.js @@ -1,29 +1,15 @@ // @flow import type { Node } from 'react'; +import type { StoresAndActionsProps } from '../../types/injectedProps.types'; import { Component } from 'react'; import { observer } from 'mobx-react'; -import type { $npm$ReactIntl$IntlFormat } from 'react-intl'; -import { intlShape } from 'react-intl'; - -import type { StoresAndActionsProps } from '../../types/injectedProps.types'; - +import { getTokenName } from '../../stores/stateless/tokenHelpers'; +import { truncateToken } from '../../utils/formatters'; import TransferTypeSelect from '../../components/transfer/cards/TransferTypeSelect'; -import { PublicDeriver } from '../../api/ada/lib/storage/models/PublicDeriver'; import YoroiTransferPage from './YoroiTransferPage'; -import { genLookupOrFail, getTokenName } from '../../stores/stateless/tokenHelpers'; -import { truncateToken } from '../../utils/formatters'; - -type Props = {| - ...StoresAndActionsProps, - publicDeriver: PublicDeriver<>, -|}; @observer -export default class WalletTransferPage extends Component { - static contextTypes: {| intl: $npm$ReactIntl$IntlFormat |} = { - intl: intlShape.isRequired, - }; - +export default class WalletTransferPage extends Component { onClose: void => void = () => { this.props.actions.dialogs.closeActiveDialog.trigger(); }; @@ -34,9 +20,14 @@ export default class WalletTransferPage extends Component { }; render(): Node { - const { actions, stores, publicDeriver } = this.props; - const defaultTokenInfo = stores.tokenInfoStore.getDefaultTokenInfo(publicDeriver.networkId); - + const { actions, stores } = this.props; + const wallet = stores.wallets.selected; + if (wallet == null) { + return null; + } + + const defaultTokenInfo = stores.tokenInfoStore.getDefaultTokenInfo(wallet.networkId); + return ( <> From 3354ed02200b7c888729b64e4511813c9fbbb4c7 Mon Sep 17 00:00:00 2001 From: Patriciu Nista Date: Thu, 7 Nov 2024 11:39:44 +0100 Subject: [PATCH 072/133] move button into support/logs section --- packages/yoroi-extension/app/Routes.js | 7 ------ .../categories/PaperWalletSettings.js | 25 ------------------- .../settings/categories/SupportSettings.js | 18 +++++++++++++ .../components/settings/menu/SettingsMenu.js | 9 ------- .../categories/PaperWalletSettingsPage.js | 15 ----------- .../categories/SupportSettingsPage.js | 3 +++ .../app/i18n/locales/en-US.json | 3 ++- 7 files changed, 23 insertions(+), 57 deletions(-) delete mode 100644 packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js delete mode 100644 packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js diff --git a/packages/yoroi-extension/app/Routes.js b/packages/yoroi-extension/app/Routes.js index 860fc2ecd1..e4a4a73a8c 100644 --- a/packages/yoroi-extension/app/Routes.js +++ b/packages/yoroi-extension/app/Routes.js @@ -79,8 +79,6 @@ const SupportSettingsPagePromise = () => import('./containers/settings/categorie const SupportSettingsPage = React.lazy(SupportSettingsPagePromise); const AnalyticsSettingsPagePromise = () => import('./containers/settings/categories/AnalyticsSettingsPage'); const AnalyticsSettingsPage = React.lazy(AnalyticsSettingsPagePromise); -const PaperWalletSettingsPagePromise = () => import('./containers/settings/categories/PaperWalletSettingsPage'); -const PaperWalletSettingsPage = React.lazy(PaperWalletSettingsPagePromise); const NightlyPagePromise = () => import('./containers/profile/NightlyPage'); const NightlyPage = React.lazy(NightlyPagePromise); @@ -427,11 +425,6 @@ const SettingsSubpages = (stores, actions) => ( path={ROUTES.SETTINGS.ANALYTICS} component={props => } /> - } - /> ); diff --git a/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js b/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js deleted file mode 100644 index 0907a18efc..0000000000 --- a/packages/yoroi-extension/app/components/settings/categories/PaperWalletSettings.js +++ /dev/null @@ -1,25 +0,0 @@ -// @flow -import type { Node } from 'react'; -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import { Button } from '@mui/material'; - -type Props = {| - onRedirect(): void, -|}; - -@observer -class PaperWalletSettings extends Component { - render(): Node { - const { onRedirect } = this.props; - return ( -
- -
- ); - } -} - -export default PaperWalletSettings; diff --git a/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js b/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js index d063636837..d072737aa3 100644 --- a/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js @@ -37,11 +37,20 @@ const messages = defineMessages({ id: 'settings.support.logs.title', defaultMessage: '!!!Logs', }, + paperWallet: { + id: 'settings.support.paperWallet.title', + defaultMessage: '!!!Paper Wallet', + }, + paperWalletTransfer: { + id: 'settings.support.paperWallet.button', + defaultMessage: '!!!Transfer from Paper Wallet', + }, }); type Props = {| +onExternalLinkClick: MouseEvent => void, +onDownloadLogs: void => void, + +onPaperWalletTransfer: void => void, |}; type InjectedProps = {| +isRevampLayout: boolean |}; @@ -150,6 +159,15 @@ class SupportSettings extends Component { > {intl.formatMessage(globalMessages.downloadLogsButtonLabel)} + + + + {intl.formatMessage(messages.paperWallet)} + + +
); } diff --git a/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js b/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js index d02cc092ed..886ce6d4b6 100644 --- a/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js +++ b/packages/yoroi-extension/app/components/settings/menu/SettingsMenu.js @@ -33,10 +33,6 @@ export const settingsMenuMessages: Object = defineMessages({ id: 'settings.menu.analytics.link.label', defaultMessage: '!!!Analytics', }, - paperWallet: { - id: 'settings.menu.paperWallet.link.label', - defaultMessage: '!!!Paper Wallet', - }, }); type Props = {| @@ -95,11 +91,6 @@ class SettingsMenu extends Component { route: ROUTES.SETTINGS.ANALYTICS, className: 'analytics', }, - { - label: intl.formatMessage(settingsMenuMessages.paperWallet), - route: ROUTES.SETTINGS.PAPER_WALLET, - className: 'paperWallet', - }, ]; return ; diff --git a/packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js deleted file mode 100644 index 073e970d8e..0000000000 --- a/packages/yoroi-extension/app/containers/settings/categories/PaperWalletSettingsPage.js +++ /dev/null @@ -1,15 +0,0 @@ -// @flow -import type { Node } from 'react'; -import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; -import { Component } from 'react'; -import { observer } from 'mobx-react'; -import { ROUTES } from '../../../routes-config'; -import PaperWalletSettings from '../../../components/settings/categories/PaperWalletSettings'; - -@observer -export default class PaperWalletSettingsPage extends Component { - render(): Node { - const { actions } = this.props; - return actions.router.redirect.trigger({ route: ROUTES.TRANSFER.ROOT })} />; - } -} diff --git a/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js b/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js index e0f6b21dac..103d4a4b56 100644 --- a/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js +++ b/packages/yoroi-extension/app/containers/settings/categories/SupportSettingsPage.js @@ -8,6 +8,7 @@ import { downloadLogs } from '../../../utils/logging'; import type { StoresAndActionsProps } from '../../../types/injectedProps.types'; import IncludePublicKeyDialog from './IncludePublicKeyDialog'; import { ComplexityLevels } from '../../../types/complexityLevelType'; +import { ROUTES } from '../../../routes-config'; @observer export default class SupportSettingsPage extends Component { @@ -54,12 +55,14 @@ export default class SupportSettingsPage extends Component {this.getDialog()} actions.router.redirect.trigger({ route: ROUTES.TRANSFER.ROOT })} /> ); diff --git a/packages/yoroi-extension/app/i18n/locales/en-US.json b/packages/yoroi-extension/app/i18n/locales/en-US.json index 26ac435dbb..48cda9c868 100644 --- a/packages/yoroi-extension/app/i18n/locales/en-US.json +++ b/packages/yoroi-extension/app/i18n/locales/en-US.json @@ -295,7 +295,6 @@ "settings.general.translation.contributors": "_", "settings.general.theme.light": "Light Theme", "settings.general.theme.dark": "Dark Theme", - "settings.menu.paperWallet.link.label": "Paper Wallet", "settings.menu.analytics.link.label": "Analytics", "settings.menu.assetDeposit.link.label": "Locked assets deposit", "settings.menu.blockchain.link.label": "Blockchain", @@ -309,6 +308,8 @@ "settings.noexternal.dialog.content": "Your memos are stored locally. They will not automatically sync with other Yoroi instances and will be lost if you delete Yoroi", "settings.noexternal.dialog.title": "No external storage", "settings.revamp.unitOfAccount.note": "Please note, that the coin price is approximate and may not match the price of any given trading platform. Any transactions based on this price approximates are done at your own risk", + "settings.support.paperWallet.title": "Paper Wallet", + "settings.support.paperWallet.button": "Transfer from Paper Wallet", "settings.support.faq.blogLinkUrl": "https://emurgo.io/en/blog/yoroi-custom-themes", "settings.support.faq.blogLinkWrapper": "blog post", "settings.support.faq.content": "If you are experiencing issues, please see the {faqLink} for guidance on known issues.", From 6b6a7acc238f77d7a79e84cab963a43bad2af76f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 03:22:04 +0000 Subject: [PATCH 073/133] Bump chromedriver from 130.0.4 to 131.0.0 in /packages/e2e-tests Bumps [chromedriver](https://github.com/giggio/node-chromedriver) from 130.0.4 to 131.0.0. - [Commits](https://github.com/giggio/node-chromedriver/compare/130.0.4...131.0.0) --- updated-dependencies: - dependency-name: chromedriver dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- packages/e2e-tests/package-lock.json | 8 ++++---- packages/e2e-tests/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/e2e-tests/package-lock.json b/packages/e2e-tests/package-lock.json index 0b44c711a7..f7064c2d92 100644 --- a/packages/e2e-tests/package-lock.json +++ b/packages/e2e-tests/package-lock.json @@ -41,7 +41,7 @@ "@emurgo/cardano-serialization-lib-nodejs": "^12.0.0-alpha.26", "bignumber.js": "^9.1.2", "chai": "^4.3.10", - "chromedriver": "130.0.4", + "chromedriver": "131.0.0", "cross-env": "^7.0.3", "json-server": "^0.17.4", "mocha": "^10.2.0", @@ -450,9 +450,9 @@ } }, "node_modules/chromedriver": { - "version": "130.0.4", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-130.0.4.tgz", - "integrity": "sha512-lpR+PWXszij1k4Ig3t338Zvll9HtCTiwoLM7n4pCCswALHxzmgwaaIFBh3rt9+5wRk9D07oFblrazrBxwaYYAQ==", + "version": "131.0.0", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-131.0.0.tgz", + "integrity": "sha512-ukYmdCox2eRsjpCYUB4AOLV1fSfWQ1ZPfcUc0PIUWZKoyjyXKEl8i4DJ14bcNzNbEvaVx2Z2pnx/nLK2CM+ruQ==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 02930995f0..7d9dfc8772 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -47,7 +47,7 @@ "@emurgo/cardano-serialization-lib-nodejs": "^12.0.0-alpha.26", "bignumber.js": "^9.1.2", "chai": "^4.3.10", - "chromedriver": "130.0.4", + "chromedriver": "131.0.0", "cross-env": "^7.0.3", "json-server": "^0.17.4", "mocha": "^10.2.0", From b628512562e589f928dfa2532e3997749c0cc4be Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 15 Nov 2024 10:05:13 +0200 Subject: [PATCH 074/133] update change data --- .../portfolio/useCases/TokensTable/TableColumnsChip.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 3ab69c0cdb..87ebf3ca2d 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -52,6 +52,8 @@ export const TokenPriceChangeChip = ({ }: TokenPriceChangeChipProps) => { const { data: ptTokenDataInterval, isFetching } = useGetPortfolioTokenChart(timeInterval, { info: { id: '' } }); + console.log('ptTokenDataInterval', ptTokenDataInterval); + if (secondaryTokenActivity === null || primaryTokenActivity === null || isFetching) { return ; } @@ -94,7 +96,7 @@ export const TokenPriceChangeChip = ({ {noDataToDisplay ? '-' : formatPriceChange( - isPrimaryToken && timeInterval !== undefined ? ptTokenDataInterval?.[50]?.changePercent ?? 0 : changePercent ?? 0 + isPrimaryToken && timeInterval !== undefined ? ptTokenDataInterval?.[167]?.changePercent ?? 0 : changePercent ?? 0 )} From 0d458d2935c9920cd93c7f4b2897f78fa7df92ec Mon Sep 17 00:00:00 2001 From: Sorin Chis Date: Fri, 15 Nov 2024 10:07:34 +0200 Subject: [PATCH 075/133] remove console.log --- .../portfolio/useCases/TokensTable/TableColumnsChip.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx index 87ebf3ca2d..9e2d645e2d 100644 --- a/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx +++ b/packages/yoroi-extension/app/UI/features/portfolio/useCases/TokensTable/TableColumnsChip.tsx @@ -52,8 +52,6 @@ export const TokenPriceChangeChip = ({ }: TokenPriceChangeChipProps) => { const { data: ptTokenDataInterval, isFetching } = useGetPortfolioTokenChart(timeInterval, { info: { id: '' } }); - console.log('ptTokenDataInterval', ptTokenDataInterval); - if (secondaryTokenActivity === null || primaryTokenActivity === null || isFetching) { return ; } From d1e0e463dd7cd21d5aa9e237c94d36a01a51ff7b Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 15 Nov 2024 14:07:24 +0300 Subject: [PATCH 076/133] font size --- .../app/components/settings/categories/SupportSettings.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js b/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js index d072737aa3..b65e00a687 100644 --- a/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js @@ -164,7 +164,9 @@ class SupportSettings extends Component { {intl.formatMessage(messages.paperWallet)} - From 8b9f98a1cefaf13ea522f3d3a8a29d2d0848176c Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 14 Nov 2024 23:30:07 +0800 Subject: [PATCH 077/133] adapt to backend return value change --- .../app/api/ada/lib/state-fetch/remoteFetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js index 8ef431f6d5..5b77f34656 100644 --- a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js +++ b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js @@ -568,7 +568,7 @@ export class RemoteFetcher implements IFetcher { } ).then(response => [ response.data ]) .catch((error) => { - if (error.response.status === 404 && error.response.data === 'Transaction not found') { + if (error.response.status === 404 && error.response.data === 'No outputs found') { return [ null ]; } Logger.error(`${nameof(RemoteFetcher)}::${nameof(this.getUtxoData)} error: ` + stringifyError(error)); From 2842b2d671a162750a5fe21c50165f34e25c81f2 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 14 Nov 2024 23:44:20 +0800 Subject: [PATCH 078/133] allow multiple foreign inputs --- .../app/connector/stores/ConnectorStore.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 5c7b730e80..1854e4b011 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -532,10 +532,13 @@ export default class ConnectorStore extends Store { const foreignInputDetails = []; if (foreignInputs.length) { - const foreignUtxos = await this.stores.substores.ada.stateFetchStore.fetcher.getUtxoData({ - network, - utxos: foreignInputs, - }); + const foreignUtxos = await Promise.all(foreignInputs.map(async (foreignInput) => { + // currently this endpoint only supports querying one at a time + return (await this.stores.substores.ada.stateFetchStore.fetcher.getUtxoData({ + network, + utxos: [foreignInput], + }))[0]; + })); for (let i = 0; i < foreignUtxos.length; i++) { const foreignUtxo = foreignUtxos[i]; if (foreignUtxo == null || typeof foreignUtxo !== 'object') { From 28b630da0d804994b0132a999144aa1f3166ec6e Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 15 Nov 2024 14:16:59 +0300 Subject: [PATCH 079/133] function ref fix --- .../app/api/ada/lib/state-fetch/remoteFetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js index 5b77f34656..ee9a789159 100644 --- a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js +++ b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js @@ -578,7 +578,7 @@ export class RemoteFetcher implements IFetcher { getLatestBlockBySlot: GetLatestBlockBySlotFunc = async (body) => { const { BackendService } = body.network.Backend; - if (BackendService == null) throw new Error(`${nameof(this.getUtxoData)} missing backend url`); + if (BackendService == null) throw new Error(`${nameof(this.getLatestBlockBySlot)} missing backend url`); return axios( `${BackendService}/api/v2.1/lastBlockBySlot`, { From 303db7379fa4dc19192dcb07a782683428039acd Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 15 Nov 2024 14:28:38 +0300 Subject: [PATCH 080/133] process multiple items on the api side, not on the caller side --- .../api/ada/lib/state-fetch/remoteFetcher.js | 40 +++++++++---------- .../app/connector/stores/ConnectorStore.js | 11 ++--- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js index ee9a789159..dc62ef3a9f 100644 --- a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js +++ b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js @@ -551,29 +551,27 @@ export class RemoteFetcher implements IFetcher { getUtxoData: GetUtxoDataRequest => Promise = async (body) => { const { BackendService } = body.network.Backend; - if (body.utxos.length !== 1) { - throw new Error('the RemoteFetcher.getUtxoData expects 1 UTXO'); - } - const { txHash, txIndex } = body.utxos[0]; if (BackendService == null) throw new Error(`${nameof(this.getUtxoData)} missing backend url`); - return axios( - `${BackendService}/api/txs/io/${txHash}/o/${txIndex}`, - { - method: 'get', - timeout: 2 * CONFIG.app.walletRefreshInterval, - headers: { - 'yoroi-version': this.getLastLaunchVersion(), - 'yoroi-locale': this.getCurrentLocale() - } - } - ).then(response => [ response.data ]) - .catch((error) => { - if (error.response.status === 404 && error.response.data === 'No outputs found') { - return [ null ]; + return Promise.all(body.utxos.map(({ txHash, txIndex }) => { + return axios( + `${BackendService}/api/txs/io/${txHash}/o/${txIndex}`, + { + method: 'get', + timeout: 2 * CONFIG.app.walletRefreshInterval, + headers: { + 'yoroi-version': this.getLastLaunchVersion(), + 'yoroi-locale': this.getCurrentLocale() + } } - Logger.error(`${nameof(RemoteFetcher)}::${nameof(this.getUtxoData)} error: ` + stringifyError(error)); - throw new GetUtxoDataError(); - }); + ).then(response => [ response.data ]) + .catch((error) => { + if (error.response.status === 404 && error.response.data === 'No outputs found') { + return [ null ]; + } + Logger.error(`${nameof(RemoteFetcher)}::${nameof(this.getUtxoData)} error: ` + stringifyError(error)); + throw new GetUtxoDataError(); + }); + })); } getLatestBlockBySlot: GetLatestBlockBySlotFunc = async (body) => { diff --git a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js index 1854e4b011..5c7b730e80 100644 --- a/packages/yoroi-extension/app/connector/stores/ConnectorStore.js +++ b/packages/yoroi-extension/app/connector/stores/ConnectorStore.js @@ -532,13 +532,10 @@ export default class ConnectorStore extends Store { const foreignInputDetails = []; if (foreignInputs.length) { - const foreignUtxos = await Promise.all(foreignInputs.map(async (foreignInput) => { - // currently this endpoint only supports querying one at a time - return (await this.stores.substores.ada.stateFetchStore.fetcher.getUtxoData({ - network, - utxos: [foreignInput], - }))[0]; - })); + const foreignUtxos = await this.stores.substores.ada.stateFetchStore.fetcher.getUtxoData({ + network, + utxos: foreignInputs, + }); for (let i = 0; i < foreignUtxos.length; i++) { const foreignUtxo = foreignUtxos[i]; if (foreignUtxo == null || typeof foreignUtxo !== 'object') { From 643ac5ca26d82f1f56cae4dcbc647f71d9dd18e4 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 15 Nov 2024 14:31:02 +0300 Subject: [PATCH 081/133] return fix --- .../app/api/ada/lib/state-fetch/remoteFetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js index dc62ef3a9f..a121f7b213 100644 --- a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js +++ b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js @@ -563,7 +563,7 @@ export class RemoteFetcher implements IFetcher { 'yoroi-locale': this.getCurrentLocale() } } - ).then(response => [ response.data ]) + ).then(response => response.data) .catch((error) => { if (error.response.status === 404 && error.response.data === 'No outputs found') { return [ null ]; From eb9ba57d371caba1c30ca9b7491cf2d00b3d53f6 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 15 Nov 2024 14:31:09 +0300 Subject: [PATCH 082/133] return fix --- .../app/api/ada/lib/state-fetch/remoteFetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js index a121f7b213..55e0e75355 100644 --- a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js +++ b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js @@ -566,7 +566,7 @@ export class RemoteFetcher implements IFetcher { ).then(response => response.data) .catch((error) => { if (error.response.status === 404 && error.response.data === 'No outputs found') { - return [ null ]; + return null; } Logger.error(`${nameof(RemoteFetcher)}::${nameof(this.getUtxoData)} error: ` + stringifyError(error)); throw new GetUtxoDataError(); From 64a667a4d4e124d09f186521cdd9469ab8dfe974 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 15 Nov 2024 15:01:39 +0300 Subject: [PATCH 083/133] lint fix --- .../components/settings/categories/SupportSettings.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js b/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js index b65e00a687..fa63317278 100644 --- a/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js +++ b/packages/yoroi-extension/app/components/settings/categories/SupportSettings.js @@ -164,9 +164,13 @@ class SupportSettings extends Component { {intl.formatMessage(messages.paperWallet)} - From 88cb1246bc74a4225c3681025eefab05f164df31 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 8 Nov 2024 16:43:12 +0800 Subject: [PATCH 084/133] Trezor wallet governance support --- .../TransactionFailed/TransactionFailed.tsx | 9 ++- .../GovernanceTransactionFailedPage.tsx | 2 +- .../api/ada/transactions/shelley/trezorTx.js | 40 ++++++++++- .../app/domain/TrezorLocalizedError.js | 6 ++ .../app/i18n/locales/en-US.json | 1 + .../ada/AdaDelegationTransactionStore.js | 70 +++++++++++-------- .../app/stores/stateless/sidebarCategories.js | 2 +- .../chrome/manifest-mv2.template.js | 2 +- .../chrome/manifest.template.js | 2 +- packages/yoroi-extension/package.json | 2 +- 10 files changed, 97 insertions(+), 39 deletions(-) diff --git a/packages/yoroi-extension/app/UI/components/TransactionFailed/TransactionFailed.tsx b/packages/yoroi-extension/app/UI/components/TransactionFailed/TransactionFailed.tsx index f40ab28149..01884d3619 100644 --- a/packages/yoroi-extension/app/UI/components/TransactionFailed/TransactionFailed.tsx +++ b/packages/yoroi-extension/app/UI/components/TransactionFailed/TransactionFailed.tsx @@ -4,9 +4,12 @@ import { FormattedMessage } from 'react-intl'; import globalMessages from '../../../i18n/global-messages'; import { useNavigateTo } from '../../features/governace/common/useNavigateTo'; import { FailedIlustration } from './FailedIlustration'; +import LocalizableError from '../../../i18n/LocalizableError'; -export const TransactionFailed = () => { +export const TransactionFailed = (props: { error: Error | null }) => { const navigate = useNavigateTo(); + const { error } = props; + return ( @@ -14,7 +17,9 @@ export const TransactionFailed = () => { - + {/* @ts-ignore */}