Skip to content

Commit

Permalink
Merge branch 'develop' into denis/swap-verified-tokens-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Sep 27, 2024
2 parents e3370d4 + c5a74ea commit 3ff9062
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export default class AmountDisplay extends Component<Props> {

if (shouldHideBalance) {
balanceDisplay = <span>{hiddenAmount}</span>;
fiatDisplay = (
<span>
{hiddenAmount} {currency}
</span>
);
fiatDisplay = <span>{hiddenAmount}</span>;
} else {
const shiftedAmount = defaultEntry.amount.shiftedBy(-tokenInfo.Metadata.numberOfDecimals);

Expand Down Expand Up @@ -90,7 +86,7 @@ export default class AmountDisplay extends Component<Props> {
)}
{showFiat === true && (
<Typography mb="5px" color="ds.text_gray_medium" fontSize="12px" id={id + '-availableFiatBalance-text'}>
{fiatDisplay || '-'} {currency || 'USD'}
{fiatDisplay || '-'}&nbsp;{currency || 'USD'}
</Typography>
)}
</>
Expand Down
26 changes: 3 additions & 23 deletions packages/yoroi-extension/app/components/topbar/WalletListDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import DialogCloseButton from '../widgets/DialogCloseButton';
import styles from './WalletListDialog.scss';
import WalletCard from './WalletCard';
import globalMessages from '../../i18n/global-messages';
import AmountDisplay, { FiatDisplay } from '../common/AmountDisplay';
import AmountDisplay from '../common/AmountDisplay';
import type { WalletType } from '../../../chrome/extension/background/types';
import type { WalletChecksum } from '@emurgo/cip4-js';
import { Typography, styled } from '@mui/material';
Expand All @@ -37,10 +37,6 @@ const messages = defineMessages({
id: 'wallet.topbar.dialog.totalBalance',
defaultMessage: '!!!Total Balance',
},
cardano: {
id: 'wallet.topbar.dialog.cardano',
defaultMessage: '!!!Cardano, ADA',
},
});

