From 30fd0c5fd08e6bfbc7ff9a2c71c09a87a9e4e634 Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:20:59 -0700 Subject: [PATCH] normalize addresses --- packages/rest-api/src/routes/bridgeLimitsRoute.ts | 4 ++++ packages/rest-api/src/utils/tokenAddressToToken.ts | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/rest-api/src/routes/bridgeLimitsRoute.ts b/packages/rest-api/src/routes/bridgeLimitsRoute.ts index 171ae84d4a..14ab637671 100644 --- a/packages/rest-api/src/routes/bridgeLimitsRoute.ts +++ b/packages/rest-api/src/routes/bridgeLimitsRoute.ts @@ -6,6 +6,8 @@ import { showFirstValidationError } from '../middleware/showFirstValidationError import { bridgeLimitsController } from '../controllers/bridgeLimitsController' import { isTokenSupportedOnChain } from './../utils/isTokenSupportedOnChain' import { isTokenAddress } from '../utils/isTokenAddress' +import { normalizeNativeTokenAddress } from '../middleware/normalizeNativeTokenAddress' +import { checksumAddresses } from '../middleware/checksumAddresses' const router = express.Router() @@ -95,6 +97,8 @@ const router = express.Router() */ router.get( '/', + normalizeNativeTokenAddress(['fromToken', 'toToken']), + checksumAddresses(['fromToken', 'toToken']), [ check('fromChain') .exists() diff --git a/packages/rest-api/src/utils/tokenAddressToToken.ts b/packages/rest-api/src/utils/tokenAddressToToken.ts index 57389b70f0..6bad892582 100644 --- a/packages/rest-api/src/utils/tokenAddressToToken.ts +++ b/packages/rest-api/src/utils/tokenAddressToToken.ts @@ -1,23 +1,19 @@ -import { getAddress } from '@ethersproject/address' - import { BRIDGE_MAP } from '../constants/bridgeMap' export const tokenAddressToToken = (chain: string, tokenAddress: string) => { - const address = getAddress(tokenAddress) - const chainData = BRIDGE_MAP[chain] if (!chainData) { return null } - const tokenInfo = chainData[address] + const tokenInfo = chainData[tokenAddress] if (!tokenInfo) { return null } return { - address, + address: tokenAddress, symbol: tokenInfo.symbol, decimals: tokenInfo.decimals, }