forked from blocto/solana-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_stake_activation.go
43 lines (36 loc) · 1.25 KB
/
get_stake_activation.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
package rpc
import (
"context"
"errors"
)
type StakeActivationState string
const (
StakeActivationStateActive StakeActivationState = "active"
StakeActivationStateInactive StakeActivationState = "inactive"
StakeActivationStateActivating StakeActivationState = "activating"
StakeActivationStateDeactivating StakeActivationState = "deactivating"
)
type GetStakeActivationConfig struct {
Commitment Commitment `json:"commitment,omitempty"`
Epoch uint64 `json:"epoch,omitempty"`
}
type GetStakeActivationResponse struct {
State StakeActivationState `json:"state"`
Active uint64 `json:"active"`
Inactive uint64 `json:"inactive"`
}
// GetStakeActivation returns epoch activation information for a stake account
func (s *RpcClient) GetStakeActivation(ctx context.Context, address string, cfg GetStakeActivationConfig) (GetStakeActivationResponse, error) {
res := struct {
GeneralResponse
Result GetStakeActivationResponse `json:"result"`
}{}
err := s.request(ctx, "getStakeActivation", []interface{}{address, cfg}, &res)
if err != nil {
return GetStakeActivationResponse{}, err
}
if res.Error != nil {
return GetStakeActivationResponse{}, errors.New(res.Error.Message)
}
return res.Result, nil
}