-
Notifications
You must be signed in to change notification settings - Fork 241
/
source.go
53 lines (44 loc) · 1.24 KB
/
source.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
package remote
import (
sdk "github.com/cosmos/cosmos-sdk/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/forbole/juno/v2/node/remote"
distrsource "github.com/forbole/bdjuno/v2/modules/distribution/source"
)
var (
_ distrsource.Source = &Source{}
)
// Source implements distrsource.Source querying the data from a remote node
type Source struct {
*remote.Source
distrClient distrtypes.QueryClient
}
// NewSource returns a new Source instace
func NewSource(source *remote.Source, distrClient distrtypes.QueryClient) *Source {
return &Source{
Source: source,
distrClient: distrClient,
}
}
// CommunityPool implements distrsource.Source
func (s Source) CommunityPool(height int64) (sdk.DecCoins, error) {
res, err := s.distrClient.CommunityPool(
remote.GetHeightRequestContext(s.Ctx, height),
&distrtypes.QueryCommunityPoolRequest{},
)
if err != nil {
return nil, err
}
return res.Pool, nil
}
// Params implements distrsource.Source
func (s Source) Params(height int64) (distrtypes.Params, error) {
res, err := s.distrClient.Params(
remote.GetHeightRequestContext(s.Ctx, height),
&distrtypes.QueryParamsRequest{},
)
if err != nil {
return distrtypes.Params{}, err
}
return res.Params, nil
}