-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathget_token_account_by_owner.go
30 lines (23 loc) · 1.34 KB
/
get_token_account_by_owner.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
package rpc
import (
"context"
)
type GetTokenAccountsByOwnerResponse JsonRpcResponse[GetTokenAccountsByOwner]
type GetTokenAccountsByOwner ValueWithContext[GetProgramAccounts]
// GetTokenAccountsByOwnerConfig is a option config for `GetTokenAccountsByOwner`
type GetTokenAccountsByOwnerConfig struct {
Commitment Commitment `json:"commitment,omitempty"`
Encoding AccountEncoding `json:"encoding,omitempty"`
DataSlice *DataSlice `json:"dataSlice,omitempty"`
}
// GetTokenAccountsByOwnerConfigFilter either mint or programId
type GetTokenAccountsByOwnerConfigFilter struct {
Mint string `json:"mint,omitempty"`
ProgramId string `json:"programId,omitempty"`
}
func (c *RpcClient) GetTokenAccountsByOwner(ctx context.Context, base58Addr string, filter GetTokenAccountsByOwnerConfigFilter) (JsonRpcResponse[ValueWithContext[GetProgramAccounts]], error) {
return call[JsonRpcResponse[ValueWithContext[GetProgramAccounts]]](c, ctx, "getTokenAccountsByOwner", base58Addr, filter)
}
func (c *RpcClient) GetTokenAccountsByOwnerWithConfig(ctx context.Context, base58Addr string, filter GetTokenAccountsByOwnerConfigFilter, cfg GetTokenAccountsByOwnerConfig) (JsonRpcResponse[ValueWithContext[GetProgramAccounts]], error) {
return call[JsonRpcResponse[ValueWithContext[GetProgramAccounts]]](c, ctx, "getTokenAccountsByOwner", base58Addr, filter, cfg)
}