Skip to content

Commit

Permalink
Merge branch 'master' into refactor-useUpdateUsdcBalances
Browse files Browse the repository at this point in the history
  • Loading branch information
fionnachan authored Jan 13, 2025
2 parents 4fc016e + 519c6d9 commit 01d4679
Show file tree
Hide file tree
Showing 48 changed files with 177 additions and 174 deletions.
6 changes: 3 additions & 3 deletions packages/arb-token-bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"exponential-backoff": "^3.1.1",
"graphql": "^16.9.0",
"lodash-es": "^4.17.21",
"next": "^14.2.15",
"next": "^14.2.22",
"next-query-params": "^5.0.0",
"overmind": "^28.0.1",
"overmind-react": "^29.0.1",
Expand All @@ -42,7 +42,7 @@
"react-use": "^17.6.0",
"react-virtualized": "^9.22.3",
"sharp": "^0.33.5",
"swr": "^2.1.2",
"swr": "^2.3.0",
"tailwind-merge": "^2.5.5",
"use-query-params": "^2.2.1",
"wagmi": "^0.12.18",
Expand Down Expand Up @@ -83,7 +83,7 @@
"devDependencies": {
"@next/eslint-plugin-next": "^13.1.5",
"@synthetixio/synpress": "3.7.3",
"@testing-library/react": "^14.2.1",
"@testing-library/react": "^16.1.0",
"@types/jest": "^29.5.1",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.6.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs'
import 'dotenv/config'
import { getArbitrumNetwork } from '@arbitrum/sdk'
import { ChainId, rpcURLs } from '../src/util/networks'
import { rpcURLs } from '../src/util/networks'
import { ChainId } from '../src/types/ChainId'
import { getChainToMonitor } from './utils'

// github secrets return '' for empty values, so we need to sanitize the value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
NormalizedCacheObject
} from '@apollo/client'

import { ChainId } from '../util/networks'
import { ChainId } from '../types/ChainId'

/**
* The API key to be used for calls to The Graph Network.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
TeleporterMergedTransaction,
WithdrawalStatus
} from '../../state/app/state'
import { ChainId, getL1BlockTime, isNetwork } from '../../util/networks'
import { getL1BlockTime, isNetwork } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { Deposit, Transfer } from '../../hooks/useTransactionHistory'
import {
getParentToChildMessageDataFromParentTxHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useMemo } from 'react'
import { twMerge } from 'tailwind-merge'

import { useAppState } from '../../state'
import { ChainId, getNetworkName, isNetwork } from '../../util/networks'
import { getNetworkName, isNetwork } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { Tooltip } from '../common/Tooltip'
import { formatAmount } from '../../util/NumberUtils'
import { useNativeCurrency } from '../../hooks/useNativeCurrency'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { BridgesTable } from '../common/BridgesTable'
import { SecurityNotGuaranteed } from './SecurityLabels'
import { Dialog, UseDialogProps } from '../common/Dialog'
import { FastBridgeInfo, FastBridgeNames } from '../../util/fastBridges'
import { ChainId, getNetworkName, isNetwork } from '../../util/networks'
import { getNetworkName, isNetwork } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { ether } from '../../constants'
import { useArbQueryParams } from '../../hooks/useArbQueryParams'
import { useNetworks } from '../../hooks/useNetworks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { Dialog } from '../common/Dialog'
import { sanitizeTokenSymbol } from '../../util/TokenUtils'
import { useNetworks } from '../../hooks/useNetworks'
import { ExternalLink } from '../common/ExternalLink'
import { ChainId, getNetworkName } from '../../util/networks'
import { getNetworkName } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { getL2ConfigForTeleport } from '../../token-bridge-sdk/teleport'
import { useNetworksRelationship } from '../../hooks/useNetworksRelationship'
import { withdrawOnlyTokens } from '../../util/WithdrawOnlyUtils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '../../../util/networks'
import { ChainId } from '../../../types/ChainId'

export enum NetworkType {
parentChain = 'parentChain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import SyntaxHighlighter from 'react-syntax-highlighter'
import { stackoverflowDark } from 'react-syntax-highlighter/dist/esm/styles/hljs'

import {
ChainId,
ChainWithRpcUrl,
getCustomChainsFromLocalStorage,
getCustomChainFromLocalStorageById,
Expand All @@ -22,6 +21,7 @@ import {
rpcURLs,
isNetwork
} from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { Loader } from './atoms/Loader'
import { Erc20Data, fetchErc20Data } from '../../util/TokenUtils'
import { getProviderForChainId } from '@/token-bridge-sdk/utils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
import { twMerge } from 'tailwind-merge'
import { AutoSizer, List, ListRowProps } from 'react-virtualized'

import { ChainId, isNetwork, getNetworkName } from '../../util/networks'
import { isNetwork, getNetworkName } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { useIsTestnetMode } from '../../hooks/useIsTestnetMode'
import { SearchPanel } from './SearchPanel/SearchPanel'
import { SearchPanelTable } from './SearchPanel/SearchPanelTable'
Expand Down
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/src/generateOpenGraphImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react'
import satori, { Font } from 'satori'
import sharp from 'sharp'
import fs from 'fs'
import { ChainId, isNetwork } from './util/networks'
import { isNetwork } from './util/networks'
import { ChainId } from './types/ChainId'
import { getBridgeUiConfigForChain } from './util/bridgeUiConfig'
import { orbitMainnets, orbitTestnets } from './util/orbitChainsList'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import useSWRImmutable from 'swr/immutable'
import { ChainId } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { getCctpUtils } from '@/token-bridge-sdk/cctp'

export function useCCTPIsBlocked() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
ChainId,
getDestinationChainIds,
getSupportedChainIds
} from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { useIsTestnetMode } from '../useIsTestnetMode'
import { useNetworks } from '../useNetworks'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* @jest-environment jsdom
*/
import { registerCustomArbitrumNetwork } from '@arbitrum/sdk'
import { ChainId, customChainLocalStorageKey } from '../../util/networks'
import { customChainLocalStorageKey } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { AmountQueryParam, ChainParam } from '../useArbQueryParams'
import { createMockOrbitChain } from './helpers'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* @jest-environment jsdom
*/
import { registerCustomArbitrumNetwork } from '@arbitrum/sdk'
import { ChainId, customChainLocalStorageKey } from '../../util/networks'
import { customChainLocalStorageKey } from '../../util/networks'
import { ChainId } from '../../types/ChainId'
import { sanitizeQueryParams } from '../useNetworks'
import { createMockOrbitChain } from './helpers'

