diff --git a/src/libs/client.ts b/src/libs/client.ts index b6783276..fcda050a 100644 --- a/src/libs/client.ts +++ b/src/libs/client.ts @@ -25,6 +25,7 @@ import { // Tendermint34Client, WebsocketClient, type CometClient, + type AbciQueryParams, } from '@cosmjs/tendermint-rpc'; import { DEFAULT } from '@/libs'; import { @@ -334,20 +335,30 @@ export class CosmosRestClient extends BaseRestClient { // ); } async getGovProposalVotes(proposal_id: string, page?: PageRequest) { - if (!page) page = new PageRequest(); - page.reverse = true; - const query = `?proposal_status={status}&${page.toQueryString()}`; - return this.request( - this.registry.gov_proposals_votes, - { proposal_id }, - query - ); + // if (!page) page = new PageRequest(); + // page.reverse = true; + // const query = `?proposal_status={status}&${page.toQueryString()}`; + // return this.request( + // this.registry.gov_proposals_votes, + // { proposal_id }, + // query + // ); + + const paginationKey = page?.key + ? Buffer.from(page.key, 'base64') + : undefined; + const res = await this.queryClient.gov.votes(proposal_id, paginationKey); + console.log(res); + return res; } async getGovProposalVotesVoter(proposal_id: string, voter: string) { - return this.request(this.registry.gov_proposals_votes_voter, { - proposal_id, - voter, - }); + // return this.request(this.registry.gov_proposals_votes_voter, { + // proposal_id, + // voter, + // }); + const res = await this.queryClient.gov.vote(proposal_id, voter); + console.log(res); + return res; } // staking async getStakingDelegations(delegator_addr: string) { @@ -475,9 +486,9 @@ export class CosmosRestClient extends BaseRestClient { } //tendermint - async getBaseAbciQuery() { + async getBaseAbciQuery(params: AbciQueryParams) { // return this.request(this.registry.base_tendermint_abci_query, {}); - const res = await this.tmClient.abciInfo(); + const res = await this.tmClient.abciQuery(params); console.log(res); return res; } @@ -500,22 +511,35 @@ export class CosmosRestClient extends BaseRestClient { return res.nodeInfo; } async getBaseValidatorsetAt(height: string | number, offset: number) { - const query = `?pagination.limit=100&pagination.offset=${offset}`; - return this.request( - this.registry.base_tendermint_validatorsets_height, - { - height, - }, - query + // const query = `?pagination.limit=100&pagination.offset=${offset}`; + // return this.request( + // this.registry.base_tendermint_validatorsets_height, + // { + // height, + // }, + // query + // ); + // const per_page = 10; + // const page = Math.ceil(offset / per_page); + + const res = await this.tmClient.validatorsAll( + Number(height) + // per_page, + // page, ); + console.log(res); + return res; } async getBaseValidatorsetLatest(offset: number) { - const query = `?pagination.limit=100&pagination.offset=${offset}`; - return this.request( - this.registry.base_tendermint_validatorsets_latest, - {}, - query - ); + // const query = `?pagination.limit=100&pagination.offset=${offset}`; + // return this.request( + // this.registry.base_tendermint_validatorsets_latest, + // {}, + // query + // ); + const res = await this.tmClient.validatorsAll(); + console.log(res); + return res; } // tx async getTxsBySender(sender: string, page?: PageRequest) { diff --git a/src/modules/[chain]/indexStore.ts b/src/modules/[chain]/indexStore.ts index 440c7e81..4b503292 100644 --- a/src/modules/[chain]/indexStore.ts +++ b/src/modules/[chain]/indexStore.ts @@ -87,33 +87,33 @@ export const useIndexModule = defineStore('module-index', { return useBankStore(); }, twitter(): string { - if(!this.coinInfo?.links?.twitter_screen_name) return "" + if (!this.coinInfo?.links?.twitter_screen_name) return ''; return `https://twitter.com/${this.coinInfo?.links.twitter_screen_name}`; }, homepage(): string { - if(!this.coinInfo?.links?.homepage) return "" + if (!this.coinInfo?.links?.homepage) return ''; const [page1, page2, page3] = this.coinInfo?.links?.homepage; return page1 || page2 || page3; }, github(): string { - if(!this.coinInfo?.links?.repos_url) return "" + if (!this.coinInfo?.links?.repos_url) return ''; const [page1, page2, page3] = this.coinInfo?.links?.repos_url?.github; return page1 || page2 || page3; }, telegram(): string { - if(!this.coinInfo?.links?.homepage) return "" + if (!this.coinInfo?.links?.homepage) return ''; return `https://t.me/${this.coinInfo?.links.telegram_channel_identifier}`; }, priceChange(): string { - if(!this.coinInfo?.market_data?.price_change_percentage_24h) return "" + if (!this.coinInfo?.market_data?.price_change_percentage_24h) return ''; const change = this.coinInfo?.market_data?.price_change_percentage_24h || 0; return numeral(change).format('+0.[00]'); }, priceColor(): string { - if(!this.coinInfo?.market_data?.price_change_percentage_24h) return "" + if (!this.coinInfo?.market_data?.price_change_percentage_24h) return ''; const change = this.coinInfo?.market_data?.price_change_percentage_24h || 0; switch (true) { @@ -126,7 +126,7 @@ export const useIndexModule = defineStore('module-index', { } }, trustColor(): string { - if(!this.coinInfo?.tickers) return "" + if (!this.coinInfo?.tickers) return ''; const change = this.coinInfo?.tickers[this.tickerIndex]?.trust_score; return change; }, @@ -137,8 +137,8 @@ export const useIndexModule = defineStore('module-index', { }, proposals() { - const gov = useGovStore() - return gov.proposals['2'] + const gov = useGovStore(); + return gov.proposals['2']; }, stats() { @@ -148,6 +148,8 @@ export const useIndexModule = defineStore('module-index', { const mintStore = useMintStore(); const formatter = useFormatter(); + console.log('base', JSON.stringify(base, null, 2)); + return [ { title: 'Height', @@ -160,7 +162,9 @@ export const useIndexModule = defineStore('module-index', { title: 'Validators', color: 'error', icon: 'mdi-human-queue', - stats: String(base?.latest?.block?.last_commit?.signatures.length || 0), + stats: String( + base?.latest?.block?.last_commit?.signatures.length || 0 + ), change: 0, }, { @@ -207,8 +211,8 @@ export const useIndexModule = defineStore('module-index', { this.tickerIndex = 0; // @ts-ignore const [firstAsset] = this.blockchain?.assets || []; - return firstAsset.coingecko_id - } + return firstAsset.coingecko_id; + }, }, actions: { async loadDashboard() {