Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OffchainLabs/arbitrum-token-bridg…
Browse files Browse the repository at this point in the history
…e into arbitrum-sdk-v4-migration
  • Loading branch information
brtkx committed Apr 25, 2024
2 parents 4040699 + 1116670 commit 2b1d456
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Erc20Bridger } from '@arbitrum/sdk'
import { constants } from 'ethers'
import { BigNumber, constants } from 'ethers'
import { ERC20__factory } from '@arbitrum/sdk/dist/lib/abi/factories/ERC20__factory'
import {
ApproveTokenProps,
Expand All @@ -14,7 +14,11 @@ import {
fetchErc20L2GatewayAddress,
getL1ERC20Address
} from '../util/TokenUtils'
import { getAddressFromSigner, getChainIdFromProvider } from './utils'
import {
getAddressFromSigner,
getChainIdFromProvider,
percentIncrease
} from './utils'
import { tokenRequiresApprovalOnL2 } from '../util/L2ApprovalUtils'
import { withdrawInitTxEstimateGas } from '../util/WithdrawalUtils'
import { addressIsSmartContract } from '../util/AddressUtils'
Expand Down Expand Up @@ -199,13 +203,24 @@ export class Erc20WithdrawalStarter extends BridgeTransferStarter {
this.sourceChainProvider
)

const tx = await erc20Bridger.withdraw({
childSigner: signer,
const request = await erc20Bridger.getWithdrawalRequest({
from: address,
erc20ParentAddress: destinationChainErc20Address,
destinationAddress: destinationAddress ?? address,
amount
})

const tx = await erc20Bridger.withdraw({
...request,
childSigner: signer,
overrides: {
gasLimit: percentIncrease(
await this.sourceChainProvider.estimateGas(request.txRequest),
BigNumber.from(30)
)
}
})

return {
transferType: this.transferType,
status: 'pending',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BigNumber } from 'ethers'
import { EthBridger } from '@arbitrum/sdk'
import {
BridgeTransferStarter,
TransferEstimateGas,
TransferProps,
TransferType
} from './BridgeTransferStarter'
import { getAddressFromSigner } from './utils'
import { getAddressFromSigner, percentIncrease } from './utils'
import { withdrawInitTxEstimateGas } from '../util/WithdrawalUtils'

export class EthWithdrawalStarter extends BridgeTransferStarter {
Expand Down Expand Up @@ -46,15 +47,25 @@ export class EthWithdrawalStarter extends BridgeTransferStarter {

public async transfer({ amount, signer }: TransferProps) {
const address = await getAddressFromSigner(signer)

const ethBridger = await EthBridger.fromProvider(this.sourceChainProvider)
const tx = await ethBridger.withdraw({

const request = await ethBridger.getWithdrawalRequest({
amount,
childSigner: signer,
destinationAddress: address,
from: address
})

const tx = await ethBridger.withdraw({
...request,
childSigner: signer,
overrides: {
gasLimit: percentIncrease(
await this.sourceChainProvider.estimateGas(request.txRequest),
BigNumber.from(30)
)
}
})

return {
transferType: this.transferType,
status: 'pending',
Expand Down

0 comments on commit 2b1d456

Please sign in to comment.