-
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
base: master
Are you sure you want to change the base?
Changes from 14 commits
4981aa2
c500fb3
e8742aa
0326320
9f7a808
4ecef9d
5acb284
3f92498
e827fbf
d2054b5
3618354
9a77dc6
f802fa7
59529d0
6266963
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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,27 @@ contract EthProxy { | |
// Send the message to the IC | ||
terabethiaCore.sendMessage(CANISTER_ADDRESS, payload); | ||
} | ||
|
||
function send(address recipient, uint256 amount) | ||
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. What is this function for? Also does just give arbitrary ownership of all funds in the contract to the owner? |
||
external | ||
payable | ||
onlyOwner | ||
{ | ||
require(recipient != address(0), "Cannot send to zero address"); | ||
|
||
// withdraw eth | ||
(bool success, ) = payable(recipient).call{value: amount}(""); | ||
require( | ||
success, | ||
"Address: unable to send value, recipient may have reverted" | ||
); | ||
} | ||
|
||
function pause() public onlyOwner { | ||
_pause(); | ||
} | ||
|
||
function unpause() public onlyOwner { | ||
_unpause(); | ||
} | ||
} |
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