Skip to content

Commit

Permalink
Merge branch 'master' into e2e-custom-fee-token
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx authored Oct 21, 2024
2 parents 18c66d2 + 7251f61 commit 76987d6
Show file tree
Hide file tree
Showing 27 changed files with 667 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/add-layerleap-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Add Layer Leap Request
description: File a request to have your Orbit chain support Layer Leap transfers
title: "[feat]: enable Layer Leap for <Orbit Chain>"
labels: ["feat", "triage"]
labels: ["Type: Add LayerLeap"]
body:
- type: markdown
attributes:
Expand Down
10 changes: 1 addition & 9 deletions .github/ISSUE_TEMPLATE/add-orbit-chain-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Add Orbit Chain Request
description: File a request to have your Orbit chain added to the bridge
title: "[feat]: Add Orbit chain "
labels: ["feat", "triage"]
labels: ["Type: Add Orbit Chain"]
body:
- type: markdown
attributes:
Expand Down Expand Up @@ -172,10 +172,6 @@ body:
attributes:
value: |
## Parent chain token bridge contract addresses
- type: markdown
attributes:
value: |
You can find this information under the `"l2Contracts" : {...}` key.
- type: input
id: parent-custom-gateway
attributes:
Expand Down Expand Up @@ -224,10 +220,6 @@ body:
attributes:
value: |
## Orbit chain token bridge contract addresses
- type: markdown
attributes:
value: |
You can find this information under the `"l3Contracts" : {...}` key.
- type: input
id: child-custom-gateway
attributes:
Expand Down
10 changes: 9 additions & 1 deletion audit-ci.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json",
"low": true,
"allowlist": []
"allowlist": [
// https://github.com/advisories/GHSA-fc9h-whq2-v747
// Valid ECDSA signatures erroneously rejected in Elliptic
// Legitimate transactions or communications may be incorrectly flagged as invalid.
// No patched version available yet
// from: arb-token-bridge-ui>@unstoppabledomains/resolution>elliptic
// from: arb-token-bridge-ui>ethers>@ethersproject/signing-key>elliptic
"GHSA-fc9h-whq2-v747"
]
}
2 changes: 2 additions & 0 deletions packages/arb-token-bridge-ui/.env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ NEXT_PUBLIC_INFURA_KEY_SEPOLIA=

# L2
NEXT_PUBLIC_INFURA_KEY_ARBITRUM_ONE=
NEXT_PUBLIC_INFURA_KEY_BASE=
# L2 Testnet
NEXT_PUBLIC_INFURA_KEY_ARBITRUM_SEPOLIA=
NEXT_PUBLIC_INFURA_KEY_BASE_SEPOLIA=

NEXT_PUBLIC_SENTRY_DSN=

