---
.../arb-token-bridge-ui/src/util/__tests__/networks.test.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/arb-token-bridge-ui/src/util/__tests__/networks.test.ts b/packages/arb-token-bridge-ui/src/util/__tests__/networks.test.ts
index 4c79cbbf28..2dbeb6f3cb 100644
--- a/packages/arb-token-bridge-ui/src/util/__tests__/networks.test.ts
+++ b/packages/arb-token-bridge-ui/src/util/__tests__/networks.test.ts
@@ -57,7 +57,7 @@ beforeAll(() => {
const polterTestnet = orbitTestnets[polterTestnetChainId]
if (!polterTestnet) {
- throw new Error(`Could not find Xai Testnet in the Orbit chains list.`)
+ throw new Error(`Could not find Polter Testnet in the Orbit chains list.`)
}
registerCustomArbitrumNetwork(polterTestnet)
From 00e73da51bb2320b7f68f9c838297d9e2e828639 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Fri, 18 Oct 2024 13:49:07 +0100
Subject: [PATCH 10/19] support base
---
.../src/hooks/useNetworks.ts | 20 +++++++++++++++++--
.../src/types/ChainQueryParam.ts | 13 +++++-------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/hooks/useNetworks.ts b/packages/arb-token-bridge-ui/src/hooks/useNetworks.ts
index 7a3809422a..b141f2d144 100644
--- a/packages/arb-token-bridge-ui/src/hooks/useNetworks.ts
+++ b/packages/arb-token-bridge-ui/src/hooks/useNetworks.ts
@@ -78,7 +78,15 @@ export function sanitizeQueryParams({
isSupportedChainId(destinationChainId)
) {
const [defaultSourceChainId] = getDestinationChainIds(destinationChainId)
- return { sourceChainId: defaultSourceChainId!, destinationChainId }
+
+ if (typeof defaultSourceChainId === 'undefined') {
+ return {
+ sourceChainId: ChainId.Ethereum,
+ destinationChainId: ChainId.ArbitrumOne
+ }
+ }
+
+ return { sourceChainId: defaultSourceChainId, destinationChainId }
}
// sourceChainId is valid and destinationChainId is undefined
@@ -87,9 +95,17 @@ export function sanitizeQueryParams({
!isSupportedChainId(destinationChainId)
) {
const [defaultDestinationChainId] = getDestinationChainIds(sourceChainId)
+
+ if (typeof defaultDestinationChainId === 'undefined') {
+ return {
+ sourceChainId: ChainId.Ethereum,
+ destinationChainId: ChainId.ArbitrumOne
+ }
+ }
+
return {
sourceChainId: sourceChainId,
- destinationChainId: defaultDestinationChainId!
+ destinationChainId: defaultDestinationChainId
}
}
diff --git a/packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts b/packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts
index b55d3feeb8..e47e93ec97 100644
--- a/packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts
+++ b/packages/arb-token-bridge-ui/src/types/ChainQueryParam.ts
@@ -15,8 +15,7 @@ const chainQueryParams = [
'sepolia',
'arbitrum-one',
'arbitrum-nova',
- // Enable when there are Orbit Chains on Base
- // 'base',
+ 'base',
'arbitrum-sepolia',
'base-sepolia',
'custom-localhost',
@@ -53,9 +52,8 @@ export function getChainQueryParamForChain(chainId: ChainId): ChainQueryParam {
case ChainId.ArbitrumNova:
return 'arbitrum-nova'
- // Enable when there are Orbit Chains on Base
- // case ChainId.Base:
- // return 'base'
+ case ChainId.Base:
+ return 'base'
case ChainId.Sepolia:
return 'sepolia'
@@ -110,9 +108,8 @@ export function getChainForChainKeyQueryParam(
case 'arbitrum-nova':
return customChains.arbitrumNova
- // Enable when there are Orbit Chains on Base
- // case 'base':
- // return customChains.base
+ case 'base':
+ return customChains.base
case 'arbitrum-sepolia':
return customChains.arbitrumSepolia
From 98ed213cf4b8c5f2ef59fd559835f627d7d95d60 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Fri, 18 Oct 2024 15:19:07 +0100
Subject: [PATCH 11/19] update
---
.../arb-token-bridge-ui/src/util/networks.ts | 46 ++++++-------------
.../src/util/orbitChainsData.json | 2 +-
2 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts
index 8ae9fe5a5b..aa977e8cfe 100644
--- a/packages/arb-token-bridge-ui/src/util/networks.ts
+++ b/packages/arb-token-bridge-ui/src/util/networks.ts
@@ -112,8 +112,8 @@ export function getBaseChainIdByChainId({
}: {
chainId: number
}): number {
- // the chain provided is an L1 chain, so we can return early
- if (isL1Chain({ chainId })) {
+ // the chain provided is an L1 chain or Base chain, so we can return early
+ if (isNonArbParentChain({ chainId })) {
return chainId
}
@@ -125,13 +125,9 @@ export function getBaseChainIdByChainId({
return chainId
}
- if (isBaseChain(currentParentChain)) {
- return currentParentChain.parentChainId
- }
-
- // keep following the parent chains until we find the L1 chain
+ // keep following the parent chains until we find the L1/Base chain
while (true) {
- if (isL1Chain(currentParentChain)) {
+ if (isNonArbParentChain(currentParentChain)) {
return currentParentChain.chainId
}
@@ -278,18 +274,10 @@ export const getExplorerUrl = (chainId: ChainId) => {
export const getL1BlockTime = (chainId: number) => {
const chain = getChainByChainId(getBaseChainIdByChainId({ chainId }))
- if (!chain || (!isL1Chain(chain) && !isBaseChain(chain))) {
+ if (!chain || !('blockTime' in chain)) {
throw new Error(`Couldn't get block time. Unexpected chain ID: ${chainId}`)
}
- const { isBase } = isNetwork(chainId)
-
- if (isBase) {
- // For Arbitrum L3s built on top of an OP Stack L2, `block.number` will return the L2 block number.
- // L2 blocks in OP Stack chains are produced every 2 seconds
- return 2
- }
-
return chain.blockTime
}
@@ -532,20 +520,13 @@ export function mapCustomChainToNetworkData(chain: ChainWithRpcUrl) {
explorerUrls[chain.chainId] = chain.explorerUrl
}
-function isL1Chain(chain: { chainId: number }): chain is L1Network {
- return typeof l1Networks[chain.chainId] !== 'undefined'
-}
-
-function isArbitrumChain(
- chain: L1Network | ArbitrumNetwork
-): chain is ArbitrumNetwork {
- return typeof (chain as ArbitrumNetwork).parentChainId !== 'undefined'
-}
-
-function isBaseChain(
- chain: L1Network | ArbitrumNetwork | BaseNetwork
-): chain is BaseNetwork {
- return (chain as BaseNetwork).isBase === true
+function isNonArbParentChain(chain: {
+ chainId: number
+}): chain is L1Network | BaseNetwork {
+ return (
+ typeof l1Networks[chain.chainId] !== 'undefined' ||
+ typeof baseNetworks[chain.chainId] !== 'undefined'
+ )
}
export const TELEPORT_ALLOWLIST: { [id: number]: number[] } = {
@@ -593,7 +574,8 @@ export function getDestinationChainIds(chainId: ChainId): ChainId[] {
return []
}
- const parentChainId = isArbitrumChain(chain) ? chain.parentChainId : undefined
+ const parentChainId =
+ 'parentChainId' in chain ? chain.parentChainId : undefined
const validDestinationChainIds = getChildChainIds(chain)
diff --git a/packages/arb-token-bridge-ui/src/util/orbitChainsData.json b/packages/arb-token-bridge-ui/src/util/orbitChainsData.json
index 6cac6b87f1..6cbb4622a1 100644
--- a/packages/arb-token-bridge-ui/src/util/orbitChainsData.json
+++ b/packages/arb-token-bridge-ui/src/util/orbitChainsData.json
@@ -820,7 +820,7 @@
"network": {
"name": "Polter Testnet",
"logo": "/images/PolterTestnetLogo.png",
- "description": "A gaming testnet for Aavegotchi's Geist Mainnet."
+ "description": "A gaming testnet for Aavegotchi's Geist Mainnet."
},
"nativeTokenData": {
"name": "Aavegotchi GHST Token",
From c48ae9a877ad82c47eae2d30c4b472d2285f7264 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Fri, 18 Oct 2024 15:33:29 +0100
Subject: [PATCH 12/19] update
---
.../src/util/wagmi/setup.ts | 37 ++++++++-----------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts b/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts
index 8f4ae1d634..fac6d8c971 100644
--- a/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts
+++ b/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts
@@ -28,18 +28,22 @@ const wagmiOrbitChains = getOrbitChains().map(chain =>
getWagmiChain(chain.chainId)
)
+const defaultChains = [
+ // mainnet, arb1, & arb nova are for network switch tests
+ mainnet,
+ arbitrum,
+ arbitrumNova,
+ base,
+ // sepolia & arb sepolia are for tx history panel tests
+ sepolia,
+ arbitrumSepolia,
+ baseSepolia,
+ holesky
+]
+
const chainList = isTestingEnvironment
? [
- // mainnet, arb1, & arb nova are for network switch tests
- mainnet,
- arbitrum,
- arbitrumNova,
- base,
- // sepolia & arb sepolia are for tx history panel tests
- sepolia,
- arbitrumSepolia,
- baseSepolia,
- holesky,
+ ...defaultChains,
// Orbit chains
...wagmiOrbitChains,
// add local environments during testing
@@ -49,18 +53,7 @@ const chainList = isTestingEnvironment
// user-added custom chains
...customChains
]
- : [
- mainnet,
- arbitrum,
- arbitrumNova,
- base,
- sepolia,
- arbitrumSepolia,
- baseSepolia,
- holesky,
- ...wagmiOrbitChains,
- ...customChains
- ]
+ : [...defaultChains, ...wagmiOrbitChains, ...customChains]
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!
From 7b6c89dabe66ce3075ef02ac5ed15b760f915816 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Fri, 18 Oct 2024 15:50:15 +0100
Subject: [PATCH 13/19] update type
---
.../arb-token-bridge-ui/src/util/networks.ts | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts
index aa977e8cfe..bca7f5573f 100644
--- a/packages/arb-token-bridge-ui/src/util/networks.ts
+++ b/packages/arb-token-bridge-ui/src/util/networks.ts
@@ -29,13 +29,13 @@ export enum ChainId {
L3Local = 333333
}
-type L1Network = {
+type NonArbParentNetwork = {
chainId: ChainId
blockTime: number
isTestnet: boolean
}
-const l1Networks: { [chainId: number]: L1Network } = {
+const l1Networks: { [chainId: number]: NonArbParentNetwork } = {
[ChainId.Ethereum]: {
chainId: ChainId.Ethereum,
blockTime: 12,
@@ -58,25 +58,21 @@ const l1Networks: { [chainId: number]: L1Network } = {
}
}
-export type BaseNetwork = L1Network & { isBase: true }
-
-const baseNetworks: { [chainId: number]: BaseNetwork } = {
+const baseNetworks: { [chainId: number]: NonArbParentNetwork } = {
[ChainId.Base]: {
chainId: ChainId.Base,
blockTime: 2,
- isTestnet: false,
- isBase: true
+ isTestnet: false
},
[ChainId.BaseSepolia]: {
chainId: ChainId.BaseSepolia,
blockTime: 2,
- isTestnet: true,
- isBase: true
+ isTestnet: true
}
}
export const getChains = () => {
- const chains: (L1Network | ArbitrumNetwork | BaseNetwork)[] = [
+ const chains: (NonArbParentNetwork | ArbitrumNetwork)[] = [
...Object.values(l1Networks),
...Object.values(baseNetworks),
...getArbitrumNetworks()
@@ -522,7 +518,7 @@ export function mapCustomChainToNetworkData(chain: ChainWithRpcUrl) {
function isNonArbParentChain(chain: {
chainId: number
-}): chain is L1Network | BaseNetwork {
+}): chain is NonArbParentNetwork {
return (
typeof l1Networks[chain.chainId] !== 'undefined' ||
typeof baseNetworks[chain.chainId] !== 'undefined'
From 2eda65c8ea0d987cb483dabebae2e221bd8ab5d5 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Fri, 18 Oct 2024 15:57:27 +0100
Subject: [PATCH 14/19] update
---
packages/arb-token-bridge-ui/src/util/networks.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts
index bca7f5573f..a1de8b502c 100644
--- a/packages/arb-token-bridge-ui/src/util/networks.ts
+++ b/packages/arb-token-bridge-ui/src/util/networks.ts
@@ -113,7 +113,7 @@ export function getBaseChainIdByChainId({
return chainId
}
- let currentParentChain: L1Network | ArbitrumNetwork | BaseNetwork
+ let currentParentChain: NonArbParentNetwork | ArbitrumNetwork
try {
currentParentChain = getArbitrumNetwork(chainId)
@@ -308,7 +308,7 @@ export const l2MoonGatewayAddresses: { [chainId: number]: string } = {
[ChainId.ArbitrumNova]: '0xA430a792c14d3E49d9D00FD7B4BA343F516fbB81'
}
-const defaultL1Network: L1Network = {
+const defaultL1Network: NonArbParentNetwork = {
blockTime: 10,
chainId: 1337,
isTestnet: true
@@ -530,7 +530,7 @@ export const TELEPORT_ALLOWLIST: { [id: number]: number[] } = {
[ChainId.Sepolia]: [1918988905] // RARI Testnet
}
-export function getChildChainIds(chain: ArbitrumNetwork | L1Network) {
+export function getChildChainIds(chain: ArbitrumNetwork | NonArbParentNetwork) {
const childChainIds = [
...getChildrenForNetwork(chain.chainId).map(chain => chain.chainId),
...(TELEPORT_ALLOWLIST[chain.chainId] ?? []) // for considering teleport (L1-L3 transfers) we will get the L3 children of the chain, if present
From 7786875d82ecf83c010acdec73b6aebbe2d2344d Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Mon, 21 Oct 2024 13:11:07 +0100
Subject: [PATCH 15/19] update desc
---
packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts b/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts
index bc2055ef64..d7d4461918 100644
--- a/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts
+++ b/packages/arb-token-bridge-ui/src/util/bridgeUiConfig.ts
@@ -111,7 +111,7 @@ export function getBridgeUiConfigForChain(chainId: number): BridgeUiConfig {
name: 'Base',
logo: '/images/BaseWhite.svg',
description:
- 'Base is built as an Ethereum L2, decentralized with the Optimism Superchain, and incubated by Coinbase.'
+ 'Base is an Optimistic Rollup built by Coinbase with the OP Stack.'
}
}
case ChainId.BaseSepolia:
From 199a74635c57ea6ca9c1f22de115e4899ab45429 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Mon, 21 Oct 2024 14:06:14 +0100
Subject: [PATCH 16/19] other chains
---
.../common/NetworkSelectionContainer.tsx | 34 ++++++++++++++++---
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx b/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx
index 95994fa261..6e11fe4d39 100644
--- a/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx
+++ b/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx
@@ -32,10 +32,11 @@ import { useActions } from '../../state'
import { useChainIdsForNetworkSelection } from '../../hooks/TransferPanel/useChainIdsForNetworkSelection'
import { useAccountType } from '../../hooks/useAccountType'
-type NetworkType = 'core' | 'orbit'
+type NetworkType = 'core' | 'other' | 'orbit'
enum ChainGroupName {
core = 'CORE CHAINS',
+ other = 'OTHER CHAINS',
orbit = 'ORBIT CHAINS'
}
@@ -48,6 +49,19 @@ const chainGroupInfo: { [key in NetworkType]: ChainGroupInfo } = {
core: {
name: ChainGroupName.core
},
+ other: {
+ name: ChainGroupName.other,
+ description: (
+
+
+
+ Independent projects using non-Arbitrum technology. These chains have
+ varying degrees of decentralization.{' '}
+ Bridge at your own risk.
+
+
+ )
+ },
orbit: {
name: ChainGroupName.orbit,
description: (
@@ -71,7 +85,7 @@ function ChainTypeInfoRow({
style: CSSProperties
}) {
const { name, description } = chainGroup
- const isCoreGroup = chainGroup.name === ChainGroupName.core
+ const isOrbitGroup = chainGroup.name === ChainGroupName.orbit
return (
@@ -236,14 +250,16 @@ function NetworksPanel({
}
const coreNetworks = chainIds.filter(
- chainId => !isNetwork(chainId).isOrbitChain
+ chainId => isNetwork(chainId).isCoreChain
)
+ const otherNetworks = chainIds.filter(chainId => isNetwork(chainId).isBase)
const orbitNetworks = chainIds.filter(
chainId => isNetwork(chainId).isOrbitChain
)
return {
core: coreNetworks,
+ other: otherNetworks,
orbit: orbitNetworks
}
}, [debouncedNetworkSearched, chainIds])
@@ -262,6 +278,10 @@ function NetworksPanel({
groupedNetworks.push(ChainGroupName.core, ...networksToShow.core)
}
+ if (networksToShow.other.length > 0) {
+ groupedNetworks.push(ChainGroupName.other, ...networksToShow.other)
+ }
+
if (networksToShow.orbit.length > 0) {
groupedNetworks.push(ChainGroupName.orbit, ...networksToShow.orbit)
}
@@ -302,6 +322,12 @@ function NetworksPanel({
)
}
+ if (networkOrChainTypeName === ChainGroupName.other) {
+ return (
+
+ )
+ }
+
if (networkOrChainTypeName === ChainGroupName.orbit) {
return (
From bc449afe05651dea3ee1b68ff1809a6e16e55e50 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Mon, 21 Oct 2024 14:33:54 +0100
Subject: [PATCH 17/19] update
---
.../src/components/common/NetworkSelectionContainer.tsx | 5 ++++-
packages/arb-token-bridge-ui/src/util/networks.ts | 8 ++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx b/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx
index 6e11fe4d39..522a69e6cb 100644
--- a/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx
+++ b/packages/arb-token-bridge-ui/src/components/common/NetworkSelectionContainer.tsx
@@ -252,7 +252,10 @@ function NetworksPanel({
const coreNetworks = chainIds.filter(
chainId => isNetwork(chainId).isCoreChain
)
- const otherNetworks = chainIds.filter(chainId => isNetwork(chainId).isBase)
+ const otherNetworks = chainIds.filter(
+ chainId =>
+ !isNetwork(chainId).isCoreChain && !isNetwork(chainId).isOrbitChain
+ )
const orbitNetworks = chainIds.filter(
chainId => isNetwork(chainId).isOrbitChain
)
diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts
index faa46ed6e2..c177be40c8 100644
--- a/packages/arb-token-bridge-ui/src/util/networks.ts
+++ b/packages/arb-token-bridge-ui/src/util/networks.ts
@@ -81,7 +81,7 @@ export const getChains = () => {
return chains.filter(chain => {
// exclude L1 chains or Base Chains with no child chains
if (
- !('parentChainId' in chain) &&
+ isNonArbParentChain(chain) &&
getChildrenForNetwork(chain.chainId).length === 0
) {
return false
@@ -206,12 +206,12 @@ export function removeCustomChainFromLocalStorage(chainId: number) {
)
}
+// Only support testnet chains
export const supportedCustomOrbitParentChains = [
ChainId.Sepolia,
ChainId.Holesky,
ChainId.ArbitrumSepolia,
- ChainId.BaseSepolia,
- ChainId.Base
+ ChainId.BaseSepolia
]
export const rpcURLs: { [chainId: number]: string } = {
@@ -270,7 +270,7 @@ export const getExplorerUrl = (chainId: ChainId) => {
export const getL1BlockTime = (chainId: number) => {
const chain = getChainByChainId(getBaseChainIdByChainId({ chainId }))
- if (!chain || !('blockTime' in chain)) {
+ if (!chain || !isNonArbParentChain(chain)) {
throw new Error(`Couldn't get block time. Unexpected chain ID: ${chainId}`)
}
From f72375c1cd97bd94901217a72e58a0dd58c6dd53 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Mon, 21 Oct 2024 14:42:41 +0100
Subject: [PATCH 18/19] revive
---
packages/arb-token-bridge-ui/src/util/networks.ts | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts
index c177be40c8..35b446f26e 100644
--- a/packages/arb-token-bridge-ui/src/util/networks.ts
+++ b/packages/arb-token-bridge-ui/src/util/networks.ts
@@ -524,6 +524,12 @@ export function mapCustomChainToNetworkData(chain: ChainWithRpcUrl) {
explorerUrls[chain.chainId] = chain.explorerUrl
}
+function isArbitrumChain(
+ chain: NonArbParentNetwork | ArbitrumNetwork
+): chain is ArbitrumNetwork {
+ return typeof (chain as ArbitrumNetwork).parentChainId !== 'undefined'
+}
+
function isNonArbParentChain(chain: {
chainId: number
}): chain is NonArbParentNetwork {
@@ -578,8 +584,7 @@ export function getDestinationChainIds(chainId: ChainId): ChainId[] {
return []
}
- const parentChainId =
- 'parentChainId' in chain ? chain.parentChainId : undefined
+ const parentChainId = isArbitrumChain(chain) ? chain.parentChainId : undefined
const validDestinationChainIds = getChildChainIds(chain)
From 9998d33cea91471702b67d27aeb80a00a2f69f62 Mon Sep 17 00:00:00 2001
From: Fionna <13184582+fionnachan@users.noreply.github.com>
Date: Mon, 21 Oct 2024 15:00:01 +0100
Subject: [PATCH 19/19] rename
---
.../arb-token-bridge-ui/src/util/networks.ts | 31 ++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/packages/arb-token-bridge-ui/src/util/networks.ts b/packages/arb-token-bridge-ui/src/util/networks.ts
index 35b446f26e..5dc8e5627c 100644
--- a/packages/arb-token-bridge-ui/src/util/networks.ts
+++ b/packages/arb-token-bridge-ui/src/util/networks.ts
@@ -29,13 +29,14 @@ export enum ChainId {
L3Local = 333333
}
-type NonArbParentNetwork = {
+/** The network that you reference when calling `block.number` in solidity */
+type BlockNumberReferenceNetwork = {
chainId: ChainId
blockTime: number
isTestnet: boolean
}
-const l1Networks: { [chainId: number]: NonArbParentNetwork } = {
+const l1Networks: { [chainId: number]: BlockNumberReferenceNetwork } = {
[ChainId.Ethereum]: {
chainId: ChainId.Ethereum,
blockTime: 12,
@@ -58,7 +59,7 @@ const l1Networks: { [chainId: number]: NonArbParentNetwork } = {
}
}
-const baseNetworks: { [chainId: number]: NonArbParentNetwork } = {
+const baseNetworks: { [chainId: number]: BlockNumberReferenceNetwork } = {
[ChainId.Base]: {
chainId: ChainId.Base,
blockTime: 2,
@@ -72,7 +73,7 @@ const baseNetworks: { [chainId: number]: NonArbParentNetwork } = {
}
export const getChains = () => {
- const chains: (NonArbParentNetwork | ArbitrumNetwork)[] = [
+ const chains: (BlockNumberReferenceNetwork | ArbitrumNetwork)[] = [
...Object.values(l1Networks),
...Object.values(baseNetworks),
...getArbitrumNetworks()
@@ -81,7 +82,7 @@ export const getChains = () => {
return chains.filter(chain => {
// exclude L1 chains or Base Chains with no child chains
if (
- isNonArbParentChain(chain) &&
+ isBlockNumberReferenceNetwork(chain) &&
getChildrenForNetwork(chain.chainId).length === 0
) {
return false
@@ -109,11 +110,11 @@ export function getBaseChainIdByChainId({
chainId: number
}): number {
// the chain provided is an L1 chain or Base chain, so we can return early
- if (isNonArbParentChain({ chainId })) {
+ if (isBlockNumberReferenceNetwork({ chainId })) {
return chainId
}
- let currentParentChain: NonArbParentNetwork | ArbitrumNetwork
+ let currentParentChain: BlockNumberReferenceNetwork | ArbitrumNetwork
try {
currentParentChain = getArbitrumNetwork(chainId)
@@ -123,7 +124,7 @@ export function getBaseChainIdByChainId({
// keep following the parent chains until we find the L1/Base chain
while (true) {
- if (isNonArbParentChain(currentParentChain)) {
+ if (isBlockNumberReferenceNetwork(currentParentChain)) {
return currentParentChain.chainId
}
@@ -270,7 +271,7 @@ export const getExplorerUrl = (chainId: ChainId) => {
export const getL1BlockTime = (chainId: number) => {
const chain = getChainByChainId(getBaseChainIdByChainId({ chainId }))
- if (!chain || !isNonArbParentChain(chain)) {
+ if (!chain || !isBlockNumberReferenceNetwork(chain)) {
throw new Error(`Couldn't get block time. Unexpected chain ID: ${chainId}`)
}
@@ -308,7 +309,7 @@ export const l2MoonGatewayAddresses: { [chainId: number]: string } = {
[ChainId.ArbitrumNova]: '0xA430a792c14d3E49d9D00FD7B4BA343F516fbB81'
}
-const defaultL1Network: NonArbParentNetwork = {
+const defaultL1Network: BlockNumberReferenceNetwork = {
blockTime: 10,
chainId: 1337,
isTestnet: true
@@ -525,14 +526,14 @@ export function mapCustomChainToNetworkData(chain: ChainWithRpcUrl) {
}
function isArbitrumChain(
- chain: NonArbParentNetwork | ArbitrumNetwork
+ chain: BlockNumberReferenceNetwork | ArbitrumNetwork
): chain is ArbitrumNetwork {
return typeof (chain as ArbitrumNetwork).parentChainId !== 'undefined'
}
-function isNonArbParentChain(chain: {
+function isBlockNumberReferenceNetwork(chain: {
chainId: number
-}): chain is NonArbParentNetwork {
+}): chain is BlockNumberReferenceNetwork {
return (
typeof l1Networks[chain.chainId] !== 'undefined' ||
typeof baseNetworks[chain.chainId] !== 'undefined'
@@ -544,7 +545,9 @@ export const TELEPORT_ALLOWLIST: { [id: number]: number[] } = {
[ChainId.Sepolia]: [1918988905] // RARI Testnet
}
-export function getChildChainIds(chain: ArbitrumNetwork | NonArbParentNetwork) {
+export function getChildChainIds(
+ chain: ArbitrumNetwork | BlockNumberReferenceNetwork
+) {
const childChainIds = [
...getChildrenForNetwork(chain.chainId).map(chain => chain.chainId),
...(TELEPORT_ALLOWLIST[chain.chainId] ?? []) // for considering teleport (L1-L3 transfers) we will get the L3 children of the chain, if present