-
Notifications
You must be signed in to change notification settings - Fork 14
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
Chore/improve eth contracts #69
Open
fcavazzoli
wants to merge
15
commits into
master
Choose a base branch
from
chore/improve_eth_contracts
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4981aa2
gas optimizations on terabethia contract
b0xtch c500fb3
eth_proxy: upgrade library
e8742aa
eth_proxy: remove unnecessary validation
0326320
eth_proxy: add owner and send method
9f7a808
eth_proxy: add pausable
4ecef9d
wiperc20
5acb284
erc20_bridge: refactor tests
3f92498
erc20_bridge: add Ownable
e827fbf
erc20_proxy: add send method
d2054b5
erc20_proxy: add pausable
3618354
add openzeppelin to gitignore
9a77dc6
erc20_proxy: add blacklist and whitelist to control supported tokens
f802fa7
erc20_bridge: specify pragma version and emit event on init
59529d0
eth_bridge: specify pragma version and emit event on init
6266963
remove send function implementation from proxies
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
pragma solidity ^0.8.0; | ||
pragma solidity 0.8.17; | ||
|
||
import "./ITerabethiaCore.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "@openzeppelin/contracts/security/Pausable.sol"; | ||
|
||
contract EthProxy { | ||
contract EthProxy is Ownable, Pausable { | ||
// Terabethia core contract. | ||
ITerabethiaCore terabethiaCore; | ||
|
||
// L2 Canister address | ||
uint256 constant CANISTER_ADDRESS = 0x00000000003001090101; | ||
|
||
// Init event | ||
event InitLog(address indexed terabethia_core); | ||
|
||
/** | ||
Initializes the contract state. | ||
*/ | ||
constructor(ITerabethiaCore terabethiaCore_) { | ||
terabethiaCore = terabethiaCore_; | ||
|
||
// emit init event | ||
emit InitLog(address(terabethiaCore)); | ||
} | ||
|
||
function withdraw(uint256 amount) external { | ||
function withdraw(uint256 amount) external whenNotPaused { | ||
// Construct the withdrawal message's payload. | ||
uint256[] memory payload = new uint256[](2); | ||
payload[0] = uint256(uint160(msg.sender)); | ||
|
@@ -27,19 +35,14 @@ contract EthProxy { | |
terabethiaCore.consumeMessage(CANISTER_ADDRESS, payload); | ||
|
||
// withdraw eth | ||
require( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason this condition was removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, cause it is useless, its gonna fail anyways |
||
address(this).balance >= amount, | ||
"Address: insufficient balance" | ||
); | ||
|
||
(bool success, ) = payable(msg.sender).call{value: amount}(""); | ||
require( | ||
success, | ||
"Address: unable to send value, recipient may have reverted" | ||
); | ||
} | ||
|
||
function deposit(uint256 user) external payable { | ||
function deposit(uint256 user) external payable whenNotPaused { | ||
require(msg.value >= 1 gwei, "DepositContract: deposit value too low"); | ||
require( | ||
msg.value % 1 gwei == 0, | ||
|
@@ -61,4 +64,12 @@ contract EthProxy { | |
// Send the message to the IC | ||
terabethiaCore.sendMessage(CANISTER_ADDRESS, payload); | ||
} | ||
|
||
function pause() public onlyOwner { | ||
_pause(); | ||
} | ||
|
||
function unpause() public onlyOwner { | ||
_unpause(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a PR open for this change already #27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Its the fist commit of this branch I used it as base