Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/components/gateway/WithdrawForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
</div>
<div>
<h6>{{ $t('components.gateway.withdraw_form_modal.balance') }} {{ balance | tokenAmount(tokenInfo.decimals)}} {{ token }}</h6>
<h6 v-if="isWithdrawalLimitEnabled && isCheckDailyRemainingWithdrawAmount()">
<h6 v-if="reachedLimit">
{{ $t('components.gateway.withdraw_form_modal.daily_withdrawal_limit_reached') }}
{{ maxPerAccountDailyWithdrawalAmount | tokenAmount(tokenInfo.decimals) }} {{ token }}
</h6>
<h6 v-if="isWithdrawalLimitEnabled && isCheckDailyRemainingWithdrawAmount() && !reachedLimit">
{{ $t('components.gateway.withdraw_form_modal.daily_remaining_withdraw_amount') }}
{{ dailyRemainingWithdrawAmount | tokenAmount(tokenInfo.decimals) }} {{ token }}
{{ dailyRemainingWithdrawAmount | tokenAmount(tokenInfo.decimals) }} /
{{ maxPerAccountDailyWithdrawalAmount | tokenAmount(tokenInfo.decimals) }} {{ token }}
</h6>
<amount-input
:min="min"
Expand Down Expand Up @@ -64,7 +69,7 @@
class="ml-2"
@click="requestWithdrawal"
variant="primary"
:disabled="validInput === false || max <= 0"
:disabled="validInput === false || max <= 0 || reachedLimit"
>{{ $t('components.gateway.withdraw_form_modal.withdraw') }}</b-btn>
</template>
</b-modal>
Expand Down Expand Up @@ -104,6 +109,7 @@ export default class WithdrawForm extends Vue {
isValidAddress: boolean = false
recepient = ""
dailyRemainingWithdrawAmount: BN = ZERO
maxPerAccountDailyWithdrawalAmount: BN = ZERO

tokenInfo: TokenData | null = null

Expand Down Expand Up @@ -173,6 +179,10 @@ export default class WithdrawForm extends Vue {
this.visible = false
}

get reachedLimit() {
return this.isWithdrawalLimitEnabled && this.dailyRemainingWithdrawAmount.lte(new BN(0))
}

setAmountIsError(isError: boolean) {
this.amountIsValid = !isError
}
Expand Down Expand Up @@ -211,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
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -884,6 +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_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.",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -829,6 +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_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.",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -829,6 +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_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.",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "출금"
}
Expand Down Expand Up @@ -829,6 +830,8 @@
"could_not_deposit_eth": "ETH를 입금할 수 없습니다. 트랜잭션 처리에 충분한 가스 수수료를 지불했는지 확인하세요.",
"deposit_approval_failed": "입금 승인 실패",
"withdraw_failed": "출금에 실패하였습니다. 다시 시도하거나 고객센터에 문의하세요.",
"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": "잔액이 충분하지 않습니다. 먼저 자금을 입금하세요.",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -829,6 +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_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.",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "提取"
}
Expand Down Expand Up @@ -829,6 +830,8 @@
"could_not_deposit_eth": "不能存入 ETH,请确认为此事务支付足够的 gas 费。",
"deposit_approval_failed": "存入批准失败。",
"withdraw_failed": "提取出错,请重试或联系客服。",
"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": "你的余额不足。请先存入一些。",
Expand Down
8 changes: 7 additions & 1 deletion src/store/gateway/plasma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@ 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("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())
}
Sentry.withScope((scope) => {
scope.setExtra("plasmaWithdraw", {
withdraw: JSON.stringify({
Expand Down