-
Notifications
You must be signed in to change notification settings - Fork 48
/
query.go
75 lines (65 loc) · 2.14 KB
/
query.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package types
// DONTCOVER
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
query "github.com/cosmos/cosmos-sdk/types/query"
)
// NewQuerySubspacePostsRequest returns a new QuerySubspacePostsRequest instance
func NewQuerySubspacePostsRequest(subspaceID uint64, pagination *query.PageRequest) *QuerySubspacePostsRequest {
return &QuerySubspacePostsRequest{
SubspaceId: subspaceID,
Pagination: pagination,
}
}
// NewQuerySectionPostsRequest returns a new QuerySectionPostsRequest instance
func NewQuerySectionPostsRequest(subspaceID uint64, sectionID uint32, pagination *query.PageRequest) *QuerySectionPostsRequest {
return &QuerySectionPostsRequest{
SubspaceId: subspaceID,
SectionId: sectionID,
Pagination: pagination,
}
}
// NewQueryPostRequest returns a new QueryPostRequest instance
func NewQueryPostRequest(subspaceID uint64, postID uint64) *QueryPostRequest {
return &QueryPostRequest{
SubspaceId: subspaceID,
PostId: postID,
}
}
// NewQueryPostAttachmentsRequest returns a new QueryPostAttachmentsRequest instance
func NewQueryPostAttachmentsRequest(
subspaceID uint64, postID uint64, pagination *query.PageRequest,
) *QueryPostAttachmentsRequest {
return &QueryPostAttachmentsRequest{
SubspaceId: subspaceID,
PostId: postID,
Pagination: pagination,
}
}
// UnpackInterfaces implements codectypes.UnpackInterfacesMessage
func (r *QueryPostAttachmentsResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
for _, a := range r.Attachments {
var content AttachmentContent
err := unpacker.UnpackAny(a.Content, &content)
if err != nil {
return err
}
}
return nil
}
// NewQueryPollAnswersRequest returns a new QueryPollAnswersRequest instance
func NewQueryPollAnswersRequest(
subspaceID uint64, postID uint64, pollID uint32, user string, pagination *query.PageRequest,
) *QueryPollAnswersRequest {
return &QueryPollAnswersRequest{
SubspaceId: subspaceID,
PostId: postID,
PollId: pollID,
User: user,
Pagination: pagination,
}
}
// NewQueryParamsRequest returns a new QueryParamsRequest instance
func NewQueryParamsRequest() *QueryParamsRequest {
return &QueryParamsRequest{}
}