-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from poanetwork/develop
Merge the changes related to security updates to the master branch
- Loading branch information
Showing
33 changed files
with
1,315 additions
and
349 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity 0.4.24; | ||
|
||
|
||
interface IOwnedUpgradeabilityProxy { | ||
function proxyOwner() public view returns (address); | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../upgradeability/EternalStorage.sol"; | ||
import "../libraries/SafeMath.sol"; | ||
import "./OwnedUpgradeability.sol"; | ||
|
||
|
||
contract OverdrawManagement is EternalStorage, OwnedUpgradeability { | ||
using SafeMath for uint256; | ||
|
||
event UserRequestForSignature(address recipient, uint256 value); | ||
|
||
function fixAssetsAboveLimits(bytes32 txHash, bool unlockOnForeign) external onlyIfOwnerOfProxy { | ||
require(!fixedAssets(txHash)); | ||
address recipient; | ||
uint256 value; | ||
(recipient, value) = txAboveLimits(txHash); | ||
require(recipient != address(0) && value > 0); | ||
setOutOfLimitAmount(outOfLimitAmount().sub(value)); | ||
if (unlockOnForeign) { | ||
emit UserRequestForSignature(recipient, value); | ||
} | ||
setFixedAssets(txHash, true); | ||
} | ||
|
||
function outOfLimitAmount() public view returns(uint256) { | ||
return uintStorage[keccak256(abi.encodePacked("outOfLimitAmount"))]; | ||
} | ||
|
||
function fixedAssets(bytes32 _txHash) public view returns(bool) { | ||
return boolStorage[keccak256(abi.encodePacked("fixedAssets", _txHash))]; | ||
} | ||
|
||
function setOutOfLimitAmount(uint256 _value) internal { | ||
uintStorage[keccak256(abi.encodePacked("outOfLimitAmount"))] = _value; | ||
} | ||
|
||
function txAboveLimits(bytes32 _txHash) internal view returns(address recipient, uint256 value) { | ||
recipient = addressStorage[keccak256(abi.encodePacked("txOutOfLimitRecipient", _txHash))]; | ||
value = uintStorage[keccak256(abi.encodePacked("txOutOfLimitValue", _txHash))]; | ||
} | ||
|
||
function setTxAboveLimits(address _recipient, uint256 _value, bytes32 _txHash) internal { | ||
addressStorage[keccak256(abi.encodePacked("txOutOfLimitRecipient", _txHash))] = _recipient; | ||
uintStorage[keccak256(abi.encodePacked("txOutOfLimitValue", _txHash))] = _value; | ||
} | ||
|
||
function setFixedAssets(bytes32 _txHash, bool _status) internal { | ||
boolStorage[keccak256(abi.encodePacked("fixedAssets", _txHash))] = _status; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pragma solidity 0.4.24; | ||
|
||
import "../IOwnedUpgradeabilityProxy.sol"; | ||
|
||
|
||
contract OwnedUpgradeability { | ||
|
||
function upgradeabilityAdmin() public view returns (address) { | ||
return IOwnedUpgradeabilityProxy(this).proxyOwner(); | ||
} | ||
|
||
// Avoid using onlyProxyOwner name to prevent issues with implementation from proxy contract | ||
modifier onlyIfOwnerOfProxy() { | ||
require(msg.sender == upgradeabilityAdmin()); | ||
_; | ||
} | ||
} |
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
Oops, something went wrong.