Skip to content

Commit

Permalink
Fixup docs and review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Aug 5, 2020
1 parent 51dab9e commit 6bb27e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/rpc_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ fn get_token_program_id_and_mint(
/// program_id) and decimals
fn get_mint_owner_and_decimals(bank: &Arc<Bank>, 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 {
Expand Down
14 changes: 8 additions & 6 deletions docs/src/apps/jsonrpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1033,16 +1033,17 @@ 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: <f64>` - the balance, using mint-prescribed decimals
- `rawAmount: <u64>` - the raw balance without decimals
- `uiAmount: <f64>` - the balance, using mint-prescribed decimals
- `amount: <string>` - the raw balance without decimals, a string representation of u64
- `decimals: <u8>` - number of base 10 digits to the right of the decimal place
#### Example:
```bash
// 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
Expand Down Expand Up @@ -1130,16 +1131,17 @@ 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: <f64>` - the total token supply, using mint-prescribed decimals
- `rawAmount: <u64>` - the raw total token supply without decimals
- `uiAmount: <f64>` - the total token supply, using mint-prescribed decimals
- `amount: <string>` - the raw total token supply without decimals, a string representation of u64
- `decimals: <u8>` - number of base 10 digits to the right of the decimal place
#### Example:
```bash
// 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
Expand Down

0 comments on commit 6bb27e9

Please sign in to comment.