Skip to content

Commit

Permalink
Merge branch 'master' into fetch-sender-receiver-sequentially
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx authored Dec 17, 2024
2 parents e5f9d90 + 9cacd2d commit 2bc11cb
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 280 deletions.
24 changes: 12 additions & 12 deletions packages/arb-token-bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@headlessui/react": "^1.7.8",
"@headlessui/tailwindcss": "^0.1.2",
"@heroicons/react": "^2.0.18",
"@offchainlabs/cobalt": "^0.3.11",
"@offchainlabs/cobalt": "^0.3.12",
"@rainbow-me/rainbowkit": "^0.12.16",
"@rehooks/local-storage": "^2.4.4",
"@sentry/react": "^8.33.1",
Expand All @@ -23,30 +23,30 @@
"axios": "^1.7.4",
"boring-avatars": "^1.7.0",
"cheerio": "^1.0.0-rc.12",
"dayjs": "^1.11.8",
"dayjs": "^1.11.13",
"ethers": "^5.6.0",
"exponential-backoff": "^3.1.1",
"graphql": "^16.8.1",
"graphql": "^16.9.0",
"lodash-es": "^4.17.21",
"next": "^14.2.12",
"next-query-params": "^5.0.0",
"overmind": "^28.0.1",
"overmind-react": "^29.0.1",
"posthog-js": "^1.155.4",
"posthog-js": "^1.200.0",
"query-string": "^8.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-loader-spinner": "^5.4.5",
"react-syntax-highlighter": "^15.6.1",
"react-toastify": "^9.1.1",
"react-use": "^17.2.4",
"react-use": "^17.6.0",
"react-virtualized": "^9.22.3",
"sharp": "^0.33.5",
"swr": "^2.1.2",
"tailwind-merge": "^2.0.0",
"tailwind-merge": "^2.5.5",
"use-query-params": "^2.2.1",
"wagmi": "^0.12.18",
"zod": "^3.22.4",
"zod": "^3.24.1",
"zustand": "^4.3.9"
},
"scripts": {
Expand Down Expand Up @@ -109,14 +109,14 @@
"jest": "^29.4.0",
"jest-environment-jsdom": "^29.4.0",
"patch-package": "^8.0.0",
"postcss": "^8.4.31",
"postcss": "^8.4.49",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.7.1",
"prettier-plugin-tailwindcss": "^0.1.11",
"satori": "^0.10.11",
"start-server-and-test": "^2.0.0",
"tailwindcss": "^3.2.4",
"ts-node": "^10.9.1",
"satori": "^0.12.0",
"start-server-and-test": "^2.0.9",
"tailwindcss": "^3.4.16",
"ts-node": "^10.9.2",
"typescript": "^5.2.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import { TokenLogoFallback } from './TokenInfo'
import { useBalanceOnSourceChain } from '../../hooks/useBalanceOnSourceChain'
import { useSourceChainNativeCurrencyDecimals } from '../../hooks/useSourceChainNativeCurrencyDecimals'

function tokenListIdsToNames(ids: number[]): string {
function tokenListIdsToNames(ids: string[]): string {
return ids
.map((tokenListId: number) => listIdsToNames[tokenListId])
.map((tokenListId: string) => listIdsToNames[tokenListId])
.join(', ')
}

Expand Down Expand Up @@ -90,7 +90,7 @@ function TokenListInfo({ token }: { token: ERC20BridgeToken | null }) {
return 'Native USDC on Arbitrum Sepolia'
}

const listIds: Set<number> = token.listIds
const listIds: Set<string> = token.listIds
const listIdsSize = listIds.size
if (listIdsSize === 0) {
return 'Added by User'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { useSetInputAmount } from '../../hooks/TransferPanel/useSetInputAmount'

export const ARB_ONE_NATIVE_USDC_TOKEN = {
...ArbOneNativeUSDC,
listIds: new Set<number>(),
listIds: new Set<string>(),
type: TokenType.ERC20,
// the address field is for L1 address but native USDC does not have an L1 address
// the L2 address is used instead to avoid errors
Expand All @@ -57,7 +57,7 @@ export const ARB_ONE_NATIVE_USDC_TOKEN = {

export const ARB_SEPOLIA_NATIVE_USDC_TOKEN = {
...ArbOneNativeUSDC,
listIds: new Set<number>(),
listIds: new Set<string>(),
type: TokenType.ERC20,
address: CommonAddress.ArbitrumSepolia.USDC,
l2Address: CommonAddress.ArbitrumSepolia.USDC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const commonUSDC = {
type: TokenType.ERC20,
symbol: 'USDC',
decimals: 6,
listIds: new Set<number>()
listIds: new Set<string>()
}

export function useUpdateUSDCTokenData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface BridgeToken {
address: string
l2Address?: string
logoURI?: string
listIds: Set<number> // no listID indicates added by user
listIds: Set<string> // no listID indicates added by user
isL2Native?: boolean
}

Expand Down Expand Up @@ -140,8 +140,8 @@ export interface ArbTokenBridgeEth {
export interface ArbTokenBridgeToken {
add: (erc20L1orL2Address: string) => Promise<void>
addL2NativeToken: (erc20L2Address: string) => void
addTokensFromList: (tokenList: TokenList, listID: number) => void
removeTokensFromList: (listID: number) => void
addTokensFromList: (tokenList: TokenList, listID: string) => void
removeTokensFromList: (listID: string) => void
updateTokenData: (l1Address: string) => Promise<void>
triggerOutbox: (params: {
event: L2ToL1EventResultPlus
Expand Down
4 changes: 2 additions & 2 deletions packages/arb-token-bridge-ui/src/hooks/useArbTokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const useArbTokenBridge = (

const l1NetworkID = useMemo(() => String(l1.network.id), [l1.network.id])

const removeTokensFromList = (listID: number) => {
const removeTokensFromList = (listID: string) => {
setBridgeTokens(prevBridgeTokens => {
const newBridgeTokens = { ...prevBridgeTokens }
for (const address in bridgeTokens) {
Expand All @@ -153,7 +153,7 @@ export const useArbTokenBridge = (
})
}

const addTokensFromList = async (arbTokenList: TokenList, listId: number) => {
const addTokensFromList = async (arbTokenList: TokenList, listId: string) => {
const l1ChainID = l1.network.id
const l2ChainID = l2.network.id

Expand Down
102 changes: 43 additions & 59 deletions packages/arb-token-bridge-ui/src/util/TokenListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import CoinGeckoLogo from '@/images/lists/coinGecko.svg'
import ArbitrumLogo from '@/images/lists/ArbitrumLogo.png'
import { ArbTokenBridge } from '../hooks/arbTokenBridge.types'
import { ChainId } from './networks'
import orbitChainsData from './orbitChainsData.json'

export const SPECIAL_ARBITRUM_TOKEN_TOKEN_LIST_ID = 0
export const SPECIAL_ARBITRUM_TOKEN_TOKEN_LIST_ID =
'SPECIAL_ARBITRUM_TOKEN_TOKEN_LIST_ID'

export interface BridgeTokenList {
id: number
// string is required here to avoid duplicates when mapping orbit chains to tokenlists
id: string
originChainID: number
url: string
name: string
Expand All @@ -34,39 +37,39 @@ export const BRIDGE_TOKEN_LISTS: BridgeTokenList[] = [
isArbitrumTokenTokenList: true
},
{
id: 1,
id: '1',
originChainID: ChainId.ArbitrumOne,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_arb_whitelist_era.json',
name: 'Arbitrum Whitelist Era',
isDefault: true,
logoURI: ArbitrumLogo
},
{
id: 2,
id: '2',
originChainID: ChainId.ArbitrumOne,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_uniswap_labs_default.json',
name: 'Arbed Uniswap List',
isDefault: true,
logoURI: UniswapLogo
},
{
id: 4,
id: '4',
originChainID: ChainId.ArbitrumOne,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_coingecko.json',
name: 'Arbed CoinGecko List',
isDefault: true,
logoURI: CoinGeckoLogo
},
{
id: 5,
id: '5',
originChainID: ChainId.ArbitrumOne,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/arbed_coinmarketcap.json',
name: 'Arbed CMC List',
isDefault: false,
logoURI: CMCLogo
},
{
id: 6,
id: '6',
originChainID: ChainId.ArbitrumNova,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_uniswap_labs_default.json',
name: 'Arbed Uniswap List',
Expand All @@ -78,7 +81,7 @@ export const BRIDGE_TOKEN_LISTS: BridgeTokenList[] = [
// TODO: remove list for chain ID 412346 after fix:
// https://github.com/OffchainLabs/arb-token-bridge/issues/564
{
id: 9,
id: '9',
// Local node
originChainID: ChainId.ArbitrumLocal,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/421613_arbed_coinmarketcap.json',
Expand All @@ -87,7 +90,7 @@ export const BRIDGE_TOKEN_LISTS: BridgeTokenList[] = [
logoURI: CMCLogo
},
{
id: 10,
id: '10',
originChainID: ChainId.ArbitrumSepolia,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_uniswap_labs.json',
name: 'Arbed Uniswap List',
Expand All @@ -96,76 +99,57 @@ export const BRIDGE_TOKEN_LISTS: BridgeTokenList[] = [
},
// CoinGecko
{
id: 11,
id: '11',
originChainID: ChainId.ArbitrumNova,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/42170_arbed_coingecko.json',
name: 'Arbed CoinGecko List',
isDefault: true,
logoURI: CoinGeckoLogo
},
{
id: 13,
id: '13',
originChainID: ChainId.ArbitrumSepolia,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/421614_arbed_coingecko.json',
name: 'Arbed CoinGecko List',
isDefault: true,
logoURI: CoinGeckoLogo
},
// Orbit
{
id: 14,
// Xai
originChainID: 660279,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/660279_arbed_uniswap_labs.json',
name: 'Arbed Uniswap List',
isDefault: true,
logoURI: UniswapLogo
},
{
id: 660279,
id: '660279',
// Xai
originChainID: 660279,
url: 'tokenLists/660279_default.json',
name: 'XAI Default List',
isDefault: true,
logoURI: '/images/XaiLogo.svg'
},
{
id: 15,
// Rari
originChainID: 1380012617,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/1380012617_arbed_uniswap_labs.json',
name: 'Arbed Uniswap List',
isDefault: true,
logoURI: UniswapLogo
},
{
id: 16,
// Muster
originChainID: 4078,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/4078_arbed_uniswap_labs.json',
name: 'Arbed Uniswap List',
isDefault: true,
logoURI: UniswapLogo
},
{
id: 17,
// Proof of Play Apex
originChainID: 70700,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/70700_arbed_uniswap_labs.json',
name: 'Arbed Uniswap List',
isDefault: true,
logoURI: UniswapLogo
},
{
id: 19,
// SX Network
originChainID: 4162,
url: 'https://tokenlist.arbitrum.io/ArbTokenLists/4162_arbed_uniswap_labs.json',
name: 'Arbed Uniswap List',
isDefault: true,
logoURI: UniswapLogo
}
// For all orbit chains,
...orbitChainsData.mainnet
.concat(orbitChainsData.testnet)
.reduce((acc, chain) => {
// Only include arbified native token list for L3 settling to ArbOne
if (chain.parentChainId === ChainId.ArbitrumOne) {
acc.push({
id: `${chain.chainId}_native`,
originChainID: chain.chainId,
url: `https://tokenlist.arbitrum.io/ArbTokenLists/${chain.chainId}_arbed_native_list.json`,
name: `${chain.name} Default List`,
isDefault: true,
logoURI: ArbitrumLogo
})
}

acc.push({
id: `${chain.chainId}_uniswap`,
originChainID: chain.chainId,
url: `https://tokenlist.arbitrum.io/ArbTokenLists/${chain.chainId}_arbed_uniswap_labs.json`,
name: `${chain.name} Arbed Uniswap List`,
isDefault: true,
logoURI: UniswapLogo
})

return acc
}, [] as BridgeTokenList[])
]

export const listIdsToNames: { [key: string]: string } = {}
Expand All @@ -176,7 +160,7 @@ BRIDGE_TOKEN_LISTS.forEach(bridgeTokenList => {

export interface TokenListWithId extends TokenList {
l2ChainId: string
bridgeTokenListId: number
bridgeTokenListId: string
isValid?: boolean
}

Expand Down
Loading

0 comments on commit 2bc11cb

Please sign in to comment.