Return token amounts as floats (#11370)
* Return token amounts as floats * Floating-point equality * Return float and raw token amounts * Fix decimals and token rpcs for native-mint tokens * Fixup docs and review comments
This commit is contained in:
@@ -9,6 +9,7 @@ use solana_sdk::{
|
||||
use std::{collections::HashMap, net::SocketAddr};
|
||||
|
||||
pub type RpcResult<T> = client_error::Result<Response<T>>;
|
||||
pub type RpcAmount = String;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct RpcResponseContext {
|
||||
@@ -220,9 +221,18 @@ pub struct RpcStakeActivation {
|
||||
pub inactive: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcTokenAmount {
|
||||
pub ui_amount: f64,
|
||||
pub decimals: u8,
|
||||
pub amount: RpcAmount,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RpcTokenAccountBalance {
|
||||
pub address: String,
|
||||
pub amount: u64,
|
||||
#[serde(flatten)]
|
||||
pub amount: RpcTokenAmount,
|
||||
}
|
||||
|
Reference in New Issue
Block a user