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

feat: update depositTo to use standard deposit #432

Merged
merged 27 commits into from
Apr 30, 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
2 changes: 0 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ jobs:
- name: Set up the local node
uses: OffchainLabs/actions/run-nitro-test-node@main
with:
nitro-testnode-ref: release
nitro-contracts-branch: validator-wallet-fix
l3-node: ${{ matrix.orbit-test == '1' }}
args: ${{ matrix.custom-fee == '1' && '--l3-fee-token' || '' }}

Expand Down
10 changes: 6 additions & 4 deletions src/lib/assetBridger/ethBridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,12 @@ export class EthBridger extends AssetBridger<
l1Provider: params.l1Signer.provider!,
})

const tx = await params.l1Signer.sendTransaction({
...retryableTicketRequest.txRequest,
...params.overrides,
})
const l1ToL2MessageCreator = new L1ToL2MessageCreator(params.l1Signer)

const tx = await l1ToL2MessageCreator.createRetryableTicket(
retryableTicketRequest,
params.l2Provider
)

return L1TransactionReceipt.monkeyPatchContractCallWait(tx)
}
Expand Down
61 changes: 61 additions & 0 deletions tests/integration/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import dotenv from 'dotenv'

import { Wallet } from '@ethersproject/wallet'
import { parseEther } from '@ethersproject/units'
import { constants } from 'ethers'

import {
fundL1,
Expand All @@ -37,6 +38,7 @@ import { testSetup } from '../../scripts/testSetup'
import { isL2NetworkWithCustomFeeToken } from './custom-fee-token/customFeeTokenTestHelpers'
import { ERC20__factory } from '../../src/lib/abi/factories/ERC20__factory'
import { itOnlyWhenEth } from './custom-fee-token/mochaExtensions'
import { L1TransactionReceipt } from '../../src'

dotenv.config()

Expand Down Expand Up @@ -211,6 +213,65 @@ describe('Ether', async () => {
)
})

it('deposit ether to a specific L2 address with manual redeem', async () => {
const { ethBridger, l1Signer, l2Signer } = await testSetup()

await fundL1(l1Signer)
const destWallet = Wallet.createRandom()

const ethToDeposit = parseEther('0.0002')
const res = await ethBridger.depositTo({
amount: ethToDeposit,
l1Signer: l1Signer,
destinationAddress: destWallet.address,
l2Provider: l2Signer.provider!,
retryableGasOverrides: {
gasLimit: {
// causes auto-redeem to fail which allows us to check balances before it happens
base: constants.Zero,
},
},
})
const rec = await res.wait()
const l1ToL2Messages = await rec.getL1ToL2Messages(l2Signer.provider!)
expect(l1ToL2Messages.length).to.eq(1, 'failed to find 1 l1 to l2 message')
const l1ToL2MessageReader = l1ToL2Messages[0]

const retryableTicketResult = await l1ToL2MessageReader.waitForStatus()

expect(retryableTicketResult.status).to.eq(
L1ToL2MessageStatus.FUNDS_DEPOSITED_ON_L2,
'unexpected status, expected auto-redeem to fail'
)

let testWalletL2EthBalance = await l2Signer.provider!.getBalance(
destWallet.address
)

expect(
testWalletL2EthBalance.eq(constants.Zero),
'balance before auto-redeem'
).to.be.true

await fundL2(l2Signer)

const l1TxHash = await l1Signer.provider!.getTransactionReceipt(res.hash)
const l1Receipt = new L1TransactionReceipt(l1TxHash)

const l1ToL2MessageWriter = (await l1Receipt.getL1ToL2Messages(l2Signer))[0]

await (await l1ToL2MessageWriter.redeem()).wait()

testWalletL2EthBalance = await l2Signer.provider!.getBalance(
destWallet.address
)

expect(
testWalletL2EthBalance.toString(),
'balance after manual redeem'
).to.eq(ethToDeposit.toString())
})

it('withdraw Ether transaction succeeds', async () => {
const { l2Signer, l1Signer, ethBridger } = await testSetup()
await fundL2(l2Signer)
Expand Down
Loading