Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extension/e2e-tests/blockaidScan.malicious.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ test.describe("BlockAid Scan - Malicious States", () => {
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText(
"Swap from",
);
await expect(page.getByText(/XLM/)).toBeVisible();
await expect(page.getByTestId("XLM-balance")).toBeVisible();
await page.getByTestId("XLM-balance").click();

await page.getByTestId("swap-dst-asset-tile").click({ force: true });
await expect(page.getByText("Swap to")).toBeVisible();
await expect(page.getByText(/USDC/)).toBeVisible();
await expect(page.getByTestId("USDC-balance")).toBeVisible();
await page.getByTestId("USDC-balance").click();

await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Swap");
Expand Down
4 changes: 2 additions & 2 deletions extension/e2e-tests/blockaidScan.safe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ test.describe("BlockAid Scan - Safe States (No Override)", () => {
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText(
"Swap from",
);
await expect(page.getByText(/XLM/)).toBeVisible();
await expect(page.getByTestId("XLM-balance")).toBeVisible();
await page.getByTestId("XLM-balance").click();

await page.getByTestId("swap-dst-asset-tile").click({ force: true });
await expect(page.getByText("Swap to")).toBeVisible();
await expect(page.getByText(/USDC/)).toBeVisible();
await expect(page.getByTestId("USDC-balance")).toBeVisible();
await page.getByTestId("USDC-balance").click();

await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Swap");
Expand Down
4 changes: 2 additions & 2 deletions extension/e2e-tests/blockaidScan.suspicious.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ test.describe("BlockAid Scan - Suspicious States", () => {
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText(
"Swap from",
);
await expect(page.getByText(/XLM/)).toBeVisible();
await expect(page.getByTestId("XLM-balance")).toBeVisible();
await page.getByTestId("XLM-balance").click();

await page.getByTestId("swap-dst-asset-tile").click({ force: true });
await expect(page.getByText("Swap to")).toBeVisible();
await expect(page.getByText(/USDC/)).toBeVisible();
await expect(page.getByTestId("USDC-balance")).toBeVisible();
await page.getByTestId("USDC-balance").click();

await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Swap");
Expand Down
4 changes: 2 additions & 2 deletions extension/e2e-tests/blockaidScan.unable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ test.describe("BlockAid Scan - Unable to Scan States", () => {
await expect(page.getByTestId("AppHeaderPageTitle")).toContainText(
"Swap from",
);
await expect(page.getByText(/XLM/)).toBeVisible();
await expect(page.getByTestId("XLM-balance")).toBeVisible();
await page.getByTestId("XLM-balance").click();

// Select destination token (USDC)
await page.getByTestId("swap-dst-asset-tile").click({ force: true });
await expect(page.getByText("Swap to")).toBeVisible();
await expect(page.getByText(/USDC/)).toBeVisible();
await expect(page.getByTestId("USDC-balance")).toBeVisible();
await page.getByTestId("USDC-balance").click();

// Wait to be back at amount step
Expand Down
20 changes: 10 additions & 10 deletions extension/e2e-tests/reviewTxFees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("Fee breakdown pane shows Soroban fees for token send", async ({
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send via Asset Detail
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -276,7 +276,7 @@ test("Custom token without destination — full fee lifecycle in EditSettings an
// Navigate to token send and set destination.
// Auto-simulation fires as soon as destination is set (isToken=true), so the
// fee display will update to the simulated total without needing an amount.
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -392,7 +392,7 @@ test("Custom token with recipient — full fee lifecycle in EditSettings and Fee
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send and set destination
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -512,7 +512,7 @@ test("Custom fee resets to default when re-entering send flow from home screen",
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// ── First session: set custom fee ─────────────────────────────────────────
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -605,7 +605,7 @@ test("Auto-simulation updates fee display on SendAmount before Review Send", asy
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send via Asset Detail
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -634,7 +634,7 @@ test("Soroban token — manually set fee is preserved when recipient is selected
await stubContractSpec(page, TEST_TOKEN_ADDRESS, true);
await loginToTestAccount({ page, extensionId, context, stubOverrides });

await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -876,7 +876,7 @@ test("Re-simulation on destination change shows correct inclusion fee in EditSet
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -947,7 +947,7 @@ test("FeesPane shows inclusion/resource rows immediately for Soroban — resourc
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send and set destination (no amount — no auto-simulation fires)
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -1005,7 +1005,7 @@ test("FeesPane shows — for all fee rows when simulation fails", async ({
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send and set destination + amount to trigger auto-simulation
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down Expand Up @@ -1048,7 +1048,7 @@ test("Send settings Default button resets to recommended fee after saving custom
await loginToTestAccount({ page, extensionId, context, stubOverrides });

// Navigate to token send and trigger Soroban simulation
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
await page.getByTestId("send-to-input").fill(FUNDED_DESTINATION);
Expand Down
10 changes: 5 additions & 5 deletions extension/e2e-tests/sendPayment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ test("Swap shows correct balances for assets", async ({
// Click on source asset tile to see asset list
await page.getByTestId("swap-src-asset-tile").click();
await expect(page.getByText("Swap from")).toBeVisible();
await expect(page.getByText(/FOO/)).toBeVisible();
await expect(page.getByTestId("FOO-balance")).toBeVisible();
await expect(page.getByTestId("FOO-balance")).toContainText("100");
await expect(page.getByTestId("BAZ-balance")).toContainText("10");
await expect(page.getByTestId("PBT-balance")).toContainText("98.997");
Expand Down Expand Up @@ -681,7 +681,7 @@ test.fixme("Send SAC to C address", async ({ page, extensionId, context }) => {
// Click on destination asset tile to select USDC
await page.getByTestId("swap-dst-asset-tile").click({ force: true });
await expect(page.getByText("Swap to")).toBeVisible();
await page.getByText("USDC").click({ force: true });
await page.getByTestId("USDC-balance").click({ force: true });

// Back at amount step, fill in amount
await expect(page.getByText("Swap")).toBeVisible();
Expand Down Expand Up @@ -1039,7 +1039,7 @@ test("Send flow from asset detail starts at destination step", async ({
await stubContractSpec(page, TEST_TOKEN_ADDRESS, true);
await loginToTestAccount({ page, extensionId, context, stubOverrides });

await page.getByText("E2E").click();
await page.getByText("E2E").first().click();
await page.getByTestId("asset-detail-send-button").click();

// Asset detail pre-selects asset via ?asset= param → starts at DESTINATION
Expand Down Expand Up @@ -1196,7 +1196,7 @@ test("Send token payment from Asset Detail", async ({
context,
stubOverrides,
});
await page.getByText("E2E").click();
await page.getByText("E2E").first().click();

await page.getByTestId("asset-detail-send-button").click();
// Asset detail navigates with ?asset= param, so we land at DESTINATION (not token picker)
Expand Down Expand Up @@ -1239,7 +1239,7 @@ test("Send XLM payment from Asset Detail", async ({
context,
stubOverrides,
});
await page.getByText("XLM").click();
await page.getByText("Stellar Lumens").click();

await page.getByTestId("asset-detail-send-button").click();
await expect(page.getByTestId("send-to-input")).toBeVisible();
Expand Down
11 changes: 9 additions & 2 deletions extension/src/helpers/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ export const computeDestMinWithSlippage = (
return new BigNumber(destMin).times(new BigNumber(mult));
};

export const title = (balance: Exclude<AssetType, LiquidityPoolShareAsset>) => {
export const NATIVE_ASSET_DISPLAY_NAME = "Stellar Lumens";

export const getDisplayName = (
balance: Exclude<AssetType, LiquidityPoolShareAsset>,
) => {
if ("type" in balance.token && balance.token.type === "native") {
return "XLM";
return NATIVE_ASSET_DISPLAY_NAME;
}
if ("symbol" in balance) {
return balance.symbol;
}

return balance.token.code;
};

export const getDisplayNameFromCode = (code: string, isNative: boolean) =>
isNative ? NATIVE_ASSET_DISPLAY_NAME : code;
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ describe("AssetTile", () => {
/>,
);

expect(screen.getByTestId("tile-primary")).toHaveTextContent("XLM");
expect(screen.getByTestId("tile-primary")).toHaveTextContent(
"Stellar Lumens",
);
expect(screen.getByTestId("tile-secondary")).toHaveTextContent("500.00");
expect(
screen.getByTestId("AccountAssets__asset--loading-XLM"),
Expand Down
6 changes: 5 additions & 1 deletion extension/src/popup/components/AssetTile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";

import { AssetIcon } from "popup/components/account/AccountAssets";
import { SelectionTile } from "popup/components/SelectionTile";
import { getDisplayNameFromCode } from "helpers/transaction";

interface AssetTileProps {
asset: {
Expand Down Expand Up @@ -48,7 +49,10 @@ export const AssetTile = ({
isSuspicious={isSuspicious}
/>
}
primaryText={asset.code}
primaryText={getDisplayNameFromCode(
asset.code,
asset.canonical === "native",
)}
secondaryText={balance}
onClick={onClick}
shouldUseIconWrapper={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getAvailableBalance } from "popup/helpers/soroban";
import { formatAmount, roundUsdValue } from "popup/helpers/formatters";
import { sortBalancesByValue } from "popup/helpers/balance";
import { AssetIcon } from "popup/components/account/AccountAssets";
import { title } from "helpers/transaction";
import { getDisplayName } from "helpers/transaction";

import "./styles.scss";

Expand Down Expand Up @@ -107,13 +107,13 @@ export const TokenList = ({
/>
<div className="TokenList__AssetRow__Title">
<div className="TokenList__AssetRow__Title__Heading">
{title(balance)}
{getDisplayName(balance)}
</div>
<div
className="TokenList__AssetRow__Title__Total"
data-testid={`${code}-balance`}
>
{displayTotal}
{displayTotal} {code}
</div>
</div>
</div>
Expand Down
12 changes: 10 additions & 2 deletions extension/src/popup/components/account/AccountAssets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ import BigNumber from "bignumber.js";
import isEqual from "lodash/isEqual";

import { ApiTokenPrices, AssetIcons, Balance } from "@shared/api/types";
import {
AssetType,
LiquidityPoolShareAsset,
} from "@shared/api/types/account-balance";
import { retryAssetIcon } from "@shared/api/internal";
import { AccountBalances } from "helpers/hooks/useGetBalances";

import { getCanonicalFromAsset } from "helpers/stellar";
import { getDisplayName } from "helpers/transaction";
import { isSorobanIssuer } from "popup/helpers/account";
import { formatTokenAmount } from "popup/helpers/soroban";
import { useIsAssetSuspicious } from "popup/helpers/blockaid";
Expand Down Expand Up @@ -314,6 +319,9 @@ export const AccountAssets = ({
}

const canonicalAsset = getCanonicalFromAsset(code, issuer?.key);
const displayName = isLP
? code
: getDisplayName(rb as Exclude<AssetType, LiquidityPoolShareAsset>);
const assetPrice = assetPrices ? assetPrices[canonicalAsset] : null;

const isSuspicious = isAssetSuspicious((rb as Balance).blockaidData);
Expand Down Expand Up @@ -351,12 +359,12 @@ export const AccountAssets = ({
isSuspicious={isSuspicious}
/>
<div className="asset-native-value">
<span className="asset-code">{code}</span>
<span className="asset-code">{displayName}</span>
<div
className="asset-native-amount"
data-testid="asset-amount"
>
{formatAmount(amountVal)}
{formatAmount(amountVal)} {code}
</div>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions extension/src/popup/components/account/AssetDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import StellarLogo from "popup/assets/stellar-logo.png";
import { formatAmount, roundUsdValue } from "popup/helpers/formatters";
import { Loading } from "popup/components/Loading";
import { AccountBalances } from "helpers/hooks/useGetBalances";
import { title } from "helpers/transaction";
import { getDisplayName } from "helpers/transaction";
import {
getBalanceByAsset,
getPriceDeltaColor,
Expand Down Expand Up @@ -216,6 +216,11 @@ export const AssetDetail = ({
: `asset/${selectedAsset.replace(":", "-")}`;

const isLpShare = "liquidityPoolId" in selectedBalance;
const displayName = isLpShare
? canonical.code
: getDisplayName(
selectedBalance as Exclude<AssetType, LiquidityPoolShareAsset>,
);
const hasBalance =
selectedBalance?.total &&
new BigNumber(selectedBalance.total).isGreaterThan(0);
Expand All @@ -236,7 +241,7 @@ export const AssetDetail = ({
<React.Fragment>
<View>
<SubviewHeader
title={canonical.code}
title={displayName}
customBackIcon={<Icon.X />}
customBackAction={handleClose}
rightButton={
Expand Down Expand Up @@ -310,12 +315,7 @@ export const AssetDetail = ({
<div className="AssetDetail__title">
{isLpShare && "liquidityPoolId" in selectedBalance
? `LP: ${truncateString(selectedBalance.liquidityPoolId as string, 12)}`
: title(
selectedBalance as Exclude<
AssetType,
LiquidityPoolShareAsset
>,
) || assetDomain}
: displayName || assetDomain}
</div>
{"contractId" in selectedBalance ? (
<div className="AssetDetail__subtitle">
Expand Down
4 changes: 2 additions & 2 deletions extension/src/popup/components/swap/SwapAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ export const SwapAmount = ({
balances: sendData.userBalances.balances,
recommendedFee: fee,
});
const displayTotal = `${formatAmount(availableBalance)}`;
const displayTotal = `${formatAmount(availableBalance)} ${srcAsset.code}`;
const dstDisplayTotal =
dstAssetBalance && dstAsset
? `${formatAmount(dstAssetBalance.total.toString())}`
? `${formatAmount(dstAssetBalance.total.toString())} ${dstAsset.code}`
: "0";
const isAmountTooHigh =
(inputType === "crypto" &&
Expand Down
1 change: 1 addition & 0 deletions extension/src/popup/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@
"Status": "Status",
"Stellar Development Foundation will never ask for your phrase": "Stellar Development Foundation will never ask for your phrase",
"Stellar Logo": "Stellar Logo",
"Stellar Lumens": "Stellar Lumens",
"Stellar Network": "Stellar Network",
"Stellar token logo": "Stellar token logo",
"Storing your secret key is your responsibility.": "Storing your secret key is your responsibility.",
Expand Down
1 change: 1 addition & 0 deletions extension/src/popup/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@
"Status": "Status",
"Stellar Development Foundation will never ask for your phrase": "A Stellar Development Foundation nunca pedirá sua frase",
"Stellar Logo": "Logo Stellar",
"Stellar Lumens": "Stellar Lumens",
"Stellar Network": "Rede Stellar",
"Stellar token logo": "Logotipo do token Stellar",
"Storing your secret key is your responsibility.": "Armazenar sua chave secreta é sua responsabilidade.",
Expand Down
Loading
Loading