Skip to content

Commit

Permalink
Merge branch 'develop' into feat/portfolio-view
Browse files Browse the repository at this point in the history
  • Loading branch information
sahar-fehri authored Nov 21, 2024
2 parents 1a8cb68 + c20ac99 commit a8de3b2
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
"@metamask/snaps-sdk": "^6.11.0",
"@metamask/snaps-utils": "^8.6.0",
"@metamask/solana-wallet-snap": "^0.1.9",
"@metamask/transaction-controller": "^38.3.0",
"@metamask/transaction-controller": "^39.1.0",
"@metamask/user-operation-controller": "^13.0.0",
"@metamask/utils": "^10.0.1",
"@ngraveio/bc-ur": "^1.1.12",
Expand Down
37 changes: 37 additions & 0 deletions test/e2e/tests/settings/account-token-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,41 @@ describe('Settings', function () {
},
);
});

it('Should show crypto value when price checker setting is off', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder()
.withConversionRateEnabled()
.withShowFiatTestnetEnabled()
.withPreferencesControllerShowNativeTokenAsMainBalanceDisabled()
.withConversionRateDisabled()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.fullTitle(),
testSpecificMock: mockInfuraResponses,
},
async ({ driver }) => {
await unlockWallet(driver);

await driver.clickElement('[data-testid="popover-close"]');
await driver.clickElement(
'[data-testid="account-overview__asset-tab"]',
);

const tokenListAmount = await driver.findElement(
'.eth-overview__primary-container',
);
await driver.delay(1000);
assert.equal(await tokenListAmount.getText(), '25\nETH');

await driver.clickElement('[data-testid="account-menu-icon"]');
const accountTokenValue = await driver.waitForSelector(
'.multichain-account-list-item .multichain-account-list-item__asset',
);

assert.equal(await accountTokenValue.getText(), '25ETH');
},
);
});
});
62 changes: 62 additions & 0 deletions ui/components/app/name/__snapshots__/name.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,68 @@ exports[`Name renders address with image 1`] = `
</div>
`;

exports[`Name renders address with long saved name 1`] = `
<div>
<div
class="mm-box mm-box--display-flex"
>
<div
class="name name__saved"
>
<div
class=""
>
<div
class="identicon"
style="height: 16px; width: 16px; border-radius: 8px;"
>
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 16px; height: 16px; display: inline-block; background: rgb(245, 196, 0);"
>
<svg
height="16"
width="16"
x="0"
y="0"
>
<rect
fill="#C8144D"
height="16"
transform="translate(-0.8205726313476182 -2.375300755278998) rotate(408.5 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#FB1860"
height="16"
transform="translate(7.733089412585649 -1.3465466417019656) rotate(402.6 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#03505E"
height="16"
transform="translate(1.1000464230208766 -13.147318085284851) rotate(308.0 8 8)"
width="16"
x="0"
y="0"
/>
</svg>
</div>
</div>
</div>
<p
class="mm-box mm-text name__name mm-text--body-md mm-box--color-text-default"
>
Very long and l...
</p>
</div>
</div>
</div>
`;