Expand Down
11 changes: 11 additions & 0 deletions packages/arb-token-bridge-ui/public/images/ApeChainLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions packages/arb-token-bridge-ui/public/images/ApeTokenLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/arb-token-bridge-ui/public/images/BaseWhite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 9 additions & 15 deletions packages/arb-token-bridge-ui/src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { BalanceUpdater } from '../syncers/BalanceUpdater'
import { TokenListSyncer } from '../syncers/TokenListSyncer'
import { Header } from '../common/Header'
import { HeaderAccountPopover } from '../common/HeaderAccountPopover'
import { getNetworkName, isNetwork } from '../../util/networks'
import { getNetworkName } from '../../util/networks'
import {
ArbQueryParamProvider,
useArbQueryParams
Expand All @@ -41,6 +41,7 @@ import { HeaderConnectWalletButton } from '../common/HeaderConnectWalletButton'
import { onDisconnectHandler } from '../../util/walletConnectUtils'
import { addressIsSmartContract } from '../../util/AddressUtils'
import { useSyncConnectedChainToAnalytics } from './useSyncConnectedChainToAnalytics'
import { isDepositMode } from '../../util/isDepositMode'

declare global {
interface Window {
Expand Down Expand Up @@ -98,30 +99,23 @@ const ArbTokenBridgeStoreSyncWrapper = (): JSX.Element | null => {
// Any time one of those changes
setTokenBridgeParams(null)
actions.app.setConnectionState(ConnectionState.LOADING)

const {
isArbitrum: isConnectedToArbitrum,
isOrbitChain: isConnectedToOrbitChain
} = isNetwork(networks.sourceChain.id)
const isParentChainEthereum = isNetwork(
parentChain.id
).isEthereumMainnetOrTestnet

actions.app.reset(networks.sourceChain.id)
actions.app.setChainIds({
l1NetworkChainId: parentChain.id,
l2NetworkChainId: childChain.id
})

if (
(isParentChainEthereum && isConnectedToArbitrum) ||
isConnectedToOrbitChain
isDepositMode({
sourceChainId: networks.sourceChain.id,
destinationChainId: networks.destinationChain.id
})
) {
console.info('Withdrawal mode detected:')
actions.app.setConnectionState(ConnectionState.L2_CONNECTED)
} else {
console.info('Deposit mode detected:')
actions.app.setConnectionState(ConnectionState.L1_CONNECTED)
} else {
console.info('Withdrawal mode detected:')
actions.app.setConnectionState(ConnectionState.L2_CONNECTED)
}

setTokenBridgeParams({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand All @@ -48,6 +49,19 @@ const chainGroupInfo: { [key in NetworkType]: ChainGroupInfo } = {
core: {
name: ChainGroupName.core
},
other: {
name: ChainGroupName.other,
description: (
<p className="mt-2 flex gap-1 whitespace-normal rounded bg-orange-dark px-2 py-1 text-xs text-orange">
<ShieldExclamationIcon className="h-4 w-4 shrink-0" />
<span>
Independent projects using non-Arbitrum technology. These chains have
varying degrees of decentralization.{' '}
<span className="font-semibold">Bridge at your own risk.</span>
</span>
</p>
)
},
orbit: {
name: ChainGroupName.orbit,
description: (
Expand All @@ -71,15 +85,15 @@ function ChainTypeInfoRow({
style: CSSProperties
}) {
const { name, description } = chainGroup
const isCoreGroup = chainGroup.name === ChainGroupName.core
const isOrbitGroup = chainGroup.name === ChainGroupName.orbit

return (
<div
key={name}
style={style}
className={twMerge(
'px-4 py-3',
!isCoreGroup &&
!isOrbitGroup &&
'before:-mt-3 before:mb-3 before:block before:h-[1px] before:w-full before:bg-white/30 before:content-[""]'
)}
>
Expand Down Expand Up @@ -236,14 +250,19 @@ function NetworksPanel({
}

const coreNetworks = chainIds.filter(
chainId => !isNetwork(chainId).isOrbitChain
chainId => isNetwork(chainId).isCoreChain
)
const otherNetworks = chainIds.filter(
chainId =>
!isNetwork(chainId).isCoreChain && !isNetwork(chainId).isOrbitChain
)
const orbitNetworks = chainIds.filter(
chainId => isNetwork(chainId).isOrbitChain
)

return {
core: coreNetworks,
other: otherNetworks,
orbit: orbitNetworks
}
}, [debouncedNetworkSearched, chainIds])
Expand All @@ -262,6 +281,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)
}
Expand Down Expand Up @@ -302,6 +325,12 @@ function NetworksPanel({
)
}

if (networkOrChainTypeName === ChainGroupName.other) {
return (
<ChainTypeInfoRow chainGroup={chainGroupInfo.other} style={style} />
)
}

if (networkOrChainTypeName === ChainGroupName.orbit) {
return (
<ChainTypeInfoRow chainGroup={chainGroupInfo.orbit} style={style} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ describe('sanitizeQueryParams', () => {
})
})
})
describe('when `destinationChainId` is valid but has no paired source chains and `sourceChainId` is undefined', () => {
it('should set `sourceChainId` to Ethereum and `destinationChainId` to Arbitrum One', () => {
const result = sanitizeQueryParams({
sourceChainId: undefined,
destinationChainId: ChainId.Holesky
})
expect(result).toEqual({
sourceChainId: ChainId.Ethereum,
destinationChainId: ChainId.ArbitrumOne
})
})
})

describe('when `destinationChainId` is invalid and `sourceChainId` is valid', () => {
it('should set `destinationChainId` based on `sourceChainId`', () => {
Expand Down Expand Up @@ -207,4 +219,16 @@ describe('sanitizeQueryParams', () => {
})
})
})
describe('when `destinationChainId` is undefined and `sourceChainId` is valid but has no paired destination chains', () => {
it('should set `sourceChainId` to Ethereum and `destinationChainId` to Arbitrum One', () => {
const result = sanitizeQueryParams({
sourceChainId: ChainId.Holesky,
destinationChainId: undefined
})
expect(result).toEqual({
sourceChainId: ChainId.Ethereum,
destinationChainId: ChainId.ArbitrumOne
})
})
})
})
26 changes: 23 additions & 3 deletions packages/arb-token-bridge-ui/src/hooks/useNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
arbitrumSepolia,
localL1Network as local,
localL2Network as arbitrumLocal,
localL3Network as l3Local
localL3Network as l3Local,
base,
baseSepolia
} from '../util/wagmi/wagmiAdditionalNetworks'

import { getDestinationChainIds } from '../util/networks'
Expand All @@ -37,7 +39,9 @@ export function isSupportedChainId(
holesky.id,
arbitrum.id,
arbitrumNova.id,
base.id,
arbitrumSepolia.id,
baseSepolia.id,
arbitrumLocal.id,
l3Local.id,
local.id,
Expand Down Expand Up @@ -74,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
Expand All @@ -83,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
}
}

Expand Down
13 changes: 6 additions & 7 deletions packages/arb-token-bridge-ui/src/token-bridge-sdk/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EthL1L3Bridger,
getArbitrumNetwork
} from '@arbitrum/sdk'
import { isDepositMode } from '../util/isDepositMode'

export const getAddressFromSigner = async (signer: Signer) => {
const address = await signer.getAddress()
Expand All @@ -28,25 +29,23 @@ export const getBridgeTransferProperties = (
const sourceChainId = props.sourceChainId
const destinationChainId = props.destinationChainId

const isSourceChainEthereumMainnetOrTestnet =
isNetwork(sourceChainId).isEthereumMainnetOrTestnet
const isDestinationChainEthereumMainnetOrTestnet =
isNetwork(destinationChainId).isEthereumMainnetOrTestnet

const isSourceChainArbitrum = isNetwork(sourceChainId).isArbitrum
const isDestinationChainArbitrum = isNetwork(destinationChainId).isArbitrum

const isSourceChainOrbit = isNetwork(sourceChainId).isOrbitChain
const isDestinationChainOrbit = isNetwork(destinationChainId).isOrbitChain

const isDeposit =
isSourceChainEthereumMainnetOrTestnet ||
(isSourceChainArbitrum && isDestinationChainOrbit)
const { isBase: isDestinationChainBase } = isNetwork(destinationChainId)

const isDeposit = isDepositMode({ sourceChainId, destinationChainId })

const isWithdrawal =
(isSourceChainArbitrum && isDestinationChainEthereumMainnetOrTestnet) || // l2 arbitrum chains to l1
(isSourceChainOrbit && isDestinationChainEthereumMainnetOrTestnet) || // l2 orbit chains to l1
(isSourceChainOrbit && isDestinationChainArbitrum) // l3 orbit chains to l1
(isSourceChainOrbit && isDestinationChainArbitrum) || // l3 orbit chains to l1
(isSourceChainOrbit && isDestinationChainBase) // l3 orbit chain to Base l2

const isTeleport = isValidTeleportChainPair({
sourceChainId,
Expand Down
Loading

0 comments on commit 76987d6

Please sign in to comment.