Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused code #2140

Merged
merged 5 commits into from
Dec 27, 2024
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { createContext, useContext, useReducer, Dispatch } from 'react'

export enum TransactionHistoryTab {
DEPOSITS = 0,
WITHDRAWALS = 1,
CCTP = 2
}
type AppContextState = {
layout: {
isTransferPanelVisible: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ const PARENT_CHAIN_TX_DETAILS_OF_CLAIM_TX =
'arbitrum:bridge:claim:parent:tx:details'
const DEPOSITS_LOCAL_STORAGE_KEY = 'arbitrum:bridge:deposits'

export enum StatusLabel {
PENDING = 'Pending',
CLAIMABLE = 'Claimable',
SUCCESS = 'Success',
EXPIRED = 'Expired',
FAILURE = 'Failure'
}

function isDeposit(tx: MergedTransaction): boolean {
return !tx.isWithdrawal
}
Expand Down
31 changes: 0 additions & 31 deletions packages/arb-token-bridge-ui/src/components/common/Hooks.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions packages/arb-token-bridge-ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export const DOCS_DOMAIN = 'https://docs.arbitrum.io'

export const USDC_LEARN_MORE_LINK = `${DOCS_DOMAIN}/bridge-tokens/concepts/usdc-concept`

export const FAST_BRIDGE_ARTICLE_LINK = `${SUPPORT_LINK_BASE}/hc/en-us/articles/18213771832987`

export const TOKEN_APPROVAL_ARTICLE_LINK = `${SUPPORT_LINK_BASE}/hc/en-us/articles/18213893952923`

export const ETH_BALANCE_ARTICLE_LINK = `${SUPPORT_LINK_BASE}/hc/en-us/articles/18213854684699`
Expand Down
40 changes: 0 additions & 40 deletions packages/arb-token-bridge-ui/src/hooks/arbTokenBridge.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ import { BigNumber, ContractReceipt } from 'ethers'
import { TokenList } from '@uniswap/token-lists'
import {
EventArgs,
ParentEthDepositTransaction,
ParentEthDepositTransactionReceipt,
ParentContractCallTransaction,
ParentContractCallTransactionReceipt,
ChildContractTransaction,
ChildTransactionReceipt,
ChildToParentMessageStatus as OutgoingMessageState,
ChildToParentTransactionEvent
} from '@arbitrum/sdk'
import { StandardArbERC20 } from '@arbitrum/sdk/dist/lib/abi/StandardArbERC20'
import { WithdrawalInitiatedEvent } from '@arbitrum/sdk/dist/lib/abi/L2ArbitrumGateway'

export { OutgoingMessageState }
Expand All @@ -32,21 +25,6 @@ export type TransactionLifecycle<Tx, TxReceipt> = Partial<{
onTxError: (error: any) => void
}>

export type L1EthDepositTransactionLifecycle = TransactionLifecycle<
ParentEthDepositTransaction,
ParentEthDepositTransactionReceipt
>

export type L1ContractCallTransactionLifecycle = TransactionLifecycle<
ParentContractCallTransaction,
ParentContractCallTransactionReceipt
>

export type L2ContractCallTransactionLifecycle = TransactionLifecycle<
ChildContractTransaction,
ChildTransactionReceipt
>

export enum NodeBlockDeadlineStatusTypes {
NODE_NOT_CREATED,
EXECUTE_CALL_EXCEPTION
Expand Down Expand Up @@ -99,27 +77,9 @@ export interface ERC20BridgeToken extends BridgeToken {
decimals: number
}

export interface L2TokenData {
balance: BigNumber
contract: StandardArbERC20
}

export interface ContractStorage<T> {
[contractAddress: string]: T | undefined
}
export interface BridgeBalance {
balance: BigNumber | null

arbChainBalance: BigNumber | null
}

// removing 'tokens' / 'balance' could result in one interface
export interface AddressToSymbol {
[tokenAddress: string]: string
}
export interface AddressToDecimals {
[tokenAddress: string]: number
}

export type GasEstimates = {
estimatedParentChainGas: BigNumber
Expand Down
17 changes: 0 additions & 17 deletions packages/arb-token-bridge-ui/src/hooks/useDebouncedValue.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/arb-token-bridge-ui/src/state/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@ export function isCustomDestinationAddressTx(
return tx.sender.toLowerCase() !== tx.destination.toLowerCase()
}

export const isWithdrawalReadyToClaim = (tx: MergedTransaction) => {
return (
isWithdrawal(tx) &&
isPending(tx) &&
tx.status === outgoingStateToString[OutgoingMessageState.CONFIRMED]
)
}

export const isDepositReadyToRedeem = (tx: MergedTransaction) => {
if (isTeleportTx(tx)) {
return (
Expand Down
7 changes: 1 addition & 6 deletions packages/arb-token-bridge-ui/src/state/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { IContext } from 'overmind'
import {
createActionsHook,
createStateHook,
createEffectsHook
} from 'overmind-react'
import { createActionsHook, createStateHook } from 'overmind-react'
import { namespaced } from 'overmind/config'

import * as app from './app'
Expand All @@ -20,4 +16,3 @@ export type Context = IContext<{

export const useAppState = createStateHook<Context>()
export const useActions = createActionsHook<Context>()
export const useEffects = createEffectsHook<Context>()
7 changes: 0 additions & 7 deletions packages/arb-token-bridge-ui/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ export const sanitizeImageSrc = (url: string): string => {
return url
}

export function preloadImages(imageSources: string[]) {
imageSources.forEach(imageSrc => {
const image = new Image()
image.src = imageSrc
})
}

export const loadEnvironmentVariableWithFallback = ({
env,
fallback
Expand Down
63 changes: 0 additions & 63 deletions packages/arb-token-bridge-ui/src/util/withdrawals/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ export type EthWithdrawal = L2ToL1EventResult & {
childChainId: number
}

export const updateAdditionalWithdrawalData = async (
withdrawalTx: L2ToL1EventResultPlus,
l1Provider: Provider,
l2Provider: Provider
) => {
const l2toL1TxWithDeadline = await attachNodeBlockDeadlineToEvent(
withdrawalTx as L2ToL1EventResultPlus,
l1Provider,
l2Provider
)

return l2toL1TxWithDeadline
}

export async function attachTimestampToTokenWithdrawal({
withdrawal,
l2Provider
Expand Down Expand Up @@ -128,55 +114,6 @@ export async function getOutgoingMessageState(
}
}

export async function attachNodeBlockDeadlineToEvent(
event: L2ToL1EventResultPlus,
l1Provider: Provider,
l2Provider: Provider
) {
if (
event.outgoingMessageState === OutgoingMessageState.EXECUTED ||
event.outgoingMessageState === OutgoingMessageState.CONFIRMED
) {
return event
}

const messageReader = ChildToParentMessageReader.fromEvent(l1Provider, event)

try {
const firstExecutableBlock = await messageReader.getFirstExecutableBlock(
l2Provider
)

return { ...event, nodeBlockDeadline: firstExecutableBlock?.toNumber() }
} catch (e) {
const expectedError = "batch doesn't exist"
const expectedError2 = 'CALL_EXCEPTION'

const err = e as Error & { error: Error }
const errorMessage = err && (err.message || err.error?.message)

if (errorMessage.includes(expectedError)) {
const nodeBlockDeadline: NodeBlockDeadlineStatus =
NodeBlockDeadlineStatusTypes.NODE_NOT_CREATED
return {
...event,
nodeBlockDeadline
}
} else if (errorMessage.includes(expectedError2)) {
// in classic we simulate `executeTransaction` in `hasExecuted`
// which might revert if the L2 to L1 call fail
const nodeBlockDeadline: NodeBlockDeadlineStatus =
NodeBlockDeadlineStatusTypes.EXECUTE_CALL_EXCEPTION
return {
...event,
nodeBlockDeadline
}
} else {
throw e
}
}
}

export function isTokenWithdrawal(
withdrawal: WithdrawalInitiated | EthWithdrawal
): withdrawal is WithdrawalInitiated {
Expand Down
Loading