diff --git a/signer-service/src/api/services/alchemypay.service.js b/signer-service/src/api/services/alchemypay.service.js index cbd1b1a7..bcdf8a72 100644 --- a/signer-service/src/api/services/alchemypay.service.js +++ b/signer-service/src/api/services/alchemypay.service.js @@ -190,6 +190,14 @@ function getAlchemyPayNetworkCode(network) { switch (network.toUpperCase()) { case 'POLYGON': return 'MATIC'; + case 'BSC': + return 'BSC'; + case 'ARBITRUM': + return 'ARBITRUM'; + case 'AVALANCHE': + return 'AVAX'; + case 'ETHEREUM': + return 'ETH'; default: return network; } diff --git a/signer-service/src/api/services/transak.service.js b/signer-service/src/api/services/transak.service.js index ebaf1e58..25405208 100644 --- a/signer-service/src/api/services/transak.service.js +++ b/signer-service/src/api/services/transak.service.js @@ -45,12 +45,7 @@ async function priceQuery(cryptoCurrency, fiatCurrency, cryptoAmount, network, i // Helper function to get the network code for Transak. It seems like Transak just uses the commonly known network names // as the code for the network parameter in their API so we just return the network as is. function getTransakNetworkCode(network) { - switch (network.toUpperCase()) { - case 'POLYGON': - return 'polygon'; - default: - return network; - } + return network.toLowerCase(); } function getCryptoCode(fromCrypto) { diff --git a/src/assets/chains/arbitrum.svg b/src/assets/chains/arbitrum.svg new file mode 100644 index 00000000..56ed24c9 --- /dev/null +++ b/src/assets/chains/arbitrum.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/assets/chains/avalanche.svg b/src/assets/chains/avalanche.svg new file mode 100644 index 00000000..ebff2a2c --- /dev/null +++ b/src/assets/chains/avalanche.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/assets/chains/base.svg b/src/assets/chains/base.svg new file mode 100644 index 00000000..eefeec83 --- /dev/null +++ b/src/assets/chains/base.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/assets/chains/bsc.svg b/src/assets/chains/bsc.svg new file mode 100644 index 00000000..d1b98da4 --- /dev/null +++ b/src/assets/chains/bsc.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/assets/chains/ethereum.svg b/src/assets/chains/ethereum.svg new file mode 100644 index 00000000..20a69608 --- /dev/null +++ b/src/assets/chains/ethereum.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/assets/coins/USDC_ARBITRUM.svg b/src/assets/coins/USDC_ARBITRUM.svg new file mode 100644 index 00000000..3ce39960 --- /dev/null +++ b/src/assets/coins/USDC_ARBITRUM.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDC_AVALANCHE.svg b/src/assets/coins/USDC_AVALANCHE.svg new file mode 100644 index 00000000..3f463968 --- /dev/null +++ b/src/assets/coins/USDC_AVALANCHE.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDC_BASE.svg b/src/assets/coins/USDC_BASE.svg new file mode 100644 index 00000000..51704966 --- /dev/null +++ b/src/assets/coins/USDC_BASE.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDC_BSC.svg b/src/assets/coins/USDC_BSC.svg new file mode 100644 index 00000000..2f520d09 --- /dev/null +++ b/src/assets/coins/USDC_BSC.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDC_ETHEREUM.svg b/src/assets/coins/USDC_ETHEREUM.svg new file mode 100644 index 00000000..d7507d86 --- /dev/null +++ b/src/assets/coins/USDC_ETHEREUM.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDT_ARBITRUM.svg b/src/assets/coins/USDT_ARBITRUM.svg new file mode 100644 index 00000000..a810783c --- /dev/null +++ b/src/assets/coins/USDT_ARBITRUM.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDT_AVALANCHE.svg b/src/assets/coins/USDT_AVALANCHE.svg new file mode 100644 index 00000000..35d41f88 --- /dev/null +++ b/src/assets/coins/USDT_AVALANCHE.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDT_BASE.svg b/src/assets/coins/USDT_BASE.svg new file mode 100644 index 00000000..43812da6 --- /dev/null +++ b/src/assets/coins/USDT_BASE.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDT_BSC.svg b/src/assets/coins/USDT_BSC.svg new file mode 100644 index 00000000..84bf51e7 --- /dev/null +++ b/src/assets/coins/USDT_BSC.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/coins/USDT_ETHEREUM.svg b/src/assets/coins/USDT_ETHEREUM.svg new file mode 100644 index 00000000..9bd7909c --- /dev/null +++ b/src/assets/coins/USDT_ETHEREUM.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/FeeComparison/index.tsx b/src/components/FeeComparison/index.tsx index a08ee989..135da6d7 100644 --- a/src/components/FeeComparison/index.tsx +++ b/src/components/FeeComparison/index.tsx @@ -5,7 +5,7 @@ import { useQuery } from '@tanstack/react-query'; import { ChevronDownIcon } from '@heroicons/react/20/solid'; import vortexIcon from '../../assets/logo/blue.svg'; -import { Networks } from '../../contexts/network'; +import { getNetworkDisplayName, isNetworkEVM, Networks } from '../../helpers/networks'; import { Skeleton } from '../Skeleton'; import { QuoteProvider, quoteProviders } from './quoteProviders'; import { OfframpingParameters, useEventsContext } from '../../contexts/events'; @@ -126,14 +126,17 @@ function FeeComparisonTable({
- Sending {amount.toFixed(2)} {sourceAssetSymbol} -
- (Polygon) -
-
+ Sending {amount.toFixed(2)} {sourceAssetSymbol}{' '} + {isNetworkEVM(network) ? ( + <> + ) : ( +
+ (Polygon) +
+ )}{' '} with
diff --git a/src/components/GenericEvent.tsx b/src/components/GenericEvent.tsx index 3883c17e..818ae4f7 100644 --- a/src/components/GenericEvent.tsx +++ b/src/components/GenericEvent.tsx @@ -6,8 +6,6 @@ export enum EventStatus { Waiting = 'waiting', } -export type RenderEventHandler = (event: string, status: EventStatus) => void; - export interface GenericEvent { value: string; status: EventStatus; diff --git a/src/components/Nabla/useSwapForm.tsx b/src/components/Nabla/useSwapForm.tsx index 8f46d996..02aae44c 100644 --- a/src/components/Nabla/useSwapForm.tsx +++ b/src/components/Nabla/useSwapForm.tsx @@ -13,39 +13,32 @@ import { import { debounce } from '../../helpers/function'; import { storageService } from '../../services/storage/local'; import schema, { SwapFormValues } from './schema'; -import { Networks, useNetwork } from '../../contexts/network'; +import { getCaseSensitiveNetwork } from '../../helpers/networks'; +import { useNetwork } from '../../contexts/network'; -interface SwapSettings { +type SwapSettings = { from: string; to: string; -} +}; + +type TokenSelectType = 'from' | 'to'; const storageSet = debounce(storageService.set, 1000); const setStorageForSwapSettings = storageSet.bind(null, storageKeys.SWAP_SETTINGS); -function getCaseSensitiveNetwork(network: string): Networks { - if (network.toLowerCase() === 'assethub') { - return Networks.AssetHub; - } else if (network.toLowerCase() === 'polygon') { - return Networks.Polygon; - } else { - console.warn('Invalid network type'); - return Networks.AssetHub; - } -} +function mergeIfDefined(target: T, source: Nullable | undefined): void { + if (!source) return; -// Helper function to merge values if they are defined -function mergeIfDefined(target: any, source: any) { - for (const key in source) { - if (source[key] !== undefined && source[key] !== null) { - target[key] = source[key]; + Object.entries(source).forEach(([key, value]) => { + if (value != null) { + target[key as keyof T] = value as T[keyof T]; } - } + }); } export const useSwapForm = () => { const [isTokenSelectModalVisible, setIsTokenSelectModalVisible] = useState(false); - const [tokenSelectModalType, setTokenModalType] = useState<'from' | 'to'>('from'); + const [tokenSelectModalType, setTokenModalType] = useState('from'); const { selectedNetwork, setSelectedNetwork } = useNetwork(); const initialState = useMemo(() => { @@ -99,14 +92,13 @@ export const useSwapForm = () => { (tokenKey: string) => { const prev = getValues(); - const updated = { + const updated: SwapSettings = { from: tokenKey, to: prev?.to, }; setStorageForSwapSettings(updated); setValue('from', tokenKey as InputTokenType); - setIsTokenSelectModalVisible(false); }, [getValues, setValue], @@ -117,14 +109,13 @@ export const useSwapForm = () => { const prev = getValues(); if (!tokenKey) return; - const updated = { + const updated: SwapSettings = { to: tokenKey, from: prev?.from, }; setStorageForSwapSettings(updated); setValue('to', tokenKey as OutputTokenType); - setIsTokenSelectModalVisible(false); }, [getValues, setValue], @@ -144,7 +135,7 @@ export const useSwapForm = () => { } }, [fromAmountString]); - const openTokenSelectModal = useCallback((type: 'from' | 'to') => { + const openTokenSelectModal = useCallback((type: TokenSelectType) => { setTokenModalType(type); setIsTokenSelectModalVisible(true); }, []); diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index f70e73f1..bdd27fbb 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -19,8 +19,12 @@ interface MobileMenuProps { } const MobileMenu: FC = ({ onClick }) => ( - ); @@ -59,7 +63,7 @@ const MobileMenuList: FC = ({ showMenu, closeMenu }) => ( exit="exit" variants={menuVariants} > -