Skip to content

Commit

Permalink
feat(namada): add 4 more abci queries
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Dec 18, 2024
1 parent 849a58a commit 8d0c2e5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/namada/NamadaChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,16 @@ export default class NamadaChain extends CW.Chain {
fetchTotalStaked (epoch?: Epoch) {
return this.getConnection().fetchTotalStakedImpl(epoch)
}
fetchDenomination (token: string) {
return this.getConnection().fetchDenominationImpl(token)
}
fetchTotalSupply (token: string) {
return this.getConnection().fetchTotalSupplyImpl(token)
}
fetchEffectiveNativeSupply () {
return this.getConnection().fetchEffectiveNativeSupplyImpl()
}
fetchStakingRewardsRate () {
return this.getConnection().fetchStakingRewardsRateImpl()
}
}
12 changes: 12 additions & 0 deletions packages/namada/NamadaConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ export default class NamadaConnection extends CW.Connection {
fetchBondWithSlashingImpl (delegator: string, validator: string, epoch?: Epoch.Epoch) {
return PoS.fetchBondWithSlashing(this, delegator, validator, epoch)
}
fetchDenominationImpl (token: string) {
return Token.fetchDenomination(this, token)
}
fetchTotalSupplyImpl (token: string) {
return Token.fetchTotalSupply(this, token)
}
fetchEffectiveNativeSupplyImpl () {
return Token.fetchEffectiveNativeSupply(this)
}
fetchStakingRewardsRateImpl () {
return Token.fetchStakingRewardsRate(this)
}
}

export function fetchStorageValue (
Expand Down
19 changes: 19 additions & 0 deletions packages/namada/NamadaToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { decode, u64 } from '@hackbg/borshest'
import type { NamadaConnection as Connection } from './namada-connection'

export async function fetchDenomination (connection: Connection, token: string) {
const binary = await connection.abciQuery(`/vp/token/denomination/${token}`)
return connection.decode.denomination(binary)
}
export async function fetchTotalSupply (connection: Connection, token: string) {
const binary = await connection.abciQuery(`/vp/token/total_supply/${token}`)
return decode(u64, binary)
}
export async function fetchEffectiveNativeSupply (connection: Connection) {
const binary = await connection.abciQuery(`/vp/token/effective_native_supply`)
return decode(u64, binary)
}
export async function fetchStakingRewardsRate (connection: Connection) {
const binary = await connection.abciQuery(`/vp/token/staking_rewards_rate`)
return connection.decode.pos_rewards_rates(binary)
}

0 comments on commit 8d0c2e5

Please sign in to comment.