diff --git a/src/libs/client.ts b/src/libs/client.ts index 4aae8cbe..38fc39b8 100644 --- a/src/libs/client.ts +++ b/src/libs/client.ts @@ -204,10 +204,17 @@ export class CosmosRestClient extends BaseRestClient { validator_addr, }); } - async getStakingValidatorsDelegations(validator_addr: string) { + async getStakingValidatorsDelegations(validator_addr: string, page?: PageRequest) { + if(!page) { + page = new PageRequest() + // page.reverse = true + page.count_total = true + page.offset = 0 + } + const query =`?${page.toQueryString()}`; return this.request(this.registry.staking_validators_delegations, { validator_addr, - }); + }, query); } async getStakingValidatorsDelegationsDelegator( validator_addr: string, diff --git a/src/modules/[chain]/staking/[validator].vue b/src/modules/[chain]/staking/[validator].vue index d9f77ec5..912362ee 100644 --- a/src/modules/[chain]/staking/[validator].vue +++ b/src/modules/[chain]/staking/[validator].vue @@ -15,7 +15,8 @@ import { pubKeyToValcons, valoperToPrefix, } from '@/libs'; -import type { Coin, Delegation, PaginatedTxs, Validator } from '@/types'; +import { PageRequest, type Coin, type Delegation, type PaginatedDelegations, type PaginatedTxs, type Validator } from '@/types'; +import PaginationBar from '@/components/PaginationBar.vue'; const props = defineProps(['validator', 'chain']); @@ -23,6 +24,7 @@ const staking = useStakingStore(); const blockchain = useBlockchain(); const format = useFormatter(); const dialog = useTxDialog(); +const page = new PageRequest(); const validator: string = props.validator; @@ -32,6 +34,7 @@ const avatars = ref(cache || {}); const identity = ref(''); const rewards = ref([] as Coin[] | undefined); const commission = ref([] as Coin[] | undefined); +const delegations = ref({} as PaginatedDelegations) const addresses = ref( {} as { account: string; @@ -133,6 +136,13 @@ onMounted(() => { } }); }); + + pageload(1) + + // blockchain.rpc.getDistributionValidatorSlashes(validator).then(res => { + // // delegations.value = res + // console.log('slashs:', res) + // }) } }); let showCopyToast = ref(0); @@ -158,6 +168,13 @@ const tipMsg = computed(() => { ? { class: 'error', msg: 'Copy Error!' } : { class: 'success', msg: 'Copy Success!' }; }); + +function pageload(p: number) { + page.setPage(p); + blockchain.rpc.getStakingValidatorsDelegations(validator, page).then(res => { + delegations.value = res + }) +}