forked from cerc-io/cosmos-explorer
update osmosis client
This commit is contained in:
parent
7662350921
commit
baf1813d1c
@ -1,11 +1,27 @@
|
|||||||
import type{ RequestRegistry } from '@/libs/registry'
|
import type{ RequestRegistry } from '@/libs/registry'
|
||||||
// import dayjs from 'dayjs'
|
// import dayjs from 'dayjs'
|
||||||
|
import { adapter } from '@/libs/registry'
|
||||||
|
import type { GovProposal, PaginatedProposals } from '@/types'
|
||||||
|
|
||||||
// which registry is store
|
// which registry is store
|
||||||
export const store = 'name' // name or version
|
export const store = 'name' // name or version
|
||||||
// Blockchain Name
|
// Blockchain Name
|
||||||
export const name = 'osmosis'
|
export const name = 'osmosis'
|
||||||
|
|
||||||
|
function proposalAdapter(p: any): GovProposal {
|
||||||
|
if(p) {
|
||||||
|
if(p.messages && p.messages.length >= 1) p.content = p.messages[0].content || p.messages[0]
|
||||||
|
p.proposal_id = p.id
|
||||||
|
p.final_tally_result = {
|
||||||
|
yes: p.final_tally_result?.yes_count,
|
||||||
|
no: p.final_tally_result?.no_count,
|
||||||
|
no_with_veto: p.final_tally_result?.no_with_veto_count,
|
||||||
|
abstain: p.final_tally_result?.abstain_count,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// osmosis custom request
|
// osmosis custom request
|
||||||
export const requests: Partial<RequestRegistry> = {
|
export const requests: Partial<RequestRegistry> = {
|
||||||
mint_inflation: {
|
mint_inflation: {
|
||||||
@ -15,4 +31,38 @@ export const requests: Partial<RequestRegistry> = {
|
|||||||
return {inflation: String(Number(first?.apr|| "0")/100.0)}
|
return {inflation: String(Number(first?.apr|| "0")/100.0)}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
gov_params_voting: { url: '/cosmos/gov/v1/params/voting', adapter },
|
||||||
|
gov_params_tally: { url: '/cosmos/gov/v1/params/tallying', adapter },
|
||||||
|
gov_params_deposit: { url: '/cosmos/gov/v1/params/deposit', adapter },
|
||||||
|
gov_proposals: { url: '/cosmos/gov/v1/proposals', adapter: (source: any): PaginatedProposals => {
|
||||||
|
const proposals = source.proposals.map((p:any) => proposalAdapter(p))
|
||||||
|
return {
|
||||||
|
proposals,
|
||||||
|
pagination: source.pagination
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
gov_proposals_proposal_id: {
|
||||||
|
url: '/cosmos/gov/v1/proposals/{proposal_id}',
|
||||||
|
adapter: (source: any): {proposal: GovProposal} => {
|
||||||
|
return {
|
||||||
|
proposal: proposalAdapter(source.proposal)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gov_proposals_deposits: {
|
||||||
|
url: '/cosmos/gov/v1/proposals/{proposal_id}/deposits',
|
||||||
|
adapter,
|
||||||
|
},
|
||||||
|
gov_proposals_tally: {
|
||||||
|
url: '/cosmos/gov/v1/proposals/{proposal_id}/tally',
|
||||||
|
adapter,
|
||||||
|
},
|
||||||
|
gov_proposals_votes: {
|
||||||
|
url: '/cosmos/gov/v1/proposals/{proposal_id}/votes',
|
||||||
|
adapter,
|
||||||
|
},
|
||||||
|
gov_proposals_votes_voter: {
|
||||||
|
url: '/cosmos/gov/v1/proposals/{proposal_id}/votes/{voter}',
|
||||||
|
adapter,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user