Added min/max limits for exchange transactions in bridge

This commit is contained in:
Kirill Fedoseev 2019-10-09 17:26:55 +03:00
parent d092475ee5
commit fcfdce153c
4 changed files with 17 additions and 4 deletions

View File

@ -10,3 +10,6 @@ VALIDATOR_ADDRESS_3=0x6352e3e6038e05b9da00c84ae851308f9774f883
#VALIDATOR_ADDRESS_4=0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa
THRESHOLD=1
MIN_TX_LIMIT=10000000000000000
MAX_TX_LIMIT=100000000000000000000

View File

@ -11,3 +11,6 @@ VALIDATOR_ADDRESS_3=0xcccc27ae510b63E30eC3C68AAD7DdD2578bD62ed
#VALIDATOR_ADDRESS_4=0xdddd9300e32fe162bA420f7313651Fd901C2ed71
THRESHOLD=1
MIN_TX_LIMIT=10000000000000000
MAX_TX_LIMIT=100000000000000000000

View File

@ -47,7 +47,10 @@ contract Bridge {
uint public epoch;
uint public nextEpoch;
constructor(uint threshold, address[] memory validators, address _tokenContract) public {
uint minTxLimit;
uint maxTxLimit;
constructor(uint threshold, address[] memory validators, address _tokenContract, uint[2] memory limits) public {
require(validators.length > 0);
require(threshold < validators.length);
@ -59,6 +62,9 @@ contract Bridge {
states[1] = State(validators, threshold, 0, 0);
minTxLimit = limits[0];
maxTxLimit = limits[1];
emit NewEpoch(0, 1);
}
@ -95,7 +101,7 @@ contract Bridge {
}
function exchange(uint value) public ready {
require(value >= 10 ** 10);
require(value >= minTxLimit && value >= 10 ** 10 && value <= maxTxLimit);
tokenContract.transferFrom(msg.sender, address(this), value);
emit ExchangeRequest(value);

View File

@ -5,7 +5,7 @@ const addresses = Object.entries(process.env)
.map(([ , value ]) => value)
const {
THRESHOLD, HOME_TOKEN_ADDRESS
THRESHOLD, HOME_TOKEN_ADDRESS, MIN_TX_LIMIT, MAX_TX_LIMIT
} = process.env
module.exports = deployer => {
@ -13,6 +13,7 @@ module.exports = deployer => {
Bridge,
THRESHOLD,
addresses,
HOME_TOKEN_ADDRESS
HOME_TOKEN_ADDRESS,
[ MIN_TX_LIMIT, MAX_TX_LIMIT ]
)
}