Skip to content
Merged
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
25 changes: 25 additions & 0 deletions extension/e2e-tests/sendPayment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,31 @@ test("Send doesn't throw error when creating muxed account", async ({
});
});

test("Send can review formatted inputs", async ({ page, extensionId }) => {
test.slow();
await loginAndFund({ page, extensionId });
await page.getByTestId("nav-link-send").click({ force: true });

await expect(page.getByText("Send")).toBeVisible();
await page
.getByTestId("send-to-input")
.fill(
"MAUPPMNJUS76SG5NA6UXVCSO5HYVAJT422LBISV6LMCX37OIEPDJGAAAAAAAAAAAAF54C",
);
await expect(
page.getByText("The destination account doesn’t exist."),
).toBeVisible();
await page.getByText("Continue").click();

await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Send");
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill("1000");
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 200000,
});
});

test("Send XLM payments to recent federated addresses", async ({
page,
extensionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface ManageAssetRowButtonProps {
code: string;
issuer: string;
isTrustlineActive: boolean;
isSac: boolean;
isLoading: boolean;
onClick: () => void;
}
Expand All @@ -22,6 +23,7 @@ export const ManageAssetRowButton = ({
code,
issuer,
isTrustlineActive,
isSac,
isLoading,
onClick,
}: ManageAssetRowButtonProps) => {
Expand Down Expand Up @@ -69,28 +71,30 @@ export const ManageAssetRowButton = ({
</>
</CopyText>
</div>
<div className="ManageAssetRowButton__dropdown__row">
<Button
className="ManageAssetRowButton__remove"
size="md"
variant="secondary"
disabled={isLoading}
isLoading={isLoading}
onClick={() => {
setRowButtonShowing("");
onClick();
}}
type="button"
data-testid="ManageAssetRowButton"
>
<div className="ManageAssetRowButton__label">
{t("Remove asset")}
</div>
{isLoading ? null : (
<img src={IconRemove} alt="icon remove" />
)}
</Button>
</div>
{!isSac && (
<div className="ManageAssetRowButton__dropdown__row">
<Button
className="ManageAssetRowButton__remove"
size="md"
variant="secondary"
disabled={isLoading}
isLoading={isLoading}
onClick={() => {
setRowButtonShowing("");
onClick();
}}
type="button"
data-testid="ManageAssetRowButton"
>
<div className="ManageAssetRowButton__label">
{t("Remove asset")}
</div>
{isLoading ? null : (
<img src={IconRemove} alt="icon remove" />
)}
</Button>
</div>
)}
{createPortal(
<div
className="ManageAssetRowButton__dropdown__background"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const SubmitTransaction = ({
)}
{isFail && (
<>
<Icon.CheckCircle className="SubmitTransaction__Title__Fail" />
<Icon.XCircle className="SubmitTransaction__Title__Fail" />
<span>Failed!</span>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { navigateTo } from "popup/helpers/navigate";
import { ROUTES } from "popup/constants/routes";

import "./styles.scss";
import { isSacContract } from "popup/helpers/soroban";
import { truncateString } from "helpers/stellar";

interface ToggleTokenInternalProps {
asset: {
Expand Down Expand Up @@ -57,6 +59,10 @@ export const ToggleTokenInternal = ({
}
navigateTo(ROUTES.account, nav);
};
const isSac =
!!asset.name &&
!!asset.contract &&
isSacContract(asset.name, asset.contract, networkDetails.networkPassphrase);
return (
<div className="ToggleToken__wrapper">
<div className="ToggleToken__wrapper__body">
Expand Down Expand Up @@ -88,7 +94,7 @@ export const ToggleTokenInternal = ({
)}

<Text as="div" size="sm" weight="medium">
{asset.name || asset.code}
{isSac ? asset.code : asset.name || truncateString(asset.contract!)}
</Text>
<div className="ToggleToken__wrapper__badge">
<Badge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { ManageAssetRowButton } from "../ManageAssetRowButton";
import { ToggleTokenInternal } from "./ToggleTokenInternal";

import "./styles.scss";
import { NetworkDetails } from "@shared/constants/stellar";
import { getNativeContractDetails } from "popup/helpers/searchAsset";

export type ManageAssetCurrency = {
code?: string;
Expand Down Expand Up @@ -86,6 +88,7 @@ export const ManageAssetRows = ({
accountBalances={balances}
verifiedAssetRows={verifiedAssetRows}
unverifiedAssetRows={unverifiedAssetRows}
networkDetails={networkDetails}
shouldSplitAssetsByVerificationStatus={
shouldSplitAssetsByVerificationStatus
}
Expand All @@ -96,6 +99,7 @@ export const ManageAssetRows = ({
image,
issuer,
isSuspicious,
isSac,
isTrustlineActive,
name,
}) => (
Expand All @@ -112,6 +116,7 @@ export const ManageAssetRows = ({
code={code}
issuer={issuer}
isTrustlineActive={!!isTrustlineActive}
isSac={isSac}
isLoading={false}
onClick={async () => {
setSelectedAsset({
Expand Down Expand Up @@ -178,11 +183,13 @@ const AssetRows = ({
shouldSplitAssetsByVerificationStatus,
unverifiedAssetRows,
verifiedAssetRows,
networkDetails,
}: {
accountBalances: AccountBalances;
shouldSplitAssetsByVerificationStatus?: boolean;
unverifiedAssetRows: ManageAssetCurrency[];
verifiedAssetRows: ManageAssetCurrency[];
networkDetails: NetworkDetails;
renderAssetRow: ({
code,
domain,
Expand All @@ -193,6 +200,7 @@ const AssetRows = ({
isContract,
isTrustlineActive,
isSuspicious,
isSac,
}: {
code: string;
domain: string;
Expand All @@ -203,6 +211,7 @@ const AssetRows = ({
isContract: boolean;
isTrustlineActive: boolean;
isSuspicious?: boolean;
isSac: boolean;
}) => React.ReactNode;
}) => {
const { t } = useTranslation();
Expand Down Expand Up @@ -242,12 +251,22 @@ const AssetRows = ({
if (!accountBalances.balances) {
return null;
}
const nativeContract = getNativeContractDetails(networkDetails);
const isContract = isContractId(contract);
const canonicalAsset = getCanonicalFromAsset(code, issuer);
const isTrustlineActive = findAssetBalance(
accountBalances.balances,
{ code, issuer },
);
const isSac =
contract === nativeContract.contract ||
(!!name &&
!!contract &&
isSacContract(
name,
contract,
networkDetails.networkPassphrase,
));
return (
<div
className="ManageAssetRows__row"
Expand All @@ -262,7 +281,10 @@ const AssetRows = ({
isContract,
issuer,
isSuspicious,
isTrustlineActive: isTrustlineActive !== undefined,
isSac,
isTrustlineActive:
isTrustlineActive !== undefined ||
contract === nativeContract.contract,
name,
})}
</div>
Expand Down Expand Up @@ -301,12 +323,23 @@ const AssetRows = ({
if (!accountBalances.balances) {
return null;
}
const nativeContract = getNativeContractDetails(networkDetails);
const isContract = isContractId(contract);
const canonicalAsset = getCanonicalFromAsset(code, issuer);
const isTrustlineActive = findAssetBalance(
accountBalances.balances,
{ code, issuer },
);
const isSac =
contract === nativeContract.contract ||
(!!name &&
!!contract &&
isSacContract(
name,
contract,
networkDetails.networkPassphrase,
));

return (
<div
className="ManageAssetRows__row"
Expand All @@ -321,7 +354,10 @@ const AssetRows = ({
isContract,
issuer,
isSuspicious,
isTrustlineActive: isTrustlineActive !== undefined,
isSac,
isTrustlineActive:
isTrustlineActive !== undefined ||
contract === nativeContract.contract,
name,
})}
</div>
Expand All @@ -347,12 +383,18 @@ const AssetRows = ({
if (!accountBalances.balances) {
return null;
}
const nativeContract = getNativeContractDetails(networkDetails);
const isContract = isContractId(contract);
const canonicalAsset = getCanonicalFromAsset(code, issuer);
const isTrustlineActive = findAssetBalance(accountBalances.balances, {
code,
issuer,
});
const isSac =
contract === nativeContract.contract ||
(!!name &&
!!contract &&
isSacContract(name, contract, networkDetails.networkPassphrase));
return (
<div
className="ManageAssetRows__row"
Expand All @@ -367,7 +409,10 @@ const AssetRows = ({
isContract,
issuer,
isSuspicious,
isTrustlineActive: isTrustlineActive !== undefined,
isSac,
isTrustlineActive:
isTrustlineActive !== undefined ||
contract === nativeContract.contract,
name,
})}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ const useAssetLookup = () => {
assetRows = [
{
code: nativeContractDetails.code,
issuer: contractId,
issuer: nativeContractDetails.issuer,
contract: contractId,
domain: nativeContractDetails.domain,
name: `${nativeContractDetails.code}:${nativeContractDetails.issuer}`,
},
];

Expand Down Expand Up @@ -325,12 +327,6 @@ const useAssetLookup = () => {
dispatch({ type: "FETCH_DATA_ERROR", payload: DEFAULT_PAYLOAD });
return;
}

// Only show records that have a domain and domains that don't have just whitespace
// We omit these results as a safety precaution and to encourage asset issuers to add a domain to their asset
assetRows = assetRows.filter(
(record) => record.domain && /\S/.test(record.domain),
);
}

const assetsListsData = await getCombinedAssetListData({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
import { findAddressBalance } from "popup/helpers/balance";
import { AppDispatch } from "popup/App";
import { useScanTx } from "popup/helpers/blockaid";
import { cleanAmount } from "popup/helpers/formatters";

interface SimClassic {
type: "classic";
Expand Down Expand Up @@ -375,7 +376,7 @@ function useSimulateTxData({
? Asset.native().contractId(networkDetails.networkPassphrase)
: assetAddress;
const parsedAmount = parseTokenAmount(
amount,
cleanAmount(amount),
Number("decimals" in assetBalance ? assetBalance.decimals : 7),
);

Expand Down Expand Up @@ -426,7 +427,7 @@ function useSimulateTxData({
{
sourceAsset,
destAsset,
amount,
amount: cleanAmount(amount),
destinationAmount,
destination,
allowedSlippage,
Expand Down
8 changes: 6 additions & 2 deletions extension/src/popup/components/swap/SwapAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ export const SwapAmount = ({

const handleContinue = async (values: { amount: string }) => {
const amount = inputType === "crypto" ? values.amount : priceValue!;
dispatch(saveAmount(cleanAmount(amount)));
await fetchSimulationData({ amount, destinationRate: dstAssetPrice });
const cleanedAmount = cleanAmount(amount);
dispatch(saveAmount(cleanedAmount));
await fetchSimulationData({
amount: cleanedAmount,
destinationRate: dstAssetPrice,
});
setIsReviewingTx(true);
};

Expand Down
Loading