-
Notifications
You must be signed in to change notification settings - Fork 81
/
get_balance.go
37 lines (30 loc) · 1.1 KB
/
get_balance.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
32
33
34
35
36
37
package rpc
import (
"context"
)
// GetBalanceResponse is a full raw rpc response of `getBalance`
type GetBalanceResponse struct {
GeneralResponse
Result GetBalanceResult `json:"result"`
}
// GetBalanceResult is a part of raw rpc response of `getBalance`
type GetBalanceResult struct {
Context Context `json:"context"`
Value uint64 `json:"value"`
}
// GetBalanceConfig is a option config for `getBalance`
type GetBalanceConfig struct {
Commitment Commitment `json:"commitment,omitempty"`
}
// GetBalance returns the SOL balance
func (c *RpcClient) GetBalance(ctx context.Context, base58Addr string) (GetBalanceResponse, error) {
return c.processGetBalance(c.Call(ctx, "getBalance", base58Addr))
}
// GetBalanceWithConfig returns the SOL balance
func (c *RpcClient) GetBalanceWithConfig(ctx context.Context, base58Addr string, cfg GetBalanceConfig) (GetBalanceResponse, error) {
return c.processGetBalance(c.Call(ctx, "getBalance", base58Addr, cfg))
}
func (c *RpcClient) processGetBalance(body []byte, rpcErr error) (res GetBalanceResponse, err error) {
err = c.processRpcCall(body, rpcErr, &res)
return
}