2020-10-28 14:20:50 +03:00
|
|
|
const { fromWei } = require('web3').utils
|
2019-05-06 13:12:53 +02:00
|
|
|
|
|
|
|
async function getMinPerTxLimit(bridge) {
|
|
|
|
const minPerTx = await bridge.methods.minPerTx().call()
|
2020-10-28 14:20:50 +03:00
|
|
|
return fromWei(minPerTx)
|
2019-05-06 13:12:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function isValidAmount(amount, bridge) {
|
|
|
|
const minLimit = await getMinPerTxLimit(bridge)
|
|
|
|
if (amount < minLimit) {
|
|
|
|
throw new Error(`The amount per Tx ${amount} should be at least ${minLimit}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getMinPerTxLimit,
|
|
|
|
isValidAmount
|
|
|
|
}
|