forked from blocto/solana-go-sdk
/
get_multiple_accounts.go
65 lines (54 loc) · 2.67 KB
/
get_multiple_accounts.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"
)
// GetMultipleAccountsConfigEncoding is account's data encode format
type GetMultipleAccountsConfigEncoding string
const (
// GetMultipleAccountConfigEncodingBase58 limited to Account data of less than 128 bytes
GetMultipleAccountsConfigEncodingBase58 GetMultipleAccountsConfigEncoding = "base58"
GetMultipleAccountsConfigEncodingJsonParsed GetMultipleAccountsConfigEncoding = "jsonParsed"
GetMultipleAccountsConfigEncodingBase64 GetMultipleAccountsConfigEncoding = "base64"
GetMultipleAccountsConfigEncodingBase64Zstd GetMultipleAccountsConfigEncoding = "base64+zstd"
)
// GetMultipleAccountsConfig is an option config for `getAccountInfo`
type GetMultipleAccountsConfig struct {
Commitment Commitment `json:"commitment,omitempty"`
Encoding GetMultipleAccountsConfigEncoding `json:"encoding,omitempty"`
DataSlice *GetMultipleAccountsConfigDataSlice `json:"dataSlice,omitempty"`
}
// GetMultipleAccountsResponse is a full raw rpc response of `getAccountInfo`
type GetMultipleAccountsResponse struct {
GeneralResponse
Result GetMultipleAccountsResult `json:"result"`
}
// GetMultipleAccountsConfigDataSlice is a part of GetAccountInfoConfig
type GetMultipleAccountsConfigDataSlice struct {
Offset uint64 `json:"offset,omitempty"`
Length uint64 `json:"length,omitempty"`
}
// GetMultipleAccountsResult is rpc result of `getAccountInfo`
type GetMultipleAccountsResult struct {
Context Context `json:"context"`
Value []GetMultipleAccountsResultValue `json:"value"`
}
// GetMultipleAccountsResultValue is rpc result of `getAccountInfo`
type GetMultipleAccountsResultValue struct {
Lamports uint64 `json:"lamports"`
Owner string `json:"owner"`
Executable bool `json:"executable"`
RentEpoch uint64 `json:"rentEpoch"`
Data interface{} `json:"data"`
}
// GetMultipleAccounts returns all information associated with the account of provided Pubkey
func (c *RpcClient) GetMultipleAccounts(ctx context.Context, base58Addrs []string) (GetMultipleAccountsResponse, error) {
return c.processGetMultipleAccounts(c.Call(ctx, "getMultipleAccounts", base58Addrs))
}
// GetMultipleAccounts returns all information associated with the account of provided Pubkey
func (c *RpcClient) GetMultipleAccountsWithConfig(ctx context.Context, base58Addrs []string, cfg GetMultipleAccountsConfig) (GetMultipleAccountsResponse, error) {
return c.processGetMultipleAccounts(c.Call(ctx, "getMultipleAccounts", base58Addrs, cfg))
}
func (c *RpcClient) processGetMultipleAccounts(body []byte, rpcErr error) (res GetMultipleAccountsResponse, err error) {
err = c.processRpcCall(body, rpcErr, &res)
return
}