From 7dbabf3e122532f31201c39b0e5ad44576e629d0 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Wed, 10 May 2023 12:20:42 +0800 Subject: [PATCH 01/11] fix: editor text style --- src/components/dynamic/TextElement.vue | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/components/dynamic/TextElement.vue b/src/components/dynamic/TextElement.vue index 7c9f5079..6e47043c 100644 --- a/src/components/dynamic/TextElement.vue +++ b/src/components/dynamic/TextElement.vue @@ -19,6 +19,50 @@ function isMD() { v-if="isMD()" :model-value="format.multiLine(value)" previewOnly + class="md-editor-recover" > {{ value }} + + \ No newline at end of file From 7a494e7b5968b7e2bd3d08c1bb0692046b58dd16 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Wed, 10 May 2023 13:15:12 +0800 Subject: [PATCH 02/11] feat: staking page UI refactor --- src/modules/[chain]/ibc/[connection_id].vue | 11 +- src/modules/[chain]/staking/index.vue | 212 +++++++++++--------- 2 files changed, 124 insertions(+), 99 deletions(-) diff --git a/src/modules/[chain]/ibc/[connection_id].vue b/src/modules/[chain]/ibc/[connection_id].vue index 8c4f4136..2bd4a7ec 100644 --- a/src/modules/[chain]/ibc/[connection_id].vue +++ b/src/modules/[chain]/ibc/[connection_id].vue @@ -136,7 +136,16 @@ function color(v: string) { {{ v.version }} {{ v.ordering }} - {{ v.state }} +
+ + {{ v.state }} +
diff --git a/src/modules/[chain]/staking/index.vue b/src/modules/[chain]/staking/index.vue index e782db81..ce1fd79d 100644 --- a/src/modules/[chain]/staking/index.vue +++ b/src/modules/[chain]/staking/index.vue @@ -163,112 +163,128 @@ const rank = function (position: number) { {{ list.length }}/{{ staking.params.max_validators }} -
- - - - - # - VALIDATOR - VOTING POWER - 24h CHANGES - COMMISSION - ACTIONS - - - - - - - - {{ i + 1 }} - - - - -
- -
-
- - {{ v.description?.moniker }} - -
- {{ - v.description?.website || v.description?.identity || '-' - }} -
-
- +
+
+ + + + + + + + + + + + + + + - - - - - - + + + - - - - - - - - Top 33% - Top 67% - - + }} + + + + + + + + + + +
#VALIDATORVOTING POWER24h CHANGESCOMMISSIONACTIONS
+ + {{ i + 1 }} + + + + +
+
-
- {{ - format.formatToken( - { - amount: parseInt(v.tokens).toString(), - denom: staking.params.bond_denom, - }, - true, - '0,0' - ) - }} +
+ + {{ v.description?.moniker }} +
{{ - format.calculatePercent( - v.delegator_shares, - staking.totalPower - ) + v.description?.website || v.description?.identity || '-' }}
-
- {{ change24Text(v.consensus_pubkey) }} - Jailed - - {{ - format.formatCommissionRate( - v.commission?.commission_rates?.rate + + +
+
+ {{ + format.formatToken( + { + amount: parseInt(v.tokens).toString(), + denom: staking.params.bond_denom, + }, + true, + '0,0' + ) + }} +
+ {{ + format.calculatePercent( + v.delegator_shares, + staking.totalPower ) - }} -
- {{ 2 }} -
+ {{ change24Text(v.consensus_pubkey) }} + Jailed + + {{ + format.formatCommissionRate( + v.commission?.commission_rates?.rate + ) + }} + + {{ 2 }} +
+
+ +
+
+
+ + Top 33% +
+
+ + Top 67% +
+
From 3b3cd95e69d4ffdcd6abd669345767c3cbfbc33c Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Wed, 10 May 2023 13:20:10 +0800 Subject: [PATCH 03/11] feat: ping-widget use github url --- package.json | 2 +- yarn.lock | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 90c5f1c7..41fc3735 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "md-editor-v3": "^2.8.1", "numeral": "^2.0.6", "osmojs": "^14.0.0-rc.0", - "ping-widget": "^0.0.4", + "ping-widget": "git+https://github.com/ping-pub/widget.git", "pinia": "^2.0.28", "postcss": "^8.4.23", "prismjs": "^1.29.0", diff --git a/yarn.lock b/yarn.lock index 6641ae56..24ceec08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6728,6 +6728,24 @@ ping-widget@^0.0.4: vue "^3.2.47" vue3-webcomponent-wrapper "^0.2.0" +"ping-widget@git+https://github.com/ping-pub/widget.git": + version "0.0.4" + resolved "git+https://github.com/ping-pub/widget.git#e91a2626cd3bf4534d40476f0be29f777c2b7c16" + dependencies: + "@cosmjs/amino" "^0.30.1" + "@cosmjs/ledger-amino" "^0.30.1" + "@cosmjs/proto-signing" "^0.30.1" + "@cosmjs/stargate" "^0.30.1" + "@ledgerhq/hw-transport-web-ble" "^6.27.13" + "@tharsis/address-converter" "^0.1.8" + "@tharsis/eip712" "^0.2.4" + "@tharsis/proto" "^0.1.20" + "@tharsis/transactions" "^0.2.6" + cross-fetch "^3.1.5" + daisyui "^2.51.6" + vue "^3.2.47" + vue3-webcomponent-wrapper "^0.2.0" + pinia@^2.0.28: version "2.0.30" resolved "https://registry.npmjs.org/pinia/-/pinia-2.0.30.tgz" From e419bd1e340e440987a884e81fc2fbb5e1d86f06 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Wed, 10 May 2023 13:23:00 +0800 Subject: [PATCH 04/11] fix: this.connectedWallet.cosmosAddress undefined --- src/stores/useWalletStore.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/stores/useWalletStore.ts b/src/stores/useWalletStore.ts index c8d54718..629ec64d 100644 --- a/src/stores/useWalletStore.ts +++ b/src/stores/useWalletStore.ts @@ -11,27 +11,30 @@ export const useWalletStore = defineStore('walletStore', { return useBlockchain(); }, connectedWallet() { - const chainStore = useBlockchain() - const key = chainStore.defaultHDPath + const chainStore = useBlockchain(); + const key = chainStore.defaultHDPath; - const connected = JSON.parse(localStorage.getItem(key)||"{}") - return connected + const connected = JSON.parse(localStorage.getItem(key) || '{}'); + return connected; }, currentAddress() { - const {prefix, data} = fromBech32(this.connectedWallet.cosmosAddress); - const chainStore = useBlockchain() - return toBech32(chainStore.current?.bech32Prefix || prefix, data) - } + if (!this.connectedWallet?.cosmosAddress) return ''; + const { prefix, data } = fromBech32(this.connectedWallet.cosmosAddress); + const chainStore = useBlockchain(); + return toBech32(chainStore.current?.bech32Prefix || prefix, data); + }, }, actions: { myBalance() { - return this.blockchain.rpc.getBankBalances(this.currentAddress) + return this.blockchain.rpc.getBankBalances(this.currentAddress); }, myDelegations() { - return this.blockchain.rpc.getStakingDelegations(this.currentAddress) + return this.blockchain.rpc.getStakingDelegations(this.currentAddress); }, myUnbonding() { - return this.blockchain.rpc.getStakingDelegatorUnbonding(this.currentAddress) - } + return this.blockchain.rpc.getStakingDelegatorUnbonding( + this.currentAddress + ); + }, }, }); From 52bcb61299f72080bdd33e9994bda5f641f28246 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Thu, 11 May 2023 00:52:52 +0800 Subject: [PATCH 05/11] feat: staking ui retactor --- src/components/icons/IconWeb.vue | 1 + src/modules/[chain]/staking/[validator].vue | 77 +++++++++++++-------- src/modules/[chain]/staking/index.vue | 44 ++++++++---- 3 files changed, 78 insertions(+), 44 deletions(-) create mode 100644 src/components/icons/IconWeb.vue diff --git a/src/components/icons/IconWeb.vue b/src/components/icons/IconWeb.vue new file mode 100644 index 00000000..5e0cd0ca --- /dev/null +++ b/src/components/icons/IconWeb.vue @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/[chain]/staking/[validator].vue b/src/modules/[chain]/staking/[validator].vue index d90a9823..179ab2a4 100644 --- a/src/modules/[chain]/staking/[validator].vue +++ b/src/modules/[chain]/staking/[validator].vue @@ -7,6 +7,7 @@ import { useStakingStore, } from '@/stores'; import { onMounted, computed, ref } from 'vue'; +import { Icon } from '@iconify/vue'; import ValidatorCommissionRate from '@/components/ValidatorCommissionRate.vue'; import { consensusPubkeyToHexAddress, @@ -132,31 +133,49 @@ onMounted(() => { + + diff --git a/yarn.lock b/yarn.lock index 1220b1f1..691f7f7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6711,7 +6711,7 @@ pify@^3.0.0: "ping-widget@git+https://github.com/ping-pub/widget.git": version "0.0.5" - resolved "git+https://github.com/ping-pub/widget.git#2c4bf89ba35ea6cb6ecbfe07e32f70ba8089e9bc" + resolved "git+https://github.com/ping-pub/widget.git#7ce4842101089476d915027f58021088afef9cb8" dependencies: "@cosmjs/amino" "^0.30.1" "@cosmjs/ledger-amino" "^0.30.1" From 65c5620348df2048d0ef4b3df37d1700586525b9 Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Thu, 11 May 2023 01:32:59 +0800 Subject: [PATCH 09/11] feat: ping-widget install git --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 691f7f7e..d7941a2f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6711,7 +6711,7 @@ pify@^3.0.0: "ping-widget@git+https://github.com/ping-pub/widget.git": version "0.0.5" - resolved "git+https://github.com/ping-pub/widget.git#7ce4842101089476d915027f58021088afef9cb8" + resolved "git+https://github.com/ping-pub/widget.git#11de05f773e60430f332fb77b4a37e5ae8c681b2" dependencies: "@cosmjs/amino" "^0.30.1" "@cosmjs/ledger-amino" "^0.30.1" From 8e1e243111aa2abcb8c0164c2e46115e7a8ae1ad Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Thu, 11 May 2023 01:48:27 +0800 Subject: [PATCH 10/11] fix: dashboard.loadingPrices() cause endless loop --- src/pages/index.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/index.vue b/src/pages/index.vue index d1333c3d..57d2cf39 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -12,7 +12,8 @@ const dashboard = useDashboard(); dashboard.$subscribe((mutation, state) => { localStorage.setItem('favorite', JSON.stringify(state.favorite)); - dashboard.loadingPrices() + // TODO: cause endless loop + // dashboard.loadingPrices() }); const keywords = ref(''); const chains = computed(() => { From e386988bdca8aed0fb8ce8d645db6592b2c0330e Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Thu, 11 May 2023 01:53:59 +0800 Subject: [PATCH 11/11] feat: add vue image lazyload --- package.json | 1 + src/main.ts | 3 +- src/modules/[chain]/staking/index.vue | 293 +++++++++++++------------- yarn.lock | 5 + 4 files changed, 158 insertions(+), 144 deletions(-) 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"