-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgs.go
46 lines (37 loc) · 819 Bytes
/
msgs.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
package request
import (
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
"github.com/bandprotocol/go-band-sdk/requester/types"
)
var (
_ types.Task = &Task{}
_ types.SuccessResponse = &SuccessResponse{}
_ types.FailResponse = &FailResponse{}
)
type Task struct {
id uint64 // ID to identify request with response later
RequestID uint64
Msg oracletypes.MsgRequestData
}
func NewTask(id, requestID uint64, msg oracletypes.MsgRequestData) Task {
return Task{
id: id,
RequestID: requestID,
Msg: msg,
}
}
func (t Task) ID() uint64 {
return t.id
}
type SuccessResponse struct {
Task
oracletypes.Result
}
type FailResponse struct {
Task
oracletypes.Result
error types.Error
}
func (r FailResponse) Error() string {
return r.error.Error()
}