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

Simplify IntermediaryOriginalToken #285

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
26 changes: 13 additions & 13 deletions contracts/pegged-bridge/tokens/IntermediaryOriginalToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ contract IntermediaryOriginalToken is ERC20, Ownable {

event BridgeUpdated(address bridge, bool enable);

modifier onlyBridge() {
require(bridges[msg.sender], "caller is not bridge");
_;
}

constructor(
string memory name_,
string memory symbol_,
Expand All @@ -30,25 +35,20 @@ contract IntermediaryOriginalToken is ERC20, Ownable {
canonical = canonical_;
}

function transfer(address _to, uint256 _amount) public virtual override returns (bool) {
bool success = super.transfer(_to, _amount);
if (bridges[msg.sender]) {
_burn(_to, _amount);
IERC20(canonical).safeTransfer(_to, _amount);
}
return success;
function transfer(address _to, uint256 _amount) public virtual override onlyBridge returns (bool) {
_burn(msg.sender, _amount);
IERC20(canonical).safeTransfer(_to, _amount);
return true;
}

function transferFrom(
address _from,
address _to,
uint256 _amount
) public virtual override returns (bool) {
if (bridges[msg.sender]) {
_mint(_from, _amount);
IERC20(canonical).safeTransferFrom(_from, address(this), _amount);
}
return super.transferFrom(_from, _to, _amount);
) public virtual override onlyBridge returns (bool) {
_mint(_to, _amount);
IERC20(canonical).safeTransferFrom(_from, address(this), _amount);
return true;
}

function updateBridge(address _bridge, bool _enable) external onlyOwner {
Expand Down
Loading