Skip to content

Commit

Permalink
Revert "Release/5.21.0 (#1349)" (#1354)
Browse files Browse the repository at this point in the history
This reverts commit ce05d1e.
  • Loading branch information
piyalbasu authored Jul 1, 2024
1 parent ce05d1e commit e9ef68c
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 874 deletions.
8 changes: 0 additions & 8 deletions @shared/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,6 @@ export interface AssetDomains {
[code: string]: string;
}

export interface SoroswapToken {
code: string;
contract: string;
decimals: number;
icon: string;
name: string;
}

export interface NativeToken {
type: SdkAssetType;
code: string;
Expand Down
22 changes: 0 additions & 22 deletions extension/INTEGRATING_SOROSWAP.MD

This file was deleted.

3 changes: 1 addition & 2 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"sass-loader": "^14.2.1",
"semver": "^7.5.4",
"ses": "^0.18.5",
"soroswap-router-sdk": "^1.2.8",
"stellar-hd-wallet": "^0.0.10",
"stellar-identicon-js": "^1.0.0",
"stellar-sdk": "yarn:stellar-sdk@^12.1.0",
Expand Down Expand Up @@ -112,4 +111,4 @@
"stellar-sdk>stellar-base>sodium-native": false
}
}
}
}
19 changes: 14 additions & 5 deletions extension/public/static/manifest/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
},
"background": {
"service_worker": "background.min.js",
"scripts": ["background.min.js"]
"scripts": [
"background.min.js"
]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentScript.min.js"],
"matches": [
"<all_urls>"
],
"js": [
"contentScript.min.js"
],
"run_at": "document_start"
}
],
Expand All @@ -35,6 +41,9 @@
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"permissions": ["storage", "alarms"],
"permissions": [
"storage",
"alarms"
],
"manifest_version": 3
}
}
25 changes: 5 additions & 20 deletions extension/src/popup/components/account/AccountAssets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ export const AssetIcon = ({
retryAssetIconFetch,
isLPShare = false,
isSorobanToken = false,
icon,
}: {
assetIcons: AssetIcons;
code: string;
issuerKey: string;
retryAssetIconFetch?: (arg: { key: string; code: string }) => void;
isLPShare?: boolean;
isSorobanToken?: boolean;
icon?: string;
}) => {
/*
We load asset icons in 2 ways:
Expand All @@ -66,13 +64,8 @@ export const AssetIcon = ({
// For all non-XLM assets (assets where we need to fetch the icon from elsewhere), start by showing a loading state as there is work to do
const [isLoading, setIsLoading] = useState(!isXlm);

const { soroswapTokens } = useSelector(transactionSubmissionSelector);

const canonicalAsset = assetIcons[getCanonicalFromAsset(code, issuerKey)];
let imgSrc = hasError ? ImageMissingIcon : canonicalAsset || "";
if (icon) {
imgSrc = icon;
}
const imgSrc = hasError ? ImageMissingIcon : canonicalAsset || "";

const _isSorobanToken = !isSorobanToken
? issuerKey && isSorobanIssuer(issuerKey)
Expand All @@ -87,17 +80,9 @@ export const AssetIcon = ({
);
}

// Get icons for Soroban tokens
if (_isSorobanToken && !icon) {
const soroswapTokenDetail = soroswapTokens.find(
(token) => token.contract === issuerKey,
);
// check to see if we have an icon from an external service, like Soroswap
if (soroswapTokenDetail?.icon) {
imgSrc = soroswapTokenDetail?.icon;
} else {
return <SorobanTokenIcon />;
}
// Placeholder for Soroban tokens
if (_isSorobanToken) {
return <SorobanTokenIcon />;
}

// If we're waiting on the icon lookup (Method 1), just return the loader until this re-renders with `assetIcons`. We can't do anything until we have it.
Expand All @@ -108,7 +93,7 @@ export const AssetIcon = ({
}

// if we have an asset path, start loading the path in an `<img>`
return canonicalAsset || isXlm || imgSrc ? (
return canonicalAsset || isXlm ? (
<div
className={`AccountAssets__asset--logo ${
hasError ? "AccountAssets__asset--error" : ""
Expand Down
48 changes: 10 additions & 38 deletions extension/src/popup/components/manageAssets/ChooseAsset/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from "react-i18next";

import { ROUTES } from "popup/constants/routes";
import { sortBalances } from "popup/helpers/account";
import { useIsSoroswapEnabled, useIsSwap } from "popup/helpers/useIsSwap";
import { useIsSwap } from "popup/helpers/useIsSwap";
import {
transactionSubmissionSelector,
AssetSelectType,
Expand All @@ -19,7 +19,6 @@ import { SubviewHeader } from "popup/components/SubviewHeader";
import { View } from "popup/basics/layout/View";
import { getCanonicalFromAsset } from "helpers/stellar";
import { getAssetDomain } from "popup/helpers/getAssetDomain";
import { getNativeContractDetails } from "popup/helpers/searchAsset";

import { Balances } from "@shared/api/types";

Expand All @@ -34,17 +33,18 @@ interface ChooseAssetProps {

export const ChooseAsset = ({ balances }: ChooseAssetProps) => {
const { t } = useTranslation();
const { assetIcons, assetSelect, soroswapTokens } = useSelector(
const { assetIcons, assetSelect } = useSelector(
transactionSubmissionSelector,
);
const isSorobanSuported = useSelector(settingsSorobanSupportedSelector);
const networkDetails = useSelector(settingsNetworkDetailsSelector);
const { networkUrl, networkPassphrase } = useSelector(
settingsNetworkDetailsSelector,
);

const [assetRows, setAssetRows] = useState([] as ManageAssetCurrency[]);
const ManageAssetRowsWrapperRef = useRef<HTMLDivElement>(null);
const [isLoading, setIsLoading] = useState(false);
const isSwap = useIsSwap();
const isSoroswapEnabled = useIsSoroswapEnabled();

const managingAssets = assetSelect.type === AssetSelectType.MANAGE;

Expand All @@ -68,8 +68,7 @@ export const ChooseAsset = ({ balances }: ChooseAssetProps) => {
contractId,
} = sortedBalances[i];

// If we are in the swap flow and the asset has decimals (is a token), we skip it if Soroswap is not enabled
if ("decimals" in sortedBalances[i] && isSwap && !isSoroswapEnabled) {
if (isSwap && "decimals" in sortedBalances[i]) {
// eslint-disable-next-line
continue;
}
Expand All @@ -82,8 +81,8 @@ export const ChooseAsset = ({ balances }: ChooseAssetProps) => {
// eslint-disable-next-line no-await-in-loop
domain = await getAssetDomain(
issuer.key as string,
networkDetails.networkUrl,
networkDetails.networkPassphrase,
networkUrl,
networkPassphrase,
);
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -111,31 +110,6 @@ export const ChooseAsset = ({ balances }: ChooseAssetProps) => {
}
}

if (isSoroswapEnabled && isSwap && !assetSelect.isSource) {
soroswapTokens.forEach((token) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const canonical = getCanonicalFromAsset(token.code, token.contract);
const nativeContractDetails =
getNativeContractDetails(networkDetails);

// if we have a balance for a token, it will have been handled above.
// This is designed to populate tokens available from Soroswap that the user does not already have
if (
balances &&
!balances[canonical] &&
token.contract !== nativeContractDetails.contract
) {
collection.push({
code: token.code,
issuer: token.contract,
image: token.icon,
domain: "",
icon: token.icon,
});
}
});
}

setAssetRows(collection);
setIsLoading(false);
};
Expand All @@ -144,13 +118,11 @@ export const ChooseAsset = ({ balances }: ChooseAssetProps) => {
}, [
assetIcons,
balances,
networkUrl,
managingAssets,
isSorobanSuported,
isSwap,
isSoroswapEnabled,
assetSelect.isSource,
soroswapTokens,
networkDetails,
networkPassphrase,
]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import "./styles.scss";
export type ManageAssetCurrency = StellarToml.Api.Currency & {
domain: string;
contract?: string;
icon?: string;
};

export interface NewAssetFlags {
Expand Down
100 changes: 45 additions & 55 deletions extension/src/popup/components/manageAssets/SelectAssetRows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
transactionSubmissionSelector,
saveAsset,
saveDestinationAsset,
saveDestinationIcon,
saveIsToken,
AssetSelectType,
saveIsSoroswap,
} from "popup/ducks/transactionSubmission";
import { AssetIcon } from "popup/components/account/AccountAssets";
import { ManageAssetCurrency } from "popup/components/manageAssets/ManageAssetRows";
Expand All @@ -31,7 +29,6 @@ export const SelectAssetRows = ({ assetRows }: SelectAssetRowsProps) => {
accountBalances: { balances = {} },
assetSelect,
blockedDomains,
soroswapTokens,
} = useSelector(transactionSubmissionSelector);
const dispatch: AppDispatch = useDispatch();
const history = useHistory();
Expand All @@ -55,7 +52,7 @@ export const SelectAssetRows = ({ assetRows }: SelectAssetRowsProps) => {
if (bal) {
return getTokenBalance(bal);
}
return "0";
return "";
};

// hide balances for path pay dest asset
Expand All @@ -66,62 +63,55 @@ export const SelectAssetRows = ({ assetRows }: SelectAssetRowsProps) => {
return (
<div className="SelectAssetRows__scrollbar">
<div className="SelectAssetRows__content">
{assetRows.map(
({ code = "", domain, image = "", issuer = "", icon }) => {
const isScamAsset = !!blockedDomains.domains[domain];
const isContract = isContractId(issuer);
const canonical = getCanonicalFromAsset(code, issuer);
{assetRows.map(({ code = "", domain, image = "", issuer = "" }) => {
const isScamAsset = !!blockedDomains.domains[domain];
const isContract = isContractId(issuer);
const canonical = getCanonicalFromAsset(code, issuer);

return (
<div
className="SelectAssetRows__row selectable"
key={canonical}
onClick={() => {
if (assetSelect.isSource) {
dispatch(saveAsset(canonical));
dispatch(saveIsToken(isContract));
history.goBack();
return (
<div
className="SelectAssetRows__row selectable"
key={canonical}
onClick={() => {
if (assetSelect.isSource) {
dispatch(saveAsset(canonical));
if (isContract) {
dispatch(saveIsToken(true));
} else {
dispatch(saveDestinationAsset(canonical));
dispatch(saveDestinationIcon(icon));
dispatch(
saveIsSoroswap(
!!soroswapTokens.find(
({ contract }) => contract === issuer,
),
),
);
history.goBack();
dispatch(saveIsToken(false));
}
}}
>
<AssetIcon
assetIcons={code !== "XLM" ? { [canonical]: image } : {}}
code={code}
issuerKey={issuer}
icon={icon}
/>
<div className="SelectAssetRows__row__info">
<div className="SelectAssetRows__row__info__header">
{code}
<ScamAssetIcon isScamAsset={isScamAsset} />
</div>
<div className="SelectAssetRows__domain">
{formatDomain(domain)}
</div>
history.goBack();
} else {
dispatch(saveDestinationAsset(canonical));
history.goBack();
}
}}
>
<AssetIcon
assetIcons={code !== "XLM" ? { [canonical]: image } : {}}
code={code}
issuerKey={issuer}
/>
<div className="SelectAssetRows__row__info">
<div className="SelectAssetRows__row__info__header">
{code}
<ScamAssetIcon isScamAsset={isScamAsset} />
</div>
<div className="SelectAssetRows__domain">
{formatDomain(domain)}
</div>
{!hideBalances && (
<div>
{isContract
? getTokenBalanceFromCanonical(canonical)
: formatAmount(getAccountBalance(canonical))}{" "}
{code}
</div>
)}
</div>
);
},
)}
{!hideBalances && (
<div>
{isContract
? getTokenBalanceFromCanonical(canonical)
: formatAmount(getAccountBalance(canonical))}{" "}
{code}
</div>
)}
</div>
);
})}
</div>
</div>
);
Expand Down
Loading

0 comments on commit e9ef68c

Please sign in to comment.