diff --git a/package.json b/package.json index 41fc3735..d98eafd5 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "cross-fetch": "^3.1.5", "daisyui": "^2.51.6", "dayjs": "^1.11.7", + "lazy-load-vue3": "^1.3.0", "long": "^5.2.1", "md-editor-v3": "^2.8.1", "numeral": "^2.0.6", diff --git a/src/main.ts b/src/main.ts index 4ab1ce78..d4d77977 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,6 +11,7 @@ import '@/plugins/vuetify/styles/styles.scss'; import '@/style.css'; import { createApp } from 'vue'; import { createPinia } from 'pinia'; +import LazyLoad from 'lazy-load-vue3'; // import router from "@/plugins/vuetify/router"; import router from './router'; import { useBaseStore } from './stores/useBaseStore'; @@ -25,7 +26,7 @@ app.use(vuetify); app.use(createPinia()); app.use(layoutsPlugin); app.use(router); - +app.use(LazyLoad, { component: true }); // Mount vue app app.mount('#app'); diff --git a/src/modules/[chain]/staking/index.vue b/src/modules/[chain]/staking/index.vue index 5bf5e75f..5d5dc434 100644 --- a/src/modules/[chain]/staking/index.vue +++ b/src/modules/[chain]/staking/index.vue @@ -22,48 +22,48 @@ onMounted(() => { }); async function fetchChange() { - console.log('fetch changes') - let page = 0 + console.log('fetch changes'); + let page = 0; - let height = Number(base.latest?.block?.header?.height || 0) + let height = Number(base.latest?.block?.header?.height || 0); if (height > 14400) { - height -= 14400 + height -= 14400; } else { - height = 1 + height = 1; } // voting power in 24h ago - while(page < staking.validators.length && height > 0) { - await base.fetchValidatorByHeight(height, page).then(x => { - x.validators.forEach(v => { - yesterday.value[v.pub_key.key] = Number(v.voting_power) - }) - }) - page += 100 + while (page < staking.validators.length && height > 0) { + await base.fetchValidatorByHeight(height, page).then((x) => { + x.validators.forEach((v) => { + yesterday.value[v.pub_key.key] = Number(v.voting_power); + }); + }); + page += 100; } - page = 0 + page = 0; // voting power for now - while(page < staking.validators.length) { - await base.fetchLatestValidators(page).then(x => { - x.validators.forEach(v => { - latest.value[v.pub_key.key] = Number(v.voting_power) - }) - }) - page += 100 + while (page < staking.validators.length) { + await base.fetchLatestValidators(page).then((x) => { + x.validators.forEach((v) => { + latest.value[v.pub_key.key] = Number(v.voting_power); + }); + }); + page += 100; } } fetchChange(); const changes = computed(() => { - const changes = {} as Record - Object.keys(latest.value).forEach(k => { - const l = latest.value[k] || 0 - const y = yesterday.value[k] || 0 - changes[k] = l - y - }) - return changes -}) + const changes = {} as Record; + Object.keys(latest.value).forEach((k) => { + const l = latest.value[k] || 0; + const y = yesterday.value[k] || 0; + changes[k] = l - y; + }); + return changes; +}); const change24 = (key: Key) => { const txt = key.key; @@ -71,7 +71,7 @@ const change24 = (key: Key) => { // const o: number = yesterday.value[txt]; // // console.log( txt, n, o) // return n > 0 && o > 0 ? n - o : 0; - return changes.value[txt] + return changes.value[txt]; }; const change24Text = (key?: Key) => { @@ -190,137 +190,144 @@ const rank = function (position: number) {
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - -
#VALIDATORVOTING POWER24h CHANGESCOMMISSIONACTIONS
-
- - {{ i + 1 }} -
-
-
-
-
-
- - +
#VALIDATORVOTING POWER24h CHANGESCOMMISSIONACTIONS
+
+ + {{ i + 1 }} +
+
+
+
+
+
+ + +
+
+ +
+
+ + {{ v.description?.moniker }} + +
+ {{ + v.description?.website || v.description?.identity || '-' + }}
- +
-
- - {{ v.description?.moniker }} - +
+ {{ + format.formatToken( + { + amount: parseInt(v.tokens).toString(), + denom: staking.params.bond_denom, + }, + true, + '0,0' + ) + }}
{{ - v.description?.website || v.description?.identity || '-' + format.calculatePercent( + v.delegator_shares, + staking.totalPower + ) }}
- -
-
-
- {{ - format.formatToken( - { - amount: parseInt(v.tokens).toString(), - denom: staking.params.bond_denom, - }, - true, - '0,0' - ) - }} -
- {{ - format.calculatePercent( - v.delegator_shares, - staking.totalPower - ) - }} -
-
- {{ change24Text(v.consensus_pubkey) }} -
+ +
- - Jailed - - - {{ - format.formatCommissionRate( - v.commission?.commission_rates?.rate - ) - }} - - {{ 2 }} -
+ {{ change24Text(v.consensus_pubkey) }} +
+ + Jailed +
+ + + + {{ + format.formatCommissionRate( + v.commission?.commission_rates?.rate + ) + }} + + + + {{ 2 }} + + + +
- +
-
- + Top 33%
-
- Top 67% diff --git a/yarn.lock b/yarn.lock index d7941a2f..8c59e1ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5977,6 +5977,11 @@ knitwork@^1.0.0: resolved "https://registry.npmjs.org/knitwork/-/knitwork-1.0.0.tgz" integrity sha512-dWl0Dbjm6Xm+kDxhPQJsCBTxrJzuGl0aP9rhr+TG8D3l+GL90N8O8lYUi7dTSAN2uuDqCtNgb6aEuQH5wsiV8Q== +lazy-load-vue3@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/lazy-load-vue3/-/lazy-load-vue3-1.3.0.tgz#6aaf573d1d09626ac11fec6b2de9fd07c0130ac0" + integrity sha512-IcyeMiDZrxzuIqqwkYkC+6RRQBdm0yTR0onIj6NITrWd6LaUlzzRmbvAmuzGB0g4H1HeVm/Oa0FokxD2lz9UAA== + ledger-cosmos-js@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/ledger-cosmos-js/-/ledger-cosmos-js-2.1.8.tgz#b409ecd1e77f630e6fb212a9f602fe5c6e8f054b"