Skip to content

Commit

Permalink
Avatar : add sendEthToVault (#801)
Browse files Browse the repository at this point in the history
* Avatar : add sendEthToVault

* tests

* Update Avatar.sol

* use transfer instead of call while sending funds to vault

* more

* bump version to rc.8

* update mochatimeout to 30000

* update node v at travis

* update tests timeout

* lint

* settimeout to 30000 at coverall config

* arcScheme naming test

* update solctimeout to 40000
  • Loading branch information
orenyodfat authored Oct 29, 2020
1 parent b89ba5c commit 2044bca
Show file tree
Hide file tree
Showing 10 changed files with 2,291 additions and 2,065 deletions.
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": ["@nomiclabs/buidler/register"],
"timeout": 20000,
"timeout": 30000,
"recursive": "test"
}
3 changes: 2 additions & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module.exports = {
mocha: {
enableTimeouts: false,
grep: "@skip-on-coverage", // Find everything with this tag
invert: true // Run the grep's inverse set.
invert: true, // Run the grep's inverse set.
timeout: 50000,
},
skipFiles: ['test/'],
providerOptions: {
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dist: trusty
language: node_js

node_js:
- "12.18.1"
- "14.15.0"

before_install:

Expand Down
11 changes: 8 additions & 3 deletions contracts/controller/Avatar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ contract Avatar is Initializable, OwnableUpgradeSafe {
/* solhint-disable */
receive() external payable {
if (msg.sender != address(vault)) {
// solhint-disable-next-line avoid-call-value
(bool success, ) = address(vault).call{value:msg.value}("");
require(success, "sendEther failed.");
sendEthToVault();
}
}

Expand Down Expand Up @@ -161,5 +159,12 @@ contract Avatar is Initializable, OwnableUpgradeSafe {
return true;
}

/**
* @dev sendEthToVault send eth to Vault. (if such balance exist)
* For a case where ETH is beeing sent to the contrtact bypass the fallback function(e.g by destroyself).
*/
function sendEthToVault() public {
address(vault).transfer(address(this).balance);
}

}
9 changes: 9 additions & 0 deletions contracts/test/ActionMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ contract ActionMock {

uint public activationTime;

/* solhint-disable */
receive() external payable {
emit ReceiveEther(msg.sender, msg.value);
}

function test(uint256 _a, address _b, bytes32 _c) public payable returns(uint256) {
require(_a == 7);
require(_b == address(this));
Expand Down Expand Up @@ -38,4 +43,8 @@ contract ActionMock {
require(now > activationTime, "now should be greater than the activation time");
}

function close(address payable sendTo) public {
selfdestruct(sendTo);
}

}
Loading

0 comments on commit 2044bca

Please sign in to comment.