Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-usdt0-rootstock-checksum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lifi/data-types": patch
---

Fix the EIP-55 checksum of the USDT0 address on Rootstock, which was mis-cased and rejected by address lookups that compare verbatim.
2 changes: 1 addition & 1 deletion src/coins/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3017,7 +3017,7 @@ export const basicCoins: BasicCoin[] = [
decimals: 6,
},
[ChainId.RSK]: {
address: '0x779dED0C9e1022225F8e0630b35A9B54Be713736',
address: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736',
decimals: 6,
},
[ChainId.ARB]: {
Expand Down
33 changes: 33 additions & 0 deletions src/coins/coins.unit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { StaticToken } from '@lifi/types'
import { isAddress } from 'viem'
import { describe, expect, it } from 'vitest'
import { supportedEVMChains } from '../chains/supportedChains.evm.js'
import { defaultCoins, wrappedTokens } from './coins.js'

const evmChainIds = new Set(supportedEVMChains.map((chain) => chain.id))

const evmTokens: StaticToken[] = [
...defaultCoins.flatMap((coin) => Object.values(coin.chains)),
...Object.values(wrappedTokens),
].filter((token) => evmChainIds.has(token.chainId))

describe('validate EVM token addresses', () => {
it('has tokens to check', () => {
expect(evmTokens.length).toBeGreaterThan(0)
})

// A mixed-case address carries its own EIP-55 checksum, so a typo in the
// casing makes it invalid. Services that compare addresses verbatim then
// fail to resolve the token instead of silently normalising it. All-lowercase
// addresses carry no checksum and stay valid.
it('are valid EIP-55 addresses', () => {
const invalid = evmTokens
.filter((token) => !isAddress(token.address, { strict: true }))
.map(
(token) =>
`${token.coinKey} on chain ${token.chainId}: ${token.address}`
)

expect(invalid).toEqual([])
})
})
Loading