Skip to content

Commit

Permalink
normalize addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboydiamonds committed Sep 24, 2024
1 parent c6b5d30 commit 30fd0c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/rest-api/src/routes/bridgeLimitsRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -95,6 +97,8 @@ const router = express.Router()
*/
router.get(
'/',
normalizeNativeTokenAddress(['fromToken', 'toToken']),
checksumAddresses(['fromToken', 'toToken']),
[
check('fromChain')
.exists()
Expand Down
8 changes: 2 additions & 6 deletions packages/rest-api/src/utils/tokenAddressToToken.ts
Original file line number Diff line number Diff line change
@@ -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,
}
Expand Down

0 comments on commit 30fd0c5

Please sign in to comment.