-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathget_token_supply.go
31 lines (24 loc) · 1.22 KB
/
get_token_supply.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package rpc
import (
"context"
)
type GetTokenSupplyResponse JsonRpcResponse[GetTokenSupply]
type GetTokenSupply ValueWithContext[GetTokenSupplyResultValue]
// GetTokenSupplyResultValue is a part of `getTokenSupply` raw response
type GetTokenSupplyResultValue struct {
Amount string `json:"amount"`
Decimals uint8 `json:"decimals"`
UIAmountString string `json:"uiAmountString"`
}
// GetTokenSupplyConfig is option config of `getTokenSupply`
type GetTokenSupplyConfig struct {
Commitment Commitment `json:"commitment,omitempty"`
}
// GetTokenSupply returns the token balance of an SPL Token account
func (c *RpcClient) GetTokenSupply(ctx context.Context, mintAddr string) (JsonRpcResponse[ValueWithContext[GetTokenSupplyResultValue]], error) {
return call[JsonRpcResponse[ValueWithContext[GetTokenSupplyResultValue]]](c, ctx, "getTokenSupply", mintAddr)
}
// GetTokenSupply returns the token balance of an SPL Token account
func (c *RpcClient) GetTokenSupplyWithConfig(ctx context.Context, mintAddr string, cfg GetTokenSupplyConfig) (JsonRpcResponse[ValueWithContext[GetTokenSupplyResultValue]], error) {
return call[JsonRpcResponse[ValueWithContext[GetTokenSupplyResultValue]]](c, ctx, "getTokenSupply", mintAddr, cfg)
}