diff --git a/src/components/ValidatorCommissionRate.vue b/src/components/ValidatorCommissionRate.vue
index 2f896c5d..b695b168 100644
--- a/src/components/ValidatorCommissionRate.vue
+++ b/src/components/ValidatorCommissionRate.vue
@@ -2,50 +2,33 @@
import VueApexCharts from 'vue3-apexcharts'
import { useTheme } from 'vuetify'
import { hexToRgb } from '@/plugins/vuetify/@layouts/utils'
-import type { PropType } from 'vue';
+import { computed, type PropType } from 'vue';
import { useFormatter } from '@/stores';
+import type { CommissionRate } from '@/types'
const props = defineProps({
- commission: { type: Object as PropType<{
- commissionRates: {
- rate: string,
- maxRate: string,
- maxChangeRate: string,
- },
- updateTime: string,
- }>},
+ commission: { type: Object as PropType
},
})
-console.log('commission:', props)
-const zeros = Math.pow(10, 16)
-let rate = Number(props.commission?.commissionRates.rate || 0)
-let change = Number(props.commission?.commissionRates.maxChangeRate || 10)
-let max = Number(props.commission?.commissionRates.maxRate || 100)
+let rate = computed(() => Number(props.commission?.commission_rates.rate || 0) * 100)
+let change = computed(() => Number(props.commission?.commission_rates.max_change_rate || 0) * 100)
+let max = computed(() => Number(props.commission?.commission_rates.max_rate || 1) * 100)
-if(rate > 100) {
- rate = rate / zeros
-}
-if(change > 100) {
- change = change / zeros
-}
-if(max > 100) {
- max = max / zeros
-}
// const rate = 15 // props.commision?.commissionRates.rate
// const change = 15
// const max = 20
const left = rate
-const right = max - rate
+const right = computed(() => max.value - rate.value)
-const s1 = left > change ? left - change : 0
-const s2 = left > change ? change: left
+const s1 = computed(() => left.value > change.value ? left.value - change.value : 0 )
+const s2 = computed(() => left.value > change.value ? change.value: left.value)
const s3 = 2
-const s4 = right > change? change: right
-const s5 = right > change? right - change: 0
+const s4 = computed(() => right.value > change.value? change.value: right.value)
+const s5 = computed(() => right.value > change.value? right.value - change.value: 0)
-const series = [s1, s2, s3, s4, s5]
+const series = computed(() => [s1.value, s2.value, s3, s4.value, s5.value])
const vuetifyTheme = useTheme()
const format = useFormatter()
@@ -99,7 +82,7 @@ const chartConfig = computed(() => {
offsetY: -15,
fontWeight: 500,
fontSize: '2.125rem',
- formatter: (value: unknown) => `${rate}%`,
+ formatter: (value: unknown) => `${rate.value}%`,
color: primaryText,
},
total: {
@@ -107,7 +90,7 @@ const chartConfig = computed(() => {
label: 'Commission Rate',
fontSize: '1rem',
color: secondaryText,
- formatter: ( ) => `${rate}%`,
+ formatter: ( ) => `${rate.value}%`,
},
},
},
@@ -127,7 +110,7 @@ const chartConfig = computed(() => {
-
+
},
+ value: { type: Array},
});
const txs = computed(() => {
- return props.value?.map(x => ({ hash: hashTx(x) , tx: decodeTxRaw(x) })) || []
+ return props.value?.map(x => ({ hash: hashTx(fromBase64(x)) , tx: decodeTxRaw(fromBase64(x)) })) || []
})
const format = useFormatter()
@@ -26,7 +26,7 @@ const chain = useBlockchain()
| {{ item.hash }} |
- {{ format.messages(item.tx.body.messages) }} |
+ {{ format.messages(item.tx.body.messages.map(x => ({"@type": x.typeUrl}))) }} |
{{ item.tx.body.memo }} |
diff --git a/src/layouts/components/ChainProfile.vue b/src/layouts/components/ChainProfile.vue
index f4253946..54aadc02 100644
--- a/src/layouts/components/ChainProfile.vue
+++ b/src/layouts/components/ChainProfile.vue
@@ -33,8 +33,8 @@ chainStore.initial()
>
-
-
+
+
{{ i.provider }}
{{ i.address }}
diff --git a/src/libs/address.ts b/src/libs/address.ts
index a4edcbe2..98226d2f 100644
--- a/src/libs/address.ts
+++ b/src/libs/address.ts
@@ -41,11 +41,14 @@ export function consensusPubkeyToHexAddress(consensusPubkey?: {"@type": string,
}
export function pubKeyToValcons(consensusPubkey: {"@type": string, key: string}, prefix: string) {
- const pubkey = fromBase64(consensusPubkey.key)
- if(pubkey) {
- const addressData = sha256(pubkey).slice(0, 20)
- return toBech32(`${prefix}valcons`, addressData)
+ if(consensusPubkey && consensusPubkey.key) {
+ const pubkey = fromBase64(consensusPubkey.key)
+ if(pubkey) {
+ const addressData = sha256(pubkey).slice(0, 20)
+ return toBech32(`${prefix}valcons`, addressData)
+ }
}
+ return ''
}
export function toETHAddress(cosmosAddress: string) {
diff --git a/src/libs/api.ts b/src/libs/api.ts
index 21fb7b51..dbbaf7bf 100644
--- a/src/libs/api.ts
+++ b/src/libs/api.ts
@@ -10,6 +10,7 @@ export const DEFAULT: RequestRegistry = {
bank_supply: { url: "/cosmos/bank/v1beta1/supply", adapter },
bank_supply_by_denom: { url: "/cosmos/bank/v1beta1/supply/{denom}", adapter },
distribution_params: { url: "/cosmos/distribution/v1beta1/params", adapter },
+ distributino_community_pool: {url: "/cosmos/distribution/v1beta1/community_pool", adapter},
distribution_validator_commission: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/commission", adapter },
distribution_validator_outstanding_rewards: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards", adapter },
distribution_validator_slashes: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes", adapter },
@@ -30,7 +31,7 @@ export const DEFAULT: RequestRegistry = {
staking_delegator_validators: { url: "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators", adapter },
staking_params: { url: "/cosmos/staking/v1beta1/params", adapter },
staking_pool: { url: "/cosmos/staking/v1beta1/pool", adapter },
- staking_validators: { url: "/cosmos/staking/v1beta1/validators", adapter },
+ staking_validators: { url: "/cosmos/staking/v1beta1/validators?pagination.limit={limit}&status={status}", adapter },
staking_validators_address: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}", adapter },
staking_validators_delegations: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations", adapter },
staking_validators_delegations_delegator: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr}", adapter },
diff --git a/src/libs/client.ts b/src/libs/client.ts
index 706992c3..e3aa122b 100644
--- a/src/libs/client.ts
+++ b/src/libs/client.ts
@@ -5,9 +5,9 @@ import { adapter, type Request, type RequestRegistry } from './registry';
export class CosmosRestClient {
endpoint: string;
registry: RequestRegistry;
- constructor(endpoint: string) {
+ constructor(endpoint: string, registry?: RequestRegistry) {
this.endpoint = endpoint
- this.registry = DEFAULT
+ this.registry = registry || DEFAULT
}
async request(request: Request, args: Record, query="") {
let url = `${this.endpoint}${request.url}${query}`
@@ -42,6 +42,9 @@ export class CosmosRestClient {
// Distribution Module
async getDistributionParams() {
return this.request(this.registry.distribution_params, {})
+ }
+ async getDistributionCommunityPool() {
+ return this.request(this.registry.distributino_community_pool, {})
}
async getDistributionValidatorCommission(validator_address: string) {
return this.request(this.registry.distribution_validator_commission, {validator_address})
@@ -69,8 +72,9 @@ export class CosmosRestClient {
async getGovParamsTally() {
return this.request(this.registry.gov_params_tally, {})
}
- async getGovProposals() {
- return this.request(this.registry.gov_proposals, {})
+ async getGovProposals(status: string, limit = 100) {
+ const query = "?proposal_status={status}&pagination.limit={limit}&pagination.reverse=true&pagination.key="
+ return this.request(this.registry.gov_proposals, {status, limit}, query)
}
async getGovProposal(proposal_id: string) {
return this.request(this.registry.gov_proposals_proposal_id, {proposal_id})
@@ -106,8 +110,8 @@ export class CosmosRestClient {
async getStakingPool() {
return this.request(this.registry.staking_pool, {})
}
- async getStakingValidators() {
- return this.request(this.registry.staking_validators, {})
+ async getStakingValidators(status: string, limit = 200) {
+ return this.request(this.registry.staking_validators, {status, limit})
}
async getStakingValidator(validator_addr: string) {
return this.request(this.registry.staking_validators_address, {validator_addr})
@@ -153,4 +157,15 @@ export class CosmosRestClient {
return this.request(this.registry.tx_hash, {hash})
}
+ // mint
+ async getMintParam() {
+ return this.request(this.registry.mint_params, {})
+ }
+ async getMintInflation() {
+ return this.request(this.registry.mint_inflation, {})
+ }
+ async getMintAnnualProvisions() {
+ return this.request(this.registry.mint_annual_provisions, {})
+ }
+
}
diff --git a/src/libs/registry.ts b/src/libs/registry.ts
index 5c937f01..0ba26c91 100644
--- a/src/libs/registry.ts
+++ b/src/libs/registry.ts
@@ -29,6 +29,16 @@ export interface RequestRegistry {
distribution_validator_commission: Request<{commission?: {commission?: Coin[]}}>;
distribution_validator_outstanding_rewards: Request<{rewards?: {rewards?: Coin[]}}>;
distribution_validator_slashes: Request;
+ distributino_community_pool: Request<{pool: Coin[]}>;
+
+ mint_inflation: Request<{inflation: string}>;
+ mint_params: Request<{
+ params: {
+ mint_denom: string,
+ blocks_per_year: string
+ }
+ }>;
+ mint_annual_provisions: Request<{annual_provisions: string}>
slashing_params: Request;
slashing_signing_info: Request;
@@ -39,7 +49,7 @@ export interface RequestRegistry {
gov_proposals: Request;
gov_proposals_proposal_id: Request<{proposal: GovProposal}>;
gov_proposals_deposits: Request;
- gov_proposals_tally: Request;
+ gov_proposals_tally: Request<{tally: Tally}>;
gov_proposals_votes: Request;
gov_proposals_votes_voter: Request<{vote: GovVote}>;
diff --git a/src/modules/[chain]/block/[height].vue b/src/modules/[chain]/block/[height].vue
index a1d528e5..4665d785 100644
--- a/src/modules/[chain]/block/[height].vue
+++ b/src/modules/[chain]/block/[height].vue
@@ -16,7 +16,7 @@ const height = computed(() => {
onBeforeRouteUpdate(async (to, from, next) => {
if (from.path !== to.path) {
- store.fetchBlock(Number(to.params.height))
+ store.fetchBlock(String(to.params.height))
next()
}
})
@@ -33,7 +33,7 @@ onBeforeRouteUpdate(async (to, from, next) => {
-
+
@@ -51,7 +51,7 @@ onBeforeRouteUpdate(async (to, from, next) => {
-
+
diff --git a/src/modules/[chain]/block/block.ts b/src/modules/[chain]/block/block.ts
index ec2f0b60..76ce7b39 100644
--- a/src/modules/[chain]/block/block.ts
+++ b/src/modules/[chain]/block/block.ts
@@ -22,7 +22,7 @@ export const useBlockModule = defineStore('blockModule', {
},
txsInRecents() {
const txs = [] as {hash:string, tx: DecodedTxRaw}[]
- this.recents.forEach((x:GetLatestBlockResponse) => x.block?.data?.txs.forEach((tx:Uint8Array) => txs.push({
+ this.recents.forEach((x) => x.block?.data?.txs.forEach((tx:Uint8Array) => txs.push({
hash: hashTx(tx),
tx :decodeTxRaw(tx)
})))
@@ -47,13 +47,13 @@ export const useBlockModule = defineStore('blockModule', {
})
},
async fetchLatest() {
- this.latest = await this.blockchain.rpc.block()
+ this.latest = await this.blockchain.rpc.getBaseBlockLatest()
if(this.recents.length >= 50) this.recents.shift()
this.recents.push(this.latest)
return this.latest
},
- async fetchBlock(height?: number) {
- this.current = await this.blockchain.rpc.block(height)
+ async fetchBlock(height: string) {
+ this.current = await this.blockchain.rpc.getBaseBlockAt(height)
return this.current
},
}
diff --git a/src/modules/[chain]/block/index.vue b/src/modules/[chain]/block/index.vue
index b80e0e94..a04146e5 100644
--- a/src/modules/[chain]/block/index.vue
+++ b/src/modules/[chain]/block/index.vue
@@ -1,14 +1,11 @@