diff --git a/README.md b/README.md index 26dd63da..a98a54c9 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,11 @@ Before you begin, ensure you have met the following requirements: Copy the .env.example file to create a new .env file: -```bash -cp .env.local.example .env -``` + ```bash + cp .env.local.example .env + ``` + Edit the `.env` file. Check the `.env.local.example` file for explanations -```md The `NEXT_PUBLIC_TEST_TOKENS_ADMIN_SECRET_KEY` should be the same as the one that deployed the tokens in the `core` repository. This is only important if you will be minting testnet tokens, otherwise is not interesting. @@ -35,34 +35,35 @@ To enable or disable features like the `Soroswap backend` or the `aggregator`, s Navigate to the the `run.sh` script inside the `docker` folder - ```bash - bash docker/run.sh - ``` + ```bash + bash docker/run.sh + ``` + If the soroswap-network does not exisit, please create: `docker network create soroswap-network` This script will set up and start the Docker containers required for Soroswap. -4. Install the Dependencies +2. Install the Dependencies After the Docker container is up, you will be inside the root folder on the container. Then, install the dependencies using Yarn: - ```bash - yarn install - ``` + ```bash + yarn install + ``` -5. Run the Development Instance +3. Run the Development Instance Now you are ready to start the development instance. Run the following command: - ```bash - yarn dev - ``` + ```bash + yarn dev + ``` This will start the Soroswap development instance. http://localhost:3000 -6. For Tesntet Development, check your Freigher Wallet Configuration if you are running your one node +4. For Tesntet Development, check your Freigher Wallet Configuration if you are running your one node THis is not necesary if you are using Mainnet or Testnet. For Standalone network @@ -89,7 +90,7 @@ To enable or disable features like the `Soroswap backend` or the `aggregator`, s ** Important:** You should also do: Preferences> Allow experimental mode -7. Last, but not least, add some lumens to your Freighter wallet! +5. Last, but not least, add some lumens to your Freighter wallet! Do it directly on the wallet or use: diff --git a/src/components/UnsafeTokenModal/UnsafeTokenModal.tsx b/src/components/UnsafeTokenModal/UnsafeTokenModal.tsx index eac739bb..26be547f 100644 --- a/src/components/UnsafeTokenModal/UnsafeTokenModal.tsx +++ b/src/components/UnsafeTokenModal/UnsafeTokenModal.tsx @@ -1,4 +1,3 @@ - import { Box, useTheme } from 'soroswap-ui'; import { ButtonPrimary } from 'components/Buttons/Button'; import { CloseButton } from 'components/Buttons/CloseButton'; @@ -32,7 +31,7 @@ const UnsafeTokenModalContent = ({ onDismiss, onConfirm, isSafe }: Props) => { {isSafe === false && ( - The chosen token has been identified as potentially unsafe due to a mismatch between its contract ID and the expected CODE:ISSUER combination indicated by its name. + The chosen token has been identified as potentially unsafe due to a mismatch between its contract ID and the expected (CODE:ISSUER or CODE-ISSUER) combination indicated by its name. )} {isSafe === undefined && ( diff --git a/src/helpers/address.ts b/src/helpers/address.ts index 323ee7cf..b0ac8ea9 100644 --- a/src/helpers/address.ts +++ b/src/helpers/address.ts @@ -43,7 +43,8 @@ export function isValidSymbol(code: string): boolean { export function isClassicStellarAssetFormat(value: string): boolean { if (!value) return false; - const parts = value.split(':'); + // Support both : and - separators + const parts = value.split(/[:-]/); if (parts.length !== 2) { return false; } @@ -53,10 +54,11 @@ export function isClassicStellarAssetFormat(value: string): boolean { return toReturn; } -//Receives the name of the token must be SYMBOL:ISSUER +//Receives the name of the token must be SYMBOL:ISSUER or SYMBOL-ISSUER export function getClassicStellarAsset(value: string) { if (!value) return false; - const parts = value.split(':'); + // Support both : and - separators + const parts = value.split(/[:-]/); if (parts.length !== 2) { return false; } @@ -68,6 +70,13 @@ export function getClassicStellarAsset(value: string) { return { assetCode, issuer, - asset: `${assetCode}:${issuer}`, + asset: `${assetCode}:${issuer}`, // Always normalize to : format internally }; } + +// Add helper function to normalize format +export function normalizeAssetFormat(value: string): string { + if (!value) return value; + // Convert CODE-ISSUER to CODE:ISSUER + return value.replace(/-([A-Z0-9]{56})/, ':$1'); +} \ No newline at end of file diff --git a/src/helpers/horizon/getHorizonPath.ts b/src/helpers/horizon/getHorizonPath.ts index 4c5c6052..8857b05c 100644 --- a/src/helpers/horizon/getHorizonPath.ts +++ b/src/helpers/horizon/getHorizonPath.ts @@ -13,6 +13,7 @@ import { PlatformType, TradeType, } from 'state/routing/types'; +import { normalizeAssetFormat } from 'helpers/address'; const getClassicAsset = (currency: TokenType) => { if (!currency) return; @@ -21,7 +22,15 @@ const getClassicAsset = (currency: TokenType) => { return nativeAsset; } if (!currency.issuer) { - //throw new Error(`Can't convert ${currency.code} to stellar classic asset`); + // Try to extract issuer from contract if it's in CODE:ISSUER or CODE-ISSUER format + if (currency.contract) { + const normalized = normalizeAssetFormat(currency.contract); + const parts = normalized.split(':'); + if (parts.length === 2) { + const asset = new Asset(parts[0], parts[1]); + return asset; + } + } return; } const asset = new Asset(currency.code, currency.issuer);