Skip to content

Commit

Permalink
fix(namada): decode decimals and pos_rew rates
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Dec 19, 2024
1 parent cdb2e78 commit 5eb10c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/namada/NamadaToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { NamadaConnection as Connection } from './NamadaConnection'

export async function fetchDenomination (connection: Connection, token: string) {
const binary = await connection.abciQuery(`/vp/token/denomination/${token}`)
return connection.decode.denomination(binary)
return decode(u8, binary)
}
export async function fetchTotalSupply (connection: Connection, token: string) {
const binary = await connection.abciQuery(`/vp/token/total_supply/${token}`)
Expand Down
9 changes: 9 additions & 0 deletions packages/namada/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,13 @@ impl Decode {
"totalAbstainPower" = result.total_abstain_power,
})
}

#[wasm_bindgen]
pub fn pos_rewards_rates (source: Uint8Array) -> Result<Object, Error> {
let result = PosRewardsRates::try_from_slice(&to_bytes(&source));
Ok(to_object! {
"stakingRewardsRate" = result.staking_rewards_rate,
"inflationRate" = result.inflation_rate,
})
}
}
3 changes: 2 additions & 1 deletion packages/namada/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub(crate) use namada_sdk::{
ValidatorState,
ValidatorStateInfo,
WeightedValidator,
}
},
rewards::PosRewardsRates,
},
storage::KeySeg,
string_encoding::Format,
Expand Down

0 comments on commit 5eb10c3

Please sign in to comment.