From 79b4bc671bdfe535005d5dc73c5e61d25022c19a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 5 Aug 2021 20:53:01 +0800 Subject: [PATCH] clean code --- src/libs/fetch.js | 5 +---- src/store/chains/index.js | 3 +-- src/views/Block.vue | 4 +--- src/views/Blocks.vue | 2 +- src/views/Home.vue | 2 +- src/views/ProposalView.vue | 2 +- src/views/Staking.vue | 4 ---- src/views/StakingValidator.vue | 2 -- src/views/Transaction.vue | 1 - 9 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 4cec7ac0..c090bf47 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -39,7 +39,6 @@ const chainAPI = class ChainFetch { chain.sdk_version = refetchVersion(chain) } this.config = chain - console.log(this.config) return this.config } @@ -52,9 +51,7 @@ const chainAPI = class ChainFetch { } async getTxs(hash) { - const FIELD = 'sdk_version' const ver = this.getSelectedConfig() ? this.config.sdk_version : '0.41' - console.log(ver, this.config[FIELD]) // /cosmos/tx/v1beta1/txs/{hash} if (ver && compareVersions(ver, '0.40') < 1) { return this.get(`/txs/${hash}`).then(data => WrapStdTx.create(data, ver)) @@ -167,7 +164,7 @@ const chainAPI = class ChainFetch { async get(url) { this.getSelectedConfig() - const ret = await fetch(this.config.api + url).then(response => response.json()).catch(e => console.log(e)) + const ret = await fetch(this.config.api + url).then(response => response.json()).catch(e => console.error(e)) return ret } } diff --git a/src/store/chains/index.js b/src/store/chains/index.js index cc5ab16a..4f474693 100644 --- a/src/store/chains/index.js +++ b/src/store/chains/index.js @@ -24,9 +24,8 @@ Object.keys(chains).forEach(key => { // eslint-disable-next-line prefer-destructuring chain.sdk_version = version[0] localStorage.setItem('chains', JSON.stringify(chains)) - console.log(`${chain.api}/node_info`, localStorage.getItem('chains')) }) - .catch(e => console.log(`Failed get api vesion of ${key}`, e)) + .catch(e => console.error(`Failed get api vesion of ${key}`, e)) }) export default { diff --git a/src/views/Block.vue b/src/views/Block.vue index 0cc594ee..b8be8789 100644 --- a/src/views/Block.vue +++ b/src/views/Block.vue @@ -78,13 +78,11 @@ export default { const tx = Tx.create(origin) tx.setHash(txs[i]) array.push(tx) - console.log('tx', origin, tx) } catch (e) { - console.log(e) + console.error(e) } } if (array.length > 0) this.txs = array - console.log(this.txs) }) }, } diff --git a/src/views/Blocks.vue b/src/views/Blocks.vue index 4d348490..d360f959 100644 --- a/src/views/Blocks.vue +++ b/src/views/Blocks.vue @@ -92,7 +92,7 @@ export default { for (let i = 1; i < 20; i += 1) { list.push(height - i) } - console.log(height, list) + let promise = Promise.resolve() list.forEach(item => { promise = promise.then(() => new Promise(resolve => { diff --git a/src/views/Home.vue b/src/views/Home.vue index 55a46198..5e326341 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -139,7 +139,7 @@ export default { Object.keys(this.chains).forEach(k => { const chain = this.chains[k] fetch(`${chain.api}/blocks/latest`).then(res => res.json()).then(b => { - console.log(b.block.header) + // console.log(b.block.header) const { header } = b.block this.$set(chain, 'height', header.height) this.$set(chain, 'time', toDay(header.time)) diff --git a/src/views/ProposalView.vue b/src/views/ProposalView.vue index 03cd2526..d020118c 100644 --- a/src/views/ProposalView.vue +++ b/src/views/ProposalView.vue @@ -265,7 +265,7 @@ export default { this.$http.getGovernance(pid).then(p => { if (p.status === 2) { - this.$http.getGovernanceTally(pid, 0).then(t => p.updateTally(t)).catch(e => console.log('failed on update voting tally:', e)) + this.$http.getGovernanceTally(pid, 0).then(t => p.updateTally(t)).catch(e => console.error('failed on update voting tally:', e)) } this.proposal = p }) diff --git a/src/views/Staking.vue b/src/views/Staking.vue index dd506420..47c913cb 100644 --- a/src/views/Staking.vue +++ b/src/views/Staking.vue @@ -161,7 +161,6 @@ export default { this.validators = temp // fetch avatar from keybase - console.log(identities) let promise = Promise.resolve() identities.forEach(item => { promise = promise.then(() => new Promise(resolve => { @@ -171,7 +170,6 @@ export default { }) }, beforeDestroy() { - console.log('destroying') this.islive = false }, methods: { @@ -202,10 +200,8 @@ export default { if (this.islive) { keybase(identity).then(d => { resolve() - console.log(identity) if (Array.isArray(d.them) && d.them.length > 0) { const pic = d.them[0].pictures - console.log('fetch new avatar:', pic) if (pic) { const validator = this.validators.find(u => u.description.identity === identity) this.$set(validator, 'avatar', pic.primary.url) diff --git a/src/views/StakingValidator.vue b/src/views/StakingValidator.vue index 5a925193..b1721ced 100644 --- a/src/views/StakingValidator.vue +++ b/src/views/StakingValidator.vue @@ -329,7 +329,6 @@ export default { this.initBlocks() }, beforeDestroy() { - console.log('destroying') clearInterval(this.timer) }, methods: { @@ -343,7 +342,6 @@ export default { this.accountAddress = operatorAddressToAccount(operAddress) this.hexAddress = consensusPubkeyToHexAddress(consensusPubkey) this.$http.getStakingDelegatorDelegation(this.accountAddress, operAddress).then(d => { - console.log(d) this.selfDelegation = d }) }, diff --git a/src/views/Transaction.vue b/src/views/Transaction.vue index 06611adc..a65b96cc 100644 --- a/src/views/Transaction.vue +++ b/src/views/Transaction.vue @@ -106,7 +106,6 @@ export default { created() { const { hash } = this.$route.params this.$http.getTxs(hash).then(res => { - console.log(res) this.tx = res }) },