From d96165de5de379e2882706f7045357f14928e5f3 Mon Sep 17 00:00:00 2001 From: emi Date: Mon, 6 Apr 2020 10:47:25 -0600 Subject: [PATCH] Fix linter errors --- .eslintrc.js | 2 +- src/App.vue | 8 +-- src/components/BigField.vue | 6 +- src/components/BlockBox.vue | 6 +- src/components/Chart.vue | 10 +-- src/components/CheckAddress.vue | 10 +-- src/components/ConnectionStatus.vue | 8 +-- src/components/ContractCode.vue | 20 +++--- src/components/CubeOfCubes.vue | 24 +++---- src/components/DataField.vue | 2 +- src/components/DataItem.vue | 18 ++--- src/components/DataPage.vue | 52 +++++++-------- src/components/DataSection.vue | 2 +- src/components/DataTable.vue | 56 ++++++++-------- src/components/ExportControls.vue | 12 ++-- src/components/FieldTitle.vue | 8 +-- src/components/ItemNavigator.vue | 4 +- src/components/LoadingCircle.vue | 22 +++--- src/components/Paginator.vue | 24 +++---- src/components/PendingBlocks.vue | 8 +-- src/components/ProgressBar.vue | 4 +- src/components/SearchBox.vue | 18 ++--- src/components/SearchPage.vue | 4 +- src/components/Spinner.vue | 8 +-- src/components/ToolTip.vue | 42 ++++++------ src/components/TransactionBox.vue | 4 +- src/components/TxChart.vue | 14 ++-- src/components/TxDensityChart.vue | 16 ++--- src/components/TxFilters.vue | 10 +-- src/components/TxPool.vue | 12 ++-- src/components/VerifyContract.vue | 78 +++++++++++----------- src/components/WaitingDots.vue | 12 ++-- src/components/controls/CopyButton.vue | 2 +- src/components/controls/CtrlBigText.vue | 2 +- src/components/controls/CtrlFiles.vue | 22 +++--- src/components/controls/CtrlRadioGrp.vue | 2 +- src/components/controls/CtrlSearch.vue | 22 +++--- src/components/controls/CtrlSwitch.vue | 2 +- src/components/controls/DownloadButton.vue | 4 +- src/config/content.js | 2 +- src/config/entities/address.js | 10 +-- src/config/entities/block.js | 10 +-- src/config/entities/event.js | 30 ++++----- src/config/entities/lib/eventsLib.js | 32 ++++----- src/config/entities/tokenAccount.js | 10 +-- src/config/entities/transaction.js | 22 +++--- src/config/entities/txPool.js | 4 +- src/config/entities/verifiedContracts.js | 2 +- src/config/messages.js | 10 +-- src/config/texts/verifyContract.js | 2 +- src/directives/hljs.js | 4 +- src/filters/BigNumberFilters.js | 2 +- src/filters/NumberFilters.js | 6 +- src/filters/TextFilters.js | 4 +- src/filters/TimeFilters.js | 18 ++--- src/filters/TokensFilters.js | 4 +- src/lib/js/EntityParser.js | 19 +++--- src/lib/js/EtherUnits.js | 12 ++-- src/lib/js/decodeField.js | 10 +-- src/lib/js/io.js | 33 ++++----- src/lib/js/menuItems.js | 2 +- src/lib/js/units.js | 64 +++++++++--------- src/lib/js/utils.js | 10 +-- src/lib/js/validate.js | 16 ++--- src/main.with.tracking.js | 2 +- src/mixins/common.js | 12 ++-- src/mixins/dataMixin.js | 66 +++++++++--------- src/router/addresses.js | 6 +- src/router/index.js | 10 +-- src/router/routes.js | 2 +- src/router/tokens.js | 4 +- src/store/actions.js | 4 +- src/store/getters.js | 16 ++--- src/store/modules/backend/actions.js | 50 +++++++------- src/store/modules/backend/getters.js | 10 +-- src/store/modules/backend/mutations.js | 8 +-- src/store/modules/config/actions.js | 6 +- src/store/modules/config/getters.js | 2 +- src/store/modules/config/mutations.js | 16 ++--- src/store/modules/entities/getters.js | 14 ++-- src/store/modules/routes/actions.js | 10 +-- src/store/modules/routes/getters.js | 10 +-- src/store/modules/search/actions.js | 14 ++-- src/store/modules/search/getters.js | 32 ++++----- src/store/modules/search/payloads.js | 10 +-- src/store/plugins/localStorage.js | 4 +- tests/unit/FieldTitle.spec.js | 12 ++-- tests/unit/decodeField.spec.js | 20 +++--- tests/unit/filters/bignumber.spec.js | 4 +- tests/unit/filters/textFilters.spec.js | 2 +- tests/unit/filters/tokenFilters.spec.js | 4 +- tests/unit/utils.spec.js | 18 ++--- tests/unit/validate.spec.js | 20 +++--- 93 files changed, 653 insertions(+), 653 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 98d04316..e637c66c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,7 +3,7 @@ module.exports = { env: { node: true }, - 'extends': [ + extends: [ 'plugin:vue/essential', '@vue/standard' ], diff --git a/src/App.vue b/src/App.vue index 30f30287..199c46d8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -97,7 +97,7 @@ export default { return (this.dbIsOutdated) ? 'DB_OUTDATED' || null : null }, networkName () { - let name = this.netName || '' + const name = this.netName || '' return (name) ? name.replace('RSK', '').trim().toLowerCase() : name } }, @@ -119,11 +119,11 @@ export default { }, getIcon (name) { if (name === 'home') return 'rsk' - let entity = this.getEntity()(name) + const entity = this.getEntity()(name) return (entity) ? entity.icon || name : name }, onResize () { - let size = { + const size = { w: this.$el.clientWidth, h: this.$el.clientHeight } @@ -132,7 +132,7 @@ export default { resizeThrottler () { this.menu = false if (!this.resizeTimeout) { - let vm = this + const vm = this this.resizeTimeout = setTimeout(() => { vm.resizeTimeout = null vm.onResize() diff --git a/src/components/BigField.vue b/src/components/BigField.vue index c0012a5f..96d7a2e0 100644 --- a/src/components/BigField.vue +++ b/src/components/BigField.vue @@ -23,7 +23,7 @@ export default { } }, created () { - let { decoded } = this + const { decoded } = this // select rlp if is available if (decoded && decoded.rlp) { this.field = 'rlp' @@ -34,14 +34,14 @@ export default { return this.options || {} }, decode () { - let { decode } = this.opts + const { decode } = this.opts return decode }, decoded () { return (this.decode) ? decodeField(this.data) : null }, value () { - let { decoded, field, data } = this + const { decoded, field, data } = this return (decoded && field) ? decoded[field] || data : data }, rows () { diff --git a/src/components/BlockBox.vue b/src/components/BlockBox.vue index da767504..6e5bfcd4 100644 --- a/src/components/BlockBox.vue +++ b/src/components/BlockBox.vue @@ -38,7 +38,7 @@ export default { }, computed: { boxFields () { - let { miner, txs, txDensity, timestamp } = this.fields + const { miner, txs, txDensity, timestamp } = this.fields // let { blockHashrate } = this.fields return [ [miner], @@ -57,11 +57,11 @@ export default { return this.getBlockColor(this.block.number) }, bStyle () { - let color = this.blockColor + const color = this.blockColor return { color, fill: color } }, blockBoxStyle () { - let color = this.blockColor + const color = this.blockColor return { 'border-color': color } } } diff --git a/src/components/Chart.vue b/src/components/Chart.vue index cd2ebf8e..d0958b63 100644 --- a/src/components/Chart.vue +++ b/src/components/Chart.vue @@ -25,14 +25,14 @@ export default { } }, mounted () { - let vm = this + const vm = this this.$nextTick(() => { vm.onResize() }) }, watch: { asize () { - let vm = this + const vm = this this.$nextTick(() => { vm.onResize() }) @@ -55,14 +55,14 @@ export default { return Object.assign({ size: this.size }, this.opts) }, hRatio () { - let hr = this.heightRatio + const hr = this.heightRatio return (undefined !== hr) ? hr : 3.5 } }, methods: { onResize () { - let w = this.$el.parentElement.offsetWidth - let h = w / this.hRatio + const w = this.$el.parentElement.offsetWidth + const h = w / this.hRatio this.size = Object.assign({}, { w, h }) } } diff --git a/src/components/CheckAddress.vue b/src/components/CheckAddress.vue index 010a346f..2fad4464 100644 --- a/src/components/CheckAddress.vue +++ b/src/components/CheckAddress.vue @@ -55,23 +55,23 @@ export default { return isAddress(this.address) }, checksumValid () { - let { address, chainId } = this + const { address, chainId } = this return isValidChecksumAddress(address, chainId) }, isValid () { - let { address, chainId } = this + const { address, chainId } = this return isValidAddress(address, chainId) }, checkSummed () { return toChecksumAddress(this.address) }, isCheckSummed () { - let { checksummed, address } = this + const { checksummed, address } = this return checksummed === address }, networks () { - let { chainId, address } = this - let nets = searchChecksummedNetworks(address) + const { chainId, address } = this + const nets = searchChecksummedNetworks(address) return nets.filter(d => `${d.chainId}` !== `${chainId}`) }, checkClass () { diff --git a/src/components/ConnectionStatus.vue b/src/components/ConnectionStatus.vue index 44cf4f17..112b55d1 100644 --- a/src/components/ConnectionStatus.vue +++ b/src/components/ConnectionStatus.vue @@ -51,7 +51,7 @@ export default { return true }, lostTime () { - let { connectionEnd, now } = this + const { connectionEnd, now } = this return (connectionEnd) ? now - connectionEnd : 0 }, waitingTime () { @@ -67,21 +67,21 @@ export default { return (this.connectionEnd) ? this.lostTime > WAITING_TIME : 0 }, connectedTime () { - let { connectionStart, now } = this + const { connectionStart, now } = this return (connectionStart) ? (now - connectionStart) || 0 : 0 }, isWaiting () { return this.waitingTime < WAITING_TIME }, connectionStatus () { - let { isLost, isWaiting, connected, lostTime, waitingTime, connectedTime } = this + const { isLost, isWaiting, connected, lostTime, waitingTime, connectedTime } = this if (connected) return [STATUS.CONNECTED, 'brand', connectedTime] if (isLost) return [STATUS.LOST, 'warn', lostTime] if (isWaiting) return [STATUS.WAITING, 'brand', waitingTime] return [STATUS.UNABLE, 'error', waitingTime] }, status () { - let [msg, css, time] = this.connectionStatus + const [msg, css, time] = this.connectionStatus return { msg, css, time } }, showTime () { diff --git a/src/components/ContractCode.vue b/src/components/ContractCode.vue index 4cd029f9..c6abcca0 100644 --- a/src/components/ContractCode.vue +++ b/src/components/ContractCode.vue @@ -65,7 +65,7 @@ export default { } }, created () { - let first = this.imports[0] + const first = this.imports[0] if (first) this.selectFile(first.name) }, computed: { @@ -78,13 +78,13 @@ export default { return this.data.code }, contractName () { - let { name, address } = this.data + const { name, address } = this.data return name || address }, abi () { - let { verification } = this - let abi = (verification) ? verification.abi : null + const { verification } = this + const abi = (verification) ? verification.abi : null return (abi) ? JSON.stringify(abi, null, 2) : null }, @@ -101,7 +101,7 @@ export default { }, imports () { - let sources = [...this.sources] + const sources = [...this.sources] return sources.splice(1) }, @@ -114,15 +114,15 @@ export default { }, verificationData () { - let result = this.result || {} - let { name: contractName, usedSettings } = result - let { evmVersion, optimizer: optimization } = usedSettings - let { version: compilerVersion } = usedSettings.compiler + const result = this.result || {} + const { name: contractName, usedSettings } = result + const { evmVersion, optimizer: optimization } = usedSettings + const { version: compilerVersion } = usedSettings.compiler return { contractName, compilerVersion, evmVersion, optimization } }, selected () { - let { fileSelected } = this + const { fileSelected } = this return this.imports.find(f => f.name === fileSelected) } diff --git a/src/components/CubeOfCubes.vue b/src/components/CubeOfCubes.vue index abe815d9..32f03c72 100644 --- a/src/components/CubeOfCubes.vue +++ b/src/components/CubeOfCubes.vue @@ -54,14 +54,14 @@ export default { }, cubes () { let cubes = [] - let cs = this.cs - let cc = this.cc - let cmod = this.mod - let cx = this.size / 1.8 - let cy = this.size / 2 - let crows = this.crows + const cs = this.cs + const cc = this.cc + const cmod = this.mod + const cx = this.size / 1.8 + const cy = this.size / 2 + const crows = this.crows for (let j = 0; j < crows; j++) { - let cyy = cy - (cs * j) + const cyy = cy - (cs * j) for (let h = 0; h < cmod; h++) { cubes = this.cLine(cubes, cx + (cc.x * h), cyy + (cc.y * h)) } @@ -71,17 +71,17 @@ export default { }, methods: { cLine (cubes, cx, cy) { - let cc = this.cc - let cmod = this.mod + const cc = this.cc + const cmod = this.mod for (let i = 1; i <= cmod; i++) { - let x = cx - (i * cc.x) - let y = cy + (i * cc.y) + const x = cx - (i * cc.x) + const y = cy + (i * cc.y) cubes.push({ x, y }) } return cubes }, cubeStyle (cube) { - let cb = this.cubeStyleCb + const cb = this.cubeStyleCb if (cb && typeof (cb) === 'function') { return cb(cube) } else { diff --git a/src/components/DataField.vue b/src/components/DataField.vue index 7ef22a30..50c1bc7e 100644 --- a/src/components/DataField.vue +++ b/src/components/DataField.vue @@ -70,7 +70,7 @@ export default { }, trimOptions () { let options = this.ttOpts - let fieldOptions = this.field.trimOptions + const fieldOptions = this.field.trimOptions if (fieldOptions) options = Object.assign(options, fieldOptions) return options }, diff --git a/src/components/DataItem.vue b/src/components/DataItem.vue index d78b1166..4b465af9 100644 --- a/src/components/DataItem.vue +++ b/src/components/DataItem.vue @@ -51,33 +51,33 @@ export default { ], computed: { delayedFields () { - let delayed = this.delayed || {} + const delayed = this.delayed || {} return delayed.fields || [] } }, methods: { value (field, format) { - let raw = !format + const raw = !format return this.getValue(field, this.data, raw) }, isDelayed (field) { - let fields = this.delayedFields + const fields = this.delayedFields return fields.indexOf(field) > -1 }, itemClass (field, rowNumber) { - let css = [] - let fieldName = field.fieldName - let pos = this.fieldPos(field) + const css = [] + const fieldName = field.fieldName + const pos = this.fieldPos(field) if (this.isFrom(fieldName, pos)) css.push('from') if (this.isTo(fieldName, pos)) css.push('to') rowNumber = rowNumber || pos - let row = (rowNumber % 2) ? 'odd' : 'even' + const row = (rowNumber % 2) ? 'odd' : 'even' css.push(row) return css }, componentProps (field) { - let tableName = `field-${field.fieldName}` - let delayed = this.isDelayed(field) + const tableName = `field-${field.fieldName}` + const delayed = this.isDelayed(field) let props = { tableName, delayed } props = (field.renderAsProps) ? Object.assign(props, field.renderAsProps) : props return props diff --git a/src/components/DataPage.vue b/src/components/DataPage.vue index d883615d..91008865 100644 --- a/src/components/DataPage.vue +++ b/src/components/DataPage.vue @@ -91,7 +91,7 @@ export default { this.getData() }, watch: { - '$route': 'onRouteChange' + $route: 'onRouteChange' }, computed: { ...mapGetters({ @@ -100,11 +100,11 @@ export default { routeParams: 'getRouterParams' }), hideTabs () { - let active = this.activeContentTab || {} + const active = this.activeContentTab || {} return active.hideTabs }, query () { - let key = this.reqKey + const key = this.reqKey return this.getQuery()(key) }, error () { @@ -126,7 +126,7 @@ export default { return this.page.total || null }, isTable () { - let { data } = this.page + const { data } = this.page return (data && Array.isArray(data)) }, delayed () { @@ -137,9 +137,9 @@ export default { }, pageTitle () { if (undefined === this.title) return this.$route.name - let title = this.title + const title = this.title if (title) { - let data = this.data || {} + const data = this.data || {} return (typeof title === 'function') ? title(data) : title } return '' @@ -152,8 +152,8 @@ export default { return this.isRequesting()(this.reqKey) }, activeTab () { - let tabs = this.tabs || [] - let tab = (tabs.length) ? tabs[0].name : null + const tabs = this.tabs || [] + const tab = (tabs.length) ? tabs[0].name : null let name = this.getActiveTab || tab if (!this.selectTabByName(name)) { name = tab @@ -162,23 +162,23 @@ export default { return name }, activeContentTab () { - let tabs = this.mainContent || [] + const tabs = this.mainContent || [] if (!tabs.length) return - let tabName = this.getActiveContentTab || tabs[0].name - let tab = tabs.find(tab => tab.name === tabName) || tabs[0] + const tabName = this.getActiveContentTab || tabs[0].name + const tab = tabs.find(tab => tab.name === tabName) || tabs[0] // reset tab if don't exist if (tab.name !== tabName) this.setActiveContentTab(tab.name) return tab }, mainContentTabs () { - let tabs = this.mainContent || [] + const tabs = this.mainContent || [] const { data } = this // execute count and render callbacks return tabs.filter(tab => { - let render = (typeof tab.render === 'function') ? tab.render(data) : true - let count = tab.count - let icon = (typeof tab.icon === 'function') ? tab.icon(data) : tab.icon + const render = (typeof tab.render === 'function') ? tab.render(data) : true + const count = tab.count + const icon = (typeof tab.icon === 'function') ? tab.icon(data) : tab.icon tab.buttonIcon = icon if (count && typeof count === 'function') tab.total = count(data) return render @@ -186,7 +186,7 @@ export default { }, tabsTotals () { return this.tabs.reduce((v, a, i) => { - let { name } = a + const { name } = a v[name] = this.getPageTotal()(name) return v }, {}) @@ -213,12 +213,12 @@ export default { this.updateRouterTabQuery('__ctab', name, event) }, isActiveContentTab (tab) { - let active = this.activeContentTab || {} + const active = this.activeContentTab || {} return active.name === tab.name }, updateRouterTabQuery (key, value, event) { - let hash = this.getRouterHashFromEvent(event) - let query = { [key]: value } + const hash = this.getRouterHashFromEvent(event) + const query = { [key]: value } this.updateRouterQuery({ query, hash, key }) }, renderTab (tab) { @@ -229,8 +229,8 @@ export default { onRouteChange (to, from) { if (to.path === from.path) { // check for query changes - let diff = plainObjectChanges(to.query, from.query) - let keys = Object.keys(diff) + const diff = plainObjectChanges(to.query, from.query) + const keys = Object.keys(diff) // dont fetch if (!keys.length) return if (keys.length === 1 && keys[0].slice(0, 2) === '__') return @@ -240,23 +240,23 @@ export default { async getData () { let { module, tabs, action, params } = this - let key = this.reqKey + const key = this.reqKey if (!module || !action) return await this.fetchRouteData({ action, params, module, key }) if (tabs) { - let active = this.activeTab + const active = this.activeTab if (active) { await this.fetchTab(active) tabs = tabs.filter(tab => tab.name !== active) } - for (let tab of tabs) { + for (const tab of tabs) { this.fetchTab(tab.name) } } }, async fetchTab (tabName) { - let tab = Object.assign({}, this.getTab(tabName)) + const tab = Object.assign({}, this.getTab(tabName)) let params = tab.params params = (params && typeof params === 'function') ? params(this.routeParams) : params params = params || {} @@ -264,7 +264,7 @@ export default { tab.params = params tab.count = true if (tab) { - let req = await this.fetchRouteData(tab) + const req = await this.fetchRouteData(tab) return req } }, diff --git a/src/components/DataSection.vue b/src/components/DataSection.vue index 154803c8..f793ffd1 100644 --- a/src/components/DataSection.vue +++ b/src/components/DataSection.vue @@ -68,7 +68,7 @@ export default { return (this.isTable) ? this.fields || Object.keys(this.data[0]) : null }, pageOptions () { - let options = this.page.pages || {} + const options = this.page.pages || {} options.key = this.reqKey return options }, diff --git a/src/components/DataTable.vue b/src/components/DataTable.vue index 4d75cfda..f00f2507 100644 --- a/src/components/DataTable.vue +++ b/src/components/DataTable.vue @@ -100,14 +100,14 @@ export default { } }, mounted () { - let vm = this - let table = this.$refs.table - let tw = this.tableConfig.w - let size = this.size - let parent = vm.$parent.$el + const vm = this + const table = this.$refs.table + const tw = this.tableConfig.w + const size = this.size + const parent = vm.$parent.$el this.$nextTick(() => { if (table) { - let tcw = table.clientWidth + const tcw = table.clientWidth if (table && (tcw > size.w || tcw > parent.clientWidth)) { if (!tw || size.w < tw) { vm.$set(vm, 'renderTable', false) @@ -122,7 +122,7 @@ export default { }), renderTable: { get () { - let r = this.tableConfig.renderTable + const r = this.tableConfig.renderTable return (undefined === r) ? true : r }, set (renderTable) { @@ -143,25 +143,25 @@ export default { return Object.keys(this.defaultSort) }, defaultSort () { - let { page } = this - let pages = page.pages || {} + const { page } = this + const pages = page.pages || {} return pages.defaultSort || { _id: -1 } }, isDefaultSort () { - let sortKeys = this.sortKeys - let defSort = this.defaultSort - let sort = this.sort + const sortKeys = this.sortKeys + const defSort = this.defaultSort + const sort = this.sort if (sortKeys.length !== this.defKeys.length) return false return (undefined !== sortKeys.find(k => defSort[k] === sort[k])) }, isDefaultSortVisible () { - let fields = Object.values(this.fields).map(f => f.path) - let keys = this.defKeys.map(k => fields.includes(k)) + const fields = Object.values(this.fields).map(f => f.path) + const keys = this.defKeys.map(k => fields.includes(k)) return keys.reduce((v, a) => v && a) }, sortableFields () { - let page = this.page - let pages = page.pages + const page = this.page + const pages = page.pages return (pages && pages.sortable) ? pages.sortable : {} }, hasSorts () { @@ -181,8 +181,8 @@ export default { return this.getTableConfig()(this.tableId) }, key () { - let page = this.page - let req = (page) ? page.req : {} + const page = this.page + const req = (page) ? page.req : {} return (req) ? req.key : null } }, @@ -198,7 +198,7 @@ export default { 'sortKey' ]), sortIcon (fieldName) { - let sort = this.sort[fieldName] + const sort = this.sort[fieldName] let icon = 'triangle-arrow-' if (sort) { icon = (sort === -1) ? icon + 'down' : icon + 'up' @@ -209,14 +209,14 @@ export default { return this.sortKeys.indexOf(field) + 1 }, getData (sort, hash) { - let key = this.key - let sortKey = this.sortKey()(key) - let query = this.removePaginationFromRoute()(key, { [sortKey]: sort }) + const key = this.key + const sortKey = this.sortKey()(key) + const query = this.removePaginationFromRoute()(key, { [sortKey]: sort }) this.updateRouterQuery({ query, hash, key }) }, sortBy (field, event) { - let hash = this.getRouterHashFromEvent(event) - let sort = {} + const hash = this.getRouterHashFromEvent(event) + const sort = {} sort[field] = this.sort[field] if (!this.isDefaultSort) { if (sort[field] === -1) delete sort[field] @@ -227,8 +227,8 @@ export default { this.getData(sort, hash) }, isSorted (field) { - let sort = this.sort - let sorted = (sort && sort[field]) + const sort = this.sort + const sorted = (sort && sort[field]) return sorted }, isSortable (field) { @@ -239,13 +239,13 @@ export default { this.renderTable = renderTable }, thClass (field) { - let css = [] + const css = [] if (this.isSorted(field)) css.push('has-sort') if (!this.isSortable(field)) css.push('unsortable') return css }, tdClass (name) { - let css = [`field__${name}`] + const css = [`field__${name}`] if (this.key === name) css.push('row-header') return css } diff --git a/src/components/ExportControls.vue b/src/components/ExportControls.vue index 26311382..f310636c 100644 --- a/src/components/ExportControls.vue +++ b/src/components/ExportControls.vue @@ -17,21 +17,21 @@ export default { mixins: [dataMixin], computed: { exportData () { - let { data } = this + const { data } = this return (data) ? JSON.stringify(data, null, 4) : null }, fileName () { let fileName = 'download' - let { entity, data, type } = this - let { key } = entity - let id = (key) ? data[key] : null + const { entity, data, type } = this + const { key } = entity + const id = (key) ? data[key] : null if (type && id) fileName = `${type}-${id}` return fileName }, downloadData () { - let value = this.exportData + const value = this.exportData if (!value) return {} - let fileType = 'json' + const fileType = 'json' let fileName = this.fileName fileName = `${fileName}.${fileType}` return { fileType, value, fileName, title: 'download' } diff --git a/src/components/FieldTitle.vue b/src/components/FieldTitle.vue index 3e145310..35e4fd3b 100644 --- a/src/components/FieldTitle.vue +++ b/src/components/FieldTitle.vue @@ -20,23 +20,23 @@ export default { } }, created () { - let options = this.options || {} + const options = this.options || {} this.forceTitle = options.forceTitle || false this.forceIcon = options.forceIcon || false this.hideIcon = options.hideIcon || false }, computed: { showTitle () { - let field = this.field || {} + const field = this.field || {} return field.showTitle || !field.hideTitle || this.forceTitle }, showIcon () { - let { field, forceIcon, hideIcon } = this + const { field, forceIcon, hideIcon } = this if (!field || (hideIcon && !forceIcon)) return false return (field.titleIcon || forceIcon) && field.icon }, description () { - let { description, hideDescription } = this.field + const { description, hideDescription } = this.field return (!hideDescription) ? description : false } } diff --git a/src/components/ItemNavigator.vue b/src/components/ItemNavigator.vue index 0ccfdfa1..418f160d 100644 --- a/src/components/ItemNavigator.vue +++ b/src/components/ItemNavigator.vue @@ -35,13 +35,13 @@ export default { }, linkTo (dest) { - let { regKey } = this + const { regKey } = this return this.getNewRoute()(regKey, dest) }, navigateTo (dest) { if (dest) { - let link = this.linkTo(dest) + const link = this.linkTo(dest) this.$router.push(link) } } diff --git a/src/components/LoadingCircle.vue b/src/components/LoadingCircle.vue index a9d3d0da..2d434b7a 100644 --- a/src/components/LoadingCircle.vue +++ b/src/components/LoadingCircle.vue @@ -37,16 +37,16 @@ export default { return this.size - this.strokeWidth }, viewBox () { - let s = this.size + const s = this.size return `0 0 ${s} ${s}` }, stroke () { - let percent = this.percent - let long = this.circumference + const percent = this.percent + const long = this.circumference return `${long / 100 * percent}, ${long}` }, strokeWidth () { - let sw = this.strokeW + const sw = this.strokeW return sw || this.size / 4 }, radius () { @@ -59,11 +59,11 @@ export default { return this.radius * 2 }, path () { - let s = this.s - let d = this.diameter - let r = this.radius - let sw = this.strokeWidth - let p = [] + const s = this.s + const d = this.diameter + const r = this.radius + const sw = this.strokeWidth + const p = [] p.push(`M ${s / 2 + sw / 2} ${sw / 2}`) p.push(`a${r} ${r} 0 0 1 0 ${d}`) p.push(`a${r} ${r} 0 0 1 0 -${d}`) @@ -78,8 +78,8 @@ export default { this.interval = requestAnimationFrame(this.animate) }, animate () { - let time = Date.now() - this.startTime - let duration = this.duration + const time = Date.now() - this.startTime + const duration = this.duration this.percent = parseInt((time * 100) / duration) if (this.percent > 99) this.setStartTime() this.nextFrame() diff --git a/src/components/Paginator.vue b/src/components/Paginator.vue index 47b601c4..ec1723b0 100644 --- a/src/components/Paginator.vue +++ b/src/components/Paginator.vue @@ -48,11 +48,11 @@ export default { return (this.pages.length) ? prevPage : prev }, nextPage () { - let aPage = this.findPage(this.page + 1) + const aPage = this.findPage(this.page + 1) return aPage || this.nextIndex }, prevPage () { - let pPage = this.findPage(this.page - 1) + const pPage = this.findPage(this.page - 1) return pPage || this.prevIndex }, total () { @@ -76,9 +76,9 @@ export default { ...mapGetters(['nextKey', 'prevKey', 'pageKey']), goNext (event) { - let { pages, next } = this - let p = pages[pages.length - 1] - let page = p.page + 1 + const { pages, next } = this + const p = pages[pages.length - 1] + const page = p.page + 1 this.goToPage({ page, next }) }, goPrev (event) { @@ -88,16 +88,16 @@ export default { }, goToPage ({ next, prev, page }, event) { - let key = this.key - let nextKey = this.nextKey()(key) - let prevKey = this.prevKey()(key) - let pageKey = this.pageKey()(key) - let query = { [nextKey]: next, [prevKey]: prev, [pageKey]: page } + const key = this.key + const nextKey = this.nextKey()(key) + const prevKey = this.prevKey()(key) + const pageKey = this.pageKey()(key) + const query = { [nextKey]: next, [prevKey]: prev, [pageKey]: page } this.updateRouterQuery({ query, key }) }, findPage (page) { - let { pages } = this - let index = pages.findIndex(p => p.page === page) + const { pages } = this + const index = pages.findIndex(p => p.page === page) return (index > -1) ? pages[index] : null } } diff --git a/src/components/PendingBlocks.vue b/src/components/PendingBlocks.vue index 3efd8e47..69ba2c5c 100644 --- a/src/components/PendingBlocks.vue +++ b/src/components/PendingBlocks.vue @@ -42,7 +42,7 @@ export default { now: 'getDate' }), mod () { - let max = (this.pending > 4) ? this.pending : 4 + const max = (this.pending > 4) ? this.pending : 4 return (max) ? Math.ceil(Math.cbrt(max)) : 0 }, step () { @@ -51,8 +51,8 @@ export default { return step }, badgeStyle () { - let width = (this.pending.toString().length) + 'em' - let height = width + const width = (this.pending.toString().length) + 'em' + const height = width return { width, height } } }, @@ -61,7 +61,7 @@ export default { ...mapGetters(['getBlockColor']), cubeStyle (cube) { - let fill = this.getBlockColor()(cube) + const fill = this.getBlockColor()(cube) return { fill } } } diff --git a/src/components/ProgressBar.vue b/src/components/ProgressBar.vue index 3765d169..6c7860ca 100644 --- a/src/components/ProgressBar.vue +++ b/src/components/ProgressBar.vue @@ -40,8 +40,8 @@ export default { methods: { animate () { if (!this.startTime) this.startTime = Date.now() - let time = Date.now() - this.startTime - let duration = this.duration + const time = Date.now() - this.startTime + const duration = this.duration this.percent = parseInt((time * 100) / duration) if (this.percent < 100) this.interval = requestAnimationFrame(this.animate) }, diff --git a/src/components/SearchBox.vue b/src/components/SearchBox.vue index 0b5f4a29..14b59098 100644 --- a/src/components/SearchBox.vue +++ b/src/components/SearchBox.vue @@ -22,7 +22,7 @@ export default { data () { return { value: undefined, - msg: `Search by: address / block / tx / name`, + msg: 'Search by: address / block / tx / name', msgTimeout: null, requestingTimeout: null } @@ -43,7 +43,7 @@ export default { 'isSearchPage' ]), results () { - let { getSearchedResults, isSearchPage, searched, value } = this + const { getSearchedResults, isSearchPage, searched, value } = this return (!isSearchPage && value === searched) ? getSearchedResults : [] }, searchBoxClass () { @@ -75,13 +75,13 @@ export default { this.clearSearchedResults() }, goTo ({ type, value }) { - let link = this.getSearchLink()({ type, value }) + const link = this.getSearchLink()({ type, value }) if (!link) return this.clearRequests() this.$router.push(link, () => { }) }, goToSearchPage (value) { - let link = `/${r.search}/${value}` + const link = `/${r.search}/${value}` this.$router.push(link, () => { }) }, @@ -105,16 +105,16 @@ export default { async search ({ value, event }) { await this.prepareSearch({ value }) value = this.searched - let { types } = this + const { types } = this if (!types || !types.length) { return this.goToSearchPage(value) } else if (types.length === 1) { - let type = types[0] + const type = types[0] return this.goTo({ type, value }) } else { await this.searchTypes({ types, value }) await this.waitForResults() - let { results } = this + const { results } = this // redirect when there is only one result if (results && results.length === 1) { return this.goTo(results[0]) @@ -124,7 +124,7 @@ export default { } }, waitForResults () { - let vm = this + const vm = this return new Promise((resolve) => { return vm.createTimeout(() => { if (vm.isLoading) resolve(vm.waitForResults()) @@ -133,7 +133,7 @@ export default { }) }, createTimeout (cb) { - let { requestingTimeout } = this + const { requestingTimeout } = this if (requestingTimeout) clearTimeout(requestingTimeout) this.requestingTimeout = setTimeout(cb, 200) } diff --git a/src/components/SearchPage.vue b/src/components/SearchPage.vue index f29cbd64..8d2c02b4 100644 --- a/src/components/SearchPage.vue +++ b/src/components/SearchPage.vue @@ -21,7 +21,7 @@ export default { Message }, created () { - let { value, searched, search } = this + const { value, searched, search } = this if (searched !== value) search(value) }, computed: { @@ -42,7 +42,7 @@ export default { 'searchTypes']), async search (value) { await this.prepareSearch({ value }) - let { types } = this + const { types } = this if (types.length) await this.searchTypes({ types, value }) else await this.fetchSearch({ value }) } diff --git a/src/components/Spinner.vue b/src/components/Spinner.vue index 84a5fb4e..8d131709 100644 --- a/src/components/Spinner.vue +++ b/src/components/Spinner.vue @@ -36,7 +36,7 @@ export default { } }, created () { - let { mod, speed } = this + const { mod, speed } = this this.limit = mod * mod * mod this.frameDuration = mod * speed this.prevFrame = Date.now() @@ -53,9 +53,9 @@ export default { this.interval = requestAnimationFrame(this.animate) }, animate () { - let date = Date.now() - let { prevFrame, frameDuration } = this - let elapsed = date - prevFrame + const date = Date.now() + const { prevFrame, frameDuration } = this + const elapsed = date - prevFrame if (elapsed < frameDuration) return this.nextFrame() this.show = (date - this.startTime >= this.delay) let step = this.step diff --git a/src/components/ToolTip.vue b/src/components/ToolTip.vue index e92286b8..f1c1e29a 100644 --- a/src/components/ToolTip.vue +++ b/src/components/ToolTip.vue @@ -67,8 +67,8 @@ export default { elStyle: { 'max-width': 'inherit !important', 'overflow-x': 'hidden !important', - 'display': 'block', - 'position': 'absolute' + display: 'block', + position: 'absolute' }, opts: { pos: 'top', @@ -85,14 +85,14 @@ export default { created () { if (this.trim !== 'auto') this.elStyle = null if (this.options) { - for (let op in this.options) { + for (const op in this.options) { this.$set(this.opts, op, this.options[op]) } } }, mounted () { if (this.trim === 'auto') { - let vm = this + const vm = this this.$nextTick(() => { vm.autoSize() @@ -101,14 +101,14 @@ export default { }, computed: { trimLen () { - let trim = this.trim + const trim = this.trim return (trim !== 'auto') ? this.trim : this.autoTrimLen }, trimed () { let trimed = [this.value] - let value = this.value - let trimAt = this.opts.trimAt - let len = this.value.length + const value = this.value + const trimAt = this.opts.trimAt + const len = this.value.length if (this.trimLen) { switch (trimAt) { case 'end': @@ -125,26 +125,26 @@ export default { return trimed }, tipPos () { - let pos = this.opts.pos + const pos = this.opts.pos if (pos === 'bottom' || pos === 'top') { - let p = (pos === 'top') ? 'bottom' : 'top' + const p = (pos === 'top') ? 'bottom' : 'top' return p + ':' + this.$el.clientHeight + 'px; left:0' } if (pos === 'left' || pos === 'right') { - let p = (pos === 'left') ? 'right' : 'left' + const p = (pos === 'left') ? 'right' : 'left' return p + ':' + this.$el.clientWidth + 'px; bottom: -50%;' } return '' }, tipClass () { - let css = [] + const css = [] if (this.anim) css.push('copying') if (this.value.length < 30) css.push('nowrap') return css }, pointsClass () { - let css = [] - let trimAt = this.opts.trimAt + const css = [] + const trimAt = this.opts.trimAt let pos = 'right' if (this.clicked) css.push('clicked') if (trimAt !== 'start') pos = (trimAt === 'end') ? 'left' : 'center' @@ -163,9 +163,9 @@ export default { const fontSize = parseInt(style.fontSize.match(/(\d+)px/)[1] || 16) if (size > parentWidth || this.opts.forceTrim) { let trimLen = parentWidth / fontSize / 2 - let max = txt.length / 3 - let trimMin = this.opts.trimMin - let trimMax = this.opts.trimMax + const max = txt.length / 3 + const trimMin = this.opts.trimMin + const trimMax = this.opts.trimMax trimLen = (trimLen > trimMin) ? trimLen : trimMin if (trimMax) { if (trimLen > trimMax || !trimLen) trimLen = trimMax @@ -176,10 +176,10 @@ export default { this.elStyle = '' }, getTexWidth (txt, font) { - let canvas = document.createElement('canvas') - let ctx = canvas.getContext('2d') + const canvas = document.createElement('canvas') + const ctx = canvas.getContext('2d') ctx.font = font - let size = ctx.measureText(txt) + const size = ctx.measureText(txt) return size.width }, touch (value) { @@ -189,7 +189,7 @@ export default { // timeout to close tip after, not for trimmeds if (this.show && !this.trimLen) { if (!this.closer) { - let vm = this + const vm = this this.closer = setTimeout(() => { vm.show = false }, 3000) diff --git a/src/components/TransactionBox.vue b/src/components/TransactionBox.vue index adfac649..37f65b1a 100644 --- a/src/components/TransactionBox.vue +++ b/src/components/TransactionBox.vue @@ -56,11 +56,11 @@ export default { return this.getBlockColor(this.tx.blockNumber) }, blockStyle2 () { - let color = this.blockColor + const color = this.blockColor return { color } }, txBoxStyle () { - let color = this.blockColor + const color = this.blockColor return { 'border-color': color } }, bField () { diff --git a/src/components/TxChart.vue b/src/components/TxChart.vue index 5d1609de..2090f5ca 100644 --- a/src/components/TxChart.vue +++ b/src/components/TxChart.vue @@ -46,7 +46,7 @@ export default { return d.transactions.length }, formatLabel (bar) { - let label = [] + const label = [] label.push('#' + bar.d.number) label.push('txs:' + bar.d.transactions.length) return label @@ -55,14 +55,14 @@ export default { } }, mounted () { - let vm = this + const vm = this this.$nextTick(() => { vm.onResize() }) }, watch: { asize () { - let vm = this + const vm = this this.$nextTick(() => { vm.onResize() }) @@ -82,13 +82,13 @@ export default { }, methods: { onResize () { - let w = this.$el.parentElement.offsetWidth - let h = w / 3.5 + const w = this.$el.parentElement.offsetWidth + const h = w / 3.5 this.size = Object.assign({}, { w, h }) }, barClick (event) { - let bar = event.bar || {} - let blockNumber = (bar.d) ? bar.d.number : null + const bar = event.bar || {} + const blockNumber = (bar.d) ? bar.d.number : null if (blockNumber) this.$router.push({ path: `${ROUTES.block}/${blockNumber}` }) } } diff --git a/src/components/TxDensityChart.vue b/src/components/TxDensityChart.vue index 2164bd45..b171181e 100644 --- a/src/components/TxDensityChart.vue +++ b/src/components/TxDensityChart.vue @@ -57,7 +57,7 @@ export default { return d.txDensity }, formatLabel (bar) { - let label = [] + const label = [] label.push('#' + bar.d.number) label.push('txd:' + bar.d.txDensity) label.push('txs:' + bar.d.transactions) @@ -67,14 +67,14 @@ export default { } }, mounted () { - let vm = this + const vm = this this.$nextTick(() => { vm.onResize() }) }, watch: { asize () { - let vm = this + const vm = this this.$nextTick(() => { vm.onResize() }) @@ -97,20 +97,20 @@ export default { let { txDensity } = _metadata txDensity = getTxDensity(txDensity) transactions = transactions.length - let time = this.blocks[0].timestamp - timestamp + const time = this.blocks[0].timestamp - timestamp return { timestamp, txDensity, number, transactions, time } }) } }, methods: { onResize () { - let w = this.$el.parentElement.offsetWidth - let h = w / 3.5 + const w = this.$el.parentElement.offsetWidth + const h = w / 3.5 this.size = Object.assign({}, { w, h }) }, barClick (event) { - let bar = event.bar || {} - let blockNumber = (bar.d) ? bar.d.number : null + const bar = event.bar || {} + const blockNumber = (bar.d) ? bar.d.number : null if (blockNumber) this.$router.push({ path: `${ROUTES.block}/${blockNumber}` }) } } diff --git a/src/components/TxFilters.vue b/src/components/TxFilters.vue index 33ff46e5..9d3817e6 100644 --- a/src/components/TxFilters.vue +++ b/src/components/TxFilters.vue @@ -20,8 +20,8 @@ export default { }, created () { this.filterValues = this.q.txType || [] - let filters = this.txFilters - let types = this.txTypes + const filters = this.txFilters + const types = this.txTypes Object.keys(types).forEach(v => { filters[types[v]] = (v === 'default') }) }, computed: { @@ -33,9 +33,9 @@ export default { ...mapActions(['updateRouterQuery']), ...mapGetters(['removePaginationFromRoute', 'qKey']), update () { - let key = this.reqKey - let qKey = this.qKey()(key) - let q = Object.assign({}, this.q) + const key = this.reqKey + const qKey = this.qKey()(key) + const q = Object.assign({}, this.q) q.txType = this.filterValues let query = { [qKey]: q } query = this.removePaginationFromRoute()('data', query) diff --git a/src/components/TxPool.vue b/src/components/TxPool.vue index b4015e5f..da8b87d2 100644 --- a/src/components/TxPool.vue +++ b/src/components/TxPool.vue @@ -43,7 +43,7 @@ export default { type: 'MonotoneX', style: { 'stroke-width': 2, - 'opacity': 0.6 + opacity: 0.6 }, gradient: { fill: false, @@ -61,12 +61,12 @@ export default { } }, colorCb: (x, d) => { - let color = this.blockColor(d.blockNumber) + const color = this.blockColor(d.blockNumber) return color }, formatLabel: bar => { - let time = bar.d.timestamp - let fill = this.blockColor(bar.d.blockNumber) + const time = bar.d.timestamp + const fill = this.blockColor(bar.d.blockNumber) return [ ({ style: { fill }, txt: `#${bar.d.blockNumber}` }), (`pending: ${bar.d.pending}`), @@ -103,7 +103,7 @@ export default { chart: state => state.backend.txPoolChart }), txs () { - let data = this.txPool.txs || [] + const data = this.txPool.txs || [] return (data.length) ? { data } : null }, options () { @@ -116,7 +116,7 @@ export default { }), blockColor (block) { - let bc = this.getBlockColor() + const bc = this.getBlockColor() return bc(block) } } diff --git a/src/components/VerifyContract.vue b/src/components/VerifyContract.vue index 28e01c79..b15a34c2 100644 --- a/src/components/VerifyContract.vue +++ b/src/components/VerifyContract.vue @@ -151,7 +151,7 @@ export default { } }, created () { - let { contractAddress, id } = this.$route.params + const { contractAddress, id } = this.$route.params this.getVersions() this.reset() if (id) this.setVerificationId(id) @@ -169,19 +169,19 @@ export default { }, verificationResultData () { - let { data } = this.verificationResult || {} + const { data } = this.verificationResult || {} return data }, verificationErrors () { - let data = this.verificationResultData || {} - let { result } = data + const data = this.verificationResultData || {} + const { result } = data return (result) ? result.errors : null }, verificationDone () { - let { verificationResultData } = this - let { match } = (verificationResultData) || {} + const { verificationResultData } = this + const { match } = (verificationResultData) || {} return undefined !== match }, @@ -189,19 +189,19 @@ export default { return this.verificationDone && this.verificationResultData.match === true }, isWaiting () { - let requesting = Object.values(KEYS).map(key => this.isRequesting()(key)).find(v => v !== null) + const requesting = Object.values(KEYS).map(key => this.isRequesting()(key)).find(v => v !== null) return (requesting || this.timer) && !this.verificationDone }, isWaitingForVerification () { - let { verificationId, verificationResult } = this - let requestingVerification = this.isRequesting()(KEYS.verificationResult) + const { verificationId, verificationResult } = this + const requestingVerification = this.isRequesting()(KEYS.verificationResult) return verificationId && !verificationResult && requestingVerification }, verifierResponse () { let { data, error, updateError } = this.getPage()(KEYS.verify) error = error || updateError if (data && data.id) { - let { id } = data + const { id } = data this.setVerificationId(id) } return { data, error } @@ -213,7 +213,7 @@ export default { return this.isRequesting()(KEYS.verify) }, contract () { - let { data, error } = this.getPage()(KEYS.contract) || {} + const { data, error } = this.getPage()(KEYS.contract) || {} return { data, error } }, contractData () { @@ -226,11 +226,11 @@ export default { return data }, isVerified () { - let { data } = this.getPage()(KEYS.isVerified) + const { data } = this.getPage()(KEYS.isVerified) return data }, isVerifiable () { - let { isVerified, contract, verificationId } = this + const { isVerified, contract, verificationId } = this return !isVerified && contract.data && !verificationId }, isNotAContract () { @@ -239,20 +239,20 @@ export default { return address && isAddress(address) && data === null && error }, versionsData () { - let { data } = this.getPage()(VERSIONS_KEY) || {} + const { data } = this.getPage()(VERSIONS_KEY) || {} return data }, versionsDataError () { - let { error } = this.getPage()(VERSIONS_KEY) || {} + const { error } = this.getPage()(VERSIONS_KEY) || {} return error }, verifierConnectionErrors () { - let { contractVerifierEnabled, versionsDataError } = this - let { verifierResponse } = this + const { contractVerifierEnabled, versionsDataError } = this + const { verifierResponse } = this return contractVerifierEnabled === false || versionsDataError || verifierResponse.error }, versions () { - let { showAllVersions, versionsData } = this + const { showAllVersions, versionsData } = this let { builds, releases } = versionsData if (builds) builds = this.buildsList(builds) if (releases) releases = this.releasesList(releases) @@ -260,32 +260,32 @@ export default { }, evmVersions () { - let { data } = this.getPage()(EVM_VERSIONS_KEY) || {} + const { data } = this.getPage()(EVM_VERSIONS_KEY) || {} return data }, isReadyToSend () { - let { address, settings, files, version, name, libs } = this - let libraries = libs.reduce((v, a, i) => { - let { name, address } = a + const { address, settings, files, version, name, libs } = this + const libraries = libs.reduce((v, a, i) => { + const { name, address } = a if (address && name) { v[name] = address } return v }, {}) - let params = Object.assign({}, { address, settings, version, name }) + const params = Object.assign({}, { address, settings, version, name }) let ready = !Object.values(params).filter(v => undefined === v).length ready = (files.length) ? ready : false if (!ready) return false - let imports = [...files] - let source = imports[0].contents + const imports = [...files] + const source = imports[0].contents return Object.assign(params, { imports, source, libraries }) }, hasFiles () { return !!this.files.length }, addressIsOk () { - let { address } = this + const { address } = this return (isAddress(address)) ? address : undefined }, formErrors () { @@ -296,7 +296,7 @@ export default { ] }, isIdOutDated () { - let id = this.verificationId + const id = this.verificationId if (!id) return return ObjectIdSecondsElapsed(id) > ID_TIMEOUT_SECONDS } @@ -326,7 +326,7 @@ export default { this.setVerificationId(undefined) }, addLibrary () { - let empty = this.libs.find(l => l.name === '') + const empty = this.libs.find(l => l.name === '') if (!empty) this.libs.push({ name: '', address: '' }) }, cssClass (input) { @@ -343,7 +343,7 @@ export default { }, setVerificationId (id) { - let { address } = this + const { address } = this if (id === this.verificationId) return this.verificationId = id this.$router.replace({ params: { contractAddress: address, id } }) @@ -358,7 +358,7 @@ export default { const key = KEYS.verificationResult if (this.isRequesting()(key)) return if (this.verificationDone || this.verificationErrors) return - let id = this.verificationId + const id = this.verificationId if (id) { this.fetch({ key, params: { id }, action: 'getVerificationResult' }) this.timer = setTimeout(() => { @@ -406,14 +406,14 @@ export default { }, buildsList (builds) { return builds.concat().reverse().reduce((v, a, i) => { - let { longVersion } = a + const { longVersion } = a v[longVersion] = longVersion return v }, {}) }, releasesList (releases) { - let newReleases = Object.assign({}, releases) - for (let p in newReleases) { + const newReleases = Object.assign({}, releases) + for (const p in newReleases) { newReleases[p] = newReleases[p].replace('soljson-v', '').replace('.js', '') } return newReleases @@ -426,7 +426,7 @@ export default { }, submit () { - let params = this.isReadyToSend + const params = this.isReadyToSend if (params) return this.requestVerification(params) this.clearErrors() if (!this.version) this.inputErrors.add('version') @@ -435,14 +435,14 @@ export default { }, async requestVerification (request) { - let action = 'verify' - let key = KEYS.verify + const action = 'verify' + const key = KEYS.verify return this.fetch({ action, params: { request }, key }) }, goToContractPage () { - let { address } = this - let path = `/${ROUTES.address}/${address}` - let query = { '__ctab': 'code' } + const { address } = this + const path = `/${ROUTES.address}/${address}` + const query = { __ctab: 'code' } this.$router.push({ path, query }) } } diff --git a/src/components/WaitingDots.vue b/src/components/WaitingDots.vue index bbbcb1c0..e5a73170 100644 --- a/src/components/WaitingDots.vue +++ b/src/components/WaitingDots.vue @@ -41,11 +41,11 @@ export default { return this.size / 2 }, width () { - let { size, dots, space } = this + const { size, dots, space } = this return size * dots + space * (dots + 1) }, viewBox () { - let { width, size } = this + const { width, size } = this return `0 0 ${width} ${size}` } }, @@ -54,9 +54,9 @@ export default { this.interval = requestAnimationFrame(this.tick) }, tick () { - let { lastTick, drawDots } = this - let time = Date.now() - let d = 1 + Math.pow(drawDots, 2) + const { lastTick, drawDots } = this + const time = Date.now() + const d = 1 + Math.pow(drawDots, 2) if (time - (this.dotDuration / d) > lastTick) { this.lastTick = time this.animate() @@ -64,7 +64,7 @@ export default { this.nextFrame() }, animate () { - let { drawDots, dots } = this + const { drawDots, dots } = this if (drawDots >= dots) { this.direction = -1 } diff --git a/src/components/controls/CopyButton.vue b/src/components/controls/CopyButton.vue index c4d3ea27..f9c73f58 100644 --- a/src/components/controls/CopyButton.vue +++ b/src/components/controls/CopyButton.vue @@ -20,7 +20,7 @@ export default { }, computed: { targetNode () { - let { refName, target } = this + const { refName, target } = this return (target) || this.$refs[refName] } }, diff --git a/src/components/controls/CtrlBigText.vue b/src/components/controls/CtrlBigText.vue index b1f818d7..15fa32a1 100644 --- a/src/components/controls/CtrlBigText.vue +++ b/src/components/controls/CtrlBigText.vue @@ -36,7 +36,7 @@ export default { return this.$slots.default }, style () { - let { height } = this + const { height } = this return { height } }, copyTitle () { diff --git a/src/components/controls/CtrlFiles.vue b/src/components/controls/CtrlFiles.vue index af656c2b..cd0a542c 100644 --- a/src/components/controls/CtrlFiles.vue +++ b/src/components/controls/CtrlFiles.vue @@ -46,27 +46,27 @@ export default { } }, created () { - let { loadFiles } = this + const { loadFiles } = this if (loadFiles) { this.files = [...loadFiles] } }, methods: { clickFile () { - let ctrl = this.$refs.filesInput + const ctrl = this.$refs.filesInput ctrl.click() }, async addFiles (event) { try { - let { target } = event - let files = [...target.files] + const { target } = event + const files = [...target.files] target.value = null - for (let file of files) { - let { name } = file - let contents = await readTextFile(file) + for (const file of files) { + const { name } = file + const contents = await readTextFile(file) if (contents) { if (this.findFileKey(name) < 0) { - let file = { name, contents } + const file = { name, contents } if (this.multiple) this.files.push(file) else this.files = [file] this.emitChange() @@ -84,14 +84,14 @@ export default { }, removeFile (fileName) { - let files = [...this.files] - let key = this.findFileKey(fileName, files) + const files = [...this.files] + const key = this.findFileKey(fileName, files) if (key > -1) files.splice(key, 1) this.files = files this.emitChange() }, emitChange () { - let files = [...this.files] + const files = [...this.files] this.$emit('change', files) } } diff --git a/src/components/controls/CtrlRadioGrp.vue b/src/components/controls/CtrlRadioGrp.vue index 0cb7295f..0da084f6 100644 --- a/src/components/controls/CtrlRadioGrp.vue +++ b/src/components/controls/CtrlRadioGrp.vue @@ -27,7 +27,7 @@ export default { } }, created () { - let { values } = this + const { values } = this if (values) this.group = values }, methods: { diff --git a/src/components/controls/CtrlSearch.vue b/src/components/controls/CtrlSearch.vue index ecc9499c..a4ea454c 100644 --- a/src/components/controls/CtrlSearch.vue +++ b/src/components/controls/CtrlSearch.vue @@ -45,7 +45,7 @@ export default { } }, created () { - let { searchValue } = this + const { searchValue } = this if (searchValue) this.value = searchValue }, methods: { @@ -55,7 +55,7 @@ export default { }, input (event, type) { this.selectResult(0) - let value = event.target.value + const value = event.target.value this.value = value this.emit(event, type, value) }, @@ -64,8 +64,8 @@ export default { this.$emit(type, { value, event }) }, changeInput (event) { - let { fullPath } = this.$route - let vm = this + const { fullPath } = this.$route + const vm = this setTimeout(() => { if (!vm.selectedResult) { if (fullPath === vm.$route.fullPath) { @@ -78,7 +78,7 @@ export default { }, 200) }, onChange (event) { - let value = this.value + const value = this.value this.emit(event, 'change', value) this.clear() }, @@ -86,8 +86,8 @@ export default { this.selectedResult = result }, gotoResult (event, key) { - let result = this.results[key] - let { link } = result + const result = this.results[key] + const { link } = result if (link) this.$router.push(link) this.selectResult(key++) this.emitResult(event, result) @@ -99,15 +99,15 @@ export default { onKey (event) { let { selectedResult, results } = this if (!results || results.length < 1) return - let { code } = event + const { code } = event // open result if (['Enter'].includes(code) && selectedResult) { this.gotoResult(event, (selectedResult - 1)) return } // select results with arrows - let codes = { ArrowUp: -1, ArrowDown: 1 } - let direction = codes[code] + const codes = { ArrowUp: -1, ArrowDown: 1 } + const direction = codes[code] if (undefined === direction) return selectedResult = selectedResult || 0 selectedResult = selectedResult + (1 * direction) @@ -120,7 +120,7 @@ export default { }, computed: { totalResults () { - let { results } = this + const { results } = this return (results) ? results.length : 0 }, isLoading () { diff --git a/src/components/controls/CtrlSwitch.vue b/src/components/controls/CtrlSwitch.vue index ecab68aa..eef89fe5 100644 --- a/src/components/controls/CtrlSwitch.vue +++ b/src/components/controls/CtrlSwitch.vue @@ -20,7 +20,7 @@ export default { }, methods: { updateValue (event) { - let value = event.target.checked + const value = event.target.checked this.$emit('change', value) } } diff --git a/src/components/controls/DownloadButton.vue b/src/components/controls/DownloadButton.vue index a03f56e4..1f75ff35 100644 --- a/src/components/controls/DownloadButton.vue +++ b/src/components/controls/DownloadButton.vue @@ -28,8 +28,8 @@ export default { }, methods: { download (event) { - let { target, fileName, fileType } = this - let text = (target) ? target.value : this.value + const { target, fileName, fileType } = this + const text = (target) ? target.value : this.value downloadText(text, fileName, fileType) this.$emit('download') } diff --git a/src/config/content.js b/src/config/content.js index 34ef33ca..a37bc33c 100644 --- a/src/config/content.js +++ b/src/config/content.js @@ -1,5 +1,5 @@ export default { - 'footer': [ + footer: [ { text: 'Privacy Policy', link: 'https://www.rsk.co/privacy-policy' diff --git a/src/config/entities/address.js b/src/config/entities/address.js index 2c186960..2b0ca61e 100644 --- a/src/config/entities/address.js +++ b/src/config/entities/address.js @@ -3,7 +3,7 @@ import { tokenAmount } from '../../filters/TokensFilters' const addressFormatRow = (data, parentData) => { data._totalSupplyResult = totalSupplyField(data) - let decimals = data.decimals + const decimals = data.decimals data.decimals = (decimals && decimals !== '0x0') ? decimals : null return data } @@ -28,9 +28,9 @@ const Addresses = () => { // type const Address = () => { - let address = Addresses() + const address = Addresses() address.formatRow = addressFormatRow - let fields = Object.assign(address.fields, { + const fields = Object.assign(address.fields, { address: { trim: 'auto' }, @@ -87,8 +87,8 @@ export const address = Address() export const addresses = Addresses() export const totalSupplyField = data => { - let totalSupply = data.totalSupply - let decimals = data.decimals + const totalSupply = data.totalSupply + const decimals = data.decimals if ((totalSupply && totalSupply !== '0x0') && decimals) { return tokenAmount(totalSupply, decimals) } diff --git a/src/config/entities/block.js b/src/config/entities/block.js index f675758b..5606e1c0 100644 --- a/src/config/entities/block.js +++ b/src/config/entities/block.js @@ -35,7 +35,7 @@ const Blocks = () => { } const Block = () => { - let block = Blocks() + const block = Blocks() block.fields = Object.assign(block.fields, { hash: { trim: 'auto' @@ -93,7 +93,7 @@ const Block = () => { } const MiningFields = () => { - let miner = Block().fields + const miner = Block().fields return { miner, bitcoinMergedMiningHeader: { trim: 'auto' }, @@ -104,8 +104,8 @@ const MiningFields = () => { } const BlockBox = () => { - let blocks = Blocks() - let { txDensity, blockHashrate } = Block().fields + const blocks = Blocks() + const { txDensity, blockHashrate } = Block().fields blocks.fields = Object.assign(blocks.fields, { miner: { trim: 4 @@ -117,7 +117,7 @@ const BlockBox = () => { } const BlockMining = () => { - let block = Block() + const block = Block() block.fields = MiningFields() return block } diff --git a/src/config/entities/event.js b/src/config/entities/event.js index c5c0615f..5094aad0 100644 --- a/src/config/entities/event.js +++ b/src/config/entities/event.js @@ -17,7 +17,7 @@ export const eventFormatRow = (event, parentData) => { const addressData = (parentData.address) ? parentData : event._addressData || {} event = formatEvent(event, addressData) // event.address = setThisContract(event.address, addressData) - let contractAddress = event.address + const contractAddress = event.address event._contractAddress = contractAddress return event } @@ -51,7 +51,7 @@ export const Events = () => { } export const EventFields = () => { - let event = Events() + const event = Events() let fields = Object.assign({ eventId: { type: 'eventId', @@ -104,9 +104,9 @@ export const EventFields = () => { } const eventFieldsFormatter = (fields, event) => { - let config = getEventConfig(event) - let cFields = config.fields || getEventAbiFields(event) - let hide = !cFields + const config = getEventConfig(event) + const cFields = config.fields || getEventAbiFields(event) + const hide = !cFields fields.eventArguments.fields = cFields fields.eventArguments.hide = hide fields.arguments.hide = !hide @@ -114,7 +114,7 @@ const eventFieldsFormatter = (fields, event) => { } export const Event = () => { - let event = Events() + const event = Events() event.fields = EventFields() delete event.fields.address event.formatFields = eventFieldsFormatter @@ -122,19 +122,19 @@ export const Event = () => { } export const EventData = () => { - let eventFields = Event().fields - let formatRow = Event().formatRow - let { transaction, blockNumber } = eventFields - let txLogFields = TxLogItem().fields + const eventFields = Event().fields + const formatRow = Event().formatRow + const { transaction, blockNumber } = eventFields + const txLogFields = TxLogItem().fields txLogFields.logIndex.link = () => { } txLogFields.eventId.field = 'eventId' - let fields = Object.assign(txLogFields, { transaction, blockNumber }) + const fields = Object.assign(txLogFields, { transaction, blockNumber }) return { formatRow, fields } } export const TransferEvents = () => { - let { from, to, value, date, created } = EventTransferFields() - let te = { + const { from, to, value, date, created } = EventTransferFields() + const te = { fields: { event: Events().fields.event, contract: { @@ -148,8 +148,8 @@ export const TransferEvents = () => { created }, formatRow: (data, parentData) => { - let eventData = formatEvent(data) - let event = eventData._arguments + const eventData = formatEvent(data) + const event = eventData._arguments const { _addressData, address } = data if (!event) return event.eventId = eventData.eventId diff --git a/src/config/entities/lib/eventsLib.js b/src/config/entities/lib/eventsLib.js index 16705c77..2cb39770 100644 --- a/src/config/entities/lib/eventsLib.js +++ b/src/config/entities/lib/eventsLib.js @@ -7,7 +7,7 @@ export const EVENTS_TYPES = { } export const EventTransferFields = (include) => { - let fields = { + const fields = { from: { type: 'eventAddress', trim: 'auto' @@ -47,8 +47,8 @@ export const EVENTS = [ type: EVENTS_TYPES.TRANSFER }, { - 'method': 'Transfer(address,address,uint256,bytes)', - 'signature': 'e19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16', + method: 'Transfer(address,address,uint256,bytes)', + signature: 'e19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16', fields: EventTransferFields(['from', 'to', 'value', 'data']), type: EVENTS_TYPES.TRANSFER } @@ -65,7 +65,7 @@ export const formatEvent = (event, data) => { // non-standard remasc events if (isRemascEvent(event)) config = remascEventConfig() - let args = eventArgs(event, config) + const args = eventArgs(event, config) if (args) event._arguments = args if (config) event._config = config return event @@ -78,18 +78,18 @@ export const getEventConfig = (event) => { } export const getEventInputs = event => { - let inputs = (event.abi) ? event.abi.inputs : [] + const inputs = (event.abi) ? event.abi.inputs : [] return inputs || [] } export const eventArgs = (event, { fields }) => { - let inputs = getEventInputs(event) + const inputs = getEventInputs(event) fields = fields || {} - let names = Object.keys(fields) || [] + const names = Object.keys(fields) || [] if (event.abi) { event.args = event.args || [] return inputs.map(i => i.name).reduce((v, a, i) => { - let name = names[i] || a + const name = names[i] || a v[name] = event.args[i] return v }, {}) @@ -97,11 +97,11 @@ export const eventArgs = (event, { fields }) => { } export const getEventConfigBySignature = signature => { - let config = EVENTS.find(e => e.signature === signature) || {} - let fields = config.fields + const config = EVENTS.find(e => e.signature === signature) || {} + const fields = config.fields if (fields) { - for (let name in fields) { - let field = fields[name] || {} + for (const name in fields) { + const field = fields[name] || {} field.field = ['_arguments', name] fields[name] = field } @@ -110,11 +110,11 @@ export const getEventConfigBySignature = signature => { } export const getEventAbiFields = event => { - let inputs = getEventInputs(event) + const inputs = getEventInputs(event) return inputs.reduce((v, a, i) => { - let { type, name } = a - let trim = (type === 'address') ? 'auto' : 0 - let field = ['_arguments', name] + const { type, name } = a + const trim = (type === 'address') ? 'auto' : 0 + const field = ['_arguments', name] v[name] = { type, field, trim } return v }, {}) diff --git a/src/config/entities/tokenAccount.js b/src/config/entities/tokenAccount.js index c7633c69..2460f0d4 100644 --- a/src/config/entities/tokenAccount.js +++ b/src/config/entities/tokenAccount.js @@ -14,7 +14,7 @@ const formatLink = (data, parentData, link, key) => { } const accountFormatRow = (data, parentData) => { - let balance = data.balance + const balance = data.balance const contractData = data._contractData || parentData || {} let decimals = contractData.decimals || 0 data.contractName = contractData.name @@ -56,7 +56,7 @@ export const TokenAccounts = () => { } const TokenAccount = () => { - let tokenAccount = TokenAccounts() + const tokenAccount = TokenAccounts() tokenAccount.fields = Object.assign(TokenAccounts().fields, { address: { field: 'address', @@ -77,12 +77,12 @@ const TokenAccount = () => { } const TokenByAddress = () => { - let taFields = TokenAccount().fields + const taFields = TokenAccount().fields return { link: accountLink, formatRow: (data, parentData) => { - let { decimals, name, symbol } = data - let row = accountFormatRow(data, { decimals, name, symbol }) + const { decimals, name, symbol } = data + const row = accountFormatRow(data, { decimals, name, symbol }) row.contractAddress = setThisContract(data.contract, data) return row }, diff --git a/src/config/entities/transaction.js b/src/config/entities/transaction.js index def40054..b7db7370 100644 --- a/src/config/entities/transaction.js +++ b/src/config/entities/transaction.js @@ -29,7 +29,7 @@ const transactionFee = tx => { const transactionFormatRow = (tx, parentData) => { let address - let contractAddress = (tx.receipt) ? tx.receipt.contractAddress : null + const contractAddress = (tx.receipt) ? tx.receipt.contractAddress : null if (parentData) address = parentData.address if (address) { tx.from = setThisAddress(tx.from, { address }) @@ -54,7 +54,7 @@ export const txStatusCss = status => { QUEUED: 'blue', PENDING: 'yellow' } - let key = Object.keys(STATUS).map(k => k).find(k => STATUS[k] === status) + const key = Object.keys(STATUS).map(k => k).find(k => STATUS[k] === status) return css[key] || '' } @@ -83,7 +83,7 @@ const TxFields = () => { return txStatusCss(txStatus((data.receipt) ? data.receipt.status : data.status || '')) }, link: (tx, value) => { - let contractAddress = (tx.receipt) ? tx.receipt.contractAddress : null + const contractAddress = (tx.receipt) ? tx.receipt.contractAddress : null return txLink(contractAddress || value) } }, @@ -116,7 +116,7 @@ const TxFields = () => { } } const Txs = () => { - let fields = TxFields() + const fields = TxFields() delete (fields.index) fields.status = Object.assign(fields.status, { filters: ['tx-icon'], @@ -148,8 +148,8 @@ const Txs = () => { } export const Tx = () => { - let tx = Txs() - let fields = TxFields() + const tx = Txs() + const fields = TxFields() const time = fields.time delete fields.gas delete fields.time @@ -213,7 +213,7 @@ export const Tx = () => { } const TxBox = () => { - let txs = Txs() + const txs = Txs() txs.fields.to.trim = 'auto' txs.fields.from.trim = 'auto' txs.fields.hash.trim = 8 @@ -222,7 +222,7 @@ const TxBox = () => { export const TxLogFormatter = tx => { let logs = (tx.receipt) ? tx.receipt.logs : null - let addresses = tx._addresses + const addresses = tx._addresses if (logs && addresses) { logs = logs.map(log => { log._addressData = addresses[log.address] @@ -246,8 +246,8 @@ export const TxLogs = () => { type: 'transactionLogItem', emptyMsg: 'The transaction does not contain token transfer events', header: (data) => { - let { logIndex, address, event } = data - let _contractName = data._addressData.name + const { logIndex, address, event } = data + const _contractName = data._addressData.name return [logIndex, _contractName, address, event] } } @@ -299,7 +299,7 @@ export const TxLogItem = () => { } export const TxTransferEvents = () => { - let te = TxLogs() + const te = TxLogs() te.formatRow = (tx) => { tx = TxLogFormatter(tx) let logs = (tx.receipt && tx.receipt.logs) ? tx.receipt.logs : [] diff --git a/src/config/entities/txPool.js b/src/config/entities/txPool.js index 6cbef6c5..43be1c47 100644 --- a/src/config/entities/txPool.js +++ b/src/config/entities/txPool.js @@ -1,8 +1,8 @@ import { Transactions, Tx, txStatusCss } from './transaction' const pool = () => { - let pool = Transactions() - let fields = ['hash', 'gas', 'from', 'to', 'value'] + const pool = Transactions() + const fields = ['hash', 'gas', 'from', 'to', 'value'] Object.keys(pool.fields).forEach(f => { if (!fields.includes(f)) delete pool.fields[f] }) diff --git a/src/config/entities/verifiedContracts.js b/src/config/entities/verifiedContracts.js index 7dc9ddc9..e2a2ffa0 100644 --- a/src/config/entities/verifiedContracts.js +++ b/src/config/entities/verifiedContracts.js @@ -1,7 +1,7 @@ export const externalLibraries = { fields: {}, formatFields: (fields, data) => { - for (let fieldName in data) { + for (const fieldName in data) { fields[fieldName] = { type: 'address', trim: 'auto' } } return fields diff --git a/src/config/messages.js b/src/config/messages.js index 5b2b755e..67fd4dce 100644 --- a/src/config/messages.js +++ b/src/config/messages.js @@ -1,9 +1,9 @@ export default { - 'DB_OUTDATED': { - 'title': 'Warning:', - 'txt': 'The database is not up to date', - 'type': 'error', - 'icon': 'warning' + DB_OUTDATED: { + title: 'Warning:', + txt: 'The database is not up to date', + type: 'error', + icon: 'warning' }, INTERNAL_TX_WARN: { title: 'Note:', diff --git a/src/config/texts/verifyContract.js b/src/config/texts/verifyContract.js index 6e1aea6c..e8c56728 100644 --- a/src/config/texts/verifyContract.js +++ b/src/config/texts/verifyContract.js @@ -30,6 +30,6 @@ export const formFields = { RUNS: add('Optimization runs'), EVM: add('EVM version', ''), LIBRARIES: add('Contract Libraries', 'If the contract uses external libraries, add them here'), - LIB_NAME: add('Library name', `The name of the library called by contract`, { placeholder: 'MyLibrary' }), + LIB_NAME: add('Library name', 'The name of the library called by contract', { placeholder: 'MyLibrary' }), LIB_ADDRESS: add('Library Address', 'Address of deployed library', { placeholder: '0x1000000000000000000000000000000000000001' }) } diff --git a/src/directives/hljs.js b/src/directives/hljs.js index 281536ad..0fa16cf5 100644 --- a/src/directives/hljs.js +++ b/src/directives/hljs.js @@ -10,7 +10,7 @@ highlightjs.registerLanguage('solidity', solidity) export const hljs = Vue.directive('hljs', { deep: true, bind: function (el, binding) { - let targets = el.querySelectorAll('code') + const targets = el.querySelectorAll('code') targets.forEach((target) => { if (binding.value) { target.textContent = binding.value @@ -19,7 +19,7 @@ export const hljs = Vue.directive('hljs', { }) }, componentUpdated: function (el, binding) { - let targets = el.querySelectorAll('code') + const targets = el.querySelectorAll('code') targets.forEach((target) => { if (binding.value) { target.textContent = binding.value diff --git a/src/filters/BigNumberFilters.js b/src/filters/BigNumberFilters.js index 12d12f3a..7886aa66 100644 --- a/src/filters/BigNumberFilters.js +++ b/src/filters/BigNumberFilters.js @@ -23,7 +23,7 @@ export const newBigNumber = value => { if (typeof value === 'object') { if (isSerializedBigNumber(value)) return unserializeBigNumber(value) if (typeof value === 'object' && undefined !== value.c && undefined !== value.e && undefined !== value.s) { - let bn = new BigNumber(0) + const bn = new BigNumber(0) bn.c = value.c bn.e = value.e bn.s = value.s diff --git a/src/filters/NumberFilters.js b/src/filters/NumberFilters.js index cadaab88..9501fae6 100644 --- a/src/filters/NumberFilters.js +++ b/src/filters/NumberFilters.js @@ -6,12 +6,12 @@ export const numerals = Vue.filter('numerals', (num, fixed) => { num = Number(num) if (!fixed) fixed = 1 fixed++ - let prefix = d3.format('.' + fixed + 's') + const prefix = d3.format('.' + fixed + 's') return prefix(num) }) export const numeralsSuffix = Vue.filter('numerals-suffix', (num) => { - let value = numerals(num) + const value = numerals(num) return value.replace(/\d/g, '').replace(/\./g, '') }) @@ -26,7 +26,7 @@ export const toInt = Vue.filter('to-int', (value) => { }) export const locale = Vue.filter('locale', (value) => { - let format = d3.format(',d') + const format = d3.format(',d') return format(value) }) diff --git a/src/filters/TextFilters.js b/src/filters/TextFilters.js index f6bb87be..b85a5c5b 100644 --- a/src/filters/TextFilters.js +++ b/src/filters/TextFilters.js @@ -18,7 +18,7 @@ export const camelCaseTo = Vue.filter('camel-case-to', (value, to = ' ') => { }) export const getTxStatus = value => { - let intValue = parseInt(value) + const intValue = parseInt(value) if (!isNaN(intValue)) { if (intValue === 1) value = 'SUCCESS' else value = 'FAIL' @@ -34,6 +34,6 @@ export const txStatus = Vue.filter('tx-status', value => { export const txIcon = Vue.filter('tx-icon', value => STATUS_ICONS[getTxStatus(value)]) export const checksumAddress = Vue.filter('checksum-address', address => { - let chainId = store.getters.chainId + const chainId = store.getters.chainId return toChecksumAddress(address, chainId) }) diff --git a/src/filters/TimeFilters.js b/src/filters/TimeFilters.js index 76635e0e..a1f09bbb 100644 --- a/src/filters/TimeFilters.js +++ b/src/filters/TimeFilters.js @@ -3,13 +3,13 @@ import * as moment from 'moment' import { isDigits } from './NumberFilters.js' export const tSecondsAgo = Vue.filter('t-seconds-ago', timestamp => { - let time = moment(timestamp).format('s') + const time = moment(timestamp).format('s') return sAgo(time) }) export const mSecondsAgo = Vue.filter('m-seconds-ago', miliseconds => { if (!miliseconds) return 0 - let seconds = mToSeconds(miliseconds) + const seconds = mToSeconds(miliseconds) return sAgo(seconds) }) @@ -41,7 +41,7 @@ export const abbreviatedTimeObj = time => { if (time < 1000) return { time, suffix } time = Math.floor(time / 1000) if (time < 1) return { time, suffix } - let ts = { + const ts = { s: 60, m: 3600, h: 86400, // 60*60*24 @@ -51,8 +51,8 @@ export const abbreviatedTimeObj = time => { suffix = 's' let ant = 1 if (time < 60) return { time, suffix } - for (let t in ts) { - let seconds = ts[t] + for (const t in ts) { + const seconds = ts[t] suffix = t if (time < seconds) { time = time / ant @@ -65,13 +65,13 @@ export const abbreviatedTimeObj = time => { } export const abbrTime = Vue.filter('abbr-time', time => { - let obj = abbreviatedTimeObj(time) + const obj = abbreviatedTimeObj(time) return obj.time + '' + obj.suffix }) export const abbrTimeSeconds = Vue.filter('abbr-time-seconds', time => { if (time < 900) return '0s' - let obj = abbreviatedTimeObj(time) + const obj = abbreviatedTimeObj(time) return obj.time + '' + obj.suffix }) @@ -82,7 +82,7 @@ export const sSeconds = Vue.filter('s-seconds', time => { export const formatDate = Vue.filter('format-date', (timestamp, format = 'YYYY/MM/DD HH:mm:ss') => { timestamp = Number(timestamp) - let date = new Date(timestamp) + const date = new Date(timestamp) return moment(String(date.toISOString())).format(format) }) @@ -102,6 +102,6 @@ export const miliseconds = Vue.filter('miliseconds', time => { time = parseInt(time) if (time === 0) return time if (time < 1000) return time + 'ms' - let seconds = Math.floor(time / 1000) + const seconds = Math.floor(time / 1000) return sAgo(seconds) }) diff --git a/src/filters/TokensFilters.js b/src/filters/TokensFilters.js index 4506be62..5d70e90f 100644 --- a/src/filters/TokensFilters.js +++ b/src/filters/TokensFilters.js @@ -9,8 +9,8 @@ export const tokenAmount = (value, decimals = 18) => { decimals = decimals || 0 // if (decimals === 0) return value decimals = newBigNumber(decimals) - let ret = newBigNumber(value) - let divisor = new BigNumber(10).exponentiatedBy(decimals.toNumber()) + const ret = newBigNumber(value) + const divisor = new BigNumber(10).exponentiatedBy(decimals.toNumber()) return ret.dividedBy(divisor) } diff --git a/src/lib/js/EntityParser.js b/src/lib/js/EntityParser.js index 4a1f1f2d..a2a44df8 100644 --- a/src/lib/js/EntityParser.js +++ b/src/lib/js/EntityParser.js @@ -6,22 +6,25 @@ export class EntityParser { this.entities = entities this.fieldsTypes = fields } + setFields (fields) { this.fields = fields } + parse () { - let res = {} - for (let name in this.entities) { + const res = {} + for (const name in this.entities) { res[name] = this.parseEntity(name, this.entities[name]) } return res } + parseEntity (name, entity) { entity.fields = entity.fields || {} entity.fieldsKeys = {} - for (let f in entity.fields) { - let field = entity.fields[f] || {} - let parsedField = this.parseField(f, field) + for (const f in entity.fields) { + const field = entity.fields[f] || {} + const parsedField = this.parseField(f, field) entity.fields[f] = parsedField entity.fieldsKeys[parsedField.field] = f } @@ -34,7 +37,7 @@ export class EntityParser { } export const defValue = (field, keys, def) => { - for (let key of keys) { + for (const key of keys) { field[key] = field[key] || def[key] } return field @@ -53,11 +56,11 @@ export const parseField = (name, field, fieldsTypes) => { field.titleIcon = field.titleIcon || false field.hideTitle = field.hideTitle || false field.title = field.title || name - let fieldDef = fieldsTypes[field.type] + const fieldDef = fieldsTypes[field.type] if (fieldDef) { field.description = field.description || fieldDef.description || null if (fieldDef.filters) { - let filters = field.filters || [] + const filters = field.filters || [] field.filters = filters.concat(fieldDef.filters) } field = defValue( diff --git a/src/lib/js/EtherUnits.js b/src/lib/js/EtherUnits.js index 76441265..b5c3a277 100644 --- a/src/lib/js/EtherUnits.js +++ b/src/lib/js/EtherUnits.js @@ -32,7 +32,7 @@ export class EtherUnits { getValueOfUnit (unit) { unit = unit ? unit.toLowerCase() : 'ether' - let unitValue = this.unitMap[unit] + const unitValue = this.unitMap[unit] if (unitValue === undefined) { // eslint-disable-next-line console.log('ERROR') @@ -41,7 +41,7 @@ export class EtherUnits { } fiatToWei (number, pricePerEther) { - let returnValue = new BigNumber(String(number)) + const returnValue = new BigNumber(String(number)) .div(pricePerEther) .times(this.getValueOfUnit('ether')) .round(0) @@ -49,19 +49,21 @@ export class EtherUnits { } toFiat (number, unit, multi) { - let returnValue = new BigNumber(this.toEther(number, unit)) + const returnValue = new BigNumber(this.toEther(number, unit)) .times(multi) .round(5) return returnValue.toString(10) } + toEther (number, unit) { - let returnValue = new BigNumber(this.toWei(number, unit)).div( + const returnValue = new BigNumber(this.toWei(number, unit)).div( this.getValueOfUnit('ether') ) return returnValue.toString(10) } + toWei (number, unit) { - let returnValue = new BigNumber(String(number)).times( + const returnValue = new BigNumber(String(number)).times( this.getValueOfUnit(unit) ) return returnValue.toString(10) diff --git a/src/lib/js/decodeField.js b/src/lib/js/decodeField.js index e3417bae..621a4e00 100644 --- a/src/lib/js/decodeField.js +++ b/src/lib/js/decodeField.js @@ -12,10 +12,10 @@ export function decodeField (data, types) { try { types = types || ['hex', 'rlp', 'decimal', 'raw'] if (!data || !isHexString(data)) return - let decoded = {} - let selectedDecoders = Object.keys(DECODERS).filter(k => types.includes(k)) - for (let d of selectedDecoders) { - let decodedValue = DECODERS[d](data) + const decoded = {} + const selectedDecoders = Object.keys(DECODERS).filter(k => types.includes(k)) + for (const d of selectedDecoders) { + const decodedValue = DECODERS[d](data) if (decodedValue) decoded[d] = decodedValue } return decoded @@ -27,7 +27,7 @@ export function decodeField (data, types) { function rlpDecode (data) { const toStr = value => value.toString() try { - let decoded = rlp.decode(data) + const decoded = rlp.decode(data) return (Array.isArray(decoded)) ? decoded.map(d => toStr(d)) : toStr(decoded) } catch (err) { // console.log(err) diff --git a/src/lib/js/io.js b/src/lib/js/io.js index e3d99cbc..26f7436b 100644 --- a/src/lib/js/io.js +++ b/src/lib/js/io.js @@ -8,7 +8,7 @@ export const createLocStorage = () => { localStorage.setItem(key, data) }, get (key) { - let data = localStorage.getItem(key) + const data = localStorage.getItem(key) if (data !== null) { return JSON.parse(data) } @@ -21,8 +21,8 @@ export const locStorage = (isBrowser) ? createLocStorage() : {} export const downloadText = (content, name, type = 'json') => { name = name || `download.${type}` - let data = `data:text/${type};charset=utf-8,${encodeURIComponent(content)}` - let el = document.createElement('a') + const data = `data:text/${type};charset=utf-8,${encodeURIComponent(content)}` + const el = document.createElement('a') el.setAttribute('href', data) el.setAttribute('download', name) el.click() @@ -31,7 +31,7 @@ export const downloadText = (content, name, type = 'json') => { export const storageAvailable = (type) => { try { var storage = window[type] - let x = '__storage_test__' + const x = '__storage_test__' storage.setItem(x, x) storage.removeItem(x) return true @@ -60,7 +60,7 @@ export const readTextFile = (file, cb, type) => { if (type) { if (!file || file.type !== type) reject(new Error('file type mismatch')) } - let reader = new FileReader() + const reader = new FileReader() reader.onload = (event) => { resolve(event.target.result) } @@ -80,22 +80,17 @@ const copyTextStyle = { export const copyText = (targetNode, attributes) => { if (!targetNode) throw new Error('Invalid node') - let style = Object.entries(copyTextStyle).map(p => p.join(':')).join(';') + const style = Object.entries(copyTextStyle).map(p => p.join(':')).join(';') attributes = attributes || { style } - let value = targetNode.value || targetNode.innerText - let el = targetNode.parentNode - let ta = document.createElement('textarea') - for (let att in attributes) { + const value = targetNode.value || targetNode.innerText + const el = targetNode.parentNode + const ta = document.createElement('textarea') + for (const att in attributes) { ta.setAttribute(att, attributes[att]) } ta.value = value - let node = el.appendChild(ta) - try { - ta.select() - document.execCommand('copy') - el.removeChild(node) - return - } catch (err) { - throw err - } + const node = el.appendChild(ta) + ta.select() + document.execCommand('copy') + el.removeChild(node) } diff --git a/src/lib/js/menuItems.js b/src/lib/js/menuItems.js index e8ff7257..5a805b12 100644 --- a/src/lib/js/menuItems.js +++ b/src/lib/js/menuItems.js @@ -1,7 +1,7 @@ import { ROUTES as r } from '../../config/types' import items from '../../config/menu.js' const menuItems = {} -for (let item of items) { +for (const item of items) { menuItems[item] = r[item] } diff --git a/src/lib/js/units.js b/src/lib/js/units.js index 83e418cd..da2ef0d1 100644 --- a/src/lib/js/units.js +++ b/src/lib/js/units.js @@ -1,37 +1,37 @@ export const SI = { - 'y': 1e-24, - 'z': 1e-21, - 'a': 1e-18, - 'f': 1e-15, - 'p': 1e-12, - 'n': 1e-9, - 'µ': 1e-6, - 'm': 1e-3, - 'k': 1e3, - 'M': 1e6, - 'G': 1e9, - 'T': 1e12, - 'P': 1e15, - 'E': 1e18, - 'Z': 1e21, - 'Y': 1e24 + y: 1e-24, + z: 1e-21, + a: 1e-18, + f: 1e-15, + p: 1e-12, + n: 1e-9, + µ: 1e-6, + m: 1e-3, + k: 1e3, + M: 1e6, + G: 1e9, + T: 1e12, + P: 1e15, + E: 1e18, + Z: 1e21, + Y: 1e24 } export const SInames = { - 'y': 'yocto', - 'z': 'zepto', - 'a': 'atto', - 'f': 'femto', - 'p': 'pico', - 'n': 'nano', - 'µ': 'micro', - 'm': 'milli', - 'k': 'kilo', - 'M': 'mega', - 'G': 'giga', - 'T': 'tera', - 'P': 'peta', - 'E': 'exa', - 'Z': 'zetta', - 'Y': 'yotta' + y: 'yocto', + z: 'zepto', + a: 'atto', + f: 'femto', + p: 'pico', + n: 'nano', + µ: 'micro', + m: 'milli', + k: 'kilo', + M: 'mega', + G: 'giga', + T: 'tera', + P: 'peta', + E: 'exa', + Z: 'zetta', + Y: 'yotta' } diff --git a/src/lib/js/utils.js b/src/lib/js/utils.js index a644210e..d72a23ca 100644 --- a/src/lib/js/utils.js +++ b/src/lib/js/utils.js @@ -16,17 +16,17 @@ export const normalizeSearch = value => { export const plainObjectChanges = (oldObj, newObj) => { oldObj = oldObj || {} if (!newObj) return oldObj - let diff = Object.assign(Object.assign({}, oldObj), newObj) - for (let p in diff) { - let newValue = newObj[p] - let oldValue = oldObj[p] + const diff = Object.assign(Object.assign({}, oldObj), newObj) + for (const p in diff) { + const newValue = newObj[p] + const oldValue = oldObj[p] if (oldValue === newValue) delete diff[p] } return diff } export const ObjectIdToDate = id => { - let timestamp = String(id).substr(0, 8) + const timestamp = String(id).substr(0, 8) return new Date(parseInt(timestamp, 16) * 1000) } diff --git a/src/lib/js/validate.js b/src/lib/js/validate.js index 0aba6002..1be60daa 100644 --- a/src/lib/js/validate.js +++ b/src/lib/js/validate.js @@ -2,19 +2,19 @@ import { isAddress } from 'rsk-utils/dist/addresses' import { isHexString, isTxOrBlockHash, add0x } from 'rsk-utils/dist/strings' export const isValidBlockNumber = (value, lastBlock) => { - let number = parseInt(value) + const number = parseInt(value) // optional checks lastBlock lastBlock = lastBlock || number return number > -1 && number <= lastBlock } export const testSearchedValue = (value, { lastBlock } = {}) => { - let number = isValidBlockNumber(value, lastBlock) - let isHex = isHexString(value) - let hex = isHex && add0x(value) - let address = hex && isAddress(hex) - let transaction = isTxOrBlockHash(hex) - let blockHash = transaction - let block = (number || blockHash) ? { number, hash: blockHash } : undefined + const number = isValidBlockNumber(value, lastBlock) + const isHex = isHexString(value) + const hex = isHex && add0x(value) + const address = hex && isAddress(hex) + const transaction = isTxOrBlockHash(hex) + const blockHash = transaction + const block = (number || blockHash) ? { number, hash: blockHash } : undefined return { block, address, transaction } } diff --git a/src/main.with.tracking.js b/src/main.with.tracking.js index acd15484..c5fd9ec8 100644 --- a/src/main.with.tracking.js +++ b/src/main.with.tracking.js @@ -2,7 +2,7 @@ import { VueI, config } from './vue.instance' import VueGtag from 'vue-gtag' const { router } = config -const id = process.env['GA_TAG'] +const id = process.env.GA_TAG if (!id) throw new Error('Missing Google Analytics tag') VueI.use(VueGtag, { config: { id } diff --git a/src/mixins/common.js b/src/mixins/common.js index 4b22cb80..aedf334a 100644 --- a/src/mixins/common.js +++ b/src/mixins/common.js @@ -32,21 +32,21 @@ export default { 'filterFieldValue']), cellStyle (field, value) { if (field) { - let style = {} - let type = field.type + const style = {} + const type = field.type if (type === 'block') style.color = this.getBlockColor(value) return style } }, getEventPosition (event) { if (!event) return - let x = event.clientX - let y = event.clientY + const x = event.clientX + const y = event.clientY return { x, y } }, getRouterHashFromEvent (event) { - let pos = this.getEventPosition(event) - let hash = (pos) ? `${pos.x}:${pos.y}` : '' + const pos = this.getEventPosition(event) + const hash = (pos) ? `${pos.x}:${pos.y}` : '' return hash } } diff --git a/src/mixins/dataMixin.js b/src/mixins/dataMixin.js index d5275c7a..cf08a263 100644 --- a/src/mixins/dataMixin.js +++ b/src/mixins/dataMixin.js @@ -20,24 +20,24 @@ export default { return this.cbParse('formatLink') }, entity () { - let type = this.type + const type = this.type if (type) { - let entity = this.dataEntity()(type) + const entity = this.dataEntity()(type) // if (!entity) console.warn(`Warning, unknown entity: ${type}`) return entity } }, fields () { - let entity = this.entity || {} + const entity = this.entity || {} let fields = entity.fields if (entity) { - let parentData = this.parentData - let data = this.data + const parentData = this.parentData + const data = this.data if (fields) { - let fcb = this.fieldsCb + const fcb = this.fieldsCb if (fcb) { fields = fcb(fields, data, parentData) - for (let name in fields) { + for (const name in fields) { fields[name] = this.parseField(name, fields[name]) } } @@ -59,8 +59,8 @@ export default { }, dataFormatted () { let data = this.data || {} - let parentData = this.parentData || {} - let fields = this.fields + const parentData = this.parentData || {} + const fields = this.fields if (this.rowCb) { if (Array.isArray(data)) { data = data.map(row => { @@ -73,14 +73,14 @@ export default { return data }, dataKeys () { - let data = this.data + const data = this.data if (data) { if (data[0]) return Object.keys(data[0]) else return Object.keys(data) } }, iconLoad () { - let entity = this.entity + const entity = this.entity let icon = 'load' if (entity) icon = entity.icon || icon return icon @@ -104,8 +104,8 @@ export default { return parseField(name, field, fieldsTypes) }, fieldFromKey (key) { - let entity = this.entity - let keys = entity.fieldsKeys + const entity = this.entity + const keys = entity.fieldsKeys if (keys) { return entity.fields[keys[key]] } @@ -116,18 +116,18 @@ export default { return typeof cb === 'function' ? cb : null }, rowClass (index) { - let cssClass = index % 2 ? 'odd' : 'even' + const cssClass = index % 2 ? 'odd' : 'even' return cssClass }, getValue (field, data, raw) { return this.getFieldFilteredValue()(field, data, raw) }, isFrom (fieldName, index) { - let next = this.visibleFields[index + 1] + const next = this.visibleFields[index + 1] return fieldName === 'from' && next === 'to' }, isTo (fieldName, index) { - let prev = this.visibleFields[index - 1] + const prev = this.visibleFields[index - 1] return fieldName === 'to' && prev === 'from' }, fieldPos (field) { @@ -137,8 +137,8 @@ export default { return this.dataKeyValue()(this.type, data) }, iconStyle (row) { - let style = {} - let value = (row) ? row[this.key] : null + const style = {} + const value = (row) ? row[this.key] : null if (this.type === 'blocks') { style.color = this.getBlockColor(value) style.fill = style.color @@ -149,7 +149,7 @@ export default { fieldFormatProp (prop, field, value, filteredValue, row) { if (undefined === value) value = this.getValue(field, this.data, true) if (undefined === filteredValue) filteredValue = this.filterFieldValue()(field, value, row) - let pv = field[prop] + const pv = field[prop] if (typeof pv === 'function') { return pv(value, filteredValue, row) } @@ -169,25 +169,25 @@ export default { }, renderAsProps (payload) { - let field = payload.field || {} - let props = field.renderAsProps + const field = payload.field || {} + const props = field.renderAsProps return (typeof props === 'function') ? props(payload) : props }, showField (field, data) { - let fieldName = field.fieldName - let hidden = this.isHidden(fieldName) - let entity = this.entity - let isTitleField = (fieldName === entity.titleField) - let value = this.getValue(field, data) - let isNotEmpty = (field.hideIfEmpty) ? value : true + const fieldName = field.fieldName + const hidden = this.isHidden(fieldName) + const entity = this.entity + const isTitleField = (fieldName === entity.titleField) + const value = this.getValue(field, data) + const isNotEmpty = (field.hideIfEmpty) ? value : true return Boolean(!field.hide && !hidden && !isTitleField && isNotEmpty) }, rowLink (row) { let link - let key = this.keyValue(row) - let linkCb = this.linkCb + const key = this.keyValue(row) + const linkCb = this.linkCb if (linkCb) return linkCb(row, this.parentData, this.entity.link, key) link = link || this.entity.link // link = link || this.$route.path @@ -197,7 +197,7 @@ export default { return link }, isHidden (field) { - let hideFields = this.hideFields + const hideFields = this.hideFields if (hideFields) { return hideFields.find(value => { return value === field @@ -206,8 +206,8 @@ export default { return false }, makeLink (field, row) { - let link = field.link - let value = this.getValue(field, row, true) + const link = field.link + const value = this.getValue(field, row, true) if (typeof link === 'function') return link(row, value, link) return ((value || value === 0) && link) ? link + value : null }, @@ -215,7 +215,7 @@ export default { value = filteredValue || value field = field || {} value = value || '' - let { trim } = field + const { trim } = field if (trim === 'forced-auto') return 'auto' if (trim === 0) return 0 if (String(value.length) > this.trimIf) { diff --git a/src/router/addresses.js b/src/router/addresses.js index 8b065d58..2f22a4f0 100644 --- a/src/router/addresses.js +++ b/src/router/addresses.js @@ -44,7 +44,7 @@ export default [ hideTabs: true, icon: data => { if (!data) return - let { verification } = data + const { verification } = data if (verification && verification.match === true) return 'check' } } @@ -58,7 +58,7 @@ export default [ module: 'transactions', msgs: [(data, parenData) => { const msgs = [] - let { balance, txBalance } = parenData + const { balance, txBalance } = parenData if (txBalance !== balance) msgs.push('INTERNAL_TX_WARN') return msgs }] @@ -88,7 +88,7 @@ export default [ module: 'tokens', action: 'getTokenAccounts', render: data => { - let methods = data.contractMethods || [] + const methods = data.contractMethods || [] return methods.indexOf('balanceOf(address)') > -1 } }, diff --git a/src/router/index.js b/src/router/index.js index e9cd9699..bbc4ff97 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -28,10 +28,10 @@ const router = new Router({ }) router.beforeEach((to, from, next) => { - let configLoaded = store.getters.isConfigLoaded + const configLoaded = store.getters.isConfigLoaded // Checks if backend configuration is loaded if (!configLoaded) { - let unwatch = store.watch((state, getters) => getters.isConfigLoaded, + const unwatch = store.watch((state, getters) => getters.isConfigLoaded, (newValue, oldValue) => { if (newValue === true) { unwatch() @@ -44,7 +44,7 @@ router.beforeEach((to, from, next) => { }) router.afterEach((to, from) => { - let r = Object.assign({}, to) + const r = Object.assign({}, to) r.hash = '' router.replace(r).catch(() => { }) }) @@ -54,8 +54,8 @@ router.afterEach((to, from) => { */ function checkBeforeEnter (to, from, next) { // let chainId = store.getters.chainId - let { params } = Object.assign({}, to) - let { address, hash } = params + const { params } = Object.assign({}, to) + const { address, hash } = params if (hash) params.hash = normalizeSearch(hash) if (!isCheckAddressPath(to) && address) { to.params.address = normalizeSearch(address) diff --git a/src/router/routes.js b/src/router/routes.js index 097f987c..c5be7f6a 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -31,7 +31,7 @@ export default [ beforeEnter (t, f) { let url = statsUrl if (!url) { - let host = window.location.host.split('.') + const host = window.location.host.split('.') host[0] = 'stats' url = window.location.protocol + '//' + host.join('.') } diff --git a/src/router/tokens.js b/src/router/tokens.js index 91cbfd74..31451464 100644 --- a/src/router/tokens.js +++ b/src/router/tokens.js @@ -32,8 +32,8 @@ export default [ component: DataPage, props: { title: (data) => { - let cData = data._contractData || {} - let title = 'Token Account' + const cData = data._contractData || {} + const title = 'Token Account' return (cData.name) ? `${cData.name} ${title}` : title }, module: 'tokens', diff --git a/src/store/actions.js b/src/store/actions.js index e27f775d..14032dfd 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -22,8 +22,8 @@ export const setDateInterval = ({ state, commit }) => { } export const updateBlocks = ({ state, commit }) => { - let blocks = state.backend.lastBlocks - let transactions = state.backend.lastTransactions + const blocks = state.backend.lastBlocks + const transactions = state.backend.lastTransactions commit('LAST_BLOCKS_TIME') commit('CLEAR_PENDING_BLOCKS') commit('SET_BLOCKS', blocks.slice()) diff --git a/src/store/getters.js b/src/store/getters.js index 1d2f3951..bbe5f2ca 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,6 +1,6 @@ export const getDate = (state, getters) => { let date = state.date - let diff = getters.timeDifference + const diff = getters.timeDifference date += diff return date } @@ -18,8 +18,8 @@ export const getColors = state => { } export const getBlockColor = state => (blockNumber, cKey = 'blocksColors') => { - let colors = state[cKey] - let c = blockNumber % 10 + const colors = state[cKey] + const c = blockNumber % 10 return colors[c] } @@ -28,21 +28,21 @@ export const getBlockColor2 = (state, getters) => blockNumber => { } export const blockStyle = (state, getters) => blockNumber => { - let color = getters.getBlockColor(blockNumber) + const color = getters.getBlockColor(blockNumber) return { color, fill: color, 'border-color': color } } export const getTableId = (state) => tableName => { // if (!tableName) console.warn('missing table name') tableName = tableName || 'Table' - let routeName = state.route.name || 'unNamedRoute' + const routeName = state.route.name || 'unNamedRoute' return `${routeName}-${tableName}` } export const dbIsOutdated = (state) => { - let missing = state.backend.missingBlocks - let now = Date.now() - let time = missing.time + const missing = state.backend.missingBlocks + const now = Date.now() + const time = missing.time return (missing.blocks > 1) && (now - time > 5000) } diff --git a/src/store/modules/backend/actions.js b/src/store/modules/backend/actions.js index b7267af7..fdfd5a62 100644 --- a/src/store/modules/backend/actions.js +++ b/src/store/modules/backend/actions.js @@ -21,8 +21,8 @@ export const subscribe = ({ commit }, to) => { // handle newTransactions from transactions channel export const socketNewTransactions = ({ state, commit, getters }, result) => { - let transactions = result.data || [] - let autoUpdate = getters.autoUpdate + const transactions = result.data || [] + const autoUpdate = getters.autoUpdate commit('LAST_TRANSACTIONS', transactions) if (!state.transactions.length || autoUpdate) { commit('SET_TRANSACTIONS', transactions.slice()) @@ -30,8 +30,8 @@ export const socketNewTransactions = ({ state, commit, getters }, result) => { } // handle newBlocks from blocks channel export const socketNewBlocks = ({ state, commit, getters }, result) => { - let blocks = result.data || [] - let autoUpdate = getters.autoUpdate + const blocks = result.data || [] + const autoUpdate = getters.autoUpdate commit('LAST_BLOCKS', blocks) if (!state.lastBlocksTime) commit('LAST_BLOCKS_TIME') if (!state.blocks.length || autoUpdate) { @@ -41,18 +41,18 @@ export const socketNewBlocks = ({ state, commit, getters }, result) => { } export const socketData = ({ state, commit, dispatch }, res) => { - let { req, pages, error, next, prev, delayed } = res - let key = req.key + const { req, pages, error, next, prev, delayed } = res + const key = req.key const total = (pages) ? pages.total : null - let sort = (pages) ? pages.sort : null - let q = (req.params && req.params.query) ? req.params.query : null - let requested = state.requesting[key] - let module = req.module || null - let action = req.action || null + const sort = (pages) ? pages.sort : null + const q = (req.params && req.params.query) ? req.params.query : null + const requested = state.requesting[key] + const module = req.module || null + const action = req.action || null if (key && requested && requested === req.time) { const response = Object.assign({}, state.responses[key]) - let updating = Object.assign(delayedObject(), response.delayed) - let isUpdating = Boolean(!updating.registry && updating.fields.length) + const updating = Object.assign(delayedObject(), response.delayed) + const isUpdating = Boolean(!updating.registry && updating.fields.length) if (!delayed) { commit('SET_REQUESTING', [key, null]) commit('SET_RESPONSE', [key, { delayed: delayedObject() }]) @@ -72,11 +72,11 @@ export const socketData = ({ state, commit, dispatch }, res) => { commit('SET_RESPONSE', [key, { error: null }]) commit('SET_TOTAL', { key, total }) if (isUpdating) { - let dFields = Object.keys(data.data) - let fields = updating.fields.filter(f => dFields.indexOf(f) < 0) + const dFields = Object.keys(data.data) + const fields = updating.fields.filter(f => dFields.indexOf(f) < 0) if (!delayed) commit('SET_RESPONSE', [key, { delayed: delayedObject({ fields }) }]) const sData = response.data || {} - for (let f in res.data) { + for (const f in res.data) { sData[f] = res.data[f] } data.data = sData @@ -97,17 +97,17 @@ export const socketDbStatus = ({ state, commit }, data) => { export const fetchData = ({ state, commit, getters }, req) => { req.params = req.params || {} - let { next, prev, query, sort, action, count, page, fields } = req - let module = req.module || null + const { next, prev, query, sort, action, count, page, fields } = req + const module = req.module || null - let limit = req.limit - let getPages = true + const limit = req.limit + const getPages = true const key = (req.key || 'data') const time = Date.now() // count = (undefined === count) - let params = Object.assign(req.params, { next, prev, query, sort, count, limit, page, getPages, fields }) + const params = Object.assign(req.params, { next, prev, query, sort, count, limit, page, getPages, fields }) const data = { module, action, params, key, time, getDelayed: true } commit('SET_REQUESTING', [key, time]) // Fix next 2 lines @@ -133,8 +133,8 @@ export const setKeyData = ({ state, commit }, [key, data]) => { } const delayedObject = (payload = {}) => { - let fields = payload.fields || [] - let registry = payload.registry || false + const fields = payload.fields || [] + const registry = payload.registry || false return { registry, fields } } @@ -153,14 +153,14 @@ export const socketStats = ({ commit }, msg) => { export const clearResponses = ({ commit }, keys) => { keys = (!Array.isArray(keys)) ? [keys] : keys - for (let key of keys) { + for (const key of keys) { commit('CLEAR_RESPONSE', key) } } export const clearRequests = ({ commit }, keys) => { keys = (!Array.isArray(keys)) ? [keys] : keys - for (let key of keys) { + for (const key of keys) { commit('CLEAR_REQUEST', key) } } diff --git a/src/store/modules/backend/getters.js b/src/store/modules/backend/getters.js index 4a9f757e..d026ddc8 100644 --- a/src/store/modules/backend/getters.js +++ b/src/store/modules/backend/getters.js @@ -3,7 +3,7 @@ export const firstListBlock = state => { } export const lastBlock = state => { - let { lastBlocks } = state + const { lastBlocks } = state return lastBlocks[0] } @@ -48,19 +48,19 @@ export const getTxPoolPending = (state) => { } export const getTxPoolTxs = (state) => status => { - let txs = state.txPool.txs || [] + const txs = state.txPool.txs || [] return (status) ? txs.filter(tx => tx.status === status) : txs } export const contractVerifierEnabled = state => { - let modules = state.systemSettings.modules || {} + const modules = state.systemSettings.modules || {} return modules.contractVerifier } export const bcNet = state => state.systemSettings.net export const chainId = state => { - let net = state.systemSettings.net + const net = state.systemSettings.net return (net) ? net.id : undefined } @@ -69,6 +69,6 @@ export const isConfigLoaded = state => { } export const netName = state => { - let { name } = state.systemSettings.net || {} + const { name } = state.systemSettings.net || {} return name } diff --git a/src/store/modules/backend/mutations.js b/src/store/modules/backend/mutations.js index 7375700c..4f96306d 100644 --- a/src/store/modules/backend/mutations.js +++ b/src/store/modules/backend/mutations.js @@ -3,7 +3,7 @@ import Vue from 'vue' export const SOCKET_EMIT = payload => { } export const SET_TIME = (state, { server, client }) => { - let date = Date.now() + const date = Date.now() state.serverTime = server || date state.clientTime = client || date } @@ -45,7 +45,7 @@ export const CLEAR_REQUEST = (state, key) => { export const SET_RESPONSE = (state, [key, data]) => { data.sort = data.sort || {} if (!state.responses[key]) Vue.set(state.responses, key, {}) - for (let p in data) { + for (const p in data) { Vue.set(state.responses[key], p, data[p]) } } @@ -60,14 +60,14 @@ export const SET_TOTAL = (state, { key, total }) => { export const SET_DB_STATUS = (state, data) => { Vue.set(state, 'dbStatus', data) - let missing = state.missingBlocks + const missing = state.missingBlocks if (!missing.blocks) missing.time = Date.now() missing.blocks = data.dbMissingBlocks Vue.set(state, 'missingBlocks', missing) } export const SET_PENDING_BLOCKS = (state, blocks) => { - let list = state.blocks.slice() + const list = state.blocks.slice() if (list.length) { blocks.map(block => { if (!list.find(b => b.number === block.number)) { diff --git a/src/store/modules/config/actions.js b/src/store/modules/config/actions.js index 716dfa38..30d746d5 100644 --- a/src/store/modules/config/actions.js +++ b/src/store/modules/config/actions.js @@ -2,15 +2,15 @@ export const setAutoUpdate = ({ state, commit }, update) => { commit('SET_CONFIG', ['autoUpdateBlocks', update]) } export const updateConfig = ({ state, commit }, config) => { - for (let c in config) { + for (const c in config) { commit('SET_CONFIG', [c, config[c]]) } commit('CONFIG_LOAD_DONE') } export const updateTableConfig = ({ state, commit, rootState }, payload) => { - let id = payload[0] - let config = payload[1] + const id = payload[0] + const config = payload[1] if (id && config) { config.w = rootState.size.w commit('SET_TABLE', [id, config]) diff --git a/src/store/modules/config/getters.js b/src/store/modules/config/getters.js index 3cb09980..f6153984 100644 --- a/src/store/modules/config/getters.js +++ b/src/store/modules/config/getters.js @@ -5,7 +5,7 @@ export const autoUpdate = state => { export const getConfig = (state, getters) => (module, action, key) => { if (module && action) { - let stype = (state[key]) ? state[key][module] : null + const stype = (state[key]) ? state[key][module] : null return (stype && stype[action]) ? stype[action] : {} } } diff --git a/src/store/modules/config/mutations.js b/src/store/modules/config/mutations.js index 97a48234..168abc8a 100644 --- a/src/store/modules/config/mutations.js +++ b/src/store/modules/config/mutations.js @@ -1,18 +1,18 @@ import Vue from 'vue' export const SET_CONFIG = (state, payload) => { - let key = payload[0] - let value = payload[1] + const key = payload[0] + const value = payload[1] if (undefined !== state[key]) { Vue.set(state, key, value) } } export const SET_CONFIG_KEY = (state, payload) => { - let module = payload.module || null - let action = payload.action || null - let key = payload.key || null - let value = payload.value || null + const module = payload.module || null + const action = payload.action || null + const key = payload.key || null + const value = payload.value || null if (module && action && key && value) { if (undefined === state[key]) Vue.set(state, key, {}) @@ -37,7 +37,7 @@ export const SET_CONFIG_TABLES = (state, payload) => { } export const SET_TABLE = (state, payload) => { - let tableId = payload[0] - let config = payload[1] + const tableId = payload[0] + const config = payload[1] Vue.set(state.tables, tableId, config) } diff --git a/src/store/modules/entities/getters.js b/src/store/modules/entities/getters.js index 22e45080..ab3ced16 100644 --- a/src/store/modules/entities/getters.js +++ b/src/store/modules/entities/getters.js @@ -9,7 +9,7 @@ export const dataFields = state => { } export const dataKey = state => type => { - let entity = state.entities[type] + const entity = state.entities[type] if (entity) return entity.key } @@ -33,10 +33,10 @@ export const getFieldFilteredValue = (state, getters) => (field, data, raw) => { export const filterFieldValue = (state, getters) => (field, value, data) => { field = field || {} - let type = field.type - let now = getters.getDate + const type = field.type + const now = getters.getDate if (type === 'timestamp' && value) value = now - value * 1000 - let filters = field.filters + const filters = field.filters if (filters) { value = getters.applyFilters(filters, value, data) } @@ -46,7 +46,7 @@ export const filterFieldValue = (state, getters) => (field, value, data) => { export const getFieldValue = state => (field, data) => { if (field) { let value = data - for (let f of field) { + for (const f of field) { value = (value && (value[f] || value[f] === 0)) ? value[f] : null } return value @@ -56,7 +56,7 @@ export const getFieldValue = state => (field, data) => { export const applyFilters = state => (filters, value, data) => { if (filters) { filters = Array.isArray(filters) ? filters : [filters] - for (let f of filters) { + for (const f of filters) { if (typeof f === 'function') { value = f(value, data) } else { @@ -68,7 +68,7 @@ export const applyFilters = state => (filters, value, data) => { } const applyFilter = (filterName, value, args) => { - let filter = Vue.filter(filterName) + const filter = Vue.filter(filterName) args = args || [] args = Array.isArray(args) ? args : [args] if (filter) { diff --git a/src/store/modules/routes/actions.js b/src/store/modules/routes/actions.js index e5731080..5d977e65 100644 --- a/src/store/modules/routes/actions.js +++ b/src/store/modules/routes/actions.js @@ -3,8 +3,8 @@ import router from '../../../router' import { Q, SORT } from '../../../config/types' export const fetchRouteData = ({ commit, getters, dispatch }, req) => { - let { module, action, key } = req - let routerQuery = getters.getRouterQuery(key, true) + const { module, action, key } = req + const routerQuery = getters.getRouterQuery(key, true) let query = routerQuery[Q] || getters.getSavedQ(module, action) || null req.sort = routerQuery[SORT] || getters.getSavedSort(module, action) || null @@ -22,7 +22,7 @@ export const fetchRouteData = ({ commit, getters, dispatch }, req) => { export const updateRouterQuery = ({ state, getters, dispatch }, { query, hash, key }) => { query = query || {} // update = getters.parseQuery(update) - let oldQuery = getters.getRouterQuery(key) + const oldQuery = getters.getRouterQuery(key) query = updateQuery(oldQuery, query) dispatch('routerPush', { query, hash, key }) } @@ -33,8 +33,8 @@ export const routerPush = ({ state, commit, getters }, { query, hash, key }) => } export const updateQuery = (query, update) => { - for (let p in update) { - let value = update[p] + for (const p in update) { + const value = update[p] if (value === null) delete query[p] else query[p] = value } diff --git a/src/store/modules/routes/getters.js b/src/store/modules/routes/getters.js index bff56048..b9d28c4a 100644 --- a/src/store/modules/routes/getters.js +++ b/src/store/modules/routes/getters.js @@ -31,8 +31,8 @@ export const decodeQueryProp = state => encoded => { export const parseQuery = (state, getters) => (query, key, decode, removeKey) => { if (!query) return - let props = getters.encodedProps(key) - let fn = (decode) ? 'decodeQueryProp' : 'encodeQueryProp' + const props = getters.encodedProps(key) + const fn = (decode) ? 'decodeQueryProp' : 'encodeQueryProp' props.forEach((p) => { let value = query[p] let k = p @@ -49,13 +49,13 @@ export const parseQuery = (state, getters) => (query, key, decode, removeKey) => } export const getQuery = (state, getters) => key => { - let query = getters.getRouterQuery(key) - let q = query.q || {} + const query = getters.getRouterQuery(key) + const q = query.q || {} return q } export const getRouterQuery = (state, getters, rootState) => (key, removeKey = false) => { - let query = Object.assign({}, rootState.route.query) + const query = Object.assign({}, rootState.route.query) return getters.parseQuery(query, key, true, removeKey) } diff --git a/src/store/modules/search/actions.js b/src/store/modules/search/actions.js index 1553dd48..5df18c02 100644 --- a/src/store/modules/search/actions.js +++ b/src/store/modules/search/actions.js @@ -8,7 +8,7 @@ const createSearchKey = (value, type) => { } export const clearSearchedResults = async ({ commit, dispatch, getters }) => { - let keys = getters.searchKeysRequested + const keys = getters.searchKeysRequested commit('CLEAR_SEARCH_REQUEST') await dispatch('clearRequests', keys) return dispatch('clearResponses', keys) @@ -16,7 +16,7 @@ export const clearSearchedResults = async ({ commit, dispatch, getters }) => { export const updateSearchedValue = async ({ commit, dispatch, state }, value) => { value = String(value).replace(/[\W_]+/g, '') - let lcValue = value.toLowerCase() + const lcValue = value.toLowerCase() value = (isHexString(value) && isTxOrBlockHash(lcValue)) ? lcValue : value if (state.value !== value) { commit('SET_SEARCH_VALUE', value) @@ -29,8 +29,8 @@ export const fetchSearch = async ({ commit, dispatch, getters }, { value, type } value = await dispatch('updateSearchedValue', value) if (!value) return type = type || DEFAULT_TYPE - let key = createSearchKey(value, type) - let payload = Object.assign({}, getters.getSearchPayloadByType(type)) + const key = createSearchKey(value, type) + const payload = Object.assign({}, getters.getSearchPayloadByType(type)) if (!payload) return let { params, searchField } = payload params = params || {} @@ -44,16 +44,16 @@ export const fetchSearch = async ({ commit, dispatch, getters }, { value, type } export const prepareSearch = async ({ commit, dispatch, rootGetters }, { value }) => { value = await dispatch('updateSearchedValue', value) if (!value) return - let chainId = rootGetters.chainId + const chainId = rootGetters.chainId let { number: lastBlock } = rootGetters.lastBlock || {} if (lastBlock) lastBlock += 2 - let types = testSearchedValue(value, { chainId, lastBlock }) + const types = testSearchedValue(value, { chainId, lastBlock }) commit('SET_SEARCH_TYPES', types) return { value, types } } export const searchTypes = async ({ dispatch }, { types, value }) => { - for (let type of types) { + for (const type of types) { await dispatch('fetchSearch', { value, type }) } } diff --git a/src/store/modules/search/getters.js b/src/store/modules/search/getters.js index 98dbd20c..db38cbbe 100644 --- a/src/store/modules/search/getters.js +++ b/src/store/modules/search/getters.js @@ -2,37 +2,37 @@ import { ROUTES as r } from '../../../config/types' export const getSearchPayloadByType = state => type => { - let payload = state.payloads[type] + const payload = state.payloads[type] return (payload) ? Object.assign({}, payload) : {} } export const searchKeysRequested = state => Object.keys(state.requested) export const getSearchLink = (state, getters) => ({ type, value }) => { - let payload = getters.getSearchPayloadByType(type) - let path = r[payload.type] + const payload = getters.getSearchPayloadByType(type) + const path = r[payload.type] if (!path || !value) return - let link = `/${path}/${value}` + const link = `/${path}/${value}` return link } export const getSearchedResults = (state, getters) => { - let { requested } = state - let results = getters.searchKeysRequested.map(key => { - let res = getters.getPage(key) + const { requested } = state + const results = getters.searchKeysRequested.map(key => { + const res = getters.getPage(key) if (res) { let { data } = res if (!data) return - let { type } = requested[key] - let { searchField, field, getName, getTime } = getters.getSearchPayloadByType(type) + const { type } = requested[key] + const { searchField, field, getName, getTime } = getters.getSearchPayloadByType(type) data = (!Array.isArray(data)) ? [data] : data return data.map(d => { if (!d) return - let k = field || searchField - let value = d[k] - let link = getters.getSearchLink({ type, value }) - let name = (typeof getName === 'function') ? getName(d) : undefined - let time = (typeof getTime === 'function') ? getTime(d) : undefined + const k = field || searchField + const value = d[k] + const link = getters.getSearchLink({ type, value }) + const name = (typeof getName === 'function') ? getName(d) : undefined + const time = (typeof getTime === 'function') ? getTime(d) : undefined return { link, type, value, name, time, data: d } }) } @@ -46,11 +46,11 @@ export const requestingSearches = (state, getters) => getters.searchKeysRequeste export const searchedValue = state => state.value export const searchedTypes = state => { - let types = state.types + const types = state.types return Object.keys(types).filter(k => types[k]) } export const isSearchPage = (state, getters) => { - let re = new RegExp(`^/${r.search}`) + const re = new RegExp(`^/${r.search}`) return re.test(getters.getRouterPath) } diff --git a/src/store/modules/search/payloads.js b/src/store/modules/search/payloads.js index a7b11707..46d4daf0 100644 --- a/src/store/modules/search/payloads.js +++ b/src/store/modules/search/payloads.js @@ -1,6 +1,6 @@ export const createPayloads = (payloads) => { - for (let p in payloads) { - let payload = payloads[p] + for (const p in payloads) { + const payload = payloads[p] let { fields, searchField, field, type } = payload payload.type = type || p fields = fields || {} @@ -13,13 +13,13 @@ export const createPayloads = (payloads) => { } const getAddressName = data => { - let { address, name } = data + const { address, name } = data return `${name} ${address}` } const getAddressTime = data => { - let { createdByTx } = data - let { timestamp } = createdByTx || {} + const { createdByTx } = data + const { timestamp } = createdByTx || {} return timestamp } diff --git a/src/store/plugins/localStorage.js b/src/store/plugins/localStorage.js index 10d3d04d..484c2f23 100644 --- a/src/store/plugins/localStorage.js +++ b/src/store/plugins/localStorage.js @@ -2,7 +2,7 @@ import { locStorage as storage } from '../../lib/js/io.js' export default (store) => { store.subscribe(mutation => { const type = mutation.type - let loading = store.state.loadingConfig + const loading = store.state.loadingConfig if (/^SET_CONFIG/.test(type) && loading === false) { const config = store.state.config config.APP = store.state.APP @@ -11,7 +11,7 @@ export default (store) => { // loads config from localStorage if (type === 'CONFIG_LOAD') { - let config = storage.get('config') || {} + const config = storage.get('config') || {} const sAPP = config.APP || {} if (store.getters.checkVersion(sAPP.version)) { store.dispatch('updateConfig', config) diff --git a/tests/unit/FieldTitle.spec.js b/tests/unit/FieldTitle.spec.js index 7d525d30..86f9823f 100644 --- a/tests/unit/FieldTitle.spec.js +++ b/tests/unit/FieldTitle.spec.js @@ -5,29 +5,29 @@ import FieldTitle from '@/components/FieldTitle.vue' const fieldDescriptionSelector = '.field-description' describe('FieldTitle.vue', () => { - let field = { + const field = { name: 'test field', description: 'test field description' } it('render field title with description', () => { - let wrapper = shallowMount(FieldTitle, { propsData: { field } }) + const wrapper = shallowMount(FieldTitle, { propsData: { field } }) expect(wrapper.contains(fieldDescriptionSelector)).equal(true) }) it('render field title without description', () => { - let field = { + const field = { description: 'test', hideDescription: true } - let wrapper = shallowMount(FieldTitle, { propsData: { field } }) + const wrapper = shallowMount(FieldTitle, { propsData: { field } }) expect(wrapper.contains(fieldDescriptionSelector)).equal(false) }) it('render field title without description', () => { - let field = { + const field = { description: '', hideDescription: false } - let wrapper = shallowMount(FieldTitle, { propsData: { field } }) + const wrapper = shallowMount(FieldTitle, { propsData: { field } }) expect(wrapper.contains(fieldDescriptionSelector)).equal(false) }) }) diff --git a/tests/unit/decodeField.spec.js b/tests/unit/decodeField.spec.js index f7e7fa36..e5a3d7c1 100644 --- a/tests/unit/decodeField.spec.js +++ b/tests/unit/decodeField.spec.js @@ -3,24 +3,24 @@ import { expect } from 'chai' import { rlp } from 'rsk-utils' describe('decodeField()', () => { - it(`should decode data`, () => { - let data = '0xffffffffffffffffff' - let result = decodeField(data, ['hex', 'raw', 'decimal']) + it('should decode data', () => { + const data = '0xffffffffffffffffff' + const result = decodeField(data, ['hex', 'raw', 'decimal']) expect(result.rlp).to.be.deep.equal(undefined) expect(result.hex).to.be.deep.equal(data) expect(result.decimal).to.be.deep.equal('4722366482869645213695') }) - it(`should be decoded as rlp`, () => { - let data = ['a', 'b', 'c'] - let encoded = '0x' + rlp.encode(data).toString('hex') - let result = decodeField(encoded) + it('should be decoded as rlp', () => { + const data = ['a', 'b', 'c'] + const encoded = '0x' + rlp.encode(data).toString('hex') + const result = decodeField(encoded) expect(result.rlp).to.be.deep.equal(data) }) - it(`decoded object should have only selected types`, () => { - let data = ['1', '2', 'a', 'b'] - let decoded = decodeField('0x' + rlp.encode(data).toString('hex'), ['rlp']) + it('decoded object should have only selected types', () => { + const data = ['1', '2', 'a', 'b'] + const decoded = decodeField('0x' + rlp.encode(data).toString('hex'), ['rlp']) expect(decoded.rlp).to.be.deep.equal(data) expect(Object.keys(decoded)).to.be.deep.equal(['rlp']) }) diff --git a/tests/unit/filters/bignumber.spec.js b/tests/unit/filters/bignumber.spec.js index 76e4d039..cad18220 100644 --- a/tests/unit/filters/bignumber.spec.js +++ b/tests/unit/filters/bignumber.spec.js @@ -7,8 +7,8 @@ const cases = [ ] describe('# BigNumber', () => { - describe(`bignumber`, () => { - for (let c of cases) { + describe('bignumber', () => { + for (const c of cases) { it(`${c.v} should be ${c.e}`, () => { expect(bignumber(c.v)).to.be.equal(c.e) }) diff --git a/tests/unit/filters/textFilters.spec.js b/tests/unit/filters/textFilters.spec.js index a8e6337c..38da1c44 100644 --- a/tests/unit/filters/textFilters.spec.js +++ b/tests/unit/filters/textFilters.spec.js @@ -32,7 +32,7 @@ test('txStatus', [ function test (name, values) { describe(`# ${name}`, () => { - for (let c of values) { + for (const c of values) { const method = textFilters[name] const [value, expected] = c it(`${addQuotes(value)} should be ${addQuotes(expected)}`, () => { diff --git a/tests/unit/filters/tokenFilters.spec.js b/tests/unit/filters/tokenFilters.spec.js index 4537c1e8..06c4d485 100644 --- a/tests/unit/filters/tokenFilters.spec.js +++ b/tests/unit/filters/tokenFilters.spec.js @@ -12,8 +12,8 @@ const tests = [ ['1000', 0, '1000'] ] -describe(`Token decimals`, function () { - for (let [value, decimals, result] of tests) { +describe('Token decimals', function () { + for (const [value, decimals, result] of tests) { it(`${value}/${decimals} should be ${result}`, () => { expect(tokenDecimals(value, decimals).toString(10)).to.be.equal(result) }) diff --git a/tests/unit/utils.spec.js b/tests/unit/utils.spec.js index 1fd42119..58b610e7 100644 --- a/tests/unit/utils.spec.js +++ b/tests/unit/utils.spec.js @@ -1,25 +1,25 @@ import { expect } from 'chai' import * as utils from '@/lib/js/utils' -describe(`# Utils`, function () { +describe('# Utils', function () { describe('# utils.plainObjectChanges()', () => { - it(`should returns object changes`, () => { + it('should returns object changes', () => { expect(utils.plainObjectChanges({ a: 1, b: 2, c: 3 }, { b: 4 })).to.be.deep.equal({ a: 1, b: 4, c: 3 }) }) - it(`should returns object differences`, () => { + it('should returns object differences', () => { expect(utils.plainObjectChanges({ a: 1, b: 2, c: 3 }, { a: 1 })).to.be.deep.equal({ b: 2, c: 3 }) }) - it(`should returns object differences`, () => { + it('should returns object differences', () => { expect(utils.plainObjectChanges({ a: 1 }, { a: 1 })).to.be.deep.equal({}) }) - it(`should returns object differences`, () => { + it('should returns object differences', () => { expect(utils.plainObjectChanges({ a: 1 }, { a: 2 })).to.be.deep.equal({ a: 2 }) }) - it(`should returns object differences`, () => { + it('should returns object differences', () => { expect(utils.plainObjectChanges({ a: 1 }, null)).to.be.deep.equal({ a: 1 }) }) }) @@ -31,9 +31,9 @@ describe(`# Utils`, function () { [0, 1, 20, 1] ] - describe(`utils.clamp()`, function () { - for (let test of clampTest) { - let [number, min, max, expected] = test + describe('utils.clamp()', function () { + for (const test of clampTest) { + const [number, min, max, expected] = test it(`clamp(${number},${min},${max}) should be ${expected}`, () => { expect(utils.clamp(number, min, max)).to.be.equal(expected) }) diff --git a/tests/unit/validate.spec.js b/tests/unit/validate.spec.js index d9db2a1f..05c1ccd8 100644 --- a/tests/unit/validate.spec.js +++ b/tests/unit/validate.spec.js @@ -3,32 +3,32 @@ import { testSearchedValue, isValidBlockNumber } from '../../src/lib/js/validate describe('# Search', function () { describe('isValidBlockNumber()', function () { - let blocks = [ + const blocks = [ [-1, undefined, false], ['10', undefined, true], ['2009', 1999, false] ] - for (let b of blocks) { - let [number, lastBlock, expected] = b + for (const b of blocks) { + const [number, lastBlock, expected] = b it(`[${number},${lastBlock}] should be ${expected}`, () => { expect(isValidBlockNumber(number, lastBlock)).to.be.deep.equal(expected) }) } }) - describe(`testSearchedValue`, function () { - let chainId = 31 - let lastBlock = '1000000' - let tests = [ + describe('testSearchedValue', function () { + const chainId = 31 + const lastBlock = '1000000' + const tests = [ ['123', { block: { number: true, hash: false } }], ['0x6eaecb5eb7b3a8f919008817ba47d312d20b80bfed89b63b28c78bbdc46b3e31', { transaction: true }], ['0x0000000000000000000000000000000001000008', { address: true }], ['0x66f9664F97F2b50f62d13eA064982F936DE76657', { address: true }] ] - for (let test of tests) { - let [value, expected] = test + for (const test of tests) { + const [value, expected] = test it(`${value} should be ${expected} `, () => { - let result = testSearchedValue(value, { chainId, lastBlock }) + const result = testSearchedValue(value, { chainId, lastBlock }) expect(result).to.deep.own.include(expected) }) }