From d37cf6fef08f0e9032fb990aade80a45eac2f594 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 4 Apr 2022 17:30:06 +0800 Subject: [PATCH] add error counter --- .../components/OperationModal/TransactionResult.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/views/components/OperationModal/TransactionResult.vue b/src/views/components/OperationModal/TransactionResult.vue index b3499815..303f52cf 100644 --- a/src/views/components/OperationModal/TransactionResult.vue +++ b/src/views/components/OperationModal/TransactionResult.vue @@ -106,6 +106,7 @@ export default { isLoading: true, succeed: false, error: '', + checkTimes: 0, } }, computed: { @@ -133,15 +134,20 @@ export default { if (this.hash) { this.error = null this.$http.getTxs(this.hash).then(res => { - console.log('tx', res) if (res.code === 0) { this.succeed = true clearInterval(this.timer) } else if (res.code !== 3) { // code 3 is tx unconfirmed(not founded). this.error = res.raw_log - console.log('error:', this.error) clearInterval(this.timer) } + }, () => { + // error statement + this.checkTimes += 1 + if (this.checkTimes > 5) { + clearInterval(this.timer) + this.error = 'Timeout' + } }).catch(e => { this.error = e clearInterval(this.timer)