Expand Down
7 changes: 5 additions & 2 deletions packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ export function useAccountIsBlocked() {
return null
}

return [address.toLowerCase(), 'useAccountIsBlocked']
return [
address.toLocaleLowerCase() as Address,
'useAccountIsBlocked'
] as const
}, [address])

const { data: isBlocked } = useSWRImmutable<boolean>(
const { data: isBlocked } = useSWRImmutable(
queryKey,
// Extracts the first element of the query key as the fetcher param
([_address]) => fetcher(_address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
getChainQueryParamForChain,
isValidChainQueryParam
} from '../types/ChainQueryParam'
import { ChainId } from '../util/networks'
import { ChainId } from '../types/ChainId'

export enum AmountQueryParamEnum {
MAX = 'max'
Expand Down
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/src/hooks/useIsTestnetMode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback } from 'react'
import { useNetworks } from './useNetworks'
import { ChainId, isNetwork } from '../util/networks'
import { isNetwork } from '../util/networks'
import { ChainId } from '../types/ChainId'

export const useIsTestnetMode = () => {
const [networks, setNetworks] = useNetworks()
Expand Down
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/src/hooks/useNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { useCallback, useMemo } from 'react'
import { mainnet, arbitrum } from '@wagmi/core/chains'

import { useArbQueryParams } from './useArbQueryParams'
import { ChainId, getCustomChainsFromLocalStorage } from '../util/networks'
import { getCustomChainsFromLocalStorage } from '../util/networks'
import { ChainId } from '../types/ChainId'
import {
sepolia,
holesky,
Expand Down
16 changes: 3 additions & 13 deletions packages/arb-token-bridge-ui/src/hooks/useTransactionHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import useSWRInfinite from 'swr/infinite'
import { useCallback, useEffect, useMemo, useState } from 'react'
import dayjs from 'dayjs'

import {
ChainId,
getChains,
getChildChainIds,
isNetwork
} from '../util/networks'
import { getChains, getChildChainIds, isNetwork } from '../util/networks'
import { ChainId } from '../types/ChainId'
import { fetchWithdrawals } from '../util/withdrawals/fetchWithdrawals'
import { fetchDeposits } from '../util/deposits/fetchDeposits'
import {
Expand Down Expand Up @@ -161,13 +157,7 @@ async function transformTransaction(tx: Transfer): Promise<MergedTransaction> {
}

if (isDeposit(tx)) {
return transformDeposit(
await updateAdditionalDepositData({
depositTx: tx,
parentProvider,
childProvider
})
)
return transformDeposit(await updateAdditionalDepositData(tx))
}

let withdrawal: L2ToL1EventResultPlus | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/pages/api/cctp/[type].ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { gql } from '@apollo/client'
import { NextApiRequest, NextApiResponse } from 'next'

import { ChainId } from '../../../util/networks'
import { ChainId } from '../../../types/ChainId'
import { Address } from '../../../util/AddressUtils'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { gql } from '@apollo/client'

import { ChainId } from '../../../../util/networks'
import { ChainId } from '../../../../types/ChainId'
import {
getL1SubgraphClient,
getL2SubgraphClient,
Expand Down
8 changes: 2 additions & 6 deletions packages/arb-token-bridge-ui/src/state/cctpState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import useSWRImmutable from 'swr/immutable'
import { useInterval } from 'react-use'

import { getCctpUtils } from '@/token-bridge-sdk/cctp'
import {
ChainId,
getL1BlockTime,
getNetworkName,
isNetwork
} from '../util/networks'
import { getL1BlockTime, getNetworkName, isNetwork } from '../util/networks'
import { ChainId } from '../types/ChainId'
import { fetchCCTPDeposits, fetchCCTPWithdrawals } from '../util/cctp/fetchCCTP'
import { DepositStatus, MergedTransaction, WithdrawalStatus } from './app/state'
import { normalizeTimestamp } from './app/utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/token-bridge-sdk/cctp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ChainDomain } from '../pages/api/cctp/[type]'
import { prepareWriteContract, writeContract } from '@wagmi/core'
import { MessageTransmitterAbi } from '../util/cctp/MessageTransmitterAbi'
import { CCTPSupportedChainId } from '../state/cctpState'
import { ChainId } from '../util/networks'
import { ChainId } from '../types/ChainId'
import { CommonAddress } from '../util/CommonAddressUtils'
import { Address } from '../util/AddressUtils'

Expand Down
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/src/token-bridge-sdk/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BigNumber, Signer } from 'ethers'
import { Provider, StaticJsonRpcProvider } from '@ethersproject/providers'

import { ChainId, isNetwork, rpcURLs } from '../util/networks'
import { isNetwork, rpcURLs } from '../util/networks'
import { ChainId } from '../types/ChainId'
import { BridgeTransferStarterPropsWithChainIds } from './BridgeTransferStarter'
import { isValidTeleportChainPair } from './teleport'
import {
Expand Down
18 changes: 18 additions & 0 deletions packages/arb-token-bridge-ui/src/types/ChainId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export enum ChainId {
// L1
Ethereum = 1,
// L1 Testnets
Local = 1337,
Sepolia = 11155111,
Holesky = 17000,
// L2
ArbitrumOne = 42161,
ArbitrumNova = 42170,
Base = 8453,
// L2 Testnets
ArbitrumSepolia = 421614,
ArbitrumLocal = 412346,
BaseSepolia = 84532,
// L3 Testnets
L3Local = 333333
}
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Chain } from 'wagmi'
import * as chains from 'wagmi/chains'
import {
ChainId,
getCustomChainFromLocalStorageById,
getSupportedChainIds
} from '../util/networks'
import { ChainId } from '../types/ChainId'
import * as customChains from '../util/wagmi/wagmiAdditionalNetworks'
import { getOrbitChains, orbitChains } from '../util/orbitChainsList'
import { chainToWagmiChain } from '../util/wagmi/wagmiAdditionalNetworks'
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/L2ApprovalUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '../util/networks'
import { ChainId } from '../types/ChainId'
import { xErc20RequiresApprovalOnChildChain } from './xErc20Utils'

export type RequireL2ApproveToken = {
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/L2NativeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '../util/networks'
import { ChainId } from '../types/ChainId'
import { CommonAddress } from './CommonAddressUtils'

export type L2NativeToken = {
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/SubgraphUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from './networks'
import { ChainId } from '../types/ChainId'
import { getAPIBaseUrl } from '.'

export function hasL1Subgraph(l2ChainId: number) {
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-token-bridge-ui/src/util/TokenListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import CMCLogo from '@/images/lists/cmc.png'
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 { ChainId } from '../types/ChainId'
import orbitChainsData from './orbitChainsData.json'

export const SPECIAL_ARBITRUM_TOKEN_TOKEN_LIST_ID =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from './networks'
import { ChainId } from '../types/ChainId'

export type TeleportEnabledToken = {
symbol: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '../util/networks'
import { ChainId } from '../types/ChainId'

export type TransferDisabledToken = {
symbol: string
Expand Down
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/src/util/TokenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory'

import { CommonAddress } from './CommonAddressUtils'
import { ChainId, isNetwork } from './networks'
import { isNetwork } from './networks'
import { ChainId } from '../types/ChainId'
import { defaultErc20Decimals } from '../defaults'
import { ERC20BridgeToken, TokenType } from '../hooks/arbTokenBridge.types'
import { getBridger, getChainIdFromProvider } from '../token-bridge-sdk/utils'
Expand Down
3 changes: 2 additions & 1 deletion packages/arb-token-bridge-ui/src/util/WithdrawOnlyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import { ethers } from 'ethers'
import { getProviderForChainId } from '@/token-bridge-sdk/utils'

import { ChainId, isNetwork } from '../util/networks'
import { isNetwork } from '../util/networks'
import { ChainId } from '../types/ChainId'
import {
isTokenArbitrumOneUSDCe,
isTokenArbitrumSepoliaUSDCe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { registerCustomArbitrumNetwork } from '@arbitrum/sdk'

import {
ChainId,
getBlockNumberReferenceChainIdByChainId,
getDestinationChainIds,
getSupportedChainIds
} from '../networks'
import { ChainId } from '../../types/ChainId'
import { orbitTestnets } from '../orbitChainsList'

const xaiTestnetChainId = 37714555429
Expand Down
Loading

0 comments on commit 01d4679

Please sign in to comment.