diff --git a/client/src/rpc_response.rs b/client/src/rpc_response.rs index 2fbbc878608049..37d390e93d214a 100644 --- a/client/src/rpc_response.rs +++ b/client/src/rpc_response.rs @@ -226,7 +226,7 @@ pub struct RpcStakeActivation { pub struct RpcTokenAmount { pub ui_amount: f64, pub decimals: u8, - pub amount: RpcAmount, // "u64" + pub amount: RpcAmount, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] diff --git a/core/src/rpc.rs b/core/src/rpc.rs index ae92cabb5b18b2..f0dd96bbb8b6d9 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -1113,7 +1113,7 @@ fn get_token_program_id_and_mint( /// program_id) and decimals fn get_mint_owner_and_decimals(bank: &Arc, mint: &Pubkey) -> Result<(Pubkey, u8)> { if mint == &spl_token_v1_0_native_mint() { - // Uncomment the following once spl_token is bumped to a version that includes ative_mint::DECIMALS + // Uncomment the following once spl_token is bumped to a version that includes native_mint::DECIMALS // Ok((spl_token_id_v1_0(), spl_token_v1_0::native_mint::DECIMALS)) Ok((spl_token_id_v1_0(), 9)) } else { diff --git a/docs/src/apps/jsonrpc-api.md b/docs/src/apps/jsonrpc-api.md index 9895e48fcb9e2d..1bd046fc843068 100644 --- a/docs/src/apps/jsonrpc-api.md +++ b/docs/src/apps/jsonrpc-api.md @@ -1033,8 +1033,9 @@ Returns the token balance of an SPL Token account. The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: -- `amount: ` - the balance, using mint-prescribed decimals -- `rawAmount: ` - the raw balance without decimals +- `uiAmount: ` - the balance, using mint-prescribed decimals +- `amount: ` - the raw balance without decimals, a string representation of u64 +- `decimals: ` - number of base 10 digits to the right of the decimal place #### Example: @@ -1042,7 +1043,7 @@ The result will be an RpcResponse JSON object with `value` equal to a JSON objec // Request curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getTokenAccountBalance", "params": ["7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7"]}' http://localhost:8899 // Result -{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"amount":98.64,"rawAmount":9864},"id":1} +{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"uiAmount":98.64,"amount":"9864","decimals":2},"id":1} ``` ### getTokenAccountsByDelegate @@ -1130,8 +1131,9 @@ Returns the total supply of an SPL Token type. The result will be an RpcResponse JSON object with `value` equal to a JSON object containing: -- `amount: ` - the total token supply, using mint-prescribed decimals -- `rawAmount: ` - the raw total token supply without decimals +- `uiAmount: ` - the total token supply, using mint-prescribed decimals +- `amount: ` - the raw total token supply without decimals, a string representation of u64 +- `decimals: ` - number of base 10 digits to the right of the decimal place #### Example: @@ -1139,8 +1141,8 @@ The result will be an RpcResponse JSON object with `value` equal to a JSON objec // Request curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getTokenSupply", "params": ["3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"]}' http://localhost:8899 // Result -{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"amount":1000.0,"rawAmount":100000},"id":1} -```} +{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"uiAmount":1000.0,"amount":"100000","decimals":2},"id":1} +``` ### getTransactionCount