Added min/max limits for exchange transactions in bridge
This commit is contained in:
parent
d092475ee5
commit
fcfdce153c
|
@ -10,3 +10,6 @@ VALIDATOR_ADDRESS_3=0x6352e3e6038e05b9da00c84ae851308f9774f883
|
||||||
#VALIDATOR_ADDRESS_4=0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa
|
#VALIDATOR_ADDRESS_4=0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa
|
||||||
|
|
||||||
THRESHOLD=1
|
THRESHOLD=1
|
||||||
|
|
||||||
|
MIN_TX_LIMIT=10000000000000000
|
||||||
|
MAX_TX_LIMIT=100000000000000000000
|
||||||
|
|
|
@ -11,3 +11,6 @@ VALIDATOR_ADDRESS_3=0xcccc27ae510b63E30eC3C68AAD7DdD2578bD62ed
|
||||||
#VALIDATOR_ADDRESS_4=0xdddd9300e32fe162bA420f7313651Fd901C2ed71
|
#VALIDATOR_ADDRESS_4=0xdddd9300e32fe162bA420f7313651Fd901C2ed71
|
||||||
|
|
||||||
THRESHOLD=1
|
THRESHOLD=1
|
||||||
|
|
||||||
|
MIN_TX_LIMIT=10000000000000000
|
||||||
|
MAX_TX_LIMIT=100000000000000000000
|
||||||
|
|
|
@ -47,7 +47,10 @@ contract Bridge {
|
||||||
uint public epoch;
|
uint public epoch;
|
||||||
uint public nextEpoch;
|
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(validators.length > 0);
|
||||||
require(threshold < validators.length);
|
require(threshold < validators.length);
|
||||||
|
|
||||||
|
@ -59,6 +62,9 @@ contract Bridge {
|
||||||
|
|
||||||
states[1] = State(validators, threshold, 0, 0);
|
states[1] = State(validators, threshold, 0, 0);
|
||||||
|
|
||||||
|
minTxLimit = limits[0];
|
||||||
|
maxTxLimit = limits[1];
|
||||||
|
|
||||||
emit NewEpoch(0, 1);
|
emit NewEpoch(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +101,7 @@ contract Bridge {
|
||||||
}
|
}
|
||||||
|
|
||||||
function exchange(uint value) public ready {
|
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);
|
tokenContract.transferFrom(msg.sender, address(this), value);
|
||||||
emit ExchangeRequest(value);
|
emit ExchangeRequest(value);
|
||||||
|
|
|
@ -5,7 +5,7 @@ const addresses = Object.entries(process.env)
|
||||||
.map(([ , value ]) => value)
|
.map(([ , value ]) => value)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
THRESHOLD, HOME_TOKEN_ADDRESS
|
THRESHOLD, HOME_TOKEN_ADDRESS, MIN_TX_LIMIT, MAX_TX_LIMIT
|
||||||
} = process.env
|
} = process.env
|
||||||
|
|
||||||
module.exports = deployer => {
|
module.exports = deployer => {
|
||||||
|
@ -13,6 +13,7 @@ module.exports = deployer => {
|
||||||
Bridge,
|
Bridge,
|
||||||
THRESHOLD,
|
THRESHOLD,
|
||||||
addresses,
|
addresses,
|
||||||
HOME_TOKEN_ADDRESS
|
HOME_TOKEN_ADDRESS,
|
||||||
|
[ MIN_TX_LIMIT, MAX_TX_LIMIT ]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue