return refund to a relayer in case of failure

This commit is contained in:
Alexey 2019-11-15 10:59:06 +03:00
parent a6519fb280
commit ce550eea58
3 changed files with 96 additions and 2 deletions

View file

@ -38,8 +38,13 @@ contract ERC20Mixer is Mixer {
if (_fee > 0) {
_safeErc20Transfer(_relayer, _fee);
}
if (_refund > 0) {
_recipient.call.value(_refund)("");
(bool success, ) = _recipient.call.value(_refund)("");
if (!success) {
// let's return _refund back to the relayer
_relayer.transfer(_refund);
}
}
}

View file

@ -0,0 +1,7 @@
pragma solidity ^0.5.0;
contract BadRecipient {
function() external {
require(false, "this contract does not accept ETH");
}
}