-
Notifications
You must be signed in to change notification settings - Fork 210
/
client.go
51 lines (43 loc) · 1.26 KB
/
client.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
package query
import (
sdkclient "github.com/cosmos/cosmos-sdk/client"
types "github.com/akash-network/akash-api/go/node/deployment/v1beta3"
)
// Client interface
type Client interface {
Deployments(DeploymentFilters) (Deployments, error)
Deployment(types.DeploymentID) (Deployment, error)
Group(types.GroupID) (Group, error)
}
// NewClient creates a client instance with provided context and key
func NewClient(ctx sdkclient.Context, key string) Client {
return &client{ctx: ctx, key: key}
}
type client struct {
ctx sdkclient.Context
key string
}
func (c *client) Deployments(dfilters DeploymentFilters) (Deployments, error) {
var obj Deployments
buf, err := NewRawClient(c.ctx, c.key).Deployments(dfilters)
if err != nil {
return obj, err
}
return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj)
}
func (c *client) Deployment(id types.DeploymentID) (Deployment, error) {
var obj Deployment
buf, err := NewRawClient(c.ctx, c.key).Deployment(id)
if err != nil {
return obj, err
}
return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj)
}
func (c *client) Group(id types.GroupID) (Group, error) {
var obj Group
buf, err := NewRawClient(c.ctx, c.key).Group(id)
if err != nil {
return obj, err
}
return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj)
}