exports[`Name renders address with no saved name 1`] = `
<div>
<div
Expand Down
18 changes: 18 additions & 0 deletions ui/components/app/name/name.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ describe('Name', () => {
expect(container).toMatchSnapshot();
});

it('renders address with long saved name', () => {
useDisplayNameMock.mockReturnValue({
name: "Very long and length saved name that doesn't seem to end, really.",
hasPetname: true,
});

const { container } = renderWithProvider(
<Name
type={NameType.ETHEREUM_ADDRESS}
value={ADDRESS_SAVED_NAME_MOCK}
variation={VARIATION_MOCK}
/>,
store,
);

expect(container).toMatchSnapshot();
});

it('renders address with image', () => {
useDisplayNameMock.mockReturnValue({
name: SAVED_NAME_MOCK,
Expand Down
10 changes: 8 additions & 2 deletions ui/components/app/name/name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NameType } from '@metamask/name-controller';
import classnames from 'classnames';
import { toChecksumAddress } from 'ethereumjs-util';
import { Box, Icon, IconName, IconSize, Text } from '../../component-library';
import { shortenAddress } from '../../../helpers/utils/util';
import { shortenAddress, shortenString } from '../../../helpers/utils/util';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
Expand Down Expand Up @@ -103,6 +103,12 @@ const Name = memo(
}, [setModalOpen]);

const formattedValue = formatValue(value, type);
const formattedName = shortenString(name || undefined, {
truncatedCharLimit: 15,
truncatedStartChars: 15,
truncatedEndChars: 0,
skipCharacterInEnd: true,
});
const hasDisplayName = Boolean(name);

return (
Expand Down Expand Up @@ -135,7 +141,7 @@ const Name = memo(
)}
{hasDisplayName ? (
<Text className="name__name" variant={TextVariant.bodyMd}>
{name}
{formattedName}
</Text>
) : (
<Text className="name__value" variant={TextVariant.bodyMd}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const AccountListItem = ({
let balanceToTranslate;
if (isEvmNetwork) {
balanceToTranslate =
shouldShowFiat || isTestnet || !process.env.PORTFOLIO_VIEW
!shouldShowFiat || isTestnet || !process.env.PORTFOLIO_VIEW
? account.balance
: totalFiatBalance;
} else {
Expand Down Expand Up @@ -345,7 +345,7 @@ const AccountListItem = ({
type={PRIMARY}
showFiat={showFiat}
isAggregatedFiatOverviewBalance={
!isTestnet && process.env.PORTFOLIO_VIEW
!isTestnet && process.env.PORTFOLIO_VIEW && shouldShowFiat
}
data-testid="first-currency-display"
privacyMode={privacyMode}
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6741,9 +6741,9 @@ __metadata:
languageName: node
linkType: hard

"@metamask/transaction-controller@npm:^38.3.0":
version: 38.3.0
resolution: "@metamask/transaction-controller@npm:38.3.0"
"@metamask/transaction-controller@npm:^39.1.0":
version: 39.1.0
resolution: "@metamask/transaction-controller@npm:39.1.0"
dependencies:
"@ethereumjs/common": "npm:^3.2.0"
"@ethereumjs/tx": "npm:^4.2.0"
Expand All @@ -6752,7 +6752,7 @@ __metadata:
"@ethersproject/contracts": "npm:^5.7.0"
"@ethersproject/providers": "npm:^5.7.0"
"@metamask/base-controller": "npm:^7.0.2"
"@metamask/controller-utils": "npm:^11.4.2"
"@metamask/controller-utils": "npm:^11.4.3"
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/metamask-eth-abis": "npm:^3.1.1"
"@metamask/nonce-tracker": "npm:^6.0.0"
Expand All @@ -6766,11 +6766,11 @@ __metadata:
uuid: "npm:^8.3.2"
peerDependencies:
"@babel/runtime": ^7.23.9
"@metamask/accounts-controller": ^18.0.0
"@metamask/accounts-controller": ^19.0.0
"@metamask/approval-controller": ^7.0.0
"@metamask/gas-fee-controller": ^22.0.0
"@metamask/network-controller": ^22.0.0
checksum: 10/f4e8e3a1a31e3e62b0d1a59bbe15ebfa4dc3e4cf077fb95c1815c00661c60ef4676046c49f57eab9749cd31d3e55ac3fed7bc247e3f5a3d459f2dcb03998633d
checksum: 10/9c18f01167ca70556323190c3b3b8df29d5c1d45846e6d50208b49d27bd3d361ab89f103d5f4a784bbc70cee3e5ef595bab8cf568926c790236d32ace07a1283
languageName: node
linkType: hard

Expand Down Expand Up @@ -26893,7 +26893,7 @@ __metadata:
"@metamask/solana-wallet-snap": "npm:^0.1.9"
"@metamask/test-bundler": "npm:^1.0.0"
"@metamask/test-dapp": "npm:8.13.0"
"@metamask/transaction-controller": "npm:^38.3.0"
"@metamask/transaction-controller": "npm:^39.1.0"
"@metamask/user-operation-controller": "npm:^13.0.0"
"@metamask/utils": "npm:^10.0.1"
"@ngraveio/bc-ur": "npm:^1.1.12"
Expand Down

0 comments on commit a8de3b2

Please sign in to comment.