From 4cc87ef61a890f5469468e1f868789f8e75018fe Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Fri, 2 Oct 2020 19:07:40 +0300 Subject: [PATCH] Use totalExecutedPerDay instead of totalSpentPerDay for calculating quota (#460) --- ui/src/stores/ForeignStore.js | 2 +- ui/src/stores/HomeStore.js | 6 +++++- ui/src/stores/utils/contract.js | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/src/stores/ForeignStore.js b/ui/src/stores/ForeignStore.js index 58e9b407..f97ed7ca 100644 --- a/ui/src/stores/ForeignStore.js +++ b/ui/src/stores/ForeignStore.js @@ -325,7 +325,7 @@ class ForeignStore { @action async getCurrentLimit() { try { - const result = await getCurrentLimit(this.foreignBridge, this.tokenDecimals) + const result = await getCurrentLimit(this.foreignBridge, this.homeStore.homeBridge, this.tokenDecimals) this.maxCurrentDeposit = result.maxCurrentDeposit this.dailyLimit = result.dailyLimit this.totalSpentPerDay = result.totalSpentPerDay diff --git a/ui/src/stores/HomeStore.js b/ui/src/stores/HomeStore.js index 99265046..1dbc9d01 100644 --- a/ui/src/stores/HomeStore.js +++ b/ui/src/stores/HomeStore.js @@ -429,7 +429,11 @@ class HomeStore { @action async getCurrentLimit() { try { - const result = await getCurrentLimit(this.homeBridge, this.tokenDecimals) + const result = await getCurrentLimit( + this.homeBridge, + this.rootStore.foreignStore.foreignBridge, + this.tokenDecimals + ) this.maxCurrentDeposit = result.maxCurrentDeposit this.dailyLimit = result.dailyLimit this.totalSpentPerDay = result.totalSpentPerDay diff --git a/ui/src/stores/utils/contract.js b/ui/src/stores/utils/contract.js index 8756b764..1bccc7d2 100644 --- a/ui/src/stores/utils/contract.js +++ b/ui/src/stores/utils/contract.js @@ -21,10 +21,10 @@ export const getMinPerTxLimit = async (contract, decimals) => { return fromDecimals(minPerTx, decimals) } -export const getCurrentLimit = async (contract, decimals) => { +export const getCurrentLimit = async (contract, otherContract, decimals) => { const currentDay = await contract.methods.getCurrentDay().call() const dailyLimit = await contract.methods.dailyLimit().call() - const totalSpentPerDay = await contract.methods.totalSpentPerDay(currentDay).call() + const totalSpentPerDay = await otherContract.methods.totalExecutedPerDay(currentDay).call() const maxCurrentDeposit = new BN(dailyLimit).minus(new BN(totalSpentPerDay)).toString(10) return { maxCurrentDeposit: fromDecimals(maxCurrentDeposit, decimals),