@@ -2,42 +2,63 @@ pragma solidity 0.4.24;
2
2
3
3
import "../upgradeability/EternalStorage.sol " ;
4
4
5
+ /**
6
+ * @title BaseOverdrawManagement
7
+ * @dev This contract implements basic functionality for tracking execution bridge operations that are out of limits.
8
+ */
5
9
contract BaseOverdrawManagement is EternalStorage {
6
- event AmountLimitExceeded (address recipient , uint256 value , bytes32 transactionHash );
7
- event AssetAboveLimitsFixed (bytes32 indexed transactionHash , uint256 value , uint256 remaining );
10
+ event MediatorAmountLimitExceeded (address recipient , uint256 value , bytes32 indexed messageId );
11
+ event AmountLimitExceeded (address recipient , uint256 value , bytes32 indexed transactionHash , bytes32 messageId );
12
+ event AssetAboveLimitsFixed (bytes32 indexed messageId , uint256 value , uint256 remaining );
8
13
9
14
bytes32 internal constant OUT_OF_LIMIT_AMOUNT = 0x145286dc85799b6fb9fe322391ba2d95683077b2adf34dd576dedc437e537ba7 ; // keccak256(abi.encodePacked("outOfLimitAmount"))
10
15
16
+ /**
17
+ * @dev Total amount coins/tokens that were bridged from the other side and are out of execution limits.
18
+ * @return total amount of all bridge operations above limits.
19
+ */
11
20
function outOfLimitAmount () public view returns (uint256 ) {
12
21
return uintStorage[OUT_OF_LIMIT_AMOUNT];
13
22
}
14
23
15
- function fixedAssets ( bytes32 _txHash ) public view returns ( bool ) {
16
- return boolStorage[ keccak256 ( abi.encodePacked ( " fixedAssets " , _txHash))];
17
- }
18
-
24
+ /**
25
+ * @dev Internal function for updating a total amount that is out of execution limits.
26
+ * @param _value new value for the total amount of bridge operations above limits.
27
+ */
19
28
function setOutOfLimitAmount (uint256 _value ) internal {
20
29
uintStorage[OUT_OF_LIMIT_AMOUNT] = _value;
21
30
}
22
31
23
- function txAboveLimits ( bytes32 _txHash ) internal view returns ( address recipient , uint256 value ) {
24
- recipient = addressStorage[ keccak256 ( abi.encodePacked ( " txOutOfLimitRecipient " , _txHash))];
25
- value = uintStorage[ keccak256 ( abi.encodePacked ( " txOutOfLimitValue " , _txHash))];
26
- }
27
-
28
- function setTxAboveLimits ( address _recipient , uint256 _value , bytes32 _txHash ) internal {
29
- addressStorage[keccak256 (abi.encodePacked ("txOutOfLimitRecipient " , _txHash ))] = _recipient ;
30
- setTxAboveLimitsValue (_value, _txHash) ;
32
+ /**
33
+ * @dev Internal function for retrieving information about out-of-limits bridge operation.
34
+ * @param _messageId id of the message that cause above-limits error.
35
+ * @return (address of the receiver, amount of coins/tokens in the bridge operation)
36
+ */
37
+ function txAboveLimits ( bytes32 _messageId ) internal view returns ( address recipient , uint256 value ) {
38
+ recipient = addressStorage[keccak256 (abi.encodePacked ("txOutOfLimitRecipient " , _messageId ))];
39
+ value = uintStorage[ keccak256 ( abi.encodePacked ( " txOutOfLimitValue " , _messageId))] ;
31
40
}
32
41
33
- function setTxAboveLimitsValue (uint256 _value , bytes32 _txHash ) internal {
34
- uintStorage[keccak256 (abi.encodePacked ("txOutOfLimitValue " , _txHash))] = _value;
42
+ /**
43
+ * @dev Internal function for updating information about tbe out-of-limits bridge operation.
44
+ * @param _recipient receiver specified in the bridge operation.
45
+ * @param _value amount of coins/tokens inside the bridge operation.
46
+ * @param _messageId id of the message that cause above-limits error.
47
+ */
48
+ function setTxAboveLimits (address _recipient , uint256 _value , bytes32 _messageId ) internal {
49
+ addressStorage[keccak256 (abi.encodePacked ("txOutOfLimitRecipient " , _messageId))] = _recipient;
50
+ setTxAboveLimitsValue (_value, _messageId);
35
51
}
36
52
37
- function setFixedAssets (bytes32 _txHash ) internal {
38
- boolStorage[keccak256 (abi.encodePacked ("fixedAssets " , _txHash))] = true ;
53
+ /**
54
+ * @dev Internal function for updating information about the remaining value of out-of-limits bridge operation.
55
+ * @param _value amount of coins/tokens inside the bridge operation.
56
+ * @param _messageId id of the message that cause above-limits error.
57
+ */
58
+ function setTxAboveLimitsValue (uint256 _value , bytes32 _messageId ) internal {
59
+ uintStorage[keccak256 (abi.encodePacked ("txOutOfLimitValue " , _messageId))] = _value;
39
60
}
40
61
41
62
/* solcov ignore next */
42
- function fixAssetsAboveLimits (bytes32 txHash , bool unlockOnForeign , uint256 valueToUnlock ) external ;
63
+ function fixAssetsAboveLimits (bytes32 messageId , bool unlockOnForeign , uint256 valueToUnlock ) external ;
43
64
}
0 commit comments