From 9c643dc40952cfef14ff776df2e89022523a9ddc Mon Sep 17 00:00:00 2001 From: ccamel Date: Thu, 8 Jun 2023 14:54:40 +0200 Subject: [PATCH 01/15] fix: improve bech32 regex (to support all prefixes) --- src/layouts/components/NavbarSearch.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/components/NavbarSearch.vue b/src/layouts/components/NavbarSearch.vue index 9cc1b6f6..d4202878 100644 --- a/src/layouts/components/NavbarSearch.vue +++ b/src/layouts/components/NavbarSearch.vue @@ -31,7 +31,7 @@ function confirm() { } const height = /^\d+$/; const txhash = /^[A-Z\d]{64}$/; - const addr = /^[a-z]+1[a-z\d]{38,58}$/; + const addr = /^[a-z\d]+1[a-z\d]{38,58}$/; const current = blockStore?.current?.chainName || ''; const routeParams = vueRouters?.currentRoute?.value; From 551816e0edf6418657f264354499eb7cc4ec7b08 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 9 Jun 2023 18:32:25 +0800 Subject: [PATCH 02/15] add accounts and supply --- package.json | 2 +- src/layouts/components/NavBarWallet.vue | 2 +- src/libs/client.ts | 11 ++-- src/modules/[chain]/account/index.vue | 86 +++++++++++++++++++++++++ src/modules/[chain]/supply/index.vue | 59 +++++++++++++++++ src/plugins/i18n/locales/cn.json | 4 +- src/plugins/i18n/locales/en.json | 4 +- yarn.lock | 8 +-- 8 files changed, 164 insertions(+), 12 deletions(-) create mode 100644 src/modules/[chain]/account/index.vue create mode 100644 src/modules/[chain]/supply/index.vue diff --git a/package.json b/package.json index 3b8aa610..f235d5cb 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "md-editor-v3": "^2.8.1", "numeral": "^2.0.6", "osmojs": "^14.0.0-rc.0", - "ping-widget": "^0.0.38", + "ping-widget": "^0.0.39", "pinia": "^2.0.28", "postcss": "^8.4.23", "qrcode": "^1.5.3", diff --git a/src/layouts/components/NavBarWallet.vue b/src/layouts/components/NavBarWallet.vue index 55588b8b..96b0a545 100644 --- a/src/layouts/components/NavBarWallet.vue +++ b/src/layouts/components/NavBarWallet.vue @@ -108,7 +108,7 @@ const tipMsg = computed(() => { diff --git a/src/libs/client.ts b/src/libs/client.ts index 442d605b..49841250 100644 --- a/src/libs/client.ts +++ b/src/libs/client.ts @@ -31,8 +31,10 @@ export class CosmosRestClient extends BaseRestClient { return new CosmosRestClient(endpoint, DEFAULT) } // Auth Module - async getAuthAccounts() { - return this.request(this.registry.auth_accounts, {}); + async getAuthAccounts(page?: PageRequest) { + if(!page) page = new PageRequest() + const query =`?${page.toQueryString()}`; + return this.request(this.registry.auth_accounts, {}, query); } async getAuthAccount(address: string) { return this.request(this.registry.auth_account_address, { address }); @@ -47,8 +49,9 @@ export class CosmosRestClient extends BaseRestClient { async getBankDenomMetadata() { return this.request(this.registry.bank_denoms_metadata, {}); } - async getBankSupply() { - return this.request(this.registry.bank_supply, {}); + async getBankSupply(page?: PageRequest) { if(!page) page = new PageRequest() + const query =`?${page.toQueryString()}`; + return this.request(this.registry.bank_supply, {}, query); } async getBankSupplyByDenom(denom: string) { return this.request(this.registry.bank_supply_by_denom, { denom }); diff --git a/src/modules/[chain]/account/index.vue b/src/modules/[chain]/account/index.vue new file mode 100644 index 00000000..3ba552bd --- /dev/null +++ b/src/modules/[chain]/account/index.vue @@ -0,0 +1,86 @@ + + + + + { + meta: { + i18n: 'account', + order: 16 + } + } + diff --git a/src/modules/[chain]/supply/index.vue b/src/modules/[chain]/supply/index.vue new file mode 100644 index 00000000..22ac1ac4 --- /dev/null +++ b/src/modules/[chain]/supply/index.vue @@ -0,0 +1,59 @@ + + + + + { + meta: { + i18n: 'supply', + order: 17 + } + } + diff --git a/src/plugins/i18n/locales/cn.json b/src/plugins/i18n/locales/cn.json index e73441e3..699c349c 100644 --- a/src/plugins/i18n/locales/cn.json +++ b/src/plugins/i18n/locales/cn.json @@ -6,7 +6,9 @@ "governance": "社区治理", "parameters": "参数", "uptime": "状态", - "consensus": "Consensus" + "consensus": "共识引擎", + "supply": "资产供应量", + "account": "账户列表" }, "index": { "slogan": "Ping Dashboard 是一个区块链浏览器,也是一个网页钱包,还有更多 ... 🛠", diff --git a/src/plugins/i18n/locales/en.json b/src/plugins/i18n/locales/en.json index 33da7d76..ecfaf020 100644 --- a/src/plugins/i18n/locales/en.json +++ b/src/plugins/i18n/locales/en.json @@ -10,7 +10,9 @@ "cosmwasm": "Cosmwasm", "widget": "Widgets", "ibc": "IBC", - "consensus": "Consensus" + "consensus": "Consensus", + "supply": "Supply", + "account": "Accounts" }, "index": { "slogan": "Ping Dashboard is not just an explorer but also a wallet and more ... 🛠", diff --git a/yarn.lock b/yarn.lock index b254c7c7..c7697ed7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5675,10 +5675,10 @@ ping-widget@^0.0.33: vue "^3.2.47" vue3-webcomponent-wrapper "^0.2.0" -ping-widget@^0.0.38: - version "0.0.38" - resolved "https://registry.yarnpkg.com/ping-widget/-/ping-widget-0.0.38.tgz#ab25e3f24d1b53002c552a181431a96f4340a1e8" - integrity sha512-x1VwKvV71Ds7BW1U4RiGCYVVb45XU4M/b09j2wpt8MdMZ8uo5y1eFnwsABJfGVQV2MuBSgXg626uhfCIBkH3TQ== +ping-widget@^0.0.39: + version "0.0.39" + resolved "https://registry.yarnpkg.com/ping-widget/-/ping-widget-0.0.39.tgz#53e8807186f363c08c4921e50aa972a8be0b7a7c" + integrity sha512-2PRXs+CNOA5G6Qq3bQeIENctj9h1v9ZBNfP1GQJYHfsFcAXAW0JcKcdPwbX7kEyx9gYNctUIB6NkUflHeLWAsg== dependencies: "@cosmjs/amino" "^0.30.1" "@cosmjs/cosmwasm-stargate" "^0.30.1" From a2b53a6f0cf8bd145c60426f50680c2eb0884a0d Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 9 Jun 2023 18:38:44 +0800 Subject: [PATCH 03/15] hidden accounts --- src/modules/[chain]/account/index.vue | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/modules/[chain]/account/index.vue b/src/modules/[chain]/account/index.vue index 3ba552bd..9425f532 100644 --- a/src/modules/[chain]/account/index.vue +++ b/src/modules/[chain]/account/index.vue @@ -75,12 +75,3 @@ function showPubkey(v: any) { - - - { - meta: { - i18n: 'account', - order: 16 - } - } - From 2131e7f9f4d0171b5793d05d8d782203f5c0df41 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 10 Jun 2023 08:08:09 +0800 Subject: [PATCH 04/15] add supply and widget module --- chains/mainnet/neutron.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chains/mainnet/neutron.json b/chains/mainnet/neutron.json index 3a005dd5..c68f58d1 100644 --- a/chains/mainnet/neutron.json +++ b/chains/mainnet/neutron.json @@ -5,7 +5,7 @@ "provider_chain": { "api": ["https://api-cosmoshub-ia.cosmosia.notional.ventures"] }, - "features": ["dashboard", "blocks", "ibc", "cosmwasm", "uptime", "parameters", "state-sync"], + "features": ["dashboard", "blocks", "ibc", "cosmwasm", "uptime", "parameters", "state-sync", "consensus", "supply", "widget"], "sdk_version": "0.45.1", "coin_type": "118", "min_tx_fee": "8000", From c07be3d8fb1f34fb8ac285b79ed5e1158f3220c0 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 10 Jun 2023 09:29:38 +0800 Subject: [PATCH 05/15] optimize default chain --- src/stores/useDashboard.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index c9246c44..077ba03e 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -252,18 +252,14 @@ export enum ConfigSource { export const useDashboard = defineStore('dashboard', { state: () => { - const fav = JSON.parse( - localStorage.getItem('favorite') || '["cosmoshub", "osmosis"]' - ); const favMap = JSON.parse( localStorage.getItem('favoriteMap') || - '{"cosmoshub":true, "osmosis":true}' + '{"cosmos":true, "osmosis":true}' ); return { status: LoadingStatus.Empty, source: ConfigSource.MainnetCosmosDirectory, networkType: NetworkType.Mainnet, - favorite: fav as string[], favoriteMap: favMap as Record, chains: {} as Record, prices: {} as Record, @@ -330,9 +326,10 @@ export const useDashboard = defineStore('dashboard', { setupDefault() { if (this.length > 0) { const blockchain = useBlockchain(); - for (let i = 0; i < this.favorite.length; i++) { - if (!blockchain.chainName && this.chains[this.favorite[i]]) { - blockchain.setCurrent(this.favorite[i]); + const keys = Object.keys(this.favoriteMap) + for (let i = 0; i < keys.length; i++) { + if (!blockchain.chainName && this.chains[keys[i]] && this.favoriteMap[keys[i]]) { + blockchain.setCurrent(keys[i]); break } } From e6067b94884b68c93ef3ded6d9d4651365fa81b8 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 10 Jun 2023 10:51:25 +0800 Subject: [PATCH 06/15] test black theme color --- chains/mainnet/axelar.json | 1 + chains/mainnet/neutron.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chains/mainnet/axelar.json b/chains/mainnet/axelar.json index 7b416ee8..f5350add 100644 --- a/chains/mainnet/axelar.json +++ b/chains/mainnet/axelar.json @@ -8,6 +8,7 @@ "min_tx_fee": "800", "addr_prefix": "axelar", "logo": "/logos/axelar.svg", + "theme_color": "#000000", "assets": [{ "base": "uaxl", "symbol": "AXL", diff --git a/chains/mainnet/neutron.json b/chains/mainnet/neutron.json index c68f58d1..4403bdf1 100644 --- a/chains/mainnet/neutron.json +++ b/chains/mainnet/neutron.json @@ -17,6 +17,6 @@ "logo": "/logos/neutron.svg" }], "addr_prefix": "neutron", - "theme_color": "", + "theme_color": "#000000", "logo": "/logos/neutron.svg" } From 082da1276ff6fc546b4d333a0a38e8fdadf1382d Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 10 Jun 2023 12:39:07 +0800 Subject: [PATCH 07/15] add endpoints --- chains/mainnet/cosmos.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chains/mainnet/cosmos.json b/chains/mainnet/cosmos.json index ca242fb9..6f0db8c4 100644 --- a/chains/mainnet/cosmos.json +++ b/chains/mainnet/cosmos.json @@ -3,7 +3,12 @@ "registry_name": "cosmoshub", "api": [ "https://api-cosmoshub-ia.cosmosia.notional.ventures", - "https://lcd-cosmoshub.blockapsis.com:443" + "https://lcd-cosmoshub.blockapsis.com:443", + "https://lcd-cosmoshub.whispernode.com:443", + "https://api-cosmoshub.pupmos.network", + "https://cosmos-rest.publicnode.com", + "https://cosmos-rest.staketab.org", + "https://api.cosmos.nodestake.top" ], "rpc": ["https://rpc.cosmos.network:443", "https://cosmos-rpc.icycro.org", "https://rpc.cosmos.dragonstake.io"], "sdk_version": "0.45.1", From 06e9f51ae904fac2dda65060c24bdf3caeb48e59 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 10 Jun 2023 20:27:35 +0800 Subject: [PATCH 08/15] update widget version to v0.0.40 --- package.json | 2 +- src/components/TxDialog.vue | 4 +++- yarn.lock | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f235d5cb..2f97b1c5 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "md-editor-v3": "^2.8.1", "numeral": "^2.0.6", "osmojs": "^14.0.0-rc.0", - "ping-widget": "^0.0.39", + "ping-widget": "^0.0.40", "pinia": "^2.0.28", "postcss": "^8.4.23", "qrcode": "^1.5.3", diff --git a/src/components/TxDialog.vue b/src/components/TxDialog.vue index e3e83e01..3617564b 100644 --- a/src/components/TxDialog.vue +++ b/src/components/TxDialog.vue @@ -1,6 +1,7 @@ diff --git a/src/modules/[chain]/account/[address].vue b/src/modules/[chain]/account/[address].vue index cb62204e..ac4dcffe 100644 --- a/src/modules/[chain]/account/[address].vue +++ b/src/modules/[chain]/account/[address].vue @@ -19,6 +19,7 @@ import type { UnbondingResponses, } from '@/types'; import type { Coin } from '@cosmjs/amino'; +import Countdown from '@/components/Countdown.vue'; const props = defineProps(['address', 'chain']); @@ -65,6 +66,11 @@ const totalAmount = computed(() => { return totalAmountByCategory.value.reduce((p, c) => c + p, 0); }); +const totalValue = computed(() => { + return 0; +}); + + function loadAccount(address: string) { blockchain.rpc.getAuthAccount(address).then((x) => { account.value = x.account; @@ -125,14 +131,10 @@ function updateEvent() {
-

Assets

-
-
- -
-
- -
+
+

Assets

+ +
+
+
+
+ +
+
@@ -299,7 +307,7 @@ function updateEvent() {
- {{ totalAmount }} + Total Value: ${{ totalValue }}
@@ -307,20 +315,22 @@ function updateEvent() {
-

Delegations

-
- - +
+

Delegations

+
+ + +
@@ -338,12 +348,12 @@ function updateEvent() { {{ - format.validatorFromBech32(v.delegation.validator_address) + format.validatorFromBech32(v.delegation.validator_address) || v.delegation.validator_address }} - -
+
- @@ -462,11 +471,10 @@ function updateEvent() { }} - - +
- {{ format.formatToken(v.balance, true, '0,0.[00]') }} + {{ format.formatToken(v.balance, true, '0,0.[000000]') }} {{ @@ -356,7 +366,7 @@ function updateEvent() { }} -
+
+ {{ - format.validatorFromBech32(v.validator_address) + v.validator_address }} - {{ format.toDay(entry.completion_time, 'to') }} +
diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index 077ba03e..5f763a8d 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -280,7 +280,7 @@ export const useDashboard = defineStore('dashboard', { const coinIds = [] as string[] Object.keys(this.favoriteMap).forEach(k => { if(this.chains[k]) this.chains[k].assets.forEach(a => { - if(a.coingecko_id !== undefined) { + if(a.coingecko_id !== undefined && a.coingecko_id.length > 0) { coinIds.push(a.coingecko_id) a.denom_units.forEach(u => { this.coingecko[u.denom] = { diff --git a/src/stores/useFormatter.ts b/src/stores/useFormatter.ts index 4c7385c3..f801adf9 100644 --- a/src/stores/useFormatter.ts +++ b/src/stores/useFormatter.ts @@ -85,6 +85,7 @@ export const useFormatter = defineStore('formatter', { } }, price(denom: string, currency = "usd") { + if(!denom || denom.length < 2) return 0 const info = this.priceInfo(denom); return info ? info[currency] || 0 : 0; }, @@ -101,13 +102,21 @@ export const useFormatter = defineStore('formatter', { } return "" }, + specialDenom(denom: string) { + switch(true) { + case denom.startsWith('u'): return 6 + case denom.startsWith("a"): return 18 + case denom==='inj': return 18 + } + return 0 + }, tokenValueNumber(token?: Coin) { - if(!token) return 0 + if(!token || !token.denom) return 0 // find the symbol, - const symbol = this.dashboard.coingecko[token.denom]?.symbol || "" + const symbol = this.dashboard.coingecko[token.denom]?.symbol || token.denom // convert denomation to to symbol const exponent = - this.dashboard.coingecko[symbol.toLowerCase()]?.exponent || 0; + this.dashboard.coingecko[symbol?.toLowerCase()]?.exponent || this.specialDenom(token.denom); // cacualte amount of symbol const amount = Number(token.amount) / (10 ** exponent) const value = amount * this.price(token.denom) From 8ec5a9822a2de1693f4f1b42a782b78a0fb435f7 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 12 Jun 2023 10:33:47 +0800 Subject: [PATCH 15/15] format total value --- src/modules/[chain]/account/[address].vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modules/[chain]/account/[address].vue b/src/modules/[chain]/account/[address].vue index ac4dcffe..409687b0 100644 --- a/src/modules/[chain]/account/[address].vue +++ b/src/modules/[chain]/account/[address].vue @@ -67,7 +67,22 @@ const totalAmount = computed(() => { }); const totalValue = computed(() => { - return 0; + let value = 0; + delegations.value?.forEach((x) => { + value += format.tokenValueNumber(x.balance); + }); + rewards.value?.total?.forEach((x) => { + value += format.tokenValueNumber(x); + }); + balances.value?.forEach((x) => { + value += format.tokenValueNumber(x); + }); + unbonding.value?.forEach((x) => { + x.entries?.forEach((y) => { + value += format.tokenValueNumber({amount: y.balance, denom: stakingStore.params.bond_denom}); + }); + }); + return format.formatNumber(value, '0,0.00'); });