export type WalletInfo = {|
Expand Down Expand Up @@ -242,11 +238,6 @@ export default class WalletListDialog extends Component<Props, State> {
sx={{ overflow: 'auto', overflowY: 'auto', height: '400px' }}
id="changeWalletDialog-walletList-box"
>
{cardanoWalletsIdx.length > 0 && (
<div className={styles.sectionHeader}>
<h1>{intl.formatMessage(messages.cardano)}</h1>
</div>
)}
<DragDropContext onDragEnd={result => this.onDragEnd('cardano', result)}>
<Droppable droppableId="cardano-list-droppable">
{provided => (
Expand Down Expand Up @@ -293,27 +284,16 @@ export default class WalletListDialog extends Component<Props, State> {

renderWalletsTotal(): ?Node {
const { unitOfAccountSetting, cardanoWallets, shouldHideBalance, getCurrentPrice } = this.props;
if (unitOfAccountSetting.enabled) {
const adaFiat = this.sumWallets(cardanoWallets).fiat;
if (adaFiat != null) {
const totalFiat = adaFiat;
const { currency } = unitOfAccountSetting;
return <FiatDisplay shouldHideBalance={shouldHideBalance} amount={totalFiat} currency={currency} />;
}
}
// either unit of account is not enabled, or fails to convert to fiat
const amount = this.sumWallets(cardanoWallets).sum;
const totalAmountId = `changeWalletDialog:total`;
return (
<AmountDisplay
shouldHideBalance={shouldHideBalance}
amount={amount}
amount={this.sumWallets(cardanoWallets).sum}
getTokenInfo={this.props.getTokenInfo}
showFiat={false}
showAmount
unitOfAccountSetting={unitOfAccountSetting}
getCurrentPrice={getCurrentPrice}
id={totalAmountId}
id="changeWalletDialog:total"
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@
background-size: contain;
background-position: center 10px;
background-repeat: no-repeat;
&.cardano {
background-image: url(../../../assets/images/my-wallets/symbol_ada.inline.svg);
}
&.cardanoTestnet {
background-image: url(../../../assets/images/my-wallets/symbol_adaTestnet.inline.svg);
}
// CONNECT HARDWARE WALLET
&.connectLedger {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-ledger-modern.inline.svg);
}
&.connectTrezor {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-trezor-modern.inline.svg);
}
}

&:hover {
Expand Down Expand Up @@ -127,31 +140,18 @@
color: var(--yoroi-palette-secondary-300);
}
}

.optionImage {
&.cardano {
background-image: url(../../../assets/images/my-wallets/symbol_ada.inline.svg);
}
&.cardanoTestnet {
background-image: url(../../../assets/images/my-wallets/symbol_adaTestnet.inline.svg);
}
&.alonzoWhiteTestnet {
background-image: url(../../../assets/images/my-wallets/symbol_adaTestnet.inline.svg);
}
// CONNECT HARDWARE WALLET
&.connectLedger {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-ledger-classic.inline.svg);
}

&.connectTrezor {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-trezor-classic.inline.svg);
}

// CREATE WALLET
&.createWallet {
background-image: url(../../../assets/images/add-wallet/create-wallet-classic.inline.svg);
}

// RESTORE WALLET
&.restoreNormalWallet {
background-image: url(../../../assets/images/add-wallet/option-dialog/restore-normal-wallet-classic.inline.svg);
Expand All @@ -168,7 +168,7 @@
}
}

:global(.YoroiModern), :global(.YoroiRevamp) {
:global(.YoroiModern) {
.optionBlockListItem {
.optionBlockWrapper {
.optionSubmitButton {
Expand All @@ -177,31 +177,11 @@
color: var(--yoroi-palette-primary-300);
}
}

.optionImage {
&.cardano {
background-image: url(../../../assets/images/my-wallets/symbol_ada.inline.svg);
}
&.cardanoTestnet {
background-image: url(../../../assets/images/my-wallets/symbol_adaTestnet.inline.svg);
}
&.alonzoWhiteTestnet {
background-image: url(../../../assets/images/my-wallets/symbol_adaTestnet.inline.svg);
}
// CONNECT HARDWARE WALLET
&.connectLedger {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-ledger-modern.inline.svg);
}

&.connectTrezor {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-trezor-modern.inline.svg);
}

// CREATE WALLET
&.createWallet {
background-image: url(../../../assets/images/add-wallet/create-wallet-modern.inline.svg);
}

// RESTORE WALLET
&.restoreNormalWallet {
background-image: url(../../../assets/images/add-wallet/option-dialog/restore-normal-wallet-modern.inline.svg);
Expand All @@ -227,28 +207,11 @@
color: var(--yoroi-palette-primary-300);
}
}

.optionImage {
&.cardano {
background-image: url(../../../assets/images/my-wallets/symbol_ada.inline.svg);
}
&.cardanoTestnet {
background-image: url(../../../assets/images/my-wallets/symbol_adaTestnet.inline.svg);
}
// CONNECT HARDWARE WALLET
&.connectLedger {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-ledger-modern.inline.svg);
}

&.connectTrezor {
background-image: url(../../../assets/images/add-wallet/option-dialog/connect-trezor-modern.inline.svg);
}

// CREATE WALLET
&.createWallet {
background-image: url(../../../assets/images/add-wallet/create-wallet-modern.inline.svg);
}

// RESTORE WALLET
&.restoreNormalWallet {
background-image: url(../../../assets/images/add-wallet/option-dialog/restore-normal-wallet-modern.inline.svg);
Expand Down
1 change: 0 additions & 1 deletion packages/yoroi-extension/app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@
"wallet.syncingOverlay.explanation": "Please wait while we process wallet data. This may take some time.",
"wallet.syncingOverlay.return": "Return to my wallets",
"wallet.syncingOverlay.title": "Wallet Syncing",
"wallet.topbar.dialog.cardano": "Cardano, ADA",
"wallet.topbar.dialog.tokenTypes": "Token types",
"wallet.topbar.dialog.totalBalance": "Total Balance",
"wallet.transaction.address.from": "From address",
Expand Down
1 change: 0 additions & 1 deletion packages/yoroi-extension/app/i18n/locales/hu-HU.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@
"wallet.syncingOverlay.explanation": "Please wait while we process wallet data. This may take some time.",
"wallet.syncingOverlay.return": "Return to my wallets",
"wallet.syncingOverlay.title": "Wallet Syncing",
"wallet.topbar.dialog.cardano": "Cardano, ADA",
"wallet.topbar.dialog.tokenTypes": "Token types",
"wallet.topbar.dialog.totalBalance": "Total Balance",
"wallet.transaction.address.from": "From address",
Expand Down
1 change: 0 additions & 1 deletion packages/yoroi-extension/app/i18n/locales/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@
"wallet.syncingOverlay.explanation": "Vui lòng đợi trong khi chúng tôi xử lý dữ liệu ví. Điều này có thể mất một thời gian.",
"wallet.syncingOverlay.return": "Quay lại ví của tôi",
"wallet.syncingOverlay.title": "Đồng bộ ví",
"wallet.topbar.dialog.cardano": "Cardano, ADA",
"wallet.topbar.dialog.tokenTypes": "Các kiểu token",
"wallet.topbar.dialog.totalBalance": "Tổng số dư",
"wallet.transaction.address.from": "Từ địa chỉ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,7 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
throw new Error('unexpected nullish headRequest.promise');
}
headRequest.promise.then(result => {
const { txs } = this.getTxHistoryState(publicDeriverId);
runInAction(() => {
txs.splice(0, 0, ...result);
});
return this._afterLoadingNewTxs(result, publicDeriver);
return this.updateNewTransactions(result, publicDeriver);
}).catch(error => {
console.error('error when loading transaction list head', error)
});
Expand Down Expand Up @@ -550,9 +546,13 @@ export default class TransactionsStore extends Store<StoresMap, ActionsMap> {
publicDeriver: WalletState,
): Promise<void> {
const { txs } = this.getTxHistoryState(publicDeriver.publicDeriverId);
// newTxs is not supposed to have duplicate txs to existing ones but there were unknown cases
// reported
const existingTxHashes = new Set(txs.map(tx => tx.txid));
const unseenTxs = [...new Set(newTxs)].filter(tx => !existingTxHashes.has(tx.txid));
runInAction(() => {
txs.splice(0, 0, ...newTxs);
txs.splice(0, 0, ...unseenTxs);
});
await this._afterLoadingNewTxs(txs, publicDeriver);
await this._afterLoadingNewTxs(unseenTxs, publicDeriver);
}
}
5 changes: 4 additions & 1 deletion packages/yoroi-extension/app/stores/toplevel/WalletStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class WalletStore extends Store<StoresMap, ActionsMap> {
}

@computed get selected(): null | WalletState {
if (typeof this.selectedIndex === 'number') {
if (this.selectedIndex != null) {
return this.wallets[this.selectedIndex];
}
return null;
Expand Down Expand Up @@ -415,6 +415,9 @@ export default class WalletStore extends Store<StoresMap, ActionsMap> {

@action onRenameSelectedWallet: (string) => void = (newName) => {
this.selectedWalletName = newName;
if (this.selectedIndex != null) {
this.wallets[this.selectedIndex].name = newName;
}
}
}

Expand Down
Loading

0 comments on commit 3ff9062

Please sign in to comment.