-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoracle_client.go
More file actions
39 lines (32 loc) · 852 Bytes
/
oracle_client.go
File metadata and controls
39 lines (32 loc) · 852 Bytes
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
package client
import (
"fmt"
)
// OracleClient provides a set of methods for the Oracle module
type OracleClient struct {
dc DnodeClient
}
// PostPrices sends asset prices to the oracle module.
func (c OracleClient) PostPrices(msgs []MsgPostPrice) (result TxResponse, err error) {
msg := make([]Msg, len(msgs))
for i, p := range msgs {
msg[i] = p
}
return c.dc.Tx().Broadcast(msg)
}
// Assets returns the array of available assets of the oracle module.
func (c OracleClient) Assets() (Assets, error) {
resp, err := c.dc.httpcl.R().Get(fmt.Sprintf("%s/oracle/assets", c.dc.nodeURL))
if err != nil {
return Assets{}, err
}
var res = struct {
Height string `json:"height"`
Result Assets `json:"result"`
}{}
err = c.dc.httpcl.JSONUnmarshal(resp.Body(), &res)
if err != nil {
return Assets{}, err
}
return res.Result, nil
}