Skip to content

Commit

Permalink
fix method usage
Browse files Browse the repository at this point in the history
  • Loading branch information
fionnachan committed Jun 12, 2024
1 parent 707c1ab commit 16d6a34
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export async function getDestinationAddressError({
async function getDestinationAddressWarning({
destinationAddress,
isEOA,
destinationProvider
destinationChainId
}: {
destinationAddress: string | undefined
isEOA: boolean
destinationProvider: Provider
destinationChainId: number
}) {
if (!destinationAddress) {
return null
Expand All @@ -100,7 +100,7 @@ async function getDestinationAddressWarning({

const destinationIsSmartContract = await addressIsSmartContract(
destinationAddress,
destinationProvider
destinationChainId
)

// checks if trying to send to a contract address, only checks EOA
Expand Down Expand Up @@ -163,9 +163,7 @@ export const AdvancedSettings = () => {
const result = await getDestinationAddressWarning({
destinationAddress,
isEOA,
destinationProvider: isDepositMode
? childChainProvider
: parentChainProvider
destinationChainId: isDepositMode ? childChain.id : parentChain.id
})
if (isSubscribed) {
setWarning(result)
Expand All @@ -181,7 +179,9 @@ export const AdvancedSettings = () => {
isDepositMode,
isEOA,
childChainProvider,
parentChainProvider
parentChainProvider,
childChain.id,
parentChain.id
])

const collapsible = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ export class Erc20WithdrawalStarter extends BridgeTransferStarter {

const address = await getAddressFromSigner(signer)

const sourceChainId = await getChainIdFromProvider(this.sourceChainProvider)

const isSmartContractWallet = await addressIsSmartContract(
address,
this.sourceChainProvider
sourceChainId
)

if (isSmartContractWallet && !destinationAddress) {
Expand Down
6 changes: 4 additions & 2 deletions packages/arb-token-bridge-ui/src/token-bridge-sdk/teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { L1GatewayRouter__factory } from '@arbitrum/sdk/dist/lib/abi/factories/L
import { IInbox__factory } from '@arbitrum/sdk/dist/lib/abi/factories/IInbox__factory'
import { IBridge__factory } from '@arbitrum/sdk/dist/lib/abi/factories/IBridge__factory'
import { IRollupCore__factory } from '@arbitrum/sdk/dist/lib/abi/factories/IRollupCore__factory'
import { getProviderForChainId } from './utils'
import { getChainIdFromProvider, getProviderForChainId } from './utils'
import { TELEPORT_ALLOWLIST } from '../util/networks'
import { addressIsSmartContract } from '../util/AddressUtils'

Expand Down Expand Up @@ -65,7 +65,9 @@ async function tryGetInboxFromRouter(
address: string,
provider: Provider
): Promise<string | undefined> {
if (!(await addressIsSmartContract(address, provider))) {
const chainId = await getChainIdFromProvider(provider)

if (!(await addressIsSmartContract(address, chainId))) {
throw new Error(
'[tryGetInboxFromRouter]: address passed is not a smart contract'
)
Expand Down
5 changes: 4 additions & 1 deletion packages/arb-token-bridge-ui/src/util/TokenDepositUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from './TokenUtils'
import { DepositGasEstimates } from '../hooks/arbTokenBridge.types'
import { addressIsSmartContract } from './AddressUtils'
import { getChainIdFromProvider } from '@/token-bridge-sdk/utils'

async function fetchTokenFallbackGasEstimates({
inboxAddress,
Expand Down Expand Up @@ -56,9 +57,11 @@ async function fetchTokenFallbackGasEstimates({
l2Provider: childChainProvider
})

const childChainId = await getChainIdFromProvider(childChainProvider)

const isFirstTimeTokenBridging = !(await addressIsSmartContract(
childChainTokenAddress,
childChainProvider
childChainId
))
if (isFirstTimeTokenBridging) {
return {
Expand Down

0 comments on commit 16d6a34

Please sign in to comment.