-
Notifications
You must be signed in to change notification settings - Fork 81
/
get_account_info.go
65 lines (54 loc) · 2.46 KB
/
get_account_info.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package rpc
import (
"context"
)
// GetAccountInfoConfigEncoding is account's data encode format
type GetAccountInfoConfigEncoding string
const (
// GetAccountInfoConfigEncodingBase58 limited to Account data of less than 128 bytes
GetAccountInfoConfigEncodingBase58 GetAccountInfoConfigEncoding = "base58"
GetAccountInfoConfigEncodingJsonParsed GetAccountInfoConfigEncoding = "jsonParsed"
GetAccountInfoConfigEncodingBase64 GetAccountInfoConfigEncoding = "base64"
GetAccountInfoConfigEncodingBase64Zstd GetAccountInfoConfigEncoding = "base64+zstd"
)
// GetAccountInfoConfig is an option config for `getAccountInfo`
type GetAccountInfoConfig struct {
Commitment Commitment `json:"commitment,omitempty"`
Encoding GetAccountInfoConfigEncoding `json:"encoding,omitempty"`
DataSlice *GetAccountInfoConfigDataSlice `json:"dataSlice,omitempty"`
}
// GetAccountInfoResponse is a full raw rpc response of `getAccountInfo`
type GetAccountInfoResponse struct {
GeneralResponse
Result GetAccountInfoResult `json:"result"`
}
// GetAccountInfoConfigDataSlice is a part of GetAccountInfoConfig
type GetAccountInfoConfigDataSlice struct {
Offset uint64 `json:"offset,omitempty"`
Length uint64 `json:"length,omitempty"`
}
// GetAccountInfoResult is rpc result of `getAccountInfo`
type GetAccountInfoResult struct {
Context Context `json:"context"`
Value GetAccountInfoResultValue `json:"value"`
}
// GetAccountInfoResultValue is rpc result of `getAccountInfo`
type GetAccountInfoResultValue struct {
Lamports uint64 `json:"lamports"`
Owner string `json:"owner"`
Excutable bool `json:"excutable"`
RentEpoch uint64 `json:"rentEpoch"`
Data interface{} `json:"data"`
}
// GetAccountInfo returns all information associated with the account of provided Pubkey
func (c *RpcClient) GetAccountInfo(ctx context.Context, base58Addr string) (GetAccountInfoResponse, error) {
return c.processGetAccountInfo(c.Call(ctx, "getAccountInfo", base58Addr))
}
// GetAccountInfo returns all information associated with the account of provided Pubkey
func (c *RpcClient) GetAccountInfoWithConfig(ctx context.Context, base58Addr string, cfg GetAccountInfoConfig) (GetAccountInfoResponse, error) {
return c.processGetAccountInfo(c.Call(ctx, "getAccountInfo", base58Addr, cfg))
}
func (c *RpcClient) processGetAccountInfo(body []byte, rpcErr error) (res GetAccountInfoResponse, err error) {
err = c.processRpcCall(body, rpcErr, &res)
return
}