-
Notifications
You must be signed in to change notification settings - Fork 210
/
rawclient.go
40 lines (33 loc) · 927 Bytes
/
rawclient.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
package query
import (
"fmt"
sdkclient "github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// RawClient interface
type RawClient interface {
Providers() ([]byte, error)
Provider(sdk.AccAddress) ([]byte, error)
}
// NewRawClient creates a client instance with provided context and key
func NewRawClient(ctx sdkclient.Context, key string) RawClient {
return &rawclient{ctx: ctx, key: key}
}
type rawclient struct {
ctx sdkclient.Context
key string
}
func (c *rawclient) Providers() ([]byte, error) {
buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getProvidersPath()), nil)
if err != nil {
return []byte{}, err
}
return buf, err
}
func (c *rawclient) Provider(id sdk.AccAddress) ([]byte, error) {
buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getProviderPath(id)), nil)
if err != nil {
return []byte{}, err
}
return buf, err
}