From 1772d254939cae5dfb095c098fcdc85517115137 Mon Sep 17 00:00:00 2001 From: mimi Date: Wed, 16 Jun 2021 14:31:17 +0700 Subject: [PATCH 1/6] check if withdrawal reached the daily limit --- src/components/gateway/WithdrawForm.vue | 15 ++++++++++++--- src/locales/en.json | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/gateway/WithdrawForm.vue b/src/components/gateway/WithdrawForm.vue index 54fedbb8..feecbd41 100644 --- a/src/components/gateway/WithdrawForm.vue +++ b/src/components/gateway/WithdrawForm.vue @@ -33,9 +33,14 @@
{{ $t('components.gateway.withdraw_form_modal.balance') }} {{ balance | tokenAmount(tokenInfo.decimals)}} {{ token }}
-
+
+ {{ $t('components.gateway.withdraw_form_modal.daily_withdrawal_limit_reached') }} + {{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }} +
+
{{ $t('components.gateway.withdraw_form_modal.daily_remaining_withdraw_amount') }} - {{ dailyRemainingWithdrawAmount | tokenAmount(tokenInfo.decimals) }} {{ token }} + {{ dailyRemainingWithdrawAmount | tokenAmount(tokenInfo.decimals) }} / + {{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }}
{{ $t('components.gateway.withdraw_form_modal.withdraw') }} @@ -173,6 +178,10 @@ export default class WithdrawForm extends Vue { this.visible = false } + reachedLimit() { + return this.isWithdrawalLimitEnabled && this.dailyRemainingWithdrawAmount.lte(new BN(0)) + } + setAmountIsError(isError: boolean) { this.amountIsValid = !isError } diff --git a/src/locales/en.json b/src/locales/en.json index 2c9c74c6..33281b13 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -578,6 +578,7 @@ "transfer_fee": "Transfer to {chain} requires a fee of ", "balance": "Your balance : ", "daily_remaining_withdraw_amount": "Daily remaining withdraw amount: ", + "daily_withdrawal_limit_reached": "Daily withdrawal limit reached", "recipient": "Recipient on {chain}", "withdraw": "Withdraw" } From cb0b4b5a8bb349188aa9a73512959ea99e09161b Mon Sep 17 00:00:00 2001 From: mimi Date: Wed, 16 Jun 2021 14:32:05 +0700 Subject: [PATCH 2/6] add translation keys --- src/locales/es.json | 1 + src/locales/ja.json | 1 + src/locales/ko.json | 1 + src/locales/th.json | 1 + src/locales/zh.json | 1 + 5 files changed, 5 insertions(+) diff --git a/src/locales/es.json b/src/locales/es.json index 99a202a0..8aec674e 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -523,6 +523,7 @@ "transfer_fee": "Transfer to {chain} requires a fee of ", "balance": "Your balance : ", "daily_remaining_withdraw_amount": "Daily remaining withdraw amount: ", + "daily_withdrawal_limit_reached": "Daily withdrawal limit reached", "recipient": "Recipient on {chain}", "withdraw": "Withdraw" } diff --git a/src/locales/ja.json b/src/locales/ja.json index 4315ea12..d7099c5e 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -523,6 +523,7 @@ "transfer_fee": "Transfer to {chain} requires a fee of ", "balance": "Your balance : ", "daily_remaining_withdraw_amount": "Daily remaining withdraw amount: ", + "daily_withdrawal_limit_reached": "Daily withdrawal limit reached", "recipient": "Recipient on {chain}", "withdraw": "Withdraw" } diff --git a/src/locales/ko.json b/src/locales/ko.json index 9d16e703..9a4172aa 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -523,6 +523,7 @@ "transfer_fee": "{chain}으로 전송하려면 수수료가 필요합니다.", "balance": "당신의 잔액 : ", "daily_remaining_withdraw_amount": "Daily remaining withdraw amount: ", + "daily_withdrawal_limit_reached": "Daily withdrawal limit reached", "recipient": "{chain} 상의 수신자", "withdraw": "출금" } diff --git a/src/locales/th.json b/src/locales/th.json index dc626136..0eb33d63 100644 --- a/src/locales/th.json +++ b/src/locales/th.json @@ -523,6 +523,7 @@ "transfer_fee": "Transfer to {chain} requires a fee of ", "balance": "Your balance : ", "daily_remaining_withdraw_amount": "Daily remaining withdraw amount: ", + "daily_withdrawal_limit_reached": "Daily withdrawal limit reached", "recipient": "Recipient on {chain}", "withdraw": "Withdraw" } diff --git a/src/locales/zh.json b/src/locales/zh.json index f2ba552c..e0a18a41 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -523,6 +523,7 @@ "transfer_fee": "转移到 {chain} 需要手续费 ", "balance": "你的余额: ", "daily_remaining_withdraw_amount": "Daily remaining withdraw amount: ", + "daily_withdrawal_limit_reached": "Daily withdrawal limit reached", "recipient": "{chain} 上的接受者", "withdraw": "提取" } From 5c4bb939c7aff1daaccea0b067dbf80981af2423 Mon Sep 17 00:00:00 2001 From: mimi Date: Wed, 16 Jun 2021 14:51:33 +0700 Subject: [PATCH 3/6] custom error for daily withdrawal limit reached --- src/locales/en.json | 1 + src/locales/es.json | 1 + src/locales/ja.json | 1 + src/locales/ko.json | 1 + src/locales/th.json | 1 + src/locales/zh.json | 1 + src/store/gateway/plasma.ts | 6 +++++- 7 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index 33281b13..c1dbf83c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -885,6 +885,7 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", + "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/es.json b/src/locales/es.json index 8aec674e..87542fb0 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -830,6 +830,7 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", + "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/ja.json b/src/locales/ja.json index d7099c5e..b9ccb192 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -830,6 +830,7 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", + "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/ko.json b/src/locales/ko.json index 9a4172aa..26a7ebc4 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -830,6 +830,7 @@ "could_not_deposit_eth": "ETH를 입금할 수 없습니다. 트랜잭션 처리에 충분한 가스 수수료를 지불했는지 확인하세요.", "deposit_approval_failed": "입금 승인 실패", "withdraw_failed": "출금에 실패하였습니다. 다시 시도하거나 고객센터에 문의하세요.", + "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "제공된 키가 이미 매핑되었습니다.", "unexpected_error_while_add_account": "계정 매핑을 추가하던 중 예상치 못한 오류가 발생했습니다.", "balance_not_enough": "잔액이 충분하지 않습니다. 먼저 자금을 입금하세요.", diff --git a/src/locales/th.json b/src/locales/th.json index 0eb33d63..ab69b954 100644 --- a/src/locales/th.json +++ b/src/locales/th.json @@ -830,6 +830,7 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", + "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/zh.json b/src/locales/zh.json index e0a18a41..e0535c44 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -830,6 +830,7 @@ "could_not_deposit_eth": "不能存入 ETH,请确认为此事务支付足够的 gas 费。", "deposit_approval_failed": "存入批准失败。", "withdraw_failed": "提取出错,请重试或联系客服。", + "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "提供的密钥已映射。", "unexpected_error_while_add_account": "添加账户映射时出现意外错误。", "balance_not_enough": "你的余额不足。请先存入一些。", diff --git a/src/store/gateway/plasma.ts b/src/store/gateway/plasma.ts index 2b23debc..4d2c65b0 100644 --- a/src/store/gateway/plasma.ts +++ b/src/store/gateway/plasma.ts @@ -334,7 +334,11 @@ export async function plasmaWithdraw(context: ActionContext, funds: Funds) { return } feedback.endTask() - feedback.showError(i18n.t("feedback_msg.error.withdraw_failed").toString()) + if (error.message.includes("limit reached")) { + feedback.showError(i18n.t("feedback_msg.error.withdraw_failed_limit_reached").toString()) + } else { + feedback.showError(i18n.t("feedback_msg.error.withdraw_failed").toString()) + } Sentry.withScope((scope) => { scope.setExtra("plasmaWithdraw", { withdraw: JSON.stringify({ From 4ceee0e27e180cbab5c9f0dea8ed5f0505dd4ab8 Mon Sep 17 00:00:00 2001 From: mimi Date: Fri, 18 Jun 2021 11:35:03 +0700 Subject: [PATCH 4/6] using maxPerAccountDailyWithdrawalAmount insteads --- src/components/gateway/WithdrawForm.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/gateway/WithdrawForm.vue b/src/components/gateway/WithdrawForm.vue index feecbd41..dcf2bdd6 100644 --- a/src/components/gateway/WithdrawForm.vue +++ b/src/components/gateway/WithdrawForm.vue @@ -33,14 +33,14 @@
{{ $t('components.gateway.withdraw_form_modal.balance') }} {{ balance | tokenAmount(tokenInfo.decimals)}} {{ token }}
-
+
{{ $t('components.gateway.withdraw_form_modal.daily_withdrawal_limit_reached') }} {{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }}
-
+
{{ $t('components.gateway.withdraw_form_modal.daily_remaining_withdraw_amount') }} {{ dailyRemainingWithdrawAmount | tokenAmount(tokenInfo.decimals) }} / - {{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }} + {{ maxPerAccountDailyWithdrawalAmount | tokenAmount(tokenInfo.decimals) }} {{ token }}
{{ $t('components.gateway.withdraw_form_modal.withdraw') }} @@ -109,6 +109,7 @@ export default class WithdrawForm extends Vue { isValidAddress: boolean = false recepient = "" dailyRemainingWithdrawAmount: BN = ZERO + maxPerAccountDailyWithdrawalAmount: BN = ZERO tokenInfo: TokenData | null = null @@ -178,7 +179,7 @@ export default class WithdrawForm extends Vue { this.visible = false } - reachedLimit() { + get reachedLimit() { return this.isWithdrawalLimitEnabled && this.dailyRemainingWithdrawAmount.lte(new BN(0)) } @@ -220,10 +221,9 @@ export default class WithdrawForm extends Vue { if (lastWithdrawalLimitResetDate.toDateString() !== todayDate.toDateString()) { totalWithdrawalAmount = new BN(0) } - const gatewayState = await gateway.getGatewayState() - const maxPerAccountDailyWithdrawalAmount: BN = gatewayState!.maxPerAccountDailyWithdrawalAmount - const remainingWithdrawAmount = maxPerAccountDailyWithdrawalAmount.sub(totalWithdrawalAmount) + this.maxPerAccountDailyWithdrawalAmount = gatewayState!.maxPerAccountDailyWithdrawalAmount + const remainingWithdrawAmount = this.maxPerAccountDailyWithdrawalAmount.sub(totalWithdrawalAmount) console.log("remainingWithdrawAmount: ", remainingWithdrawAmount.toString()) return remainingWithdrawAmount From 7317acf5a5deb6df9c93f70205cf8a7ee312f131 Mon Sep 17 00:00:00 2001 From: mimi Date: Fri, 18 Jun 2021 11:44:01 +0700 Subject: [PATCH 5/6] using gateway error codes for catch error --- src/locales/en.json | 3 ++- src/locales/es.json | 3 ++- src/locales/ja.json | 3 ++- src/locales/ko.json | 3 ++- src/locales/th.json | 3 ++- src/locales/zh.json | 3 ++- src/store/gateway/plasma.ts | 6 ++++-- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index c1dbf83c..7a53467b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -885,7 +885,8 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", - "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_total_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_account_limit_reached": "Account daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/es.json b/src/locales/es.json index 87542fb0..2920a57e 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -830,7 +830,8 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", - "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_total_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_account_limit_reached": "Account daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/ja.json b/src/locales/ja.json index b9ccb192..6526f30c 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -830,7 +830,8 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", - "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_total_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_account_limit_reached": "Account daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/ko.json b/src/locales/ko.json index 26a7ebc4..f605d40e 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -830,7 +830,8 @@ "could_not_deposit_eth": "ETH를 입금할 수 없습니다. 트랜잭션 처리에 충분한 가스 수수료를 지불했는지 확인하세요.", "deposit_approval_failed": "입금 승인 실패", "withdraw_failed": "출금에 실패하였습니다. 다시 시도하거나 고객센터에 문의하세요.", - "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_total_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_account_limit_reached": "Account daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "제공된 키가 이미 매핑되었습니다.", "unexpected_error_while_add_account": "계정 매핑을 추가하던 중 예상치 못한 오류가 발생했습니다.", "balance_not_enough": "잔액이 충분하지 않습니다. 먼저 자금을 입금하세요.", diff --git a/src/locales/th.json b/src/locales/th.json index ab69b954..95e5da47 100644 --- a/src/locales/th.json +++ b/src/locales/th.json @@ -830,7 +830,8 @@ "could_not_deposit_eth": "Could not deposit ETH, please make sure you pay enough gas for the transaction.", "deposit_approval_failed": "Deposit approval failed.", "withdraw_failed": "Withdraw failed, please try again or contact support.", - "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_total_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_account_limit_reached": "Account daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "The supplied key is already mapped.", "unexpected_error_while_add_account": "Unexpected error while adding account mapping.", "balance_not_enough": "Your balance isn't enough. Please deposit first.", diff --git a/src/locales/zh.json b/src/locales/zh.json index e0535c44..29fe82ae 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -830,7 +830,8 @@ "could_not_deposit_eth": "不能存入 ETH,请确认为此事务支付足够的 gas 费。", "deposit_approval_failed": "存入批准失败。", "withdraw_failed": "提取出错,请重试或联系客服。", - "withdraw_failed_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_total_limit_reached": "Total daily withdrawal limit has been reached, please try again tomorrow.", + "withdraw_failed_account_limit_reached": "Account daily withdrawal limit has been reached, please try again tomorrow.", "supplied_key_already_mapped": "提供的密钥已映射。", "unexpected_error_while_add_account": "添加账户映射时出现意外错误。", "balance_not_enough": "你的余额不足。请先存入一些。", diff --git a/src/store/gateway/plasma.ts b/src/store/gateway/plasma.ts index 4d2c65b0..257b46e4 100644 --- a/src/store/gateway/plasma.ts +++ b/src/store/gateway/plasma.ts @@ -334,8 +334,10 @@ export async function plasmaWithdraw(context: ActionContext, funds: Funds) { return } feedback.endTask() - if (error.message.includes("limit reached")) { - feedback.showError(i18n.t("feedback_msg.error.withdraw_failed_limit_reached").toString()) + if (error.message.includes("TG024")) { + feedback.showError(i18n.t("feedback_msg.error.withdraw_failed_total_limit_reached").toString()) + } else if (error.message.includes("TG025")) { + feedback.showError(i18n.t("feedback_msg.error.withdraw_failed_account_limit_reached").toString()) } else { feedback.showError(i18n.t("feedback_msg.error.withdraw_failed").toString()) } From 4c81decd6d946d39f04fcb13f54692b1b3243f4e Mon Sep 17 00:00:00 2001 From: mimi Date: Fri, 18 Jun 2021 11:47:06 +0700 Subject: [PATCH 6/6] maxPerAccountDailyWithdrawalAmount instead of isWithdrawalLimitEnabled --- src/components/gateway/WithdrawForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/gateway/WithdrawForm.vue b/src/components/gateway/WithdrawForm.vue index dcf2bdd6..941acd2f 100644 --- a/src/components/gateway/WithdrawForm.vue +++ b/src/components/gateway/WithdrawForm.vue @@ -35,7 +35,7 @@
{{ $t('components.gateway.withdraw_form_modal.balance') }} {{ balance | tokenAmount(tokenInfo.decimals)}} {{ token }}
{{ $t('components.gateway.withdraw_form_modal.daily_withdrawal_limit_reached') }} - {{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }} + {{ maxPerAccountDailyWithdrawalAmount | tokenAmount(tokenInfo.decimals) }} {{ token }}
{{ $t('components.gateway.withdraw_form_modal.daily_remaining_withdraw_amount') }}