Skip to content

[WIP] Deposit withdrawal contracts#216

Closed
Jinglan wants to merge 29 commits intomasterfrom
YAS-404/DepositWithdrawalContracts
Closed

[WIP] Deposit withdrawal contracts#216
Jinglan wants to merge 29 commits intomasterfrom
YAS-404/DepositWithdrawalContracts

Conversation

@Jinglan
Copy link

@Jinglan Jinglan commented Aug 13, 2020

Description

Questions

Metadata

Fixes

  • Fixes # [Link to Issue]

Contributing Agreement

Copy link
Contributor

@K-Ho K-Ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Left some comments, mostly style - I can go through and make all of these changes myself or happy to walk you through


using SafeMath for uint;

uint256 constant private MAX_UINT256 = 2**256 - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line isn't needed because we have SafeMath

}

function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure we can remove this line. Also need to add check that the amount allowed is greater than or equal to the value, see: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.0.0/contracts/token/ERC20/ERC20.sol#L96

_amount
);
// Tell L2 to mint corresponding coins
MockL1ToL2MessagePasser(l1ToL2MessagePasser).passMessageToL2(messageData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MockL1ToL2MessagePasser(l1ToL2MessagePasser).passMessageToL2(messageData);
IL1ToL2MessagePasser(l1ToL2MessagePasser).passMessageToL2(messageData);

pragma experimental ABIEncoderV2;
import { ERC20 } from "./ERC20.sol";
import { ContractResolver } from "../utils/resolvers/ContractResolver.sol";
import { MockL1ToL2MessagePasser } from "../ovm/test-helpers/MockL1ToL2MessagePasser.sol";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { MockL1ToL2MessagePasser } from "../ovm/test-helpers/MockL1ToL2MessagePasser.sol";
import { IL1ToL2MessagePasser } from "./IL1ToL2MessagePasser.sol";

it('sets DepositedERC20 factory address correctly', async () => {
const factoryAddress = await depositedERC20.l2ERC20Bridge()
factoryAddress.should.equal(await wallet.getAddress())
console.log('test')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment on lines +41 to +47
const evilDepositedERC20 = depositedERC20.connect(badwallet)
await TestUtils.assertRevertsAsync(
'Get outta here. L2 factory bridge address ONLY.',
async () => {
await evilDepositedERC20.processDeposit('0x' + '00'.repeat(20), 5)
}
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const evilDepositedERC20 = depositedERC20.connect(badwallet)
await TestUtils.assertRevertsAsync(
'Get outta here. L2 factory bridge address ONLY.',
async () => {
await evilDepositedERC20.processDeposit('0x' + '00'.repeat(20), 5)
}
)
await TestUtils.assertRevertsAsync(
'Get outta here. L2 factory bridge address ONLY.',
async () => {
await depositedERC20
.connect(badwallet)
.processDeposit('0x' + '00'.repeat(20), 5)
}
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can update '0x' + '00'.repeat(20) -> ZERO_ADDRESS

it('mints tokens and increases total supply', async () => {

const initialTotalSupply = (await depositedERC20.totalSupply()).toNumber()
const depositAmount = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define a DEFAULT_DEPOSIT_AMOUNT = 5 at the start of test file and you can just use that in all of your tests :)

MockL1ToL2MessagePasser = await ethers.getContractFactory(
'MockL1ToL2MessagePasser'
)
ERC20 = await (await ethers.getContractFactory('ERC20')).connect(depositer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ERC20 = await (await ethers.getContractFactory('ERC20')).connect(depositer)
ERC20 = await ethers.getContractFactory('ERC20').connect(depositer)

describe('setCorrespondingL2BridgeAddress()', async () => {
it('Sets address correctly, and throws if address has already been set', async () => {
await l1ERC20Bridge.setCorrespondingL2BridgeAddress(l2ERC20Bridge.address)
const l2BridgeAddress = await l1ERC20Bridge.l2ERC20BridgeAddress()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need another check that this was actually set to l2ERC20Bridge.address

_amount
);
// Tell L2 to mint corresponding coins
MockL1ToL2MessagePasser(l1ToL2MessagePasser).passMessageToL2(messageData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send to L1ToL2Transaction queue with
{calldata: messageData,
to: L2ERC20Bridge
gasLimit..
etc
}

@K-Ho
Copy link
Contributor

K-Ho commented Sep 18, 2020

Closing for now, can always re-open if needed

@K-Ho K-Ho closed this Sep 18, 2020
@gakonst gakonst deleted the YAS-404/DepositWithdrawalContracts branch March 18, 2021 15:02
snario pushed a commit that referenced this pull request Apr 14, 2021
* Bump version to 0.1.5

* Update changelog
bap2pecs pushed a commit to babylonlabs-io/optimism that referenced this pull request Jul 31, 2024
OptimismBot pushed a commit that referenced this pull request Jan 28, 2025
xibao-nr pushed a commit to node-real/combo-optimism that referenced this pull request Feb 19, 2025
Zena-park added a commit to tokamak-network/optimism that referenced this pull request Dec 30, 2025
theochap pushed a commit that referenced this pull request Jan 15, 2026
### Description

Removes the publishing of basic docs to gh-pages. There's now a nice
mdbook that's published by the books.yml workflow.
emhane pushed a commit that referenced this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants