diff --git a/.changeset/entries/f05be9e498c60b54bc0db2bf70d9b5660a0ad227da70dc03061063957e756e9c.yaml b/.changeset/entries/f05be9e498c60b54bc0db2bf70d9b5660a0ad227da70dc03061063957e756e9c.yaml new file mode 100644 index 0000000000..47e82bfbf3 --- /dev/null +++ b/.changeset/entries/f05be9e498c60b54bc0db2bf70d9b5660a0ad227da70dc03061063957e756e9c.yaml @@ -0,0 +1,6 @@ +type: feat +module: x/subspaces +pull_request: 866 +description: Added support for subspaces sections +backward_compatible: false +date: 2022-05-18T09:05:33.838945166Z diff --git a/app/params/weights.go b/app/params/weights.go index 1358838671..b940598b2b 100644 --- a/app/params/weights.go +++ b/app/params/weights.go @@ -17,8 +17,13 @@ const ( DefaultWeightMsgCreateSubspace int = 80 DefaultWeightMsgEditSubspace int = 30 DefaultWeightMsgDeleteSubspace int = 5 + DefaultWeightMsgCreateSection int = 20 + DefaultWeightMsgEditSection int = 12 + DefaultWeightMsgMoveSection int = 10 + DefaultWeightMsgDeleteSection int = 5 DefaultWeightMsgCreateUserGroup int = 10 DefaultWeightMsgEditUserGroup int = 30 + DefaultWeightMsgMoveUserGroup int = 30 DefaultWeightMsgSetUserGroupPermissions int = 50 DefaultWeightMsgDeleteUserGroup int = 5 DefaultWeightMsgAddUserToUserGroup int = 7 diff --git a/client/docs/config.json b/client/docs/config.json index 8e1a29033c..9f70371019 100644 --- a/client/docs/config.json +++ b/client/docs/config.json @@ -18,7 +18,7 @@ "url": "./tmp-swagger-gen/desmos/relationships/v1/query.swagger.json" }, { - "url": "./tmp-swagger-gen/desmos/subspaces/v1/query.swagger.json" + "url": "./tmp-swagger-gen/desmos/subspaces/v2/query.swagger.json" }, { "url": "./tmp-swagger-gen/desmos/posts/v1/query.swagger.json", diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 1371bc9fed..82978611bc 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -4303,6 +4303,12 @@ paths: type: string format: uint64 title: ID of the subspace inside which this group exists + section_id: + type: integer + format: int64 + title: >- + (optional) Id of the section inside which this group is + valid id: type: integer format: int64 @@ -4376,10 +4382,17 @@ paths: format: byte parameters: - name: subspace_id + description: Id of the subspace to query the groups for in: path required: true type: string format: uint64 + - name: section_id + description: (optional) Section id to query the groups for. + in: query + required: false + type: integer + format: int64 - name: pagination.key description: |- key is a value returned in PageResponse.next_key to begin @@ -4459,6 +4472,12 @@ paths: type: string format: uint64 title: ID of the subspace inside which this group exists + section_id: + type: integer + format: int64 + title: >- + (optional) Id of the section inside which this group is + valid id: type: integer format: int64 @@ -4671,6 +4690,14 @@ paths: items: type: object properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace for which this permission is valid + section_id: + type: integer + format: int64 + title: Id of the section for which this permission is valid user: title: User represents a user permission type: object @@ -4730,6 +4757,236 @@ paths: in: path required: true type: string + - name: section_id + in: query + required: false + type: integer + format: int64 + tags: + - Query + '/desmos/subspaces/v2/{subspace_id}/sections': + get: + summary: Sections allows to query for the sections of a specific subspace + operationId: Sections + responses: + '200': + description: A successful response. + schema: + type: object + properties: + sections: + type: array + items: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace inside which the section exists + id: + type: integer + format: int64 + title: Unique id of the section within the subspace + parent_id: + type: integer + format: int64 + title: (optional) Id of the parent section + name: + type: string + title: Name of the section within the subspace + description: + type: string + title: (optional) Description of the section + title: Section contains the data of a single subspace section + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: >- + QuerySectionsResponse is the response type for Query/Sections RPC + method + default: + description: An unexpected error response + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: subspace_id + description: Id of the subspace to query the sections for + in: path + required: true + type: string + format: uint64 + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + format: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + format: boolean + tags: + - Query + '/desmos/subspaces/v2/{subspace_id}/sections/{section_id}': + get: + summary: Section queries all the information about the section with the given id + operationId: Section + responses: + '200': + description: A successful response. + schema: + type: object + properties: + section: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace inside which the section exists + id: + type: integer + format: int64 + title: Unique id of the section within the subspace + parent_id: + type: integer + format: int64 + title: (optional) Id of the parent section + name: + type: string + title: Name of the section within the subspace + description: + type: string + title: (optional) Description of the section + title: Section contains the data of a single subspace section + title: >- + QuerySectionResponse is the response type for Query/Section RPC + method + default: + description: An unexpected error response + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + value: + type: string + format: byte + parameters: + - name: subspace_id + description: Id of the subspace inside which to search for + in: path + required: true + type: string + format: uint64 + - name: section_id + description: Id of the searched section + in: path + required: true + type: integer + format: int64 tags: - Query /desmos/posts/v1/params: @@ -4946,8 +5203,8 @@ paths: - Query '/desmos/posts/v1/{subspace_id}/posts': get: - summary: Posts queries all the posts inside a given subspace - operationId: Posts + summary: SubspacePosts queries all the posts inside a given subspace + operationId: SubspacePosts responses: '200': description: A successful response. @@ -4965,6 +5222,10 @@ paths: title: >- Id of the subspace inside which the post has been created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created id: type: string format: uint64 @@ -5138,8 +5399,10 @@ paths: PageResponse page = 2; } title: >- - QueryPostsResponse is the response type for the Query/Posts RPC - method + QuerySubspacePostsResponse is the response type for the + Query/SubspacePosts + + RPC method default: description: An unexpected error response schema: @@ -5413,6 +5676,10 @@ paths: type: string format: uint64 title: Id of the subspace inside which the post has been created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created id: type: string format: uint64 @@ -5784,6 +6051,14 @@ paths: attachment should be connected is + section_id: + type: integer + format: int64 + title: >- + Id of the subspace section inside which the post to + which this attachment + + should be connected is post_id: type: string format: uint64 @@ -6286,6 +6561,12 @@ paths: title: >- Subspace id inside which the post related to this attachment is located + section_id: + type: integer + format: int64 + title: >- + Section id inside which the post related to this + attachment is located post_id: type: string format: uint64 @@ -6609,38 +6890,502 @@ paths: format: boolean tags: - Query - /desmos/fees/v1/params: + '/desmos/posts/v1/{subspace_id}/{section_id}/posts': get: - summary: Params queries the fees module params - operationId: FeesParams + summary: SectionPosts queries all the posts inside a given section + operationId: SectionPosts responses: '200': description: A successful response. schema: type: object properties: - params: - type: object - properties: - min_fees: - type: array - items: - type: object - properties: - message_type: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. + posts: + type: array + items: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: >- + Id of the subspace inside which the post has been + created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created + id: + type: string + format: uint64 + title: Unique id of the post + external_id: + type: string + title: (optional) External id for this post + text: + type: string + title: (optional) Text of the post + entities: + title: (optional) Entities connected to this post + type: object + properties: + hashtags: + type: array + items: + type: object + properties: + start: + type: string + format: uint64 + title: >- + Index of the character inside the text at + which the tag starts + end: + type: string + format: uint64 + title: >- + Index of the character inside the text at + which the tag ends + tag: + type: string + title: >- + Tag reference (user address, hashtag value, + etc) + title: Tag represents a generic tag + mentions: + type: array + items: + type: object + properties: + start: + type: string + format: uint64 + title: >- + Index of the character inside the text at + which the tag starts + end: + type: string + format: uint64 + title: >- + Index of the character inside the text at + which the tag ends + tag: + type: string + title: >- + Tag reference (user address, hashtag value, + etc) + title: Tag represents a generic tag + urls: + type: array + items: + type: object + properties: + start: + type: string + format: uint64 + title: >- + Index of the character inside the text at + which the URL starts + end: + type: string + format: uint64 + title: >- + Index of the character inside the text at + which the URL ends + url: + type: string + title: >- + Value of the URL where the user should be + redirected to + display_url: + type: string + title: (optional) Display value of the URL + title: Url contains the details of a generic URL + author: + type: string + title: Author of the post + conversation_id: + type: string + format: uint64 + title: (optional) Id of the original post of the conversation + referenced_posts: + type: array + items: + type: object + properties: + type: + title: Type of reference + type: string + enum: + - TYPE_UNSPECIFIED + - TYPE_REPLIED_TO + - TYPE_QUOTED + - TYPE_REPOSTED + default: TYPE_UNSPECIFIED + description: |- + - TYPE_UNSPECIFIED: No reference specified + - TYPE_REPLIED_TO: This post is a reply to the referenced post + - TYPE_QUOTED: This post is a quote to the referenced post + - TYPE_REPOSTED: This post is a report of the referenced post + post_id: + type: string + format: uint64 + title: Id of the referenced post + title: PostReference contains the details of a post reference + title: >- + A list this posts references (either as a reply, repost + or quote) + reply_settings: + title: Reply settings of this post + type: string + enum: + - REPLY_SETTING_UNSPECIFIED + - REPLY_SETTING_EVERYONE + - REPLY_SETTING_FOLLOWERS + - REPLY_SETTING_MUTUAL + - REPLY_SETTING_MENTIONS + default: REPLY_SETTING_UNSPECIFIED + description: |- + - REPLY_SETTING_UNSPECIFIED: No reply setting specified + - REPLY_SETTING_EVERYONE: Everyone will be able to reply to this post + - REPLY_SETTING_FOLLOWERS: Only followers of the author will be able to reply to this post + - REPLY_SETTING_MUTUAL: Only the author mutual followers will be able to reply to this post + - REPLY_SETTING_MENTIONS: Only people mentioned inside this post will be able to reply + creation_date: + type: string + format: date-time + title: Creation date of the post + last_edited_date: + type: string + format: date-time + title: (optional) Last edited time of the post + title: Post contains all the information about a single post + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: >- + QuerySectionPostsResponse is the response type for the + Query/SectionPosts RPC + + method + default: + description: An unexpected error response + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := ptypes.MarshalAny(foo) + ... + foo := &pb.Foo{} + if err := ptypes.UnmarshalAny(any, foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + parameters: + - name: subspace_id + description: Id of the subspace to query the posts for + in: path + required: true + type: string + format: uint64 + - name: section_id + description: Id of the section to query the posts for + in: path + required: true + type: integer + format: int64 + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + format: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + format: boolean + tags: + - Query + /desmos/fees/v1/params: + get: + summary: Params queries the fees module params + operationId: FeesParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + type: object + properties: + min_fees: + type: array + items: + type: object + properties: + message_type: + type: string + amount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. NOTE: The amount field is an Int which implements @@ -10320,9 +11065,17 @@ definitions: Blocked user. - desmos.subspaces.v1.PermissionDetail: + desmos.subspaces.v2.PermissionDetail: type: object properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace for which this permission is valid + section_id: + type: integer + format: int64 + title: Id of the section for which this permission is valid user: title: User represents a user permission type: object @@ -10347,7 +11100,7 @@ definitions: format: int64 title: Permission set to the group title: PermissionDetail contains the details data of a permission - desmos.subspaces.v1.PermissionDetail.Group: + desmos.subspaces.v2.PermissionDetail.Group: type: object properties: group_id: @@ -10359,7 +11112,7 @@ definitions: format: int64 title: Permission set to the group title: Group is a permission that has been set to a user group - desmos.subspaces.v1.PermissionDetail.User: + desmos.subspaces.v2.PermissionDetail.User: type: object properties: user: @@ -10370,7 +11123,86 @@ definitions: format: int64 title: Permission set to the user title: User is a permission that has been set to a specific user - desmos.subspaces.v1.QuerySubspaceResponse: + desmos.subspaces.v2.QuerySectionResponse: + type: object + properties: + section: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace inside which the section exists + id: + type: integer + format: int64 + title: Unique id of the section within the subspace + parent_id: + type: integer + format: int64 + title: (optional) Id of the parent section + name: + type: string + title: Name of the section within the subspace + description: + type: string + title: (optional) Description of the section + title: Section contains the data of a single subspace section + title: QuerySectionResponse is the response type for Query/Section RPC method + desmos.subspaces.v2.QuerySectionsResponse: + type: object + properties: + sections: + type: array + items: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace inside which the section exists + id: + type: integer + format: int64 + title: Unique id of the section within the subspace + parent_id: + type: integer + format: int64 + title: (optional) Id of the parent section + name: + type: string + title: Name of the section within the subspace + description: + type: string + title: (optional) Description of the section + title: Section contains the data of a single subspace section + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: QuerySectionsResponse is the response type for Query/Sections RPC method + desmos.subspaces.v2.QuerySubspaceResponse: type: object properties: subspace: @@ -10405,7 +11237,7 @@ definitions: title: the creation time of the subspace title: Subspace contains all the data of a Desmos subspace title: QuerySubspaceResponse is the response type for the Query/Subspace method - desmos.subspaces.v1.QuerySubspacesResponse: + desmos.subspaces.v2.QuerySubspacesResponse: type: object properties: subspaces: @@ -10469,7 +11301,7 @@ definitions: title: |- QuerySubspacesResponse is the response type for the Query/Subspaces RPC method - desmos.subspaces.v1.QueryUserGroupMembersResponse: + desmos.subspaces.v2.QueryUserGroupMembersResponse: type: object properties: members: @@ -10504,7 +11336,7 @@ definitions: title: |- QueryUserGroupMembersResponse is the response type for the Query/UserGroupMembers RPC method - desmos.subspaces.v1.QueryUserGroupResponse: + desmos.subspaces.v2.QueryUserGroupResponse: type: object properties: group: @@ -10514,6 +11346,10 @@ definitions: type: string format: uint64 title: ID of the subspace inside which this group exists + section_id: + type: integer + format: int64 + title: (optional) Id of the section inside which this group is valid id: type: integer format: int64 @@ -10534,7 +11370,7 @@ definitions: title: |- QueryUserGroupResponse is the response type for the Query/UserGroup RPC method - desmos.subspaces.v1.QueryUserGroupsResponse: + desmos.subspaces.v2.QueryUserGroupsResponse: type: object properties: groups: @@ -10546,6 +11382,10 @@ definitions: type: string format: uint64 title: ID of the subspace inside which this group exists + section_id: + type: integer + format: int64 + title: (optional) Id of the section inside which this group is valid id: type: integer format: int64 @@ -10591,7 +11431,7 @@ definitions: title: |- QueryUserGroupsResponse is the response type for the Query/UserGroups RPC method - desmos.subspaces.v1.QueryUserPermissionsResponse: + desmos.subspaces.v2.QueryUserPermissionsResponse: type: object properties: permissions: @@ -10602,6 +11442,14 @@ definitions: items: type: object properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace for which this permission is valid + section_id: + type: integer + format: int64 + title: Id of the section for which this permission is valid user: title: User represents a user permission type: object @@ -10629,7 +11477,29 @@ definitions: title: |- QueryUserPermissionsRequest is the response type for the Query/UserPermissions method - desmos.subspaces.v1.Subspace: + desmos.subspaces.v2.Section: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace inside which the section exists + id: + type: integer + format: int64 + title: Unique id of the section within the subspace + parent_id: + type: integer + format: int64 + title: (optional) Id of the parent section + name: + type: string + title: Name of the section within the subspace + description: + type: string + title: (optional) Description of the section + title: Section contains the data of a single subspace section + desmos.subspaces.v2.Subspace: type: object properties: id: @@ -10660,13 +11530,17 @@ definitions: format: date-time title: the creation time of the subspace title: Subspace contains all the data of a Desmos subspace - desmos.subspaces.v1.UserGroup: + desmos.subspaces.v2.UserGroup: type: object properties: subspace_id: type: string format: uint64 title: ID of the subspace inside which this group exists + section_id: + type: integer + format: int64 + title: (optional) Id of the section inside which this group is valid id: type: integer format: int64 @@ -10693,6 +11567,14 @@ definitions: should be connected is + section_id: + type: integer + format: int64 + title: >- + Id of the subspace section inside which the post to which this + attachment + + should be connected is post_id: type: string format: uint64 @@ -10935,6 +11817,10 @@ definitions: type: string format: uint64 title: Id of the subspace inside which the post has been created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created id: type: string format: uint64 @@ -11128,6 +12014,12 @@ definitions: title: >- Subspace id inside which the post related to this attachment is located + section_id: + type: integer + format: int64 + title: >- + Section id inside which the post related to this attachment is + located post_id: type: string format: uint64 @@ -11192,6 +12084,14 @@ definitions: attachment should be connected is + section_id: + type: integer + format: int64 + title: >- + Id of the subspace section inside which the post to which this + attachment + + should be connected is post_id: type: string format: uint64 @@ -11409,6 +12309,10 @@ definitions: type: string format: uint64 title: Id of the subspace inside which the post has been created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created id: type: string format: uint64 @@ -11547,7 +12451,194 @@ definitions: title: (optional) Last edited time of the post title: Post contains all the information about a single post title: QueryPostResponse is the response type for the Query/Post RPC method - desmos.posts.v1.QueryPostsResponse: + desmos.posts.v1.QuerySectionPostsResponse: + type: object + properties: + posts: + type: array + items: + type: object + properties: + subspace_id: + type: string + format: uint64 + title: Id of the subspace inside which the post has been created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created + id: + type: string + format: uint64 + title: Unique id of the post + external_id: + type: string + title: (optional) External id for this post + text: + type: string + title: (optional) Text of the post + entities: + title: (optional) Entities connected to this post + type: object + properties: + hashtags: + type: array + items: + type: object + properties: + start: + type: string + format: uint64 + title: >- + Index of the character inside the text at which the + tag starts + end: + type: string + format: uint64 + title: >- + Index of the character inside the text at which the + tag ends + tag: + type: string + title: 'Tag reference (user address, hashtag value, etc)' + title: Tag represents a generic tag + mentions: + type: array + items: + type: object + properties: + start: + type: string + format: uint64 + title: >- + Index of the character inside the text at which the + tag starts + end: + type: string + format: uint64 + title: >- + Index of the character inside the text at which the + tag ends + tag: + type: string + title: 'Tag reference (user address, hashtag value, etc)' + title: Tag represents a generic tag + urls: + type: array + items: + type: object + properties: + start: + type: string + format: uint64 + title: >- + Index of the character inside the text at which the + URL starts + end: + type: string + format: uint64 + title: >- + Index of the character inside the text at which the + URL ends + url: + type: string + title: >- + Value of the URL where the user should be redirected + to + display_url: + type: string + title: (optional) Display value of the URL + title: Url contains the details of a generic URL + author: + type: string + title: Author of the post + conversation_id: + type: string + format: uint64 + title: (optional) Id of the original post of the conversation + referenced_posts: + type: array + items: + type: object + properties: + type: + title: Type of reference + type: string + enum: + - TYPE_UNSPECIFIED + - TYPE_REPLIED_TO + - TYPE_QUOTED + - TYPE_REPOSTED + default: TYPE_UNSPECIFIED + description: |- + - TYPE_UNSPECIFIED: No reference specified + - TYPE_REPLIED_TO: This post is a reply to the referenced post + - TYPE_QUOTED: This post is a quote to the referenced post + - TYPE_REPOSTED: This post is a report of the referenced post + post_id: + type: string + format: uint64 + title: Id of the referenced post + title: PostReference contains the details of a post reference + title: >- + A list this posts references (either as a reply, repost or + quote) + reply_settings: + title: Reply settings of this post + type: string + enum: + - REPLY_SETTING_UNSPECIFIED + - REPLY_SETTING_EVERYONE + - REPLY_SETTING_FOLLOWERS + - REPLY_SETTING_MUTUAL + - REPLY_SETTING_MENTIONS + default: REPLY_SETTING_UNSPECIFIED + description: |- + - REPLY_SETTING_UNSPECIFIED: No reply setting specified + - REPLY_SETTING_EVERYONE: Everyone will be able to reply to this post + - REPLY_SETTING_FOLLOWERS: Only followers of the author will be able to reply to this post + - REPLY_SETTING_MUTUAL: Only the author mutual followers will be able to reply to this post + - REPLY_SETTING_MENTIONS: Only people mentioned inside this post will be able to reply + creation_date: + type: string + format: date-time + title: Creation date of the post + last_edited_date: + type: string + format: date-time + title: (optional) Last edited time of the post + title: Post contains all the information about a single post + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: >- + QuerySectionPostsResponse is the response type for the Query/SectionPosts + RPC + + method + desmos.posts.v1.QuerySubspacePostsResponse: type: object properties: posts: @@ -11559,6 +12650,10 @@ definitions: type: string format: uint64 title: Id of the subspace inside which the post has been created + section_id: + type: integer + format: int64 + title: Id of the section inside which the post has been created id: type: string format: uint64 @@ -11725,7 +12820,11 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - title: QueryPostsResponse is the response type for the Query/Posts RPC method + title: >- + QuerySubspacePostsResponse is the response type for the + Query/SubspacePosts + + RPC method desmos.posts.v1.ReplySetting: type: string enum: @@ -11784,6 +12883,10 @@ definitions: title: >- Subspace id inside which the post related to this attachment is located + section_id: + type: integer + format: int64 + title: Section id inside which the post related to this attachment is located post_id: type: string format: uint64 diff --git a/proto/desmos/posts/v1/models.proto b/proto/desmos/posts/v1/models.proto index 7de8b0bfc4..253cf70f69 100644 --- a/proto/desmos/posts/v1/models.proto +++ b/proto/desmos/posts/v1/models.proto @@ -15,36 +15,39 @@ message Post { // Id of the subspace inside which the post has been created uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + // Id of the section inside which the post has been created + uint32 section_id = 2 [ (gogoproto.customname) = "SectionID" ]; + // Unique id of the post - uint64 id = 2 [ (gogoproto.customname) = "ID" ]; + uint64 id = 3 [ (gogoproto.customname) = "ID" ]; // (optional) External id for this post - string external_id = 3 [ (gogoproto.customname) = "ExternalID" ]; + string external_id = 4 [ (gogoproto.customname) = "ExternalID" ]; // (optional) Text of the post - string text = 4; + string text = 5; // (optional) Entities connected to this post - Entities entities = 5; + Entities entities = 6; // Author of the post - string author = 6; + string author = 7; // (optional) Id of the original post of the conversation - uint64 conversation_id = 7 [ (gogoproto.customname) = "ConversationID" ]; + uint64 conversation_id = 8 [ (gogoproto.customname) = "ConversationID" ]; // A list this posts references (either as a reply, repost or quote) - repeated PostReference referenced_posts = 8 [ (gogoproto.nullable) = false ]; + repeated PostReference referenced_posts = 9 [ (gogoproto.nullable) = false ]; // Reply settings of this post - ReplySetting reply_settings = 9; + ReplySetting reply_settings = 10; // Creation date of the post - google.protobuf.Timestamp creation_date = 10 + google.protobuf.Timestamp creation_date = 11 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; // (optional) Last edited time of the post - google.protobuf.Timestamp last_edited_date = 11 + google.protobuf.Timestamp last_edited_date = 12 [ (gogoproto.stdtime) = true ]; } @@ -149,14 +152,18 @@ message Attachment { // connected is uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + // Id of the subspace section inside which the post to which this attachment + // should be connected is + uint32 section_id = 2 [ (gogoproto.customname) = "SectionID" ]; + // Id of the post to which this attachment should be connected - uint64 post_id = 2 [ (gogoproto.customname) = "PostID" ]; + uint64 post_id = 3 [ (gogoproto.customname) = "PostID" ]; // If of this attachment - uint32 id = 3 [ (gogoproto.customname) = "ID" ]; + uint32 id = 4 [ (gogoproto.customname) = "ID" ]; // Content of the attachment - google.protobuf.Any content = 4; + google.protobuf.Any content = 5; } // Media represents a media attachment @@ -213,17 +220,20 @@ message UserAnswer { // Subspace id inside which the post related to this attachment is located uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + // Section id inside which the post related to this attachment is located + uint32 section_id = 2 [ (gogoproto.customname) = "SectionID" ]; + // Id of the post associated to this attachment - uint64 post_id = 2 [ (gogoproto.customname) = "PostID" ]; + uint64 post_id = 3 [ (gogoproto.customname) = "PostID" ]; // Id of the poll to which this answer is associated - uint32 poll_id = 3 [ (gogoproto.customname) = "PollID" ]; + uint32 poll_id = 4 [ (gogoproto.customname) = "PollID" ]; // Indexes of the answers inside the ProvidedAnswers array - repeated uint32 answers_indexes = 4; + repeated uint32 answers_indexes = 5; // Address of the user answering the poll - string user = 5; + string user = 6; } // PollTallyResults contains the tally results for a poll diff --git a/proto/desmos/posts/v1/msgs.proto b/proto/desmos/posts/v1/msgs.proto index 298cec3eeb..79545518a5 100644 --- a/proto/desmos/posts/v1/msgs.proto +++ b/proto/desmos/posts/v1/msgs.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "google/protobuf/timestamp.proto"; +import "desmos/subspaces/v2/models.proto"; import "desmos/posts/v1/models.proto"; option go_package = "github.com/desmos-labs/desmos/v3/x/posts/types"; @@ -37,29 +38,32 @@ message MsgCreatePost { // Id of the subspace inside which the post must be created uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + // Id of the section inside which the post must be created + uint32 section_id = 2 [ (gogoproto.customname) = "SectionID" ]; + // (optional) External id for this post - string external_id = 2 [ (gogoproto.customname) = "ExternalID" ]; + string external_id = 3 [ (gogoproto.customname) = "ExternalID" ]; // (optional) Text of the post - string text = 3; + string text = 4; // (optional) Entities connected to this post - Entities entities = 4; + Entities entities = 5; // Attachments of the post - repeated google.protobuf.Any attachments = 5; + repeated google.protobuf.Any attachments = 6; // Author of the post - string author = 6; + string author = 7; // (optional) Id of the original post of the conversation - uint64 conversation_id = 7 [ (gogoproto.customname) = "ConversationID" ]; + uint64 conversation_id = 8 [ (gogoproto.customname) = "ConversationID" ]; // Reply settings of this post - ReplySetting reply_settings = 8; + ReplySetting reply_settings = 9; // A list this posts references (either as a reply, repost or quote) - repeated PostReference referenced_posts = 9 [ (gogoproto.nullable) = false ]; + repeated PostReference referenced_posts = 10 [ (gogoproto.nullable) = false ]; } // MsgCreatePostResponse defines the Msg/CreatePost response type. diff --git a/proto/desmos/posts/v1/query.proto b/proto/desmos/posts/v1/query.proto index 782e9d5352..8980c89af2 100644 --- a/proto/desmos/posts/v1/query.proto +++ b/proto/desmos/posts/v1/query.proto @@ -11,11 +11,19 @@ option go_package = "github.com/desmos-labs/desmos/v3/x/posts/types"; // Query defines the gRPC querier service service Query { - // Posts queries all the posts inside a given subspace - rpc Posts(QueryPostsRequest) returns (QueryPostsResponse) { + // SubspacePosts queries all the posts inside a given subspace + rpc SubspacePosts(QuerySubspacePostsRequest) + returns (QuerySubspacePostsResponse) { option (google.api.http).get = "/desmos/posts/v1/{subspace_id}/posts"; } + // SectionPosts queries all the posts inside a given section + rpc SectionPosts(QuerySectionPostsRequest) + returns (QuerySectionPostsResponse) { + option (google.api.http).get = + "/desmos/posts/v1/{subspace_id}/{section_id}/posts"; + } + // Post queries for a single post inside a given subspace rpc Post(QueryPostRequest) returns (QueryPostResponse) { option (google.api.http).get = @@ -41,8 +49,9 @@ service Query { } } -// QueryPostsRequest is the request type for the Query/Posts RPC method -message QueryPostsRequest { +// QuerySubspacePostsRequest is the request type for the Query/SubspacePosts RPC +// method +message QuerySubspacePostsRequest { // Id of the subspace to query the posts for uint64 subspace_id = 1; @@ -50,8 +59,29 @@ message QueryPostsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 2; } -// QueryPostsResponse is the response type for the Query/Posts RPC method -message QueryPostsResponse { +// QuerySubspacePostsResponse is the response type for the Query/SubspacePosts +// RPC method +message QuerySubspacePostsResponse { + repeated Post posts = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QuerySectionPostsRequest is the request type for the Query/SectionPosts RPC +// method +message QuerySectionPostsRequest { + // Id of the subspace to query the posts for + uint64 subspace_id = 1; + + // Id of the section to query the posts for + uint32 section_id = 2; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +// QuerySectionPostsResponse is the response type for the Query/SectionPosts RPC +// method +message QuerySectionPostsResponse { repeated Post posts = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/desmos/subspaces/v1/genesis.proto b/proto/desmos/subspaces/v1/genesis.proto deleted file mode 100644 index c4a32de2a3..0000000000 --- a/proto/desmos/subspaces/v1/genesis.proto +++ /dev/null @@ -1,55 +0,0 @@ -syntax = "proto3"; -package desmos.subspaces.v1; - -import "gogoproto/gogo.proto"; -import "desmos/subspaces/v1/models.proto"; - -option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/types"; - -// GenesisState contains the data of the genesis state for the subspaces module -message GenesisState { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = true; - - uint64 initial_subspace_id = 1 - [ (gogoproto.customname) = "InitialSubspaceID" ]; - - repeated GenesisSubspace subspaces = 2 [ (gogoproto.nullable) = false ]; - - repeated ACLEntry acl = 3 - [ (gogoproto.customname) = "ACL", (gogoproto.nullable) = false ]; - - repeated UserGroup user_groups = 4 [ (gogoproto.nullable) = false ]; - - repeated UserGroupMembersEntry user_groups_members = 5 - [ (gogoproto.nullable) = false ]; -} - -// GenesisSubspace contains the genesis data for a single subspace -message GenesisSubspace { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = true; - - Subspace subspace = 1 [ (gogoproto.nullable) = false ]; - uint32 initial_group_id = 2 [ (gogoproto.customname) = "InitialGroupID" ]; -} - -// ACLEntry represents a single Access Control List entry -message ACLEntry { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = true; - - uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; - string user = 2; - uint32 permissions = 3; -} - -// UserGroupMembersEntry contains all the members of a specific user group -message UserGroupMembersEntry { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = true; - - uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; - uint32 group_id = 2 [ (gogoproto.customname) = "GroupID" ]; - repeated string members = 3; -} \ No newline at end of file diff --git a/proto/desmos/subspaces/v1/models.proto b/proto/desmos/subspaces/v1/models.proto index f6c57efe78..4739efeabc 100644 --- a/proto/desmos/subspaces/v1/models.proto +++ b/proto/desmos/subspaces/v1/models.proto @@ -4,7 +4,7 @@ package desmos.subspaces.v1; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/types"; +option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/legacy/v2"; // Subspace contains all the data of a Desmos subspace message Subspace { diff --git a/proto/desmos/subspaces/v2/genesis.proto b/proto/desmos/subspaces/v2/genesis.proto new file mode 100644 index 0000000000..54c1607cc5 --- /dev/null +++ b/proto/desmos/subspaces/v2/genesis.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; +package desmos.subspaces.v2; + +import "gogoproto/gogo.proto"; +import "desmos/subspaces/v2/models.proto"; + +option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/types"; + +// GenesisState contains the data of the genesis state for the subspaces module +message GenesisState { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + uint64 initial_subspace_id = 1 + [ (gogoproto.customname) = "InitialSubspaceID" ]; + + repeated SubspaceData subspaces_data = 2 [ (gogoproto.nullable) = false ]; + + repeated Subspace subspaces = 3 [ (gogoproto.nullable) = false ]; + + repeated Section sections = 4 [ (gogoproto.nullable) = false ]; + + repeated UserPermission user_permissions = 5 [ (gogoproto.nullable) = false ]; + + repeated UserGroup user_groups = 6 [ (gogoproto.nullable) = false ]; + + repeated UserGroupMemberEntry user_groups_members = 7 + [ (gogoproto.nullable) = false ]; +} + +// SubspaceData contains the genesis data for a single subspace +message SubspaceData { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + uint32 next_group_id = 2 [ (gogoproto.customname) = "NextGroupID" ]; + uint32 next_section_id = 3 [ (gogoproto.customname) = "NextSectionID" ]; +} + +// UserPermission represents a single Access Control List entry +message UserPermission { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + uint32 section_id = 2 [ (gogoproto.customname) = "SectionID" ]; + string user = 3; + uint32 permissions = 4; +} + +// UserGroupMemberEntry contains the details of a user group member +message UserGroupMemberEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID" ]; + uint32 group_id = 2 [ (gogoproto.customname) = "GroupID" ]; + string user = 3; +} \ No newline at end of file diff --git a/proto/desmos/subspaces/v2/models.proto b/proto/desmos/subspaces/v2/models.proto new file mode 100644 index 0000000000..9ff5a5dade --- /dev/null +++ b/proto/desmos/subspaces/v2/models.proto @@ -0,0 +1,99 @@ +syntax = "proto3"; +package desmos.subspaces.v2; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/types"; + +// Subspace contains all the data of a Desmos subspace +message Subspace { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + // Unique id that identifies the subspace + uint64 id = 1 + [ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ]; + + // Human-readable name of the subspace + string name = 2 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // Optional description of this subspace + string description = 3 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // Represents the account that is associated with the subspace and + // should be used to connect external applications to verify this subspace + string treasury = 4 [ (gogoproto.moretags) = "yaml:\"treasury\"" ]; + + // Address of the user that owns the subspace + string owner = 5 [ (gogoproto.moretags) = "yaml:\"owner\"" ]; + + // Address of the subspace creator + string creator = 6 [ (gogoproto.moretags) = "yaml:\"creator\"" ]; + + // the creation time of the subspace + google.protobuf.Timestamp creation_time = 7 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"creation_time\"" + ]; +} + +// Section contains the data of a single subspace section +message Section { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + // Id of the subspace inside which the section exists + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // Unique id of the section within the subspace + uint32 id = 2 + [ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ]; + + // (optional) Id of the parent section + uint32 parent_id = 3 [ + (gogoproto.customname) = "ParentID", + (gogoproto.moretags) = "yaml:\"parent_id\"" + ]; + + // Name of the section within the subspace + string name = 4 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // (optional) Description of the section + string description = 5 [ (gogoproto.moretags) = "yaml:\"description\"" ]; +} + +// UserGroup represents a group of users +message UserGroup { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + // ID of the subspace inside which this group exists + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // (optional) Id of the section inside which this group is valid + uint32 section_id = 2 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; + + // Unique id that identifies the group + uint32 id = 3 + [ (gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\"" ]; + + // Human-readable name of the user group + string name = 4 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // Optional description of this group + string description = 5 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // Permissions that will be granted to all the users part of this group + uint32 permissions = 6 [ (gogoproto.moretags) = "yaml:\"permissions\"" ]; +} diff --git a/proto/desmos/subspaces/v1/msgs.proto b/proto/desmos/subspaces/v2/msgs.proto similarity index 56% rename from proto/desmos/subspaces/v1/msgs.proto rename to proto/desmos/subspaces/v2/msgs.proto index ab08cafd9b..ce5633c52b 100644 --- a/proto/desmos/subspaces/v1/msgs.proto +++ b/proto/desmos/subspaces/v2/msgs.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package desmos.subspaces.v1; +package desmos.subspaces.v2; import "gogoproto/gogo.proto"; -import "desmos/subspaces/v1/models.proto"; +import "desmos/subspaces/v2/models.proto"; option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/types"; @@ -18,12 +18,27 @@ service Msg { // DeleteSubspace allows to delete a subspace rpc DeleteSubspace(MsgDeleteSubspace) returns (MsgDeleteSubspaceResponse); + // CreateSection allows to create a new subspace section + rpc CreateSection(MsgCreateSection) returns (MsgCreateSectionResponse); + + // EditSection allows to edit an existing section + rpc EditSection(MsgEditSection) returns (MsgEditSectionResponse); + + // MoveSection allows to move an existing section to another parent + rpc MoveSection(MsgMoveSection) returns (MsgMoveSectionResponse); + + // DeleteSection allows to delete an existing section + rpc DeleteSection(MsgDeleteSection) returns (MsgDeleteSectionResponse); + // CreateUserGroup allows to create a user group rpc CreateUserGroup(MsgCreateUserGroup) returns (MsgCreateUserGroupResponse); // EditUserGroup allows to edit a user group rpc EditUserGroup(MsgEditUserGroup) returns (MsgEditUserGroupResponse); + // MoveUserGroup allows to move a user group from a section to another + rpc MoveUserGroup(MsgMoveUserGroup) returns (MsgMoveUserGroupResponse); + // SetUserGroupPermissions allows to set the permissions for a specific group rpc SetUserGroupPermissions(MsgSetUserGroupPermissions) returns (MsgSetUserGroupPermissionsResponse); @@ -67,8 +82,6 @@ message MsgCreateSubspaceResponse { ]; } -// -------------------------------------------------------------------------------------------------------------------- - // MsgEditSubspace represents the message used to edit a subspace fields message MsgEditSubspace { option (gogoproto.equal) = false; @@ -89,8 +102,6 @@ message MsgEditSubspace { // MsgEditSubspaceResponse defines the Msg/EditSubspace response type message MsgEditSubspaceResponse {} -// -------------------------------------------------------------------------------------------------------------------- - // MsgDeleteSubspace represents the message used to delete a subspace message MsgDeleteSubspace { option (gogoproto.equal) = false; @@ -108,25 +119,145 @@ message MsgDeleteSubspaceResponse {} // -------------------------------------------------------------------------------------------------------------------- +// MsgCreateSection represents the message to be used when creating a subspace +// section +message MsgCreateSection { + // Id of the subspace inside which the section will be placed + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // Name of the section to be created + string name = 2 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // (optional) Description of the section + string description = 3 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // (optional) Id of the parent section + uint32 parent_id = 4 [ + (gogoproto.customname) = "ParentID", + (gogoproto.moretags) = "yaml:\"parent_id\"" + ]; + + // User creating the section + string creator = 5 [ (gogoproto.moretags) = "yaml:\"creator\"" ]; +} + +// MsgCreateSectionResponse represents the Msg/CreateSection response type +message MsgCreateSectionResponse { + // Id of the newly created section + uint32 section_id = 1 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; +} + +// MsgEditSection represents the message to be used when editing a subspace +// section +message MsgEditSection { + // Id of the subspace inside which the section to be edited is + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // Id of the section to be edited + uint32 section_id = 2 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; + + // (optional) New name of the section + string name = 3 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // (optional) New description of the section + string description = 4 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // User editing the section + string editor = 5 [ (gogoproto.moretags) = "yaml:\"editor\"" ]; +} + +// MsgEditSectionResponse represents the Msg/EditSection response type +message MsgEditSectionResponse {} + +// MsgMoveSection represents the message to be used when moving a section to +// another parent +message MsgMoveSection { + // Id of the subspace inside which the section lies + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // Id of the section to be moved + uint32 section_id = 2 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; + + // Id of the new parent + uint32 new_parent_id = 3 [ + (gogoproto.customname) = "NewParentID", + (gogoproto.moretags) = "yaml:\"new_parent_id\"" + ]; + + // Signer of the message + string signer = 4 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; +} + +// MsgMoveSectionResponse +message MsgMoveSectionResponse {} + +// MsgDeleteSection represents the message to be used when deleting a section +message MsgDeleteSection { + // Id of the subspace inside which the section to be deleted is + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // Id of the section to delete + uint32 section_id = 2 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; + + // User deleting the section + string signer = 3 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; +} + +// MsgDeleteSectionResponse represents the Msg/DeleteSection response type +message MsgDeleteSectionResponse {} + +// -------------------------------------------------------------------------------------------------------------------- + // MsgCreateUserGroup represents the message used to create a user group message MsgCreateUserGroup { + // Id of the subspace inside which the group will be created uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + // (optional) Id of the section inside which the group will be created + uint32 section_id = 2 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; + // Name of the group - string name = 2 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + string name = 3 [ (gogoproto.moretags) = "yaml:\"name\"" ]; - // Optional description of the group - string description = 3 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + // (optional) Description of the group + string description = 4 [ (gogoproto.moretags) = "yaml:\"description\"" ]; // Default permissions to be applied to the group - uint32 default_permissions = 4 + uint32 default_permissions = 5 [ (gogoproto.moretags) = "yaml:\"default_permissions\"" ]; // Creator of the group - string creator = 5 [ (gogoproto.moretags) = "yaml:\"creator\"" ]; + string creator = 6 [ (gogoproto.moretags) = "yaml:\"creator\"" ]; } // MsgCreateUserGroupResponse defines the Msg/CreateUserGroup response type @@ -137,40 +268,80 @@ message MsgCreateUserGroupResponse { ]; } -// -------------------------------------------------------------------------------------------------------------------- - // MsgEditUserGroup represents the message used to edit a user group message MsgEditUserGroup { + // Id of the subspace inside which the group to be edited is uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + + // Id of the group to be edited uint32 group_id = 2 [ (gogoproto.customname) = "GroupID", (gogoproto.moretags) = "yaml:\"group_id\"" ]; + + // (optional) New name of the group string name = 3 [ (gogoproto.moretags) = "yaml:\"name\"" ]; + + // (optional) New description of the group string description = 4 [ (gogoproto.moretags) = "yaml:\"description\"" ]; + + // User editing the group string signer = 5 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; } // MsgEditUserGroupResponse defines the Msg/EditUserGroup response type message MsgEditUserGroupResponse {} -// -------------------------------------------------------------------------------------------------------------------- +// MsgMoveUserGroup represents the message used to move one user group from a +// section to anoter +message MsgMoveUserGroup { + // Id of the subspace inside which the group to move is + uint64 subspace_id = 1 [ + (gogoproto.customname) = "SubspaceID", + (gogoproto.moretags) = "yaml:\"subspace_id\"" + ]; + + // Id of the group to be moved + uint32 group_id = 2 [ + (gogoproto.customname) = "GroupID", + (gogoproto.moretags) = "yaml:\"group_id\"" + ]; + + // Id of the new section where to move the group + uint32 new_section_id = 3 [ + (gogoproto.customname) = "NewSectionID", + (gogoproto.moretags) = "yaml:\"new_section_id\"" + ]; + + // User signing the message + string signer = 4 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; +} + +// MsgMoveUserGroupResponse defines the Msg/MoveUserGroup response type +message MsgMoveUserGroupResponse {} // MsgSetUserGroupPermissions represents the message used to set the permissions // of a user group message MsgSetUserGroupPermissions { + // Id of the subspace inside which the group is uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + + // Id of the group for which to set the new permissions uint32 group_id = 2 [ (gogoproto.customname) = "GroupID", (gogoproto.moretags) = "yaml:\"group_id\"" ]; + + // New permissions to be set to the group uint32 permissions = 3 [ (gogoproto.moretags) = "yaml:\"permissions\"" ]; + + // User setting the new permissions string signer = 4 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; } @@ -178,18 +349,21 @@ message MsgSetUserGroupPermissions { // Msg/SetUserGroupPermissionsResponse response type message MsgSetUserGroupPermissionsResponse {} -// -------------------------------------------------------------------------------------------------------------------- - // MsgDeleteUserGroup represents the message used to delete a user group message MsgDeleteUserGroup { + // Id of the subspace inside which the group to delete is uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + + // Id of the group to be deleted uint32 group_id = 2 [ (gogoproto.customname) = "GroupID", (gogoproto.moretags) = "yaml:\"group_id\"" ]; + + // User deleting the group string signer = 3 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; } @@ -201,15 +375,22 @@ message MsgDeleteUserGroupResponse {} // MsgAddUserToUserGroup represents the message used to add a user to a user // group message MsgAddUserToUserGroup { + // Id of the subspace inside which the group is uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + + // Id of the group to which to add the user uint32 group_id = 2 [ (gogoproto.customname) = "GroupID", (gogoproto.moretags) = "yaml:\"group_id\"" ]; + + // User to be added to the group string user = 3 [ (gogoproto.moretags) = "yaml:\"user\"" ]; + + // User signing the message string signer = 4 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; } @@ -217,20 +398,25 @@ message MsgAddUserToUserGroup { // response type message MsgAddUserToUserGroupResponse {} -// -------------------------------------------------------------------------------------------------------------------- - // MsgRemoveUserFromUserGroup represents the message used to remove a user from // a user group message MsgRemoveUserFromUserGroup { + // Id of the subspace inside which the group to remove the user from is uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + + // Id of the group from which to remove the user uint32 group_id = 2 [ (gogoproto.customname) = "GroupID", (gogoproto.moretags) = "yaml:\"group_id\"" ]; + + // User to be removed from the group string user = 3 [ (gogoproto.moretags) = "yaml:\"user\"" ]; + + // User signing the message string signer = 4 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; } @@ -243,13 +429,26 @@ message MsgRemoveUserFromUserGroupResponse {} // MsgSetUserPermissions represents the message used to set the permissions of a // specific user message MsgSetUserPermissions { + // Id of the subspace inside which to set the permissions uint64 subspace_id = 1 [ (gogoproto.customname) = "SubspaceID", (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; - string user = 2 [ (gogoproto.moretags) = "yaml:\"user\"" ]; - uint32 permissions = 3 [ (gogoproto.moretags) = "yaml:\"permissions\"" ]; - string signer = 4 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; + + // Id of the section for which to set the permissions + uint32 section_id = 2 [ + (gogoproto.customname) = "SectionID", + (gogoproto.moretags) = "yaml:\"section_id\"" + ]; + + // User for which to set the permissions + string user = 3 [ (gogoproto.moretags) = "yaml:\"user\"" ]; + + // Permissions to be set to the user + uint32 permissions = 4 [ (gogoproto.moretags) = "yaml:\"permissions\"" ]; + + // User signing the message + string signer = 5 [ (gogoproto.moretags) = "yaml:\"signer\"" ]; } // MsgSetUserPermissionsResponse defines the Msg/SetPermissionsResponse diff --git a/proto/desmos/subspaces/v1/query.proto b/proto/desmos/subspaces/v2/query.proto similarity index 63% rename from proto/desmos/subspaces/v1/query.proto rename to proto/desmos/subspaces/v2/query.proto index 56c96458b5..a8afade7b2 100644 --- a/proto/desmos/subspaces/v1/query.proto +++ b/proto/desmos/subspaces/v2/query.proto @@ -1,11 +1,12 @@ syntax = "proto3"; -package desmos.subspaces.v1; +package desmos.subspaces.v2; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "desmos/subspaces/v1/models.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "desmos/subspaces/v2/models.proto"; + option go_package = "github.com/desmos-labs/desmos/v3/x/subspaces/types"; // Query defines the gRPC querier service @@ -22,6 +23,18 @@ service Query { "/desmos/subspaces/v1/subspaces/{subspace_id}"; } + // Sections allows to query for the sections of a specific subspace + rpc Sections(QuerySectionsRequest) returns (QuerySectionsResponse) { + option (google.api.http).get = + "/desmos/subspaces/v2/{subspace_id}/sections"; + } + + // Section queries all the information about the section with the given id + rpc Section(QuerySectionRequest) returns (QuerySectionResponse) { + option (google.api.http).get = + "/desmos/subspaces/v2/{subspace_id}/sections/{section_id}"; + } + // UserGroups queries all the groups that are present inside the subspace with // the given id rpc UserGroups(QueryUserGroupsRequest) returns (QueryUserGroupsResponse) { @@ -66,8 +79,6 @@ message QuerySubspacesResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// -------------------------------------------------------------------------------------------------------------------- - // QuerySubspace is the request type for the Query/Subspace RPC method message QuerySubspaceRequest { option (gogoproto.equal) = false; @@ -78,7 +89,40 @@ message QuerySubspaceRequest { // QuerySubspaceResponse is the response type for the Query/Subspace method message QuerySubspaceResponse { - desmos.subspaces.v1.Subspace subspace = 1 [ (gogoproto.nullable) = false ]; + Subspace subspace = 1 [ (gogoproto.nullable) = false ]; +} + +// -------------------------------------------------------------------------------------------------------------------- + +// QuerySectionsRequest is the request type for Query/Sections RPC method +message QuerySectionsRequest { + // Id of the subspace to query the sections for + uint64 subspace_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QuerySectionsResponse is the response type for Query/Sections RPC method +message QuerySectionsResponse { + repeated Section sections = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// -------------------------------------------------------------------------------------------------------------------- + +// QuerySectionRequest is the request type for Query/Section RPC method +message QuerySectionRequest { + // Id of the subspace inside which to search for + uint64 subspace_id = 1; + + // Id of the searched section + uint32 section_id = 2; +} + +// QuerySectionResponse is the response type for Query/Section RPC method +message QuerySectionResponse { + Section section = 1 [ (gogoproto.nullable) = false ]; } // -------------------------------------------------------------------------------------------------------------------- @@ -86,10 +130,14 @@ message QuerySubspaceResponse { // QueryUserGroupsRequest is the request type for the Query/UserGroups RPC // method message QueryUserGroupsRequest { + // Id of the subspace to query the groups for uint64 subspace_id = 1 [ (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; + // (optional) Section id to query the groups for + uint32 section_id = 2; + // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } // QueryUserGroupsResponse is the response type for the Query/UserGroups RPC @@ -99,8 +147,6 @@ message QueryUserGroupsResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// -------------------------------------------------------------------------------------------------------------------- - // QueryUserGroupRequest is the request type for the Query/UserGroup RPC method message QueryUserGroupRequest { uint64 subspace_id = 1 [ (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; @@ -113,8 +159,6 @@ message QueryUserGroupResponse { UserGroup group = 1 [ (gogoproto.nullable) = false ]; } -// -------------------------------------------------------------------------------------------------------------------- - // QueryUserGroupMembersRequest is the request type for the // Query/UserGroupMembers RPC method message QueryUserGroupMembersRequest { @@ -141,7 +185,8 @@ message QueryUserPermissionsRequest { option (gogoproto.goproto_getters) = false; uint64 subspace_id = 1 [ (gogoproto.moretags) = "yaml:\"subspace_id\"" ]; - string user = 2 [ (gogoproto.moretags) = "yaml:\"user\"" ]; + uint32 section_id = 2 [ (gogoproto.moretags) = "yaml:\"section_id\"" ]; + string user = 3 [ (gogoproto.moretags) = "yaml:\"user\"" ]; } // QueryUserPermissionsRequest is the response type for the @@ -152,4 +197,53 @@ message QueryUserPermissionsResponse { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"details\"" ]; +} + +// PermissionDetail contains the details data of a permission +message PermissionDetail { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = true; + + // Id of the subspace for which this permission is valid + uint64 subspace_id = 1; + + // Id of the section for which this permission is valid + uint32 section_id = 2; + + // sum is the oneof that specifies whether this represents a user or + // group permission detail + oneof sum { + // User represents a user permission + User user = 3; + + // Group represents a group permission + Group group = 4; + } + + // User is a permission that has been set to a specific user + message User { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = true; + + // User for which the permission was set + string user = 1 [ (gogoproto.moretags) = "yaml:\"user\"" ]; + + // Permission set to the user + uint32 permission = 2 [ (gogoproto.moretags) = "yaml:\"permission\"" ]; + } + + // Group is a permission that has been set to a user group + message Group { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = true; + + // Unique id of the group + uint32 group_id = 1 [ + (gogoproto.customname) = "GroupID", + (gogoproto.moretags) = "yaml:\"group_id\"" + ]; + + // Permission set to the group + uint32 permission = 2; + } } \ No newline at end of file diff --git a/x/posts/abci.go b/x/posts/abci.go index 08b8b2f198..12e9bf0160 100644 --- a/x/posts/abci.go +++ b/x/posts/abci.go @@ -13,7 +13,7 @@ import ( // EndBlocker called every block, process ended polls func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { // Iterate over all the active polls that have been ended by the current block time - keeper.IterateActivePollsQueue(ctx, ctx.BlockTime(), func(index int64, poll types.Attachment) (stop bool) { + keeper.IterateActivePollsQueue(ctx, ctx.BlockTime(), func(poll types.Attachment) (stop bool) { // Compute the poll results results := keeper.Tally(ctx, poll.SubspaceID, poll.PostID, poll.ID) diff --git a/x/posts/client/cli/cli_test.go b/x/posts/client/cli/cli_test.go index 25c509b8f4..6058a992eb 100644 --- a/x/posts/client/cli/cli_test.go +++ b/x/posts/client/cli/cli_test.go @@ -44,8 +44,11 @@ func (s *IntegrationTestSuite) SetupSuite() { // Initialize the subspaces module genesis state subspacesGenesis := subspacestypes.NewGenesisState( 2, - []subspacestypes.GenesisSubspace{ - subspacestypes.NewGenesisSubspace(subspacestypes.NewSubspace( + []subspacestypes.SubspaceData{ + subspacestypes.NewSubspaceData(1, 2, 1), + }, + []subspacestypes.Subspace{ + subspacestypes.NewSubspace( 1, "Test subspace", "This is a test subspace", @@ -53,9 +56,14 @@ func (s *IntegrationTestSuite) SetupSuite() { "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), 1), + ), + }, + []subspacestypes.Section{ + subspacestypes.NewSection(1, 1, 0, "Test section", "Test section"), }, - nil, nil, nil, + nil, + nil, + nil, ) subspacesDataBz, err := cfg.Codec.MarshalJSON(subspacesGenesis) s.Require().NoError(err) @@ -64,11 +72,12 @@ func (s *IntegrationTestSuite) SetupSuite() { // Initialize the module genesis data postsGenesis := types.NewGenesisState( []types.SubspaceDataEntry{ - types.NewSubspaceDataEntry(1, 2), + types.NewSubspaceDataEntry(1, 3), }, []types.GenesisPost{ types.NewGenesisPost(2, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -80,6 +89,20 @@ func (s *IntegrationTestSuite) SetupSuite() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), nil, )), + types.NewGenesisPost(1, types.NewPost( + 1, + 1, + 2, + "External ID", + "This is a text", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + []types.PostReference{}, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + )), }, []types.Attachment{ types.NewAttachment(1, 1, 1, types.NewPoll( @@ -133,7 +156,7 @@ func (s *IntegrationTestSuite) TestCmdQueryPost() { { name: "non existing post returns error", args: []string{ - "1", "2", + "1", "10", fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, shouldErr: true, @@ -148,6 +171,7 @@ func (s *IntegrationTestSuite) TestCmdQueryPost() { expResponse: types.QueryPostResponse{ Post: types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -189,33 +213,61 @@ func (s *IntegrationTestSuite) TestCmdQueryPosts() { name string args []string shouldErr bool - expResponse types.QueryPostsResponse + expResponse proto.Message + expPosts []types.Post }{ { - name: "posts are returned correctly", + name: "posts are returned correctly with only subspace", args: []string{ "1", fmt.Sprintf("--%s=%d", flags.FlagLimit, 1), fmt.Sprintf("--%s=%d", flags.FlagPage, 1), fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, - shouldErr: false, - expResponse: types.QueryPostsResponse{ - Posts: []types.Post{ - types.NewPost( - 1, - 1, - "External ID", - "This is a text", - "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", - 0, - nil, - []types.PostReference{}, - types.REPLY_SETTING_EVERYONE, - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - nil, - ), - }, + shouldErr: false, + expResponse: &types.QuerySubspacePostsResponse{}, + expPosts: []types.Post{ + types.NewPost( + 1, + 0, + 1, + "External ID", + "This is a text", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + []types.PostReference{}, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + ), + }, + }, + { + name: "posts are returned correctly with section", + args: []string{ + "1", "1", + fmt.Sprintf("--%s=%d", flags.FlagLimit, 1), + fmt.Sprintf("--%s=%d", flags.FlagPage, 1), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + shouldErr: false, + expResponse: &types.QuerySectionPostsResponse{}, + expPosts: []types.Post{ + types.NewPost( + 1, + 1, + 2, + "External ID", + "This is a text", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + []types.PostReference{}, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + ), }, }, } @@ -231,10 +283,14 @@ func (s *IntegrationTestSuite) TestCmdQueryPosts() { s.Require().Error(err) } else { s.Require().NoError(err) - - var response types.QueryPostsResponse - s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) - s.Require().Equal(tc.expResponse.Posts, response.Posts) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.expResponse), out.String()) + + switch res := tc.expResponse.(type) { + case *types.QuerySubspacePostsResponse: + s.Require().Equal(tc.expPosts, res.Posts) + case *types.QuerySectionPostsResponse: + s.Require().Equal(tc.expPosts, res.Posts) + } } }) } @@ -446,7 +502,7 @@ func (s *IntegrationTestSuite) TestCmdCreatePost() { { name: "valid data returns no error", args: []string{ - "1", filePath, + "1", "1", filePath, fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), diff --git a/x/posts/client/cli/query.go b/x/posts/client/cli/query.go index 3574aec4e6..171397b689 100644 --- a/x/posts/client/cli/query.go +++ b/x/posts/client/cli/query.go @@ -6,6 +6,8 @@ import ( "context" "fmt" + "github.com/gogo/protobuf/proto" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" @@ -75,10 +77,10 @@ func GetCmdQueryPost() *cobra.Command { // GetCmdQueryPosts returns the command to query all the posts inside a subspace func GetCmdQueryPosts() *cobra.Command { cmd := &cobra.Command{ - Use: "posts [subspace-id]", - Short: "Query the posts inside a specific subspace", + Use: "posts [subspace-id] [[section-id]]", + Short: "Query the posts inside a specific subspace with optional section", Example: fmt.Sprintf(`%s query posts posts 1 --page=2 --limit=100`, version.AppName), - Args: cobra.ExactArgs(1), + Args: cobra.RangeArgs(1, 2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -96,9 +98,22 @@ func GetCmdQueryPosts() *cobra.Command { return err } - res, err := queryClient.Posts(context.Background(), types.NewQueryPostsRequest(subspaceID, pageReq)) - if err != nil { - return err + var res proto.Message + if len(args) == 1 { + res, err = queryClient.SubspacePosts(context.Background(), types.NewQuerySubspacePostsRequest(subspaceID, pageReq)) + if err != nil { + return err + } + } else { + sectionID, err := subspacestypes.ParseSectionID(args[1]) + if err != nil { + return err + } + + res, err = queryClient.SectionPosts(context.Background(), types.NewQuerySectionPostsRequest(subspaceID, sectionID, pageReq)) + if err != nil { + return err + } } return clientCtx.PrintProto(res) diff --git a/x/posts/client/cli/tx.go b/x/posts/client/cli/tx.go index 5d97ae95e2..5e1978b911 100644 --- a/x/posts/client/cli/tx.go +++ b/x/posts/client/cli/tx.go @@ -43,11 +43,11 @@ func NewTxCmd() *cobra.Command { // GetCmdCreatePost returns the command allowing to create a new post func GetCmdCreatePost() *cobra.Command { cmd := &cobra.Command{ - Use: "create [subspace-id] [json-file-path]", - Args: cobra.ExactArgs(2), + Use: "create [subspace-id] [section-id] [json-file-path]", + Args: cobra.ExactArgs(3), Short: "Create a new post", Long: `Create a new post containing the data specified inside the JSON file located at the provided path.`, - Example: fmt.Sprintf(`%s tx posts create 1 /path/to/my/file.json --from alice`, version.AppName), + Example: fmt.Sprintf(`%s tx posts create 1 1 /path/to/my/file.json --from alice`, version.AppName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -59,7 +59,12 @@ func GetCmdCreatePost() *cobra.Command { return err } - data, err := cliutils.ParseCreatePostJSON(clientCtx.Codec, args[1]) + sectionID, err := subspacestypes.ParseSectionID(args[1]) + if err != nil { + return err + } + + data, err := cliutils.ParseCreatePostJSON(clientCtx.Codec, args[2]) if err != nil { return err } @@ -73,6 +78,7 @@ func GetCmdCreatePost() *cobra.Command { msg := types.NewMsgCreatePost( subspaceID, + sectionID, data.ExternalID, data.Text, data.ConversationID, diff --git a/x/posts/keeper/alias_functions.go b/x/posts/keeper/alias_functions.go index e0fd00eb4c..544a6f74d4 100644 --- a/x/posts/keeper/alias_functions.go +++ b/x/posts/keeper/alias_functions.go @@ -17,9 +17,14 @@ func (k Keeper) HasSubspace(ctx sdk.Context, subspaceID uint64) bool { return k.sk.HasSubspace(ctx, subspaceID) } +// HasSection tells whether the section having the given id exists inside the provided subspace +func (k Keeper) HasSection(ctx sdk.Context, subspaceID uint64, sectionID uint32) bool { + return k.sk.HasSection(ctx, subspaceID, sectionID) +} + // HasPermission checks whether the given user has the provided permissions or not -func (k Keeper) HasPermission(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permission subspacetypes.Permission) bool { - return k.sk.HasPermission(ctx, subspaceID, user, permission) +func (k Keeper) HasPermission(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permission subspacetypes.Permission) bool { + return k.sk.HasPermission(ctx, subspaceID, sectionID, user, permission) } // HasUserBlocked tells whether the given blocker has blocked the user inside the provided subspace @@ -35,47 +40,64 @@ func (k Keeper) HasRelationship(ctx sdk.Context, user, counterparty string, subs // -------------------------------------------------------------------------------------------------------------------- // IteratePostIDs iterates over all the next post ids and performs the provided function -func (k Keeper) IteratePostIDs(ctx sdk.Context, fn func(index int64, subspaceID uint64, postID uint64) (stop bool)) { +func (k Keeper) IteratePostIDs(ctx sdk.Context, fn func(subspaceID uint64, postID uint64) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.NextPostIDPrefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { subspaceID := subspacetypes.GetSubspaceIDFromBytes(bytes.TrimPrefix(iterator.Key(), types.NextPostIDPrefix)) postID := types.GetPostIDFromBytes(iterator.Value()) - stop := fn(i, subspaceID, postID) + stop := fn(subspaceID, postID) if stop { break } - i++ } } // -------------------------------------------------------------------------------------------------------------------- // IteratePosts iterates over all the posts stored inside the context and performs the provided function -func (k Keeper) IteratePosts(ctx sdk.Context, fn func(index int64, post types.Post) (stop bool)) { +func (k Keeper) IteratePosts(ctx sdk.Context, fn func(post types.Post) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.PostPrefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var post types.Post k.cdc.MustUnmarshal(iterator.Value(), &post) - stop := fn(i, post) + stop := fn(post) + if stop { + break + } + } +} + +// IterateSectionPosts iterates over all the posts stored inside the given section and performs the provided function +func (k Keeper) IterateSectionPosts(ctx sdk.Context, subspaceID uint64, sectionID uint32, fn func(post types.Post) (stop bool)) { + store := ctx.KVStore(k.storeKey) + storePrefix := types.SectionPostsPrefix(subspaceID, sectionID) + iterator := sdk.KVStorePrefixIterator(store, storePrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + subspaceID, _, postID := types.SplitPostSectionStoreKey(append(storePrefix, iterator.Key()...)) + post, found := k.GetPost(ctx, subspaceID, postID) + if !found { + panic(fmt.Sprintf("post does not exist: subspace id %d, post id %d", subspaceID, postID)) + } + + stop := fn(post) if stop { break } - i++ } } // GetPosts returns all the posts stored inside the given context func (k Keeper) GetPosts(ctx sdk.Context) []types.Post { var posts []types.Post - k.IteratePosts(ctx, func(index int64, post types.Post) (stop bool) { + k.IteratePosts(ctx, func(post types.Post) (stop bool) { posts = append(posts, post) return false }) @@ -83,32 +105,29 @@ func (k Keeper) GetPosts(ctx sdk.Context) []types.Post { } // IterateSubspacePosts iterates over all the posts stored inside the given subspace and performs the provided function -func (k Keeper) IterateSubspacePosts(ctx sdk.Context, subspaceID uint64, fn func(index int64, post types.Post) (stop bool)) { +func (k Keeper) IterateSubspacePosts(ctx sdk.Context, subspaceID uint64, fn func(post types.Post) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.SubspacePostsPrefix(subspaceID)) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var post types.Post k.cdc.MustUnmarshal(iterator.Value(), &post) - stop := fn(i, post) + stop := fn(post) if stop { break } - i++ } } // -------------------------------------------------------------------------------------------------------------------- // IterateActivePolls iterates over the polls in the active polls queue and performs the provided function -func (k Keeper) IterateActivePolls(ctx sdk.Context, fn func(index int64, poll types.Attachment) (stop bool)) { +func (k Keeper) IterateActivePolls(ctx sdk.Context, fn func(poll types.Attachment) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.ActivePollQueuePrefix) defer iterator.Close() - index := int64(0) for ; iterator.Valid(); iterator.Next() { subspaceID, postID, pollID, _ := types.SplitActivePollQueueKey(iterator.Key()) attachment, found := k.GetAttachment(ctx, subspaceID, postID, pollID) @@ -116,21 +135,19 @@ func (k Keeper) IterateActivePolls(ctx sdk.Context, fn func(index int64, poll ty panic(fmt.Sprintf("poll %d %d %d does not exist", subspaceID, postID, pollID)) } - stop := fn(index, attachment) + stop := fn(attachment) if stop { break } - index++ } } // IterateActivePollsQueue iterates over the polls that are still active by the time given performs the provided function -func (k Keeper) IterateActivePollsQueue(ctx sdk.Context, endTime time.Time, fn func(index int64, poll types.Attachment) (stop bool)) { +func (k Keeper) IterateActivePollsQueue(ctx sdk.Context, endTime time.Time, fn func(poll types.Attachment) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := store.Iterator(types.ActivePollQueuePrefix, sdk.PrefixEndBytes(types.ActivePollByTimeKey(endTime))) defer iterator.Close() - index := int64(0) for ; iterator.Valid(); iterator.Next() { subspaceID, postID, pollID, _ := types.SplitActivePollQueueKey(iterator.Key()) attachment, found := k.GetAttachment(ctx, subspaceID, postID, pollID) @@ -138,54 +155,49 @@ func (k Keeper) IterateActivePollsQueue(ctx sdk.Context, endTime time.Time, fn f panic(fmt.Sprintf("poll %d %d %d does not exist", subspaceID, postID, pollID)) } - stop := fn(index, attachment) + stop := fn(attachment) if stop { break } - index++ } } // IterateAttachments iterates over all the attachments in the given context and performs the provided function -func (k Keeper) IterateAttachments(ctx sdk.Context, fn func(index int64, attachment types.Attachment) (stop bool)) { +func (k Keeper) IterateAttachments(ctx sdk.Context, fn func(attachment types.Attachment) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.AttachmentPrefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var attachment types.Attachment k.cdc.MustUnmarshal(iterator.Value(), &attachment) - stop := fn(i, attachment) + stop := fn(attachment) if stop { break } - i++ } } // IteratePostAttachments iterates through the attachments associated with the provided post and performs the given function -func (k Keeper) IteratePostAttachments(ctx sdk.Context, subspaceID uint64, postID uint64, fn func(index int64, attachment types.Attachment) (stop bool)) { +func (k Keeper) IteratePostAttachments(ctx sdk.Context, subspaceID uint64, postID uint64, fn func(attachment types.Attachment) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.PostAttachmentsPrefix(subspaceID, postID)) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var attachment types.Attachment k.cdc.MustUnmarshal(iterator.Value(), &attachment) - stop := fn(i, attachment) + stop := fn(attachment) if stop { break } - i++ } } // GetPostAttachments returns all the attachments associated to the given post func (k Keeper) GetPostAttachments(ctx sdk.Context, subspaceID uint64, postID uint64) []types.Attachment { var attachments []types.Attachment - k.IteratePostAttachments(ctx, subspaceID, postID, func(index int64, attachment types.Attachment) (stop bool) { + k.IteratePostAttachments(ctx, subspaceID, postID, func(attachment types.Attachment) (stop bool) { attachments = append(attachments, attachment) return false }) @@ -195,45 +207,41 @@ func (k Keeper) GetPostAttachments(ctx sdk.Context, subspaceID uint64, postID ui // -------------------------------------------------------------------------------------------------------------------- // IterateUserAnswers iterates over all the polls user answers and performs the provided function -func (k Keeper) IterateUserAnswers(ctx sdk.Context, fn func(index int64, answer types.UserAnswer) (stop bool)) { +func (k Keeper) IterateUserAnswers(ctx sdk.Context, fn func(answer types.UserAnswer) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.UserAnswerPrefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var answer types.UserAnswer k.cdc.MustUnmarshal(iterator.Value(), &answer) - stop := fn(i, answer) + stop := fn(answer) if stop { break } - i++ } } // IteratePollUserAnswers iterates through the answers to the given poll and performs the provided function -func (k Keeper) IteratePollUserAnswers(ctx sdk.Context, subspaceID uint64, postID uint64, pollID uint32, fn func(index int64, answer types.UserAnswer) (stop bool)) { +func (k Keeper) IteratePollUserAnswers(ctx sdk.Context, subspaceID uint64, postID uint64, pollID uint32, fn func(answer types.UserAnswer) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.PollAnswersPrefix(subspaceID, postID, pollID)) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var answer types.UserAnswer k.cdc.MustUnmarshal(iterator.Value(), &answer) - stop := fn(i, answer) + stop := fn(answer) if stop { break } - i++ } } // GetPollUserAnswers returns all the user answers for the given poll func (k Keeper) GetPollUserAnswers(ctx sdk.Context, subspaceID uint64, postID uint64, pollID uint32) []types.UserAnswer { var answers []types.UserAnswer - k.IteratePollUserAnswers(ctx, subspaceID, postID, pollID, func(index int64, answer types.UserAnswer) (stop bool) { + k.IteratePollUserAnswers(ctx, subspaceID, postID, pollID, func(answer types.UserAnswer) (stop bool) { answers = append(answers, answer) return false }) diff --git a/x/posts/keeper/genesis.go b/x/posts/keeper/genesis.go index 586c44f4c6..6e29218643 100644 --- a/x/posts/keeper/genesis.go +++ b/x/posts/keeper/genesis.go @@ -23,7 +23,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { // getSubspaceDataEntries returns the subspaces data entries stored in the given context func (k Keeper) getSubspaceDataEntries(ctx sdk.Context) []types.SubspaceDataEntry { var entries []types.SubspaceDataEntry - k.sk.IterateSubspaces(ctx, func(index int64, subspace subspacestypes.Subspace) (stop bool) { + k.sk.IterateSubspaces(ctx, func(subspace subspacestypes.Subspace) (stop bool) { nextPostID, err := k.GetNextPostID(ctx, subspace.ID) if err != nil { panic(err) @@ -38,7 +38,7 @@ func (k Keeper) getSubspaceDataEntries(ctx sdk.Context) []types.SubspaceDataEntr // getPostData returns the posts data stored in the given context func (k Keeper) getPostData(ctx sdk.Context) []types.GenesisPost { var posts []types.GenesisPost - k.IteratePosts(ctx, func(index int64, post types.Post) (stop bool) { + k.IteratePosts(ctx, func(post types.Post) (stop bool) { attachmentID, err := k.GetNextAttachmentID(ctx, post.SubspaceID, post.ID) if err != nil { panic(err) @@ -53,7 +53,7 @@ func (k Keeper) getPostData(ctx sdk.Context) []types.GenesisPost { // getAllAttachments returns all the attachments stored inside the given context func (k Keeper) getAllAttachments(ctx sdk.Context) []types.Attachment { var attachments []types.Attachment - k.IterateAttachments(ctx, func(index int64, attachment types.Attachment) (stop bool) { + k.IterateAttachments(ctx, func(attachment types.Attachment) (stop bool) { attachments = append(attachments, attachment) return false }) @@ -63,7 +63,7 @@ func (k Keeper) getAllAttachments(ctx sdk.Context) []types.Attachment { // getAllActivePollsData returns the active polls data func (k Keeper) getAllActivePollsData(ctx sdk.Context) []types.ActivePollData { var data []types.ActivePollData - k.IterateActivePolls(ctx, func(index int64, poll types.Attachment) (stop bool) { + k.IterateActivePolls(ctx, func(poll types.Attachment) (stop bool) { data = append(data, types.NewActivePollData( poll.SubspaceID, poll.PostID, @@ -78,7 +78,7 @@ func (k Keeper) getAllActivePollsData(ctx sdk.Context) []types.ActivePollData { // getAllUserAnswers returns all the user answers stored inside the given context func (k Keeper) getAllUserAnswers(ctx sdk.Context) []types.UserAnswer { var answers []types.UserAnswer - k.IterateUserAnswers(ctx, func(index int64, answer types.UserAnswer) (stop bool) { + k.IterateUserAnswers(ctx, func(answer types.UserAnswer) (stop bool) { answers = append(answers, answer) return false }) diff --git a/x/posts/keeper/genesis_test.go b/x/posts/keeper/genesis_test.go index fc78ad2ca4..4d2bd62ab6 100644 --- a/x/posts/keeper/genesis_test.go +++ b/x/posts/keeper/genesis_test.go @@ -55,6 +55,7 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { suite.k.SetNextAttachmentID(ctx, 1, 1, 1) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -70,6 +71,7 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { suite.k.SetNextAttachmentID(ctx, 1, 2, 3) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 2, "External ID", "This is a text", @@ -85,6 +87,7 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { expGenesis: types.NewGenesisState(nil, []types.GenesisPost{ types.NewGenesisPost(1, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -98,6 +101,7 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { )), types.NewGenesisPost(3, types.NewPost( 1, + 0, 2, "External ID", "This is a text", @@ -267,6 +271,7 @@ func (suite *KeeperTestsuite) TestKeeper_ImportGenesis() { GenesisPosts: []types.GenesisPost{ types.NewGenesisPost(2, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -285,6 +290,7 @@ func (suite *KeeperTestsuite) TestKeeper_ImportGenesis() { suite.Require().True(found) suite.Require().Equal(types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -317,6 +323,7 @@ func (suite *KeeperTestsuite) TestKeeper_ImportGenesis() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -361,6 +368,7 @@ func (suite *KeeperTestsuite) TestKeeper_ImportGenesis() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", diff --git a/x/posts/keeper/grpc_query.go b/x/posts/keeper/grpc_query.go index 79d3da2ee9..cc9f0db7ac 100644 --- a/x/posts/keeper/grpc_query.go +++ b/x/posts/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +16,8 @@ import ( var _ types.QueryServer = &Keeper{} -// Posts implements the QueryPosts gRPC method -func (k Keeper) Posts(ctx context.Context, request *types.QueryPostsRequest) (*types.QueryPostsResponse, error) { +// SubspacePosts implements the QuerySubspacePosts gRPC method +func (k Keeper) SubspacePosts(ctx context.Context, request *types.QuerySubspacePostsRequest) (*types.QuerySubspacePostsResponse, error) { if request.SubspaceId == 0 { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id") } @@ -24,10 +25,10 @@ func (k Keeper) Posts(ctx context.Context, request *types.QueryPostsRequest) (*t sdkCtx := sdk.UnwrapSDKContext(ctx) store := sdkCtx.KVStore(k.storeKey) - postsSubspace := prefix.NewStore(store, types.SubspacePostsPrefix(request.SubspaceId)) + postsStore := prefix.NewStore(store, types.SubspacePostsPrefix(request.SubspaceId)) var posts []types.Post - pageRes, err := query.Paginate(postsSubspace, request.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(postsStore, request.Pagination, func(key []byte, value []byte) error { var post types.Post if err := k.cdc.Unmarshal(value, &post); err != nil { return status.Error(codes.Internal, err.Error()) @@ -41,7 +42,41 @@ func (k Keeper) Posts(ctx context.Context, request *types.QueryPostsRequest) (*t return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryPostsResponse{ + return &types.QuerySubspacePostsResponse{ + Posts: posts, + Pagination: pageRes, + }, nil +} + +// SectionPosts implements the QuerySectionPosts gRPC method +func (k Keeper) SectionPosts(ctx context.Context, request *types.QuerySectionPostsRequest) (*types.QuerySectionPostsResponse, error) { + if request.SubspaceId == 0 { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := sdkCtx.KVStore(k.storeKey) + postsPrefix := types.SectionPostsPrefix(request.SubspaceId, request.SectionId) + sectionsPostsStore := prefix.NewStore(store, postsPrefix) + + var posts []types.Post + pageRes, err := query.Paginate(sectionsPostsStore, request.Pagination, func(key []byte, value []byte) error { + subspaceID, _, postID := types.SplitPostSectionStoreKey(append(postsPrefix, key...)) + post, found := k.GetPost(sdkCtx, subspaceID, postID) + if !found { + return fmt.Errorf("post not found: subspace id %d, post id %d", subspaceID, postID) + } + + posts = append(posts, post) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QuerySectionPostsResponse{ Posts: posts, Pagination: pageRes, }, nil diff --git a/x/posts/keeper/grpc_query_test.go b/x/posts/keeper/grpc_query_test.go index 8382567635..3c1bb3392c 100644 --- a/x/posts/keeper/grpc_query_test.go +++ b/x/posts/keeper/grpc_query_test.go @@ -9,23 +9,176 @@ import ( "github.com/desmos-labs/desmos/v3/x/posts/types" ) -func (suite *KeeperTestsuite) TestQueryServer_Posts() { +func (suite *KeeperTestsuite) TestQueryServer_SubspacePosts() { testCases := []struct { name string store func(ctx sdk.Context) - request *types.QueryPostsRequest + request *types.QuerySubspacePostsRequest shouldErr bool expPosts []types.Post }{ { name: "invalid subspace id returns error", - request: types.NewQueryPostsRequest(0, nil), + request: types.NewQuerySubspacePostsRequest(0, nil), shouldErr: true, }, { name: "valid request without pagination returns properly", store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( + 1, + 0, + 1, + "", + "First post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + )) + suite.k.SavePost(ctx, types.NewPost( + 1, + 0, + 2, + "", + "Second post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 1, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 13, 00, 00, 000, time.UTC), + nil, + )) + }, + request: types.NewQuerySubspacePostsRequest(1, nil), + shouldErr: false, + expPosts: []types.Post{ + types.NewPost( + 1, + 0, + 1, + "", + "First post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + ), + types.NewPost( + 1, + 0, + 2, + "", + "Second post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 1, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 13, 00, 00, 000, time.UTC), + nil, + ), + }, + }, + { + name: "valid request with pagination returns properly", + store: func(ctx sdk.Context) { + suite.k.SavePost(ctx, types.NewPost( + 1, + 0, + 1, + "", + "First post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + )) + suite.k.SavePost(ctx, types.NewPost( + 1, + 0, + 2, + "", + "Second post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 1, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 13, 00, 00, 000, time.UTC), + nil, + )) + }, + request: types.NewQuerySubspacePostsRequest(1, &query.PageRequest{ + Limit: 1, + }), + shouldErr: false, + expPosts: []types.Post{ + types.NewPost( + 1, + 0, + 1, + "", + "First post!", + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + 0, + nil, + nil, + types.REPLY_SETTING_EVERYONE, + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + nil, + ), + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + res, err := suite.k.SubspacePosts(sdk.WrapSDKContext(ctx), tc.request) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expPosts, res.Posts) + } + }) + } +} + +func (suite *KeeperTestsuite) TestQueryServer_SectionPosts() { + testCases := []struct { + name string + store func(ctx sdk.Context) + request *types.QuerySectionPostsRequest + shouldErr bool + expPosts []types.Post + }{ + { + name: "invalid subspace id returns error", + request: types.NewQuerySectionPostsRequest(0, 1, nil), + shouldErr: true, + }, + { + name: "valid request without pagination returns properly", + store: func(ctx sdk.Context) { + suite.k.SavePost(ctx, types.NewPost( + 1, 1, 1, "", @@ -39,6 +192,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { nil, )) suite.k.SavePost(ctx, types.NewPost( + 1, 1, 2, "", @@ -52,10 +206,11 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { nil, )) }, - request: types.NewQueryPostsRequest(1, nil), + request: types.NewQuerySectionPostsRequest(1, 1, nil), shouldErr: false, expPosts: []types.Post{ types.NewPost( + 1, 1, 1, "", @@ -69,6 +224,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { nil, ), types.NewPost( + 1, 1, 2, "", @@ -87,6 +243,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { name: "valid request with pagination returns properly", store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( + 1, 1, 1, "", @@ -100,6 +257,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { nil, )) suite.k.SavePost(ctx, types.NewPost( + 1, 1, 2, "", @@ -113,12 +271,13 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { nil, )) }, - request: types.NewQueryPostsRequest(1, &query.PageRequest{ + request: types.NewQuerySectionPostsRequest(1, 1, &query.PageRequest{ Limit: 1, }), shouldErr: false, expPosts: []types.Post{ types.NewPost( + 1, 1, 1, "", @@ -143,7 +302,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Posts() { tc.store(ctx) } - res, err := suite.k.Posts(sdk.WrapSDKContext(ctx), tc.request) + res, err := suite.k.SectionPosts(sdk.WrapSDKContext(ctx), tc.request) if tc.shouldErr { suite.Require().Error(err) } else { @@ -182,6 +341,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Post() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -198,6 +358,7 @@ func (suite *KeeperTestsuite) TestQueryServer_Post() { shouldErr: false, expPost: types.NewPost( 1, + 0, 1, "External ID", "This is a text", diff --git a/x/posts/keeper/invariants.go b/x/posts/keeper/invariants.go index dabbd136c9..bd31abe2fb 100644 --- a/x/posts/keeper/invariants.go +++ b/x/posts/keeper/invariants.go @@ -30,7 +30,7 @@ func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper) { func ValidSubspacesInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (message string, broken bool) { var invalidSubspaces []subspacestypes.Subspace - k.sk.IterateSubspaces(ctx, func(index int64, subspace subspacestypes.Subspace) (stop bool) { + k.sk.IterateSubspaces(ctx, func(subspace subspacestypes.Subspace) (stop bool) { // Make sure the next post id exists for the subspace if !k.HasNextPostID(ctx, subspace.ID) { @@ -60,7 +60,7 @@ func formatOutputSubspaces(subspaces []subspacestypes.Subspace) (output string) func ValidPostsInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (message string, broken bool) { var invalidPosts []types.Post - k.IteratePosts(ctx, func(_ int64, post types.Post) (stop bool) { + k.IteratePosts(ctx, func(post types.Post) (stop bool) { invalid := false // The only check we need to perform here is if the subspace still exists. @@ -69,6 +69,11 @@ func ValidPostsInvariant(k Keeper) sdk.Invariant { invalid = true } + // Make sure the section exists + if !k.HasSection(ctx, post.SubspaceID, post.SectionID) { + invalid = true + } + nextPostID, err := k.GetNextPostID(ctx, post.SubspaceID) if err != nil { invalid = true @@ -118,7 +123,7 @@ func formatOutputPosts(posts []types.Post) (output string) { func ValidAttachmentsInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (message string, broken bool) { var invalidAttachments []types.Attachment - k.IterateAttachments(ctx, func(_ int64, attachment types.Attachment) (stop bool) { + k.IterateAttachments(ctx, func(attachment types.Attachment) (stop bool) { invalid := false // Check subspace @@ -175,7 +180,7 @@ func formatOutputAttachments(attachments []types.Attachment) (output string) { func ValidUserAnswersInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (message string, broken bool) { var invalidUserAnswers []types.UserAnswer - k.IterateUserAnswers(ctx, func(_ int64, answer types.UserAnswer) (stop bool) { + k.IterateUserAnswers(ctx, func(answer types.UserAnswer) (stop bool) { invalid := false // Check subspace @@ -227,7 +232,7 @@ func formatOutputUserAnswers(answers []types.UserAnswer) (output string) { func ValidActivePollsInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (message string, broken bool) { var invalidActivePolls []types.Attachment - k.IterateActivePolls(ctx, func(_ int64, attachment types.Attachment) (stop bool) { + k.IterateActivePolls(ctx, func(attachment types.Attachment) (stop bool) { poll := attachment.Content.GetCachedValue().(*types.Poll) // Make sure active polls do not have tally results yet diff --git a/x/posts/keeper/invariants_test.go b/x/posts/keeper/invariants_test.go index f3b26b0946..c907dadd6a 100644 --- a/x/posts/keeper/invariants_test.go +++ b/x/posts/keeper/invariants_test.go @@ -75,6 +75,7 @@ func (suite *KeeperTestsuite) TestValidPostsInvariant() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -104,6 +105,7 @@ func (suite *KeeperTestsuite) TestValidPostsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -134,6 +136,7 @@ func (suite *KeeperTestsuite) TestValidPostsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -164,6 +167,7 @@ func (suite *KeeperTestsuite) TestValidPostsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -195,6 +199,7 @@ func (suite *KeeperTestsuite) TestValidPostsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -226,6 +231,7 @@ func (suite *KeeperTestsuite) TestValidPostsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -306,6 +312,7 @@ func (suite *KeeperTestsuite) TestValidAttachmentsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -339,6 +346,7 @@ func (suite *KeeperTestsuite) TestValidAttachmentsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -373,6 +381,7 @@ func (suite *KeeperTestsuite) TestValidAttachmentsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -407,6 +416,7 @@ func (suite *KeeperTestsuite) TestValidAttachmentsInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -487,6 +497,7 @@ func (suite *KeeperTestsuite) TestValidUserAnswersInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -518,6 +529,7 @@ func (suite *KeeperTestsuite) TestValidUserAnswersInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -561,6 +573,7 @@ func (suite *KeeperTestsuite) TestValidUserAnswersInvariant() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "Text", diff --git a/x/posts/keeper/msg_server.go b/x/posts/keeper/msg_server.go index 5452285d2f..1ab2d079c1 100644 --- a/x/posts/keeper/msg_server.go +++ b/x/posts/keeper/msg_server.go @@ -29,18 +29,23 @@ var _ types.MsgServer = &msgServer{} func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) (*types.MsgCreatePostResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } + // Check if the section exists + if !k.HasSection(ctx, msg.SubspaceID, msg.SectionID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace section with id %d not found", msg.SectionID) + } + author, err := sdk.AccAddressFromBech32(msg.Author) if err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid author address: %s", msg.Author) } // Check the permission to create content - if !k.HasPermission(ctx, msg.SubspaceID, author, subspacestypes.PermissionWrite) { + if !k.HasPermission(ctx, msg.SubspaceID, msg.SectionID, author.String(), subspacestypes.PermissionWrite) { return nil, sdkerrors.Wrap(subspacestypes.ErrPermissionDenied, "you cannot create content inside this subspace") } @@ -53,6 +58,7 @@ func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) ( // Create and validate the post post := types.NewPost( msg.SubspaceID, + msg.SectionID, postID, msg.ExternalID, msg.Text, @@ -99,6 +105,7 @@ func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) ( sdk.NewEvent( types.EventTypeCreatePost, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), sdk.NewAttribute(types.AttributeKeyPostID, fmt.Sprintf("%d", post.ID)), sdk.NewAttribute(types.AttributeKeyAuthor, msg.Author), sdk.NewAttribute(types.AttributeKeyCreationTime, post.CreationDate.Format(time.RFC3339)), @@ -115,7 +122,7 @@ func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) ( func (k msgServer) EditPost(goCtx context.Context, msg *types.MsgEditPost) (*types.MsgEditPostResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } @@ -137,7 +144,7 @@ func (k msgServer) EditPost(goCtx context.Context, msg *types.MsgEditPost) (*typ } // Check the permission to create content - if !k.HasPermission(ctx, msg.SubspaceID, editor, subspacestypes.PermissionEditOwnContent) { + if !k.HasPermission(ctx, msg.SubspaceID, post.SectionID, editor.String(), subspacestypes.PermissionEditOwnContent) { return nil, sdkerrors.Wrap(subspacestypes.ErrPermissionDenied, "you cannot edit content inside this subspace") } @@ -177,7 +184,7 @@ func (k msgServer) EditPost(goCtx context.Context, msg *types.MsgEditPost) (*typ func (k msgServer) DeletePost(goCtx context.Context, msg *types.MsgDeletePost) (*types.MsgDeletePostResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } @@ -194,8 +201,8 @@ func (k msgServer) DeletePost(goCtx context.Context, msg *types.MsgDeletePost) ( } // Check the permission to remove the post - isModerator := k.HasPermission(ctx, msg.SubspaceID, editor, subspacestypes.PermissionModerateContent) - canEdit := post.Author == msg.Signer && k.HasPermission(ctx, msg.SubspaceID, editor, subspacestypes.PermissionEditOwnContent) + isModerator := k.HasPermission(ctx, msg.SubspaceID, post.SectionID, editor.String(), subspacestypes.PermissionModerateContent) + canEdit := post.Author == msg.Signer && k.HasPermission(ctx, msg.SubspaceID, post.SectionID, editor.String(), subspacestypes.PermissionEditOwnContent) if !isModerator && !canEdit { return nil, sdkerrors.Wrap(subspacestypes.ErrPermissionDenied, "you cannot edit content inside this subspace") } @@ -266,7 +273,7 @@ func (k msgServer) storePostAttachment(ctx sdk.Context, subspaceID uint64, postI func (k msgServer) AddPostAttachment(goCtx context.Context, msg *types.MsgAddPostAttachment) (*types.MsgAddPostAttachmentResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } @@ -288,7 +295,7 @@ func (k msgServer) AddPostAttachment(goCtx context.Context, msg *types.MsgAddPos } // Check the permission to edit content - if !k.HasPermission(ctx, msg.SubspaceID, editor, subspacestypes.PermissionEditOwnContent) { + if !k.HasPermission(ctx, msg.SubspaceID, post.SectionID, editor.String(), subspacestypes.PermissionEditOwnContent) { return nil, sdkerrors.Wrap(subspacestypes.ErrPermissionDenied, "you cannot edit content inside this subspace") } @@ -340,7 +347,7 @@ func (k msgServer) AddPostAttachment(goCtx context.Context, msg *types.MsgAddPos func (k msgServer) RemovePostAttachment(goCtx context.Context, msg *types.MsgRemovePostAttachment) (*types.MsgRemovePostAttachmentResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } @@ -357,8 +364,8 @@ func (k msgServer) RemovePostAttachment(goCtx context.Context, msg *types.MsgRem } // Check the permission to remove the attachment - isModerator := k.HasPermission(ctx, msg.SubspaceID, editor, subspacestypes.PermissionModerateContent) - canEdit := post.Author == msg.Editor && k.HasPermission(ctx, msg.SubspaceID, editor, subspacestypes.PermissionEditOwnContent) + isModerator := k.HasPermission(ctx, msg.SubspaceID, post.SectionID, editor.String(), subspacestypes.PermissionModerateContent) + canEdit := post.Author == msg.Editor && k.HasPermission(ctx, msg.SubspaceID, post.SectionID, editor.String(), subspacestypes.PermissionEditOwnContent) if !isModerator && !canEdit { return nil, sdkerrors.Wrap(subspacestypes.ErrPermissionDenied, "you cannot edit content inside this subspace") } @@ -405,26 +412,27 @@ func (k msgServer) RemovePostAttachment(goCtx context.Context, msg *types.MsgRem func (k msgServer) AnswerPoll(goCtx context.Context, msg *types.MsgAnswerPoll) (*types.MsgAnswerPollResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } + // Make sure the post exists + post, found := k.GetPost(ctx, msg.SubspaceID, msg.PostID) + if !found { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "post with id %d does not exist", msg.PostID) + } + signer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address: %s", msg.Signer) } // Check the permission to interact with content - if !k.HasPermission(ctx, msg.SubspaceID, signer, subspacestypes.PermissionInteractWithContent) { + if !k.HasPermission(ctx, msg.SubspaceID, post.SectionID, signer.String(), subspacestypes.PermissionInteractWithContent) { return nil, sdkerrors.Wrap(subspacestypes.ErrPermissionDenied, "you cannot interact with content inside this subspace") } - // Make sure the post exists - if !k.HasPost(ctx, msg.SubspaceID, msg.PostID) { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "post with id %d does not exist", msg.PostID) - } - // Get the poll poll, found := k.GetPoll(ctx, msg.SubspaceID, msg.PostID, msg.PollID) if !found { diff --git a/x/posts/keeper/msg_server_test.go b/x/posts/keeper/msg_server_test.go index 42ed05886a..74d773a6df 100644 --- a/x/posts/keeper/msg_server_test.go +++ b/x/posts/keeper/msg_server_test.go @@ -24,6 +24,23 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { { name: "non existing subspace returns error", msg: types.NewMsgCreatePost( + 1, + 1, + "External ID", + "This is a text", + 1, + types.REPLY_SETTING_EVERYONE, + nil, + nil, + nil, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + ), + shouldErr: true, + }, + { + name: "non existing section returns error", + msg: types.NewMsgCreatePost( + 1, 1, "External ID", "This is a text", @@ -34,6 +51,17 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { nil, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", ), + store: func(ctx sdk.Context) { + suite.sk.SaveSubspace(ctx, subspacestypes.NewSubspace( + 1, + "Test", + "Testing subspace", + "cosmos1sg2j68v5n8qvehew6ml0etun3lmv7zg7r49s67", + "cosmos1sg2j68v5n8qvehew6ml0etun3lmv7zg7r49s67", + "cosmos1sg2j68v5n8qvehew6ml0etun3lmv7zg7r49s67", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, shouldErr: true, }, { @@ -51,6 +79,7 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 1, @@ -75,14 +104,18 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionWrite, + ) suite.k.SetParams(ctx, types.DefaultParams()) }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 1, @@ -107,14 +140,18 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionWrite, + ) suite.k.SetParams(ctx, types.DefaultParams()) }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 0, @@ -143,12 +180,16 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionWrite, + ) }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 0, @@ -176,9 +217,12 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionWrite, + ) suite.k.SetNextPostID(ctx, 1, 1) @@ -187,6 +231,7 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 0, @@ -214,9 +259,12 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionWrite, + ) suite.k.SetNextPostID(ctx, 1, 1) @@ -224,6 +272,7 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 0, @@ -253,9 +302,12 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionWrite, + ) suite.k.SetNextPostID(ctx, 1, 1) @@ -263,6 +315,7 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { }, msg: types.NewMsgCreatePost( 1, + 0, "External ID", "This is a text", 0, @@ -289,6 +342,7 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { sdk.NewEvent( types.EventTypeCreatePost, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeySectionID, "0"), sdk.NewAttribute(types.AttributeKeyPostID, "1"), sdk.NewAttribute(types.AttributeKeyAuthor, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), sdk.NewAttribute(types.AttributeKeyCreationTime, time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC).Format(time.RFC3339)), @@ -300,6 +354,7 @@ func (suite *KeeperTestsuite) TestMsgServer_CreatePost() { suite.Require().True(found) suite.Require().Equal(types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -413,6 +468,7 @@ func (suite *KeeperTestsuite) TestMsgServer_EditPost() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a new post", @@ -449,6 +505,7 @@ func (suite *KeeperTestsuite) TestMsgServer_EditPost() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a new post", @@ -486,12 +543,16 @@ func (suite *KeeperTestsuite) TestMsgServer_EditPost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a new post", @@ -532,14 +593,18 @@ func (suite *KeeperTestsuite) TestMsgServer_EditPost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SetParams(ctx, types.DefaultParams()) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a new post", @@ -585,6 +650,7 @@ func (suite *KeeperTestsuite) TestMsgServer_EditPost() { editDate := time.Date(2021, 1, 1, 12, 00, 00, 000, time.UTC) suite.Require().Equal(types.NewPost( 1, + 0, 1, "External ID", "This is my new text", @@ -656,9 +722,12 @@ func (suite *KeeperTestsuite) TestMsgServer_DeletePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionWrite&subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) }, msg: types.NewMsgDeletePost(1, 1, "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd"), shouldErr: true, @@ -678,6 +747,7 @@ func (suite *KeeperTestsuite) TestMsgServer_DeletePost() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -706,12 +776,16 @@ func (suite *KeeperTestsuite) TestMsgServer_DeletePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -740,12 +814,16 @@ func (suite *KeeperTestsuite) TestMsgServer_DeletePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionModerateContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4", + subspacestypes.PermissionModerateContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -790,12 +868,16 @@ func (suite *KeeperTestsuite) TestMsgServer_DeletePost() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -914,6 +996,7 @@ func (suite *KeeperTestsuite) TestMsgServer_AddPostAttachment() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -949,6 +1032,7 @@ func (suite *KeeperTestsuite) TestMsgServer_AddPostAttachment() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -986,6 +1070,7 @@ func (suite *KeeperTestsuite) TestMsgServer_AddPostAttachment() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -998,9 +1083,12 @@ func (suite *KeeperTestsuite) TestMsgServer_AddPostAttachment() { nil, )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) }, msg: types.NewMsgAddPostAttachment( 1, @@ -1030,6 +1118,7 @@ func (suite *KeeperTestsuite) TestMsgServer_AddPostAttachment() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1042,9 +1131,12 @@ func (suite *KeeperTestsuite) TestMsgServer_AddPostAttachment() { nil, )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) }, msg: types.NewMsgAddPostAttachment( 1, @@ -1178,6 +1270,7 @@ func (suite *KeeperTestsuite) TestMsgServer_RemovePostAttachment() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1211,12 +1304,16 @@ func (suite *KeeperTestsuite) TestMsgServer_RemovePostAttachment() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1250,12 +1347,16 @@ func (suite *KeeperTestsuite) TestMsgServer_RemovePostAttachment() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1292,14 +1393,18 @@ func (suite *KeeperTestsuite) TestMsgServer_RemovePostAttachment() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionModerateContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos1r9jamre0x0qqy562rhhckt6sryztwhnvhafyz4", + subspacestypes.PermissionModerateContent, + ) suite.k.SetParams(ctx, types.DefaultParams()) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1372,14 +1477,18 @@ func (suite *KeeperTestsuite) TestMsgServer_RemovePostAttachment() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionEditOwnContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionEditOwnContent, + ) suite.k.SetParams(ctx, types.DefaultParams()) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1522,9 +1631,12 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) }, msg: types.NewMsgAnswerPoll( 1, @@ -1548,12 +1660,16 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1588,12 +1704,16 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1653,12 +1773,16 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1710,12 +1834,16 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1767,12 +1895,16 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -1858,12 +1990,16 @@ func (suite *KeeperTestsuite) TestMsgServer_AnswerPoll() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - user, err := sdk.AccAddressFromBech32("cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd") - suite.Require().NoError(err) - suite.sk.SetUserPermissions(ctx, 1, user, subspacestypes.PermissionInteractWithContent) + suite.sk.SetUserPermissions(ctx, + 1, + 0, + "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", + subspacestypes.PermissionInteractWithContent, + ) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", diff --git a/x/posts/keeper/polls.go b/x/posts/keeper/polls.go index dea11c519e..3a2ddff2e3 100644 --- a/x/posts/keeper/polls.go +++ b/x/posts/keeper/polls.go @@ -42,7 +42,7 @@ func (k Keeper) Tally(ctx sdk.Context, subspaceID uint64, postID uint64, pollID results[uint32(i)] = 0 } - k.IteratePollUserAnswers(ctx, subspaceID, postID, pollID, func(_ int64, answer types.UserAnswer) (stop bool) { + k.IteratePollUserAnswers(ctx, subspaceID, postID, pollID, func(answer types.UserAnswer) (stop bool) { // Update the results for _, answerIndex := range answer.AnswersIndexes { results[answerIndex]++ diff --git a/x/posts/keeper/posts.go b/x/posts/keeper/posts.go index 3efe45a667..c75980b8ed 100644 --- a/x/posts/keeper/posts.go +++ b/x/posts/keeper/posts.go @@ -121,7 +121,7 @@ func (k Keeper) ValidatePost(ctx sdk.Context, post types.Post) error { err := post.Validate() if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + return sdkerrors.Wrapf(types.ErrInvalidPost, err.Error()) } return nil @@ -134,6 +134,9 @@ func (k Keeper) SavePost(ctx sdk.Context, post types.Post) { // Store the post store.Set(types.PostStoreKey(post.SubspaceID, post.ID), k.cdc.MustMarshal(&post)) + // Store the section reference + store.Set(types.PostSectionStoreKey(post.SubspaceID, post.SectionID, post.ID), []byte{0x01}) + // If the initial attachment id does not exist, create it now if !k.HasNextAttachmentID(ctx, post.SubspaceID, post.ID) { k.SetNextAttachmentID(ctx, post.SubspaceID, post.ID, 1) @@ -167,17 +170,26 @@ func (k Keeper) GetPost(ctx sdk.Context, subspaceID uint64, postID uint64) (post func (k Keeper) DeletePost(ctx sdk.Context, subspaceID uint64, postID uint64) { store := ctx.KVStore(k.storeKey) + // Get the post + post, found := k.GetPost(ctx, subspaceID, postID) + if !found { + return + } + // Delete the post - store.Delete(types.PostStoreKey(subspaceID, postID)) + store.Delete(types.PostStoreKey(post.SubspaceID, post.ID)) + + // Delete the section reference + store.Delete(types.PostSectionStoreKey(post.SubspaceID, post.SectionID, post.ID)) // Delete all the attachments - k.IteratePostAttachments(ctx, subspaceID, postID, func(_ int64, attachment types.Attachment) (stop bool) { + k.IteratePostAttachments(ctx, post.SubspaceID, post.ID, func(attachment types.Attachment) (stop bool) { k.DeleteAttachment(ctx, attachment.SubspaceID, attachment.PostID, attachment.ID) return false }) // Delete the attachment id key - k.DeleteNextAttachmentID(ctx, subspaceID, postID) + k.DeleteNextAttachmentID(ctx, post.SubspaceID, post.ID) - k.AfterPostDeleted(ctx, subspaceID, postID) + k.AfterPostDeleted(ctx, post.SubspaceID, post.ID) } diff --git a/x/posts/keeper/posts_test.go b/x/posts/keeper/posts_test.go index 1fd36b660f..3151afd89b 100644 --- a/x/posts/keeper/posts_test.go +++ b/x/posts/keeper/posts_test.go @@ -178,6 +178,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReference() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "This is a long post text to make sure tags are valid", @@ -200,6 +201,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReference() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "This is a long post text to make sure tags are valid", @@ -258,6 +260,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReply() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a test post", @@ -286,6 +289,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReply() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a test post", @@ -314,6 +318,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReply() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a test post", @@ -348,6 +353,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReply() { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a test post", @@ -370,6 +376,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReply() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "", "This is a test post", @@ -392,6 +399,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePostReply() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "cosmos1t457f629cc3ykftepjejgzxv0vmz5dw2gn940g", "This is a test post", @@ -445,6 +453,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePost() { }, post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -477,6 +486,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePost() { }, post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -507,6 +517,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePost() { }, post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -540,6 +551,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePost() { post: types.NewPost( 1, 0, + 0, "External id", "Text", "cosmos1eqpa6mv2jgevukaqtjmx5535vhc3mm3cf458zg", @@ -558,6 +570,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePost() { suite.k.SetParams(ctx, types.DefaultParams()) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External id", "This is a long post text to make sure tags are valid", @@ -572,6 +585,7 @@ func (suite *KeeperTestsuite) TestKeeper_ValidatePost() { }, post: types.NewPost( 1, + 0, 2, "External id", "This is a long post text to make sure tags are valid", @@ -628,6 +642,7 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { name: "non existing post is saved properly", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -657,6 +672,7 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { suite.Require().True(found) suite.Require().Equal(types.NewPost( 1, + 0, 2, "External id", "Text", @@ -681,8 +697,12 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { nil, ), stored) - // Make sure the attachment it is generated properly store := ctx.KVStore(suite.storeKey) + + // Make sure the section reference is properly set + suite.Require().True(store.Has(types.PostSectionStoreKey(1, 0, 2))) + + // Make sure the attachment it is generated properly attachmentID := types.GetAttachmentIDFromBytes(store.Get(types.NextAttachmentIDStoreKey(1, 2))) suite.Require().Equal(uint32(1), attachmentID) }, @@ -692,6 +712,7 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 2, "External id", "Text", @@ -718,6 +739,7 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { }, post: types.NewPost( 1, + 0, 2, "External id", "This is a new text", @@ -747,6 +769,7 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { suite.Require().True(found) suite.Require().Equal(types.NewPost( 1, + 0, 2, "External id", "This is a new text", @@ -771,8 +794,12 @@ func (suite *KeeperTestsuite) TestKeeper_SavePost() { nil, ), stored) - // Make sure the attachment it is generated properly store := ctx.KVStore(suite.storeKey) + + // Make sure the section reference is stored + suite.Require().True(store.Has(types.PostSectionStoreKey(1, 0, 2))) + + // Make sure the attachment it is generated properly attachmentID := types.GetAttachmentIDFromBytes(store.Get(types.NextAttachmentIDStoreKey(1, 2))) suite.Require().Equal(uint32(1), attachmentID) }, @@ -814,6 +841,7 @@ func (suite *KeeperTestsuite) TestKeeper_HasPost() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 2, "External id", "Text", @@ -879,6 +907,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetPost() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 2, "External id", "Text", @@ -908,6 +937,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetPost() { expFound: true, expPost: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -970,6 +1000,7 @@ func (suite *KeeperTestsuite) TestKeeper_DeletePost() { store: func(ctx sdk.Context) { suite.k.SavePost(ctx, types.NewPost( 1, + 0, 2, "External id", "Text", @@ -1004,7 +1035,9 @@ func (suite *KeeperTestsuite) TestKeeper_DeletePost() { subspaceID: 1, postID: 2, check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) suite.Require().False(suite.k.HasPost(ctx, 1, 2)) + suite.Require().False(store.Has(types.PostSectionStoreKey(1, 0, 1))) suite.Require().False(suite.k.HasNextAttachmentID(ctx, 1, 2)) suite.Require().False(suite.k.HasAttachment(ctx, 1, 2, 1)) }, diff --git a/x/posts/keeper/subspace_hooks_test.go b/x/posts/keeper/subspace_hooks_test.go index 8636a2ea64..71ae11044a 100644 --- a/x/posts/keeper/subspace_hooks_test.go +++ b/x/posts/keeper/subspace_hooks_test.go @@ -69,6 +69,7 @@ func (suite *KeeperTestsuite) TestKeeper_AfterSubspaceDeleted() { suite.k.SetNextPostID(ctx, 1, 1) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -82,6 +83,7 @@ func (suite *KeeperTestsuite) TestKeeper_AfterSubspaceDeleted() { )) suite.k.SavePost(ctx, types.NewPost( 1, + 0, 2, "External ID", "This is a text", diff --git a/x/posts/keeper/subspaces_hooks.go b/x/posts/keeper/subspaces_hooks.go index f054f8a581..f3e92f9234 100644 --- a/x/posts/keeper/subspaces_hooks.go +++ b/x/posts/keeper/subspaces_hooks.go @@ -30,7 +30,19 @@ func (h Hooks) AfterSubspaceDeleted(ctx sdk.Context, subspaceID uint64) { h.k.DeleteNextPostID(ctx, subspaceID) // Delete all the posts - h.k.IterateSubspacePosts(ctx, subspaceID, func(_ int64, post types.Post) (stop bool) { + h.k.IterateSubspacePosts(ctx, subspaceID, func(post types.Post) (stop bool) { + h.k.DeletePost(ctx, post.SubspaceID, post.ID) + return false + }) +} + +// AfterSubspaceSectionSaved implements subspacestypes.Hooks +func (h Hooks) AfterSubspaceSectionSaved(sdk.Context, uint64, uint32) {} + +// AfterSubspaceSectionDeleted implements subspacestypes.Hooks +func (h Hooks) AfterSubspaceSectionDeleted(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + // Delete all the posts + h.k.IterateSectionPosts(ctx, subspaceID, sectionID, func(post types.Post) (stop bool) { h.k.DeletePost(ctx, post.SubspaceID, post.ID) return false }) @@ -40,17 +52,17 @@ func (h Hooks) AfterSubspaceDeleted(ctx sdk.Context, subspaceID uint64) { func (h Hooks) AfterSubspaceGroupSaved(sdk.Context, uint64, uint32) {} // AfterSubspaceGroupMemberAdded implements subspacestypes.Hooks -func (h Hooks) AfterSubspaceGroupMemberAdded(sdk.Context, uint64, uint32, sdk.AccAddress) {} +func (h Hooks) AfterSubspaceGroupMemberAdded(sdk.Context, uint64, uint32, string) {} // AfterSubspaceGroupMemberRemoved implements subspacestypes.Hooks -func (h Hooks) AfterSubspaceGroupMemberRemoved(sdk.Context, uint64, uint32, sdk.AccAddress) {} +func (h Hooks) AfterSubspaceGroupMemberRemoved(sdk.Context, uint64, uint32, string) {} // AfterSubspaceGroupDeleted implements subspacestypes.Hooks func (h Hooks) AfterSubspaceGroupDeleted(sdk.Context, uint64, uint32) {} // AfterUserPermissionSet implements subspacestypes.Hooks -func (h Hooks) AfterUserPermissionSet(sdk.Context, uint64, sdk.AccAddress, subspacestypes.Permission) { +func (h Hooks) AfterUserPermissionSet(sdk.Context, uint64, uint32, string, subspacestypes.Permission) { } // AfterUserPermissionRemoved implements subspacestypes.Hooks -func (h Hooks) AfterUserPermissionRemoved(sdk.Context, uint64, sdk.AccAddress) {} +func (h Hooks) AfterUserPermissionRemoved(sdk.Context, uint64, uint32, string) {} diff --git a/x/posts/legacy/v2/store.go b/x/posts/legacy/v2/store.go index b1beff80f9..ef17bfe2f3 100644 --- a/x/posts/legacy/v2/store.go +++ b/x/posts/legacy/v2/store.go @@ -8,7 +8,7 @@ import ( ) type SubspacesKeeper interface { - IterateSubspaces(ctx sdk.Context, fn func(index int64, subspaces subspacestypes.Subspace) (stop bool)) + IterateSubspaces(ctx sdk.Context, fn func(subspaces subspacestypes.Subspace) (stop bool)) } // MigrateStore performs in-place store migrations from v1 to v2 @@ -17,7 +17,7 @@ func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, sk SubspacesKeeper) er store := ctx.KVStore(storeKey) // Set the next post id for all the subspaces - sk.IterateSubspaces(ctx, func(index int64, subspaces subspacestypes.Subspace) (stop bool) { + sk.IterateSubspaces(ctx, func(subspaces subspacestypes.Subspace) (stop bool) { store.Set(types.NextPostIDStoreKey(subspaces.ID), types.GetPostIDBytes(1)) return false }) diff --git a/x/posts/simulation/decoder_test.go b/x/posts/simulation/decoder_test.go index 7d8fb7d0a7..1b9f595c82 100644 --- a/x/posts/simulation/decoder_test.go +++ b/x/posts/simulation/decoder_test.go @@ -19,6 +19,7 @@ func TestDecodeStore(t *testing.T) { post := types.NewPost( 1, + 0, 2, "External id", "This is a post text that does not contain any useful information", diff --git a/x/posts/simulation/genesis.go b/x/posts/simulation/genesis.go index 2044145e30..4a35cdbb52 100644 --- a/x/posts/simulation/genesis.go +++ b/x/posts/simulation/genesis.go @@ -37,12 +37,12 @@ func RandomizeGenState(simState *module.SimulationState) { } // randomPosts returns randomly generated genesis posts -func randomPosts(r *rand.Rand, subspaces []subspacestypes.GenesisSubspace, accs []simtypes.Account, params types.Params) (posts []types.Post) { +func randomPosts(r *rand.Rand, subspaces []subspacestypes.Subspace, accs []simtypes.Account, params types.Params) (posts []types.Post) { postsNumber := uint64(r.Intn(100)) posts = make([]types.Post, postsNumber) for index := uint64(0); index < postsNumber; index++ { - subspace := subspacessim.RandomGenesisSubspace(r, subspaces) - posts[index] = GenerateRandomPost(r, accs, subspace.Subspace.ID, index+1, params) + subspace := subspacessim.RandomSubspace(r, subspaces) + posts[index] = GenerateRandomPost(r, accs, subspace.ID, subspacestypes.RootSectionID, index+1, params) } return posts } diff --git a/x/posts/simulation/operations_attachments.go b/x/posts/simulation/operations_attachments.go index 00239065b7..e900909540 100644 --- a/x/posts/simulation/operations_attachments.go +++ b/x/posts/simulation/operations_attachments.go @@ -68,8 +68,7 @@ func randomAddPostAttachmentFields( postID = post.ID // Get an editor - editorAdd, _ := sdk.AccAddressFromBech32(post.Author) - acc := subspacessim.GetAccount(editorAdd, accs) + acc := subspacessim.GetAccount(post.Author, accs) if acc == nil { // Skip because the author is not an account we have access to skip = true @@ -128,15 +127,16 @@ func randomRemovePostAttachmentFields( } post := RandomPost(r, posts) subspaceID = post.SubspaceID + sectionID := post.SectionID postID = post.ID // Get an editor - editorAddr, _ := sdk.AccAddressFromBech32(post.Author) + editorAddr := post.Author if r.Intn(101) < 50 { // 50% of a moderator removing an attachment - moderators, _ := sk.GetUsersWithPermission(ctx, subspaceID, subspacestypes.PermissionModerateContent) + moderators, _ := sk.GetUsersWithRootPermission(ctx, subspaceID, subspacestypes.PermissionModerateContent) editorAddr = subspacessim.RandomAddress(r, moderators) - } else if !sk.HasPermission(ctx, subspaceID, editorAddr, subspacestypes.PermissionEditOwnContent) { + } else if !sk.HasPermission(ctx, subspaceID, sectionID, editorAddr, subspacestypes.PermissionEditOwnContent) { // Skip because the user has not the permission to edit their own content skip = true return diff --git a/x/posts/simulation/operations_polls.go b/x/posts/simulation/operations_polls.go index a96d33d3c7..c0056cc0e3 100644 --- a/x/posts/simulation/operations_polls.go +++ b/x/posts/simulation/operations_polls.go @@ -58,7 +58,7 @@ func randomAnswerPollFields( // Get a poll var polls []types.Attachment - k.IterateActivePollsQueue(ctx, time.Now(), func(index int64, poll types.Attachment) (stop bool) { + k.IterateActivePollsQueue(ctx, time.Now(), func(poll types.Attachment) (stop bool) { polls = append(polls, poll) return false }) @@ -72,7 +72,7 @@ func randomAnswerPollFields( poll := RandomAttachment(r, polls) // Get a user - users, _ := sk.GetUsersWithPermission(ctx, poll.SubspaceID, subspacestypes.PermissionInteractWithContent) + users, _ := sk.GetUsersWithRootPermission(ctx, poll.SubspaceID, subspacestypes.PermissionInteractWithContent) acc := subspacessim.GetAccount(subspacessim.RandomAddress(r, users), accs) if acc == nil { // Skip the operation withofut error as the account is not valid diff --git a/x/posts/simulation/operations_posts.go b/x/posts/simulation/operations_posts.go index 223814967c..6bae1fb914 100644 --- a/x/posts/simulation/operations_posts.go +++ b/x/posts/simulation/operations_posts.go @@ -38,6 +38,7 @@ func SimulateMsgCreatePost( msg := types.NewMsgCreatePost( data.SubspaceID, + data.SectionID, data.ExternalID, data.Text, data.ConversationID, @@ -67,16 +68,16 @@ func randomPostCreateFields( } // Get a subspace id - subspaces := sk.GetAllSubspaces(ctx) - if len(subspaces) == 0 { - // Skip because there are no subspaces + sections := sk.GetAllSections(ctx) + if len(sections) == 0 { + // Skip because there are no sections skip = true return } - subspace := subspacessim.RandomSubspace(r, subspaces) + section := subspacessim.RandomSection(r, sections) // Get an author - users, _ := sk.GetUsersWithPermission(ctx, subspace.ID, subspacestypes.PermissionWrite) + users, _ := sk.GetUsersWithRootPermission(ctx, section.SubspaceID, subspacestypes.PermissionWrite) acc := subspacessim.GetAccount(subspacessim.RandomAddress(r, users), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -85,12 +86,12 @@ func randomPostCreateFields( } author = *acc - postID, err := k.GetNextPostID(ctx, subspace.ID) + postID, err := k.GetNextPostID(ctx, section.SubspaceID) if err != nil { panic(err) } - post = GenerateRandomPost(r, accs, subspace.ID, postID, k.GetParams(ctx)) + post = GenerateRandomPost(r, accs, section.SubspaceID, section.ID, postID, k.GetParams(ctx)) err = k.ValidatePost(ctx, post) if err != nil { // Skip the operation because the post is not valid (there are too many reasons why it might be) @@ -146,11 +147,11 @@ func randomPostEditFields( } post := RandomPost(r, posts) subspaceID = post.SubspaceID + sectionID := post.SectionID postID = post.ID // Get the post author - authorAdr, _ := sdk.AccAddressFromBech32(post.Author) - authorAcc := subspacessim.GetAccount(authorAdr, accs) + authorAcc := subspacessim.GetAccount(post.Author, accs) if authorAcc == nil { // Skip because the author is not an account we have access to skip = true @@ -159,7 +160,7 @@ func randomPostEditFields( editor = *authorAcc // Check the permissions - if !sk.HasPermission(ctx, subspaceID, authorAdr, subspacestypes.PermissionEditOwnContent) { + if !sk.HasPermission(ctx, subspaceID, sectionID, post.Author, subspacestypes.PermissionEditOwnContent) { // Skip because the user has not the permissions skip = true return @@ -219,21 +220,22 @@ func randomPostDeleteFields( } post := RandomPost(r, posts) subspaceID = post.SubspaceID + sectionID := post.SectionID postID = post.ID // Get the user - authorAdr, _ := sdk.AccAddressFromBech32(post.Author) + authorAddr := post.Author if r.Intn(101) < 50 { // 50% of a moderator deleting the post - moderators, _ := sk.GetUsersWithPermission(ctx, subspaceID, subspacestypes.PermissionModerateContent) - authorAdr = subspacessim.RandomAddress(r, moderators) - } else if !sk.HasPermission(ctx, subspaceID, authorAdr, subspacestypes.PermissionEditOwnContent) { + moderators, _ := sk.GetUsersWithRootPermission(ctx, subspaceID, subspacestypes.PermissionModerateContent) + authorAddr = subspacessim.RandomAddress(r, moderators) + } else if !sk.HasPermission(ctx, subspaceID, sectionID, authorAddr, subspacestypes.PermissionEditOwnContent) { // Skip because the user has not the permissions skip = true return } - userAcc := subspacessim.GetAccount(authorAdr, accs) + userAcc := subspacessim.GetAccount(authorAddr, accs) if userAcc == nil { // Skip because the author is not an account we have access to skip = true diff --git a/x/posts/simulation/utils.go b/x/posts/simulation/utils.go index 747c67da68..d7b72097f6 100644 --- a/x/posts/simulation/utils.go +++ b/x/posts/simulation/utils.go @@ -27,10 +27,11 @@ var ( ) // GenerateRandomPost generates a random post -func GenerateRandomPost(r *rand.Rand, accounts []simtypes.Account, subspaceID uint64, postID uint64, params types.Params) types.Post { +func GenerateRandomPost(r *rand.Rand, accounts []simtypes.Account, subspaceID uint64, sectionID uint32, postID uint64, params types.Params) types.Post { author, _ := simtypes.RandomAcc(r, accounts) return types.NewPost( subspaceID, + sectionID, postID, GenerateRandomText(r, 20), GenerateRandomText(r, params.MaxTextLength), diff --git a/x/posts/types/events.go b/x/posts/types/events.go index db794be213..ad2d07ecb4 100644 --- a/x/posts/types/events.go +++ b/x/posts/types/events.go @@ -12,6 +12,7 @@ const ( AttributeValueCategory = ModuleName AttributeKeySubspaceID = "subspace_id" + AttributeKeySectionID = "section_id" AttributeKeyPostID = "post_id" AttributeKeyAuthor = "author" AttributeKeyCreationTime = "creation_date" diff --git a/x/posts/types/expected_keepers.go b/x/posts/types/expected_keepers.go index a8eb1ea5a2..126bb3cf0a 100644 --- a/x/posts/types/expected_keepers.go +++ b/x/posts/types/expected_keepers.go @@ -11,11 +11,14 @@ type SubspacesKeeper interface { // HasSubspace tells whether the subspace with the given id exists or not HasSubspace(ctx sdk.Context, subspaceID uint64) bool + // HasSection tells whether the section having the given id exists inside the provided subspace + HasSection(ctx sdk.Context, subspaceID uint64, sectionID uint32) bool + // HasPermission tells whether the given user has the provided permission inside the subspace with the specified id - HasPermission(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permission subspacestypes.Permission) bool + HasPermission(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permission subspacestypes.Permission) bool // IterateSubspaces iterates through the subspaces set and performs the given function - IterateSubspaces(ctx sdk.Context, fn func(index int64, subspace subspacestypes.Subspace) (stop bool)) + IterateSubspaces(ctx sdk.Context, fn func(subspace subspacestypes.Subspace) (stop bool)) } // RelationshipsKeeper represents a keeper that deals with relationships diff --git a/x/posts/types/genesis_test.go b/x/posts/types/genesis_test.go index 592ed9fc3f..b6aaff0e67 100644 --- a/x/posts/types/genesis_test.go +++ b/x/posts/types/genesis_test.go @@ -35,6 +35,7 @@ func TestValidateGenesis(t *testing.T) { data: types.NewGenesisState(nil, []types.GenesisPost{ types.NewGenesisPost(0, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -59,6 +60,7 @@ func TestValidateGenesis(t *testing.T) { types.NewGenesisPost(1, types.NewPost( 1, 0, + 0, "External ID", "This is a text", "cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd", @@ -86,6 +88,7 @@ func TestValidateGenesis(t *testing.T) { []types.GenesisPost{ types.NewGenesisPost(1, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -99,6 +102,7 @@ func TestValidateGenesis(t *testing.T) { )), types.NewGenesisPost(3, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -127,6 +131,7 @@ func TestValidateGenesis(t *testing.T) { []types.GenesisPost{ types.NewGenesisPost(1, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -164,6 +169,7 @@ func TestValidateGenesis(t *testing.T) { []types.GenesisPost{ types.NewGenesisPost(0, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -197,6 +203,7 @@ func TestValidateGenesis(t *testing.T) { []types.GenesisPost{ types.NewGenesisPost(1, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -265,6 +272,7 @@ func TestValidateGenesis(t *testing.T) { []types.GenesisPost{ types.NewGenesisPost(2, types.NewPost( 1, + 0, 1, "External ID", "This is a text", @@ -360,6 +368,7 @@ func TestGenesisPost_Validate(t *testing.T) { name: "invalid initial attachment id returns error", post: types.NewGenesisPost(0, types.NewPost( 1, + 0, 1, "External id", "Text", @@ -376,6 +385,7 @@ func TestGenesisPost_Validate(t *testing.T) { { name: "invalid post returns error", post: types.NewGenesisPost(1, types.NewPost( + 0, 0, 1, "External id", @@ -394,6 +404,7 @@ func TestGenesisPost_Validate(t *testing.T) { name: "valid data returns no error", post: types.NewGenesisPost(1, types.NewPost( 1, + 0, 1, "External id", "Text", diff --git a/x/posts/types/keys.go b/x/posts/types/keys.go index 26c37ffc04..9ae7915aec 100644 --- a/x/posts/types/keys.go +++ b/x/posts/types/keys.go @@ -31,10 +31,11 @@ const ( var ( NextPostIDPrefix = []byte{0x00} PostPrefix = []byte{0x01} - NextAttachmentIDPrefix = []byte{0x02} - AttachmentPrefix = []byte{0x03} - UserAnswerPrefix = []byte{0x04} - ActivePollQueuePrefix = []byte{0x05} + PostSectionPrefix = []byte{0x02} + NextAttachmentIDPrefix = []byte{0x10} + AttachmentPrefix = []byte{0x11} + UserAnswerPrefix = []byte{0x20} + ActivePollQueuePrefix = []byte{0x21} ) // GetPostIDBytes returns the byte representation of the postID @@ -69,6 +70,41 @@ func PostStoreKey(subspaceID uint64, postID uint64) []byte { return append(SubspacePostsPrefix(subspaceID), GetPostIDBytes(postID)...) } +// SubspaceSectionsPrefix returns the prefix used to store all the section references for the given subspace +func SubspaceSectionsPrefix(subspaceID uint64) []byte { + return append(PostSectionPrefix, subspacetypes.GetSubspaceIDBytes(subspaceID)...) +} + +// SectionPostsPrefix returns the prefix used to store all the section references for the given section +func SectionPostsPrefix(subspaceID uint64, sectionID uint32) []byte { + return append(SubspaceSectionsPrefix(subspaceID), subspacetypes.GetSectionIDBytes(sectionID)...) +} + +// PostSectionStoreKey returns the key used to store the section reference for the given post +func PostSectionStoreKey(subspaceID uint64, sectionID uint32, postID uint64) []byte { + return append(SectionPostsPrefix(subspaceID, sectionID), GetPostIDBytes(postID)...) +} + +var ( + PostSectionPrefixLen = len(PostSectionPrefix) + SubspaceIDLen = len(subspacetypes.GetSubspaceIDBytes(1)) + SectionIDLen = len(subspacetypes.GetSectionIDBytes(1)) + PostIDLen = len(GetPostIDBytes(1)) +) + +func SplitPostSectionStoreKey(key []byte) (subspaceID uint64, sectionID uint32, postID uint64) { + expectedLen := PostSectionPrefixLen + SubspaceIDLen + SectionIDLen + PostIDLen + if len(key) != expectedLen { + panic(fmt.Errorf("invalid key length; expected %d but got %d", expectedLen, len(key))) + } + + key = key[PostSectionPrefixLen:] + subspaceID = subspacetypes.GetSubspaceIDFromBytes(key[:SubspaceIDLen]) + sectionID = subspacetypes.GetSectionIDFromBytes(key[SubspaceIDLen : SubspaceIDLen+SectionIDLen]) + postID = GetPostIDFromBytes(key[SubspaceIDLen+SectionIDLen:]) + return subspaceID, sectionID, postID +} + // -------------------------------------------------------------------------------------------------------------------- // GetAttachmentIDBytes returns the byte representation of the attachmentID diff --git a/x/posts/types/models.go b/x/posts/types/models.go index 5e6b3ca1e3..5c58eff7d1 100644 --- a/x/posts/types/models.go +++ b/x/posts/types/models.go @@ -29,6 +29,7 @@ func ParsePostID(value string) (uint64, error) { // NewPost allows to build a new Post instance func NewPost( subspaceID uint64, + sectionID uint32, id uint64, externalID string, text string, @@ -42,6 +43,7 @@ func NewPost( ) Post { return Post{ SubspaceID: subspaceID, + SectionID: sectionID, ID: id, ExternalID: externalID, Text: text, @@ -204,6 +206,7 @@ func (p Post) Update(update PostUpdate) Post { return NewPost( p.SubspaceID, + p.SectionID, p.ID, p.ExternalID, update.Text, diff --git a/x/posts/types/models.pb.go b/x/posts/types/models.pb.go index 2f179dfd1c..7db4b0fd9b 100644 --- a/x/posts/types/models.pb.go +++ b/x/posts/types/models.pb.go @@ -108,26 +108,28 @@ func (PostReference_Type) EnumDescriptor() ([]byte, []int) { type Post struct { // Id of the subspace inside which the post has been created SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Id of the section inside which the post has been created + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` // Unique id of the post - ID uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` + ID uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` // (optional) External id for this post - ExternalID string `protobuf:"bytes,3,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty"` + ExternalID string `protobuf:"bytes,4,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty"` // (optional) Text of the post - Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"` + Text string `protobuf:"bytes,5,opt,name=text,proto3" json:"text,omitempty"` // (optional) Entities connected to this post - Entities *Entities `protobuf:"bytes,5,opt,name=entities,proto3" json:"entities,omitempty"` + Entities *Entities `protobuf:"bytes,6,opt,name=entities,proto3" json:"entities,omitempty"` // Author of the post - Author string `protobuf:"bytes,6,opt,name=author,proto3" json:"author,omitempty"` + Author string `protobuf:"bytes,7,opt,name=author,proto3" json:"author,omitempty"` // (optional) Id of the original post of the conversation - ConversationID uint64 `protobuf:"varint,7,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"` + ConversationID uint64 `protobuf:"varint,8,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"` // A list this posts references (either as a reply, repost or quote) - ReferencedPosts []PostReference `protobuf:"bytes,8,rep,name=referenced_posts,json=referencedPosts,proto3" json:"referenced_posts"` + ReferencedPosts []PostReference `protobuf:"bytes,9,rep,name=referenced_posts,json=referencedPosts,proto3" json:"referenced_posts"` // Reply settings of this post - ReplySettings ReplySetting `protobuf:"varint,9,opt,name=reply_settings,json=replySettings,proto3,enum=desmos.posts.v1.ReplySetting" json:"reply_settings,omitempty"` + ReplySettings ReplySetting `protobuf:"varint,10,opt,name=reply_settings,json=replySettings,proto3,enum=desmos.posts.v1.ReplySetting" json:"reply_settings,omitempty"` // Creation date of the post - CreationDate time.Time `protobuf:"bytes,10,opt,name=creation_date,json=creationDate,proto3,stdtime" json:"creation_date"` + CreationDate time.Time `protobuf:"bytes,11,opt,name=creation_date,json=creationDate,proto3,stdtime" json:"creation_date"` // (optional) Last edited time of the post - LastEditedDate *time.Time `protobuf:"bytes,11,opt,name=last_edited_date,json=lastEditedDate,proto3,stdtime" json:"last_edited_date,omitempty"` + LastEditedDate *time.Time `protobuf:"bytes,12,opt,name=last_edited_date,json=lastEditedDate,proto3,stdtime" json:"last_edited_date,omitempty"` } func (m *Post) Reset() { *m = Post{} } @@ -170,6 +172,13 @@ func (m *Post) GetSubspaceID() uint64 { return 0 } +func (m *Post) GetSectionID() uint32 { + if m != nil { + return m.SectionID + } + return 0 +} + func (m *Post) GetID() uint64 { if m != nil { return m.ID @@ -498,12 +507,15 @@ type Attachment struct { // Id of the subspace inside which the post to which this attachment should be // connected is SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Id of the subspace section inside which the post to which this attachment + // should be connected is + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` // Id of the post to which this attachment should be connected - PostID uint64 `protobuf:"varint,2,opt,name=post_id,json=postId,proto3" json:"post_id,omitempty"` + PostID uint64 `protobuf:"varint,3,opt,name=post_id,json=postId,proto3" json:"post_id,omitempty"` // If of this attachment - ID uint32 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` + ID uint32 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty"` // Content of the attachment - Content *types.Any `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` + Content *types.Any `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"` } func (m *Attachment) Reset() { *m = Attachment{} } @@ -546,6 +558,13 @@ func (m *Attachment) GetSubspaceID() uint64 { return 0 } +func (m *Attachment) GetSectionID() uint32 { + if m != nil { + return m.SectionID + } + return 0 +} + func (m *Attachment) GetPostID() uint64 { if m != nil { return m.PostID @@ -770,14 +789,16 @@ func (m *Poll_ProvidedAnswer) GetAttachments() []Attachment { type UserAnswer struct { // Subspace id inside which the post related to this attachment is located SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Section id inside which the post related to this attachment is located + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` // Id of the post associated to this attachment - PostID uint64 `protobuf:"varint,2,opt,name=post_id,json=postId,proto3" json:"post_id,omitempty"` + PostID uint64 `protobuf:"varint,3,opt,name=post_id,json=postId,proto3" json:"post_id,omitempty"` // Id of the poll to which this answer is associated - PollID uint32 `protobuf:"varint,3,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` + PollID uint32 `protobuf:"varint,4,opt,name=poll_id,json=pollId,proto3" json:"poll_id,omitempty"` // Indexes of the answers inside the ProvidedAnswers array - AnswersIndexes []uint32 `protobuf:"varint,4,rep,packed,name=answers_indexes,json=answersIndexes,proto3" json:"answers_indexes,omitempty"` + AnswersIndexes []uint32 `protobuf:"varint,5,rep,packed,name=answers_indexes,json=answersIndexes,proto3" json:"answers_indexes,omitempty"` // Address of the user answering the poll - User string `protobuf:"bytes,5,opt,name=user,proto3" json:"user,omitempty"` + User string `protobuf:"bytes,6,opt,name=user,proto3" json:"user,omitempty"` } func (m *UserAnswer) Reset() { *m = UserAnswer{} } @@ -820,6 +841,13 @@ func (m *UserAnswer) GetSubspaceID() uint64 { return 0 } +func (m *UserAnswer) GetSectionID() uint32 { + if m != nil { + return m.SectionID + } + return 0 +} + func (m *UserAnswer) GetPostID() uint64 { if m != nil { return m.PostID @@ -1015,86 +1043,89 @@ func init() { func init() { proto.RegisterFile("desmos/posts/v1/models.proto", fileDescriptor_9cb993d391569998) } var fileDescriptor_9cb993d391569998 = []byte{ - // 1263 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x73, 0xdb, 0x44, - 0x14, 0x8f, 0x6c, 0xd7, 0x71, 0x9e, 0xe3, 0x3f, 0xdd, 0x86, 0xd6, 0x75, 0xa9, 0x9d, 0xb6, 0x0c, - 0x64, 0x98, 0x41, 0x9e, 0xa6, 0x43, 0x99, 0x29, 0x07, 0x48, 0x6a, 0x15, 0xc4, 0x24, 0x71, 0xba, - 0x96, 0x61, 0x0a, 0x07, 0xcd, 0xc6, 0xda, 0x3a, 0x62, 0xd6, 0x92, 0xd1, 0xae, 0x53, 0xfb, 0x1b, - 0x70, 0xec, 0x91, 0x63, 0x07, 0xbe, 0x02, 0x77, 0xae, 0x3d, 0x31, 0x3d, 0x70, 0xe8, 0x29, 0x30, - 0xee, 0x85, 0x0f, 0xc0, 0x07, 0x60, 0x76, 0x57, 0x72, 0xe4, 0xa4, 0x50, 0x72, 0xe0, 0xb6, 0xfb, - 0xde, 0xef, 0x3d, 0xed, 0xfe, 0xde, 0xdb, 0xdf, 0x13, 0xbc, 0xed, 0x51, 0x3e, 0x0c, 0x79, 0x6b, - 0x14, 0x72, 0xc1, 0x5b, 0x47, 0xb7, 0x5b, 0xc3, 0xd0, 0xa3, 0x8c, 0x9b, 0xa3, 0x28, 0x14, 0x21, - 0xaa, 0x68, 0xaf, 0xa9, 0xbc, 0xe6, 0xd1, 0xed, 0xfa, 0xda, 0x20, 0x1c, 0x84, 0xca, 0xd7, 0x92, - 0x2b, 0x0d, 0xab, 0x5f, 0x1d, 0x84, 0xe1, 0x80, 0xd1, 0x96, 0xda, 0x1d, 0x8c, 0x1f, 0xb7, 0x48, - 0x30, 0x8d, 0x5d, 0xcd, 0xd3, 0x2e, 0xe1, 0x0f, 0x29, 0x17, 0x64, 0x38, 0xd2, 0x80, 0x9b, 0x2f, - 0x73, 0x90, 0xdb, 0x0f, 0xb9, 0x40, 0x2d, 0x28, 0xf2, 0xf1, 0x01, 0x1f, 0x91, 0x3e, 0x75, 0x7d, - 0xaf, 0x66, 0xac, 0x1b, 0x1b, 0xb9, 0xed, 0xf2, 0xec, 0xb8, 0x09, 0xdd, 0xd8, 0x6c, 0xb7, 0x31, - 0x24, 0x10, 0xdb, 0x43, 0x97, 0x21, 0xe3, 0x7b, 0xb5, 0x8c, 0xc2, 0xe5, 0x67, 0xc7, 0xcd, 0x8c, - 0xdd, 0xc6, 0x19, 0xdf, 0x93, 0x89, 0xe8, 0x44, 0xd0, 0x28, 0x20, 0x4c, 0x26, 0xca, 0xae, 0x1b, - 0x1b, 0x2b, 0x3a, 0x91, 0x15, 0x9b, 0x65, 0xa2, 0x04, 0x62, 0x7b, 0x08, 0x41, 0x4e, 0xd0, 0x89, - 0xa8, 0xe5, 0x24, 0x12, 0xab, 0x35, 0xfa, 0x10, 0x0a, 0x34, 0x10, 0xbe, 0xf0, 0x29, 0xaf, 0x5d, - 0x58, 0x37, 0x36, 0x8a, 0x9b, 0x57, 0xcd, 0x53, 0x64, 0x98, 0x56, 0x0c, 0xc0, 0x73, 0x28, 0xba, - 0x0c, 0x79, 0x32, 0x16, 0x87, 0x61, 0x54, 0xcb, 0xab, 0x64, 0xf1, 0x0e, 0x7d, 0x0c, 0x95, 0x7e, - 0x18, 0x1c, 0xd1, 0x88, 0x13, 0xe1, 0x87, 0x81, 0x3c, 0xd7, 0xb2, 0x3a, 0x38, 0x9a, 0x1d, 0x37, - 0xcb, 0xf7, 0x53, 0x2e, 0xbb, 0x8d, 0xcb, 0x69, 0xa8, 0xed, 0xa1, 0x0e, 0x54, 0x23, 0xfa, 0x98, - 0x46, 0x34, 0xe8, 0x53, 0xcf, 0x55, 0x9f, 0xaf, 0x15, 0xd6, 0xb3, 0x1b, 0xc5, 0xcd, 0xc6, 0x99, - 0x33, 0x49, 0x2a, 0x71, 0x02, 0xde, 0xce, 0x3d, 0x3f, 0x6e, 0x2e, 0xe1, 0xca, 0x49, 0xb4, 0x74, - 0x73, 0xd4, 0x86, 0x72, 0x44, 0x47, 0x6c, 0xea, 0x72, 0x2a, 0x84, 0x1f, 0x0c, 0x78, 0x6d, 0x65, - 0xdd, 0xd8, 0x28, 0x6f, 0x5e, 0x3f, 0x93, 0x0e, 0x4b, 0x58, 0x57, 0xa3, 0x70, 0x29, 0x4a, 0xed, - 0x38, 0xb2, 0xa1, 0xd4, 0x8f, 0xa8, 0xbe, 0x8f, 0x47, 0x04, 0xad, 0x81, 0xe2, 0xa9, 0x6e, 0xea, - 0x92, 0x9b, 0x49, 0xc9, 0x4d, 0x27, 0x29, 0xf9, 0x76, 0x41, 0x9e, 0xe7, 0xe9, 0xef, 0x4d, 0x03, - 0xaf, 0x26, 0xa1, 0x6d, 0x22, 0x28, 0xfa, 0x02, 0xaa, 0x8c, 0x70, 0xe1, 0x52, 0xcf, 0x17, 0xd4, - 0xd3, 0xd9, 0x8a, 0x6f, 0xcc, 0x96, 0x53, 0x99, 0xca, 0x32, 0xd2, 0x52, 0x81, 0x32, 0xd7, 0xbd, - 0xc2, 0x0f, 0xcf, 0x9a, 0xc6, 0x9f, 0xcf, 0x9a, 0xc6, 0xcd, 0xdf, 0x0c, 0x28, 0x2d, 0xf0, 0x81, - 0x3e, 0x82, 0x9c, 0x98, 0x8e, 0xa8, 0x6a, 0xae, 0xf2, 0xe6, 0xad, 0x7f, 0x67, 0xcf, 0x74, 0xa6, - 0x23, 0x8a, 0x55, 0x00, 0xba, 0x05, 0xcb, 0x12, 0xe4, 0xce, 0x1b, 0x0e, 0x66, 0xc7, 0xcd, 0xbc, - 0x84, 0xdb, 0x6d, 0x9c, 0x97, 0x2e, 0xdb, 0xbb, 0xf9, 0x0d, 0xe4, 0x64, 0x08, 0x5a, 0x83, 0xaa, - 0xf3, 0x68, 0xdf, 0x72, 0x7b, 0x7b, 0xdd, 0x7d, 0xeb, 0xbe, 0xfd, 0xc0, 0xb6, 0xda, 0xd5, 0x25, - 0x74, 0x09, 0x2a, 0xca, 0x8a, 0xad, 0xfd, 0x1d, 0xdb, 0x6a, 0xbb, 0x4e, 0xa7, 0x6a, 0xa0, 0x0a, - 0x14, 0x95, 0xf1, 0x61, 0xaf, 0xe3, 0x58, 0xed, 0x6a, 0x06, 0x5d, 0x84, 0x52, 0x82, 0xea, 0x74, - 0xa5, 0x29, 0x5b, 0xcf, 0x7d, 0xff, 0x53, 0x63, 0x29, 0x75, 0xad, 0x9f, 0x0d, 0x28, 0x24, 0xad, - 0x87, 0xee, 0x42, 0xe1, 0x90, 0xf0, 0x43, 0x41, 0x06, 0xbc, 0x66, 0xa8, 0x9e, 0x58, 0x3b, 0x73, - 0x2b, 0x87, 0x0c, 0xe2, 0x4e, 0x98, 0x63, 0x65, 0xdc, 0x50, 0x76, 0x6d, 0x18, 0xf0, 0x5a, 0xe6, - 0xcd, 0x71, 0x09, 0x16, 0x99, 0x90, 0x1b, 0x47, 0x8c, 0xd7, 0xb2, 0xff, 0x10, 0xd3, 0x8b, 0x58, - 0x1c, 0xa3, 0x70, 0xa9, 0x63, 0xdb, 0x90, 0x75, 0xc8, 0x00, 0xad, 0xc1, 0x05, 0x2e, 0x48, 0x24, - 0xf4, 0x03, 0xc7, 0x7a, 0x83, 0xaa, 0x90, 0xa5, 0x41, 0xcc, 0x2d, 0x96, 0x4b, 0x69, 0x11, 0x64, - 0xa0, 0x5f, 0x2f, 0x96, 0xcb, 0x54, 0xaa, 0x6f, 0x21, 0xdb, 0x8b, 0xd8, 0x79, 0x52, 0x8d, 0x23, - 0x96, 0xa4, 0x1a, 0x47, 0x0c, 0x35, 0xa1, 0xe8, 0xf9, 0x7c, 0xc4, 0xc8, 0xd4, 0x95, 0x1e, 0xfd, - 0xf0, 0x21, 0x36, 0xf5, 0x22, 0xb6, 0xc8, 0x36, 0x6c, 0x09, 0x41, 0xfa, 0x87, 0x92, 0x83, 0xf3, - 0xab, 0xd4, 0x7f, 0xe9, 0x9c, 0x58, 0xca, 0xe4, 0x01, 0x4b, 0x0b, 0x52, 0x66, 0xc2, 0x72, 0x3f, - 0x0c, 0x04, 0x0d, 0xb4, 0x38, 0x49, 0xc2, 0x4f, 0x3f, 0x87, 0xad, 0x60, 0x8a, 0x13, 0x50, 0xea, - 0xd8, 0x9f, 0xc2, 0x85, 0x5d, 0xea, 0xf9, 0x44, 0x5f, 0xde, 0x57, 0xdf, 0x56, 0x97, 0xf7, 0xd1, - 0x35, 0x58, 0x19, 0xfa, 0x43, 0xea, 0xaa, 0x97, 0xa0, 0x49, 0x29, 0x48, 0x83, 0xec, 0xdd, 0x54, - 0x86, 0xbf, 0xb2, 0x52, 0x98, 0x19, 0x43, 0x75, 0x28, 0x7c, 0x37, 0xa6, 0x5c, 0xd6, 0x5f, 0xdd, - 0x77, 0x05, 0xcf, 0xf7, 0xa8, 0x07, 0xd5, 0x51, 0x14, 0x1e, 0xf9, 0x1e, 0xf5, 0x5c, 0x12, 0xf0, - 0x27, 0x34, 0x4a, 0xda, 0xe9, 0x9d, 0xd7, 0x3c, 0x2e, 0xc6, 0xcc, 0xfd, 0x18, 0xbd, 0xa5, 0xc0, - 0x89, 0x40, 0x8d, 0x16, 0xac, 0x1c, 0x7d, 0x22, 0xd5, 0x37, 0xd6, 0x81, 0xec, 0x39, 0x54, 0x65, - 0x99, 0x06, 0x4a, 0x04, 0xd0, 0x5d, 0xb8, 0x42, 0x18, 0x0b, 0x9f, 0x70, 0x77, 0x38, 0x66, 0xc2, - 0x1f, 0x31, 0x3a, 0x3f, 0x9e, 0x24, 0xb2, 0x80, 0xdf, 0xd2, 0xee, 0xdd, 0xd8, 0x9b, 0x7c, 0xd8, - 0x84, 0x4b, 0x71, 0x9c, 0x86, 0x2b, 0x45, 0xd2, 0x13, 0xa0, 0x80, 0x2f, 0x6a, 0x97, 0xc6, 0x4a, - 0xc5, 0xe1, 0xe8, 0x21, 0x5c, 0x7a, 0xec, 0xcb, 0x41, 0x23, 0x08, 0x63, 0x53, 0x37, 0xa2, 0x7c, - 0xcc, 0x04, 0x57, 0xe2, 0x5f, 0xdc, 0xbc, 0xf1, 0x5a, 0x0a, 0x1c, 0x89, 0xc4, 0x1a, 0x88, 0x2f, - 0xaa, 0xe8, 0xb4, 0xa9, 0xce, 0xa1, 0xbc, 0x48, 0xd2, 0x7c, 0x3e, 0x19, 0xa9, 0xf9, 0x74, 0x1f, - 0x8a, 0x64, 0xde, 0x95, 0x09, 0xe7, 0xd7, 0xce, 0x7c, 0xf0, 0xa4, 0x73, 0x63, 0xaa, 0xd3, 0x51, - 0x27, 0xc5, 0x4e, 0x95, 0xfd, 0x57, 0x03, 0xa0, 0xc7, 0x69, 0x14, 0x7f, 0xfb, 0xff, 0xe9, 0x77, - 0x05, 0x62, 0xf3, 0xf1, 0x5c, 0x4a, 0x40, 0x8c, 0x69, 0x10, 0x93, 0x63, 0xf9, 0x3d, 0xa8, 0xc4, - 0x35, 0x73, 0xfd, 0xc0, 0xa3, 0x13, 0x2a, 0x6b, 0x97, 0xdd, 0x28, 0xe1, 0x72, 0x6c, 0xb6, 0xb5, - 0x55, 0xf2, 0x33, 0xe6, 0x34, 0x52, 0x55, 0x5a, 0xc1, 0x6a, 0x9d, 0xba, 0xd0, 0x2f, 0x06, 0x54, - 0x4f, 0xf3, 0x8e, 0xf6, 0x60, 0x39, 0xa9, 0x95, 0x56, 0x4d, 0xf3, 0x8d, 0xb5, 0x32, 0x35, 0x23, - 0x7a, 0x17, 0xb3, 0x99, 0x24, 0xa9, 0x3f, 0x84, 0xd5, 0xb4, 0x1b, 0xdd, 0x80, 0xd5, 0xb8, 0x81, - 0xd4, 0xd1, 0x15, 0x6f, 0x25, 0x5c, 0xd4, 0x36, 0x75, 0x6e, 0xa9, 0x5e, 0x47, 0xa1, 0xa0, 0x3c, - 0x56, 0x2a, 0xbd, 0x79, 0x6d, 0x49, 0xee, 0x41, 0x7e, 0x9f, 0x44, 0x64, 0xc8, 0xd1, 0xbb, 0x50, - 0x19, 0x92, 0x89, 0x2b, 0x3b, 0xc0, 0x65, 0x34, 0x18, 0x88, 0xc3, 0x38, 0x73, 0x69, 0x48, 0x26, - 0x0e, 0x9d, 0x88, 0x1d, 0x65, 0x3c, 0x89, 0x7d, 0xff, 0x47, 0x03, 0x56, 0xd3, 0x43, 0x1c, 0x5d, - 0x87, 0xab, 0x72, 0x02, 0x3d, 0x72, 0xbb, 0x96, 0xe3, 0xd8, 0x7b, 0x9f, 0x9d, 0x9a, 0x52, 0x75, - 0xb8, 0xbc, 0xe8, 0xb6, 0xbe, 0xb4, 0xf0, 0xa3, 0xce, 0x9e, 0x55, 0x35, 0xd0, 0x35, 0xb8, 0xb2, - 0xe8, 0x7b, 0xd0, 0xd9, 0xd9, 0xe9, 0x7c, 0x65, 0xe1, 0x6e, 0x35, 0x83, 0x6a, 0xb0, 0xb6, 0xe8, - 0xdc, 0xed, 0x39, 0xbd, 0xad, 0x9d, 0x6a, 0xf6, 0x6c, 0xca, 0x5d, 0x6b, 0xcf, 0xb1, 0x3b, 0x7b, - 0xdd, 0x6a, 0x4e, 0xcf, 0xb6, 0xed, 0xcf, 0x9f, 0xcf, 0x1a, 0xc6, 0x8b, 0x59, 0xc3, 0xf8, 0x63, - 0xd6, 0x30, 0x9e, 0xbe, 0x6a, 0x2c, 0xbd, 0x78, 0xd5, 0x58, 0x7a, 0xf9, 0xaa, 0xb1, 0xf4, 0xb5, - 0x39, 0xf0, 0xc5, 0xe1, 0xf8, 0xc0, 0xec, 0x87, 0xc3, 0x96, 0x2e, 0xd0, 0x07, 0x8c, 0x1c, 0xf0, - 0x78, 0xdd, 0x3a, 0xba, 0xd3, 0x9a, 0xc4, 0xbf, 0xae, 0x52, 0xcd, 0xf8, 0x41, 0x5e, 0xc9, 0xc3, - 0x9d, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x93, 0x8d, 0xe6, 0x1f, 0xd7, 0x0a, 0x00, 0x00, + // 1297 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xda, 0x8e, 0x63, 0x3f, 0xc7, 0x7f, 0x3a, 0x0d, 0xad, 0xeb, 0x52, 0x3b, 0x6d, 0x11, + 0x58, 0x08, 0xd6, 0x6a, 0x2a, 0x8a, 0x54, 0x0e, 0x90, 0xd4, 0x5b, 0x58, 0x94, 0xc4, 0xe9, 0xd8, + 0x06, 0x15, 0x0e, 0xab, 0x89, 0x77, 0xea, 0x2c, 0x1a, 0xef, 0x9a, 0x9d, 0x71, 0x6a, 0x7f, 0x01, + 0xc4, 0xb1, 0x47, 0x8e, 0x15, 0x7c, 0x05, 0xee, 0x5c, 0x7b, 0xec, 0x81, 0x03, 0xa7, 0x80, 0xdc, + 0x0b, 0x1f, 0x80, 0x23, 0x07, 0x34, 0x33, 0xbb, 0xce, 0x26, 0x69, 0x89, 0x7a, 0x40, 0xe2, 0x36, + 0xf3, 0xde, 0xef, 0xbd, 0x99, 0xf9, 0xbd, 0xb7, 0xbf, 0xb7, 0xf0, 0xa6, 0x4b, 0xf9, 0x28, 0xe0, + 0xad, 0x71, 0xc0, 0x05, 0x6f, 0x1d, 0xde, 0x6a, 0x8d, 0x02, 0x97, 0x32, 0x6e, 0x8e, 0xc3, 0x40, + 0x04, 0xa8, 0xac, 0xbd, 0xa6, 0xf2, 0x9a, 0x87, 0xb7, 0x6a, 0x6b, 0xc3, 0x60, 0x18, 0x28, 0x5f, + 0x4b, 0xae, 0x34, 0xac, 0x76, 0x65, 0x18, 0x04, 0x43, 0x46, 0x5b, 0x6a, 0xb7, 0x3f, 0x79, 0xd4, + 0x22, 0xfe, 0x2c, 0x72, 0x35, 0x4e, 0xbb, 0x84, 0x37, 0xa2, 0x5c, 0x90, 0xd1, 0x58, 0x03, 0x6e, + 0x7c, 0xb7, 0x0c, 0x99, 0xbd, 0x80, 0x0b, 0xd4, 0x82, 0x02, 0x9f, 0xec, 0xf3, 0x31, 0x19, 0x50, + 0xc7, 0x73, 0xab, 0xc6, 0xba, 0xd1, 0xcc, 0x6c, 0x95, 0xe6, 0x47, 0x0d, 0xe8, 0x46, 0x66, 0xbb, + 0x8d, 0x21, 0x86, 0xd8, 0x2e, 0x7a, 0x0f, 0x80, 0xd3, 0x81, 0xf0, 0x02, 0x5f, 0xe2, 0x53, 0xeb, + 0x46, 0xb3, 0xb8, 0x55, 0x9c, 0x1f, 0x35, 0xf2, 0x5d, 0x6d, 0xb5, 0xdb, 0x38, 0x1f, 0x01, 0x6c, + 0x17, 0x5d, 0x82, 0x94, 0xe7, 0x56, 0xd3, 0x2a, 0x6b, 0x76, 0x7e, 0xd4, 0x48, 0xd9, 0x6d, 0x9c, + 0xf2, 0x5c, 0x79, 0x2c, 0x9d, 0x0a, 0x1a, 0xfa, 0x84, 0xc9, 0x34, 0x99, 0x75, 0xa3, 0x99, 0xd7, + 0xc7, 0x5a, 0x91, 0x59, 0x1e, 0x1b, 0x43, 0x6c, 0x17, 0x21, 0xc8, 0x08, 0x3a, 0x15, 0xd5, 0x65, + 0x89, 0xc4, 0x6a, 0x8d, 0x3e, 0x80, 0x1c, 0xf5, 0x85, 0x27, 0x3c, 0xca, 0xab, 0xd9, 0x75, 0xa3, + 0x59, 0xd8, 0xb8, 0x62, 0x9e, 0xa2, 0xce, 0xb4, 0x22, 0x00, 0x5e, 0x40, 0xd1, 0x25, 0xc8, 0x92, + 0x89, 0x38, 0x08, 0xc2, 0xea, 0x8a, 0x4a, 0x16, 0xed, 0xd0, 0x47, 0x50, 0x1e, 0x04, 0xfe, 0x21, + 0x0d, 0x39, 0x89, 0x9f, 0x97, 0x53, 0x17, 0x47, 0xf3, 0xa3, 0x46, 0xe9, 0x5e, 0xc2, 0x65, 0xb7, + 0x71, 0x29, 0x09, 0xb5, 0x5d, 0xd4, 0x81, 0x4a, 0x48, 0x1f, 0xd1, 0x90, 0xfa, 0x03, 0xea, 0x3a, + 0xea, 0xf8, 0x6a, 0x7e, 0x3d, 0xdd, 0x2c, 0x6c, 0xd4, 0xcf, 0xdc, 0x49, 0x12, 0x8f, 0x63, 0xf0, + 0x56, 0xe6, 0xd9, 0x51, 0x63, 0x09, 0x97, 0x8f, 0xa3, 0xa5, 0x9b, 0xa3, 0x36, 0x94, 0x42, 0x3a, + 0x66, 0x33, 0x87, 0x53, 0x21, 0x3c, 0x7f, 0xc8, 0xab, 0xb0, 0x6e, 0x34, 0x4b, 0x1b, 0xd7, 0xce, + 0xa4, 0xc3, 0x12, 0xd6, 0xd5, 0x28, 0x5c, 0x0c, 0x13, 0x3b, 0x8e, 0x6c, 0x28, 0x0e, 0x42, 0xaa, + 0xdf, 0xe3, 0x12, 0x41, 0xab, 0x05, 0xc5, 0x53, 0xcd, 0xd4, 0x0d, 0x62, 0xc6, 0x0d, 0x62, 0xf6, + 0xe2, 0x06, 0xd9, 0xca, 0xc9, 0xfb, 0x3c, 0xf9, 0xbd, 0x61, 0xe0, 0xd5, 0x38, 0xb4, 0x4d, 0x04, + 0x45, 0x9f, 0x43, 0x85, 0x11, 0x2e, 0x1c, 0xea, 0x7a, 0x82, 0xba, 0x3a, 0xdb, 0xea, 0xb9, 0xd9, + 0x32, 0x2a, 0x53, 0x49, 0x46, 0x5a, 0x2a, 0x50, 0xe6, 0xba, 0x9b, 0xfb, 0xe1, 0x69, 0xc3, 0xf8, + 0xf3, 0x69, 0xc3, 0xb8, 0xf1, 0xab, 0x01, 0xc5, 0x13, 0x7c, 0xa0, 0x0f, 0x21, 0x23, 0x66, 0x63, + 0xaa, 0x5a, 0xb1, 0xb4, 0x71, 0xf3, 0xdf, 0xd9, 0x33, 0x7b, 0xb3, 0x31, 0xc5, 0x2a, 0x00, 0xdd, + 0x84, 0x15, 0x09, 0x8a, 0xdb, 0x32, 0xb3, 0x05, 0xf3, 0xa3, 0x46, 0x56, 0xc2, 0xed, 0x36, 0xce, + 0x4a, 0x97, 0xed, 0xde, 0xf8, 0x1a, 0x32, 0x32, 0x04, 0xad, 0x41, 0xa5, 0xf7, 0x70, 0xcf, 0x72, + 0xfa, 0xbb, 0xdd, 0x3d, 0xeb, 0x9e, 0x7d, 0xdf, 0xb6, 0xda, 0x95, 0x25, 0x74, 0x11, 0xca, 0xca, + 0x8a, 0xad, 0xbd, 0x6d, 0xdb, 0x6a, 0x3b, 0xbd, 0x4e, 0xc5, 0x40, 0x65, 0x28, 0x28, 0xe3, 0x83, + 0x7e, 0xa7, 0x67, 0xb5, 0x2b, 0x29, 0x74, 0x01, 0x8a, 0x31, 0xaa, 0xd3, 0x95, 0xa6, 0x74, 0x2d, + 0xf3, 0xfd, 0x4f, 0xf5, 0xa5, 0xc4, 0xb3, 0x7e, 0x36, 0x20, 0x17, 0xb7, 0x1e, 0xba, 0x03, 0xb9, + 0x03, 0xc2, 0x0f, 0x04, 0x19, 0xf2, 0xaa, 0xa1, 0x7a, 0x62, 0xed, 0xcc, 0xab, 0x7a, 0x64, 0x18, + 0x75, 0xc2, 0x02, 0x2b, 0xe3, 0x46, 0xb2, 0x6b, 0x03, 0x9f, 0x57, 0x53, 0xe7, 0xc7, 0xc5, 0x58, + 0x64, 0x42, 0x66, 0x12, 0x32, 0x5e, 0x4d, 0xbf, 0x22, 0xa6, 0x1f, 0xb2, 0x28, 0x46, 0xe1, 0x12, + 0xd7, 0xb6, 0x21, 0xdd, 0x23, 0x43, 0xb4, 0x06, 0xcb, 0x5c, 0x90, 0x50, 0x68, 0x39, 0xc0, 0x7a, + 0x83, 0x2a, 0x90, 0xa6, 0x7e, 0xc4, 0x2d, 0x96, 0x4b, 0x69, 0x11, 0x64, 0xa8, 0x3e, 0xef, 0x3c, + 0x96, 0xcb, 0x44, 0xaa, 0x6f, 0x20, 0xdd, 0x0f, 0xd9, 0xeb, 0xa4, 0x9a, 0x84, 0x2c, 0x4e, 0x35, + 0x09, 0x19, 0x6a, 0x40, 0xc1, 0xf5, 0xf8, 0x98, 0x91, 0x99, 0x23, 0x3d, 0x4a, 0x22, 0x30, 0x44, + 0xa6, 0x7e, 0xc8, 0x12, 0x67, 0xcd, 0x0d, 0x80, 0x4d, 0x21, 0xc8, 0xe0, 0x40, 0x72, 0xf0, 0x5f, + 0x6b, 0x5a, 0xa2, 0xcf, 0xd2, 0xaf, 0xea, 0xb3, 0x48, 0xf8, 0x32, 0x2a, 0x55, 0x52, 0xf8, 0x4c, + 0x58, 0x19, 0x04, 0xbe, 0xa0, 0xbe, 0x96, 0x32, 0x59, 0x9e, 0xd3, 0x1f, 0xcf, 0xa6, 0x3f, 0xc3, + 0x31, 0x28, 0xf1, 0xc8, 0x4f, 0x60, 0x79, 0x87, 0xba, 0x1e, 0xd1, 0x54, 0x79, 0xea, 0x9a, 0x8a, + 0x2a, 0x0f, 0x5d, 0x85, 0xfc, 0xc8, 0x1b, 0x51, 0x47, 0x7d, 0x37, 0x9a, 0xc2, 0x9c, 0x34, 0xc8, + 0x4e, 0x4f, 0x64, 0xf8, 0x2b, 0x2d, 0x45, 0x9f, 0x31, 0x54, 0x83, 0xdc, 0xb7, 0x13, 0xca, 0xe5, + 0x7b, 0x14, 0x3b, 0x79, 0xbc, 0xd8, 0xa3, 0x3e, 0x54, 0xc6, 0x61, 0x70, 0xe8, 0xb9, 0xd4, 0x75, + 0x88, 0xcf, 0x1f, 0xd3, 0x30, 0x6e, 0xbe, 0xb7, 0x5e, 0xf2, 0x29, 0x32, 0x66, 0xee, 0x45, 0xe8, + 0x4d, 0x05, 0x8e, 0xe5, 0x6c, 0x7c, 0xc2, 0xca, 0xd1, 0xc7, 0x52, 0xab, 0x23, 0xd5, 0x48, 0xbf, + 0x86, 0x06, 0xad, 0x50, 0x5f, 0x49, 0x06, 0xba, 0x03, 0x97, 0x09, 0x63, 0xc1, 0x63, 0xee, 0x8c, + 0x26, 0x4c, 0x78, 0x63, 0x46, 0x17, 0xd7, 0x93, 0x2c, 0xe7, 0xf0, 0x1b, 0xda, 0xbd, 0x13, 0x79, + 0xe3, 0x83, 0x4d, 0xb8, 0x18, 0xc5, 0x69, 0xb8, 0xd2, 0x2f, 0xae, 0xc8, 0xcf, 0xe1, 0x0b, 0xda, + 0xa5, 0xb1, 0x52, 0x9f, 0x38, 0x7a, 0x00, 0x17, 0x1f, 0x79, 0x72, 0x2c, 0x09, 0xc2, 0xd8, 0xcc, + 0x09, 0x29, 0x9f, 0x30, 0x11, 0xcf, 0x97, 0xeb, 0x2f, 0xa5, 0xa0, 0x27, 0x91, 0x58, 0x03, 0xf1, + 0x05, 0x15, 0x9d, 0x34, 0xd5, 0x38, 0x94, 0x4e, 0x92, 0xb4, 0x98, 0x66, 0x46, 0x62, 0x9a, 0xdd, + 0x83, 0x02, 0x59, 0xf4, 0x70, 0xcc, 0xf9, 0xd5, 0x33, 0x07, 0x1e, 0xf7, 0x79, 0x44, 0x75, 0x32, + 0xea, 0xb8, 0xd8, 0x89, 0xb2, 0xff, 0x6d, 0x00, 0xf4, 0x39, 0x0d, 0xa3, 0xb3, 0xff, 0x0f, 0x5f, + 0x87, 0x02, 0xb1, 0xc5, 0xe8, 0x2f, 0xc6, 0x20, 0xc6, 0x34, 0x88, 0xc9, 0x91, 0xff, 0x0e, 0x94, + 0xa3, 0x0a, 0x3b, 0x9e, 0xef, 0xd2, 0x29, 0x95, 0x55, 0x4b, 0x37, 0x8b, 0xb8, 0x14, 0x99, 0x6d, + 0x6d, 0x95, 0x6c, 0x4e, 0x38, 0x0d, 0x55, 0x8d, 0xf2, 0x58, 0xad, 0x13, 0xcf, 0xff, 0xc5, 0x80, + 0xca, 0xe9, 0x2a, 0xa1, 0x5d, 0x58, 0x89, 0x2b, 0xab, 0x15, 0xd9, 0x3c, 0xb7, 0xb2, 0xa6, 0xe6, + 0x4f, 0xef, 0x22, 0xee, 0xe3, 0x24, 0xb5, 0x07, 0xb0, 0x9a, 0x74, 0xa3, 0xeb, 0xb0, 0x1a, 0xb5, + 0x9b, 0xba, 0xba, 0x62, 0xb9, 0x88, 0x0b, 0xda, 0xa6, 0xee, 0x2d, 0x95, 0xf1, 0x30, 0x10, 0x94, + 0x47, 0x2a, 0xa8, 0x37, 0x2f, 0x2d, 0xe0, 0x5d, 0xc8, 0xee, 0x91, 0x90, 0x8c, 0x38, 0x7a, 0x1b, + 0xca, 0x23, 0x32, 0x75, 0x64, 0xbf, 0x38, 0x8c, 0xfa, 0x43, 0x71, 0x10, 0x65, 0x2e, 0x8e, 0xc8, + 0xb4, 0x47, 0xa7, 0x62, 0x5b, 0x19, 0x8f, 0x63, 0xdf, 0xfd, 0xd1, 0x80, 0xd5, 0xe4, 0x0f, 0x02, + 0xba, 0x06, 0x57, 0xe4, 0x74, 0x7b, 0xe8, 0x74, 0xad, 0x5e, 0xcf, 0xde, 0xfd, 0xf4, 0xd4, 0x04, + 0xac, 0xc1, 0xa5, 0x93, 0x6e, 0xeb, 0x0b, 0x0b, 0x3f, 0xec, 0xec, 0x5a, 0x15, 0x03, 0x5d, 0x85, + 0xcb, 0x27, 0x7d, 0xf7, 0x3b, 0xdb, 0xdb, 0x9d, 0x2f, 0x2d, 0xdc, 0xad, 0xa4, 0x50, 0x15, 0xd6, + 0x4e, 0x3a, 0x77, 0xfa, 0xbd, 0xfe, 0xe6, 0x76, 0x25, 0x7d, 0x36, 0xe5, 0x8e, 0xb5, 0xdb, 0xb3, + 0x3b, 0xbb, 0xdd, 0x4a, 0x46, 0xcf, 0xcd, 0xad, 0xcf, 0x9e, 0xcd, 0xeb, 0xc6, 0xf3, 0x79, 0xdd, + 0xf8, 0x63, 0x5e, 0x37, 0x9e, 0xbc, 0xa8, 0x2f, 0x3d, 0x7f, 0x51, 0x5f, 0xfa, 0xed, 0x45, 0x7d, + 0xe9, 0x2b, 0x73, 0xe8, 0x89, 0x83, 0xc9, 0xbe, 0x39, 0x08, 0x46, 0x2d, 0x5d, 0xa0, 0xf7, 0x19, + 0xd9, 0xe7, 0xd1, 0xba, 0x75, 0x78, 0xbb, 0x35, 0x8d, 0x7e, 0xa2, 0xa5, 0xf6, 0xf1, 0xfd, 0xac, + 0x12, 0x93, 0xdb, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x23, 0x4e, 0xeb, 0x80, 0x61, 0x0b, 0x00, + 0x00, } func (this *Post) Equal(that interface{}) bool { @@ -1119,6 +1150,9 @@ func (this *Post) Equal(that interface{}) bool { if this.SubspaceID != that1.SubspaceID { return false } + if this.SectionID != that1.SectionID { + return false + } if this.ID != that1.ID { return false } @@ -1317,6 +1351,9 @@ func (this *Attachment) Equal(that interface{}) bool { if this.SubspaceID != that1.SubspaceID { return false } + if this.SectionID != that1.SectionID { + return false + } if this.PostID != that1.PostID { return false } @@ -1453,6 +1490,9 @@ func (this *UserAnswer) Equal(that interface{}) bool { if this.SubspaceID != that1.SubspaceID { return false } + if this.SectionID != that1.SectionID { + return false + } if this.PostID != that1.PostID { return false } @@ -1580,7 +1620,7 @@ func (m *Post) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintModels(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 } n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CreationDate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CreationDate):]) if err2 != nil { @@ -1589,11 +1629,11 @@ func (m *Post) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n2 i = encodeVarintModels(dAtA, i, uint64(n2)) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a if m.ReplySettings != 0 { i = encodeVarintModels(dAtA, i, uint64(m.ReplySettings)) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x50 } if len(m.ReferencedPosts) > 0 { for iNdEx := len(m.ReferencedPosts) - 1; iNdEx >= 0; iNdEx-- { @@ -1606,20 +1646,20 @@ func (m *Post) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintModels(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } } if m.ConversationID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.ConversationID)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if len(m.Author) > 0 { i -= len(m.Author) copy(dAtA[i:], m.Author) i = encodeVarintModels(dAtA, i, uint64(len(m.Author))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if m.Entities != nil { { @@ -1631,25 +1671,30 @@ func (m *Post) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintModels(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.Text) > 0 { i -= len(m.Text) copy(dAtA[i:], m.Text) i = encodeVarintModels(dAtA, i, uint64(len(m.Text))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.ExternalID) > 0 { i -= len(m.ExternalID) copy(dAtA[i:], m.ExternalID) i = encodeVarintModels(dAtA, i, uint64(len(m.ExternalID))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if m.ID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.ID)) i-- + dAtA[i] = 0x18 + } + if m.SectionID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.SectionID)) + i-- dAtA[i] = 0x10 } if m.SubspaceID != 0 { @@ -1875,16 +1920,21 @@ func (m *Attachment) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintModels(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if m.ID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if m.PostID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.PostID)) i-- + dAtA[i] = 0x18 + } + if m.SectionID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.SectionID)) + i-- dAtA[i] = 0x10 } if m.SubspaceID != 0 { @@ -2085,7 +2135,7 @@ func (m *UserAnswer) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.User) i = encodeVarintModels(dAtA, i, uint64(len(m.User))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if len(m.AnswersIndexes) > 0 { dAtA8 := make([]byte, len(m.AnswersIndexes)*10) @@ -2103,16 +2153,21 @@ func (m *UserAnswer) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], dAtA8[:j7]) i = encodeVarintModels(dAtA, i, uint64(j7)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if m.PollID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.PollID)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if m.PostID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.PostID)) i-- + dAtA[i] = 0x18 + } + if m.SectionID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.SectionID)) + i-- dAtA[i] = 0x10 } if m.SubspaceID != 0 { @@ -2241,6 +2296,9 @@ func (m *Post) Size() (n int) { if m.SubspaceID != 0 { n += 1 + sovModels(uint64(m.SubspaceID)) } + if m.SectionID != 0 { + n += 1 + sovModels(uint64(m.SectionID)) + } if m.ID != 0 { n += 1 + sovModels(uint64(m.ID)) } @@ -2374,6 +2432,9 @@ func (m *Attachment) Size() (n int) { if m.SubspaceID != 0 { n += 1 + sovModels(uint64(m.SubspaceID)) } + if m.SectionID != 0 { + n += 1 + sovModels(uint64(m.SectionID)) + } if m.PostID != 0 { n += 1 + sovModels(uint64(m.PostID)) } @@ -2463,6 +2524,9 @@ func (m *UserAnswer) Size() (n int) { if m.SubspaceID != 0 { n += 1 + sovModels(uint64(m.SubspaceID)) } + if m.SectionID != 0 { + n += 1 + sovModels(uint64(m.SectionID)) + } if m.PostID != 0 { n += 1 + sovModels(uint64(m.PostID)) } @@ -2580,6 +2644,25 @@ func (m *Post) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } @@ -2598,7 +2681,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExternalID", wireType) } @@ -2630,7 +2713,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { } m.ExternalID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) } @@ -2662,7 +2745,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { } m.Text = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Entities", wireType) } @@ -2698,7 +2781,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Author", wireType) } @@ -2730,7 +2813,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { } m.Author = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConversationID", wireType) } @@ -2749,7 +2832,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ReferencedPosts", wireType) } @@ -2783,7 +2866,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ReplySettings", wireType) } @@ -2802,7 +2885,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { break } } - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CreationDate", wireType) } @@ -2835,7 +2918,7 @@ func (m *Post) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastEditedDate", wireType) } @@ -3453,6 +3536,25 @@ func (m *Attachment) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PostID", wireType) } @@ -3471,7 +3573,7 @@ func (m *Attachment) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } @@ -3490,7 +3592,7 @@ func (m *Attachment) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) } @@ -4051,6 +4153,25 @@ func (m *UserAnswer) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PostID", wireType) } @@ -4069,7 +4190,7 @@ func (m *UserAnswer) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PollID", wireType) } @@ -4088,7 +4209,7 @@ func (m *UserAnswer) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType == 0 { var v uint32 for shift := uint(0); ; shift += 7 { @@ -4164,7 +4285,7 @@ func (m *UserAnswer) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field AnswersIndexes", wireType) } - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) } diff --git a/x/posts/types/models_test.go b/x/posts/types/models_test.go index 575d755260..ce26914958 100644 --- a/x/posts/types/models_test.go +++ b/x/posts/types/models_test.go @@ -19,6 +19,7 @@ func TestPost_Validate(t *testing.T) { { name: "invalid subspace id returns error", post: types.NewPost( + 0, 0, 2, "External id", @@ -50,6 +51,7 @@ func TestPost_Validate(t *testing.T) { post: types.NewPost( 1, 0, + 0, "External id", "Text", "cosmos1eqpa6mv2jgevukaqtjmx5535vhc3mm3cf458zg", @@ -78,6 +80,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid entities returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -107,6 +110,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid hashtag index returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -126,6 +130,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid mention index returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -145,6 +150,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid url index returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -164,6 +170,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid author address returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -193,6 +200,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid conversation id returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -222,6 +230,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid post reference returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -251,6 +260,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid post reference id returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -280,6 +290,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid reply setting returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -309,6 +320,7 @@ func TestPost_Validate(t *testing.T) { name: "invalid creation date returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -338,6 +350,7 @@ func TestPost_Validate(t *testing.T) { name: "zero-value last edited date returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -367,6 +380,7 @@ func TestPost_Validate(t *testing.T) { name: "last edited date before creation date returns error", post: types.NewPost( 1, + 0, 2, "External id", "Text", @@ -396,6 +410,7 @@ func TestPost_Validate(t *testing.T) { name: "valid post returns no error", post: types.NewPost( 1, + 0, 2, "External id", "This is a post text that does not contain any useful information", diff --git a/x/posts/types/msgs.go b/x/posts/types/msgs.go index 04110d33e5..454fc3f1fd 100644 --- a/x/posts/types/msgs.go +++ b/x/posts/types/msgs.go @@ -21,6 +21,7 @@ var ( // NewMsgCreatePost returns a new MsgCreatePost instance func NewMsgCreatePost( subspaceID uint64, + sectionID uint32, externalID string, text string, conversationID uint64, @@ -41,6 +42,7 @@ func NewMsgCreatePost( return &MsgCreatePost{ SubspaceID: subspaceID, + SectionID: sectionID, ExternalID: externalID, Text: text, Entities: entities, @@ -185,7 +187,12 @@ func (msg MsgEditPost) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // NewMsgAddPostAttachment returns a new MsgAddPostAttachment instance -func NewMsgAddPostAttachment(subspaceID uint64, postID uint64, content AttachmentContent, editor string) *MsgAddPostAttachment { +func NewMsgAddPostAttachment( + subspaceID uint64, + postID uint64, + content AttachmentContent, + editor string, +) *MsgAddPostAttachment { contentAny, err := codectypes.NewAnyWithValue(content) if err != nil { panic(fmt.Errorf("failed to pack attachment content to any")) diff --git a/x/posts/types/msgs.pb.go b/x/posts/types/msgs.pb.go index 0967d48245..57a3dc8c78 100644 --- a/x/posts/types/msgs.pb.go +++ b/x/posts/types/msgs.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/desmos-labs/desmos/v3/x/subspaces/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -37,22 +38,24 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgCreatePost struct { // Id of the subspace inside which the post must be created SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Id of the section inside which the post must be created + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` // (optional) External id for this post - ExternalID string `protobuf:"bytes,2,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty"` + ExternalID string `protobuf:"bytes,3,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty"` // (optional) Text of the post - Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"` + Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"` // (optional) Entities connected to this post - Entities *Entities `protobuf:"bytes,4,opt,name=entities,proto3" json:"entities,omitempty"` + Entities *Entities `protobuf:"bytes,5,opt,name=entities,proto3" json:"entities,omitempty"` // Attachments of the post - Attachments []*types.Any `protobuf:"bytes,5,rep,name=attachments,proto3" json:"attachments,omitempty"` + Attachments []*types.Any `protobuf:"bytes,6,rep,name=attachments,proto3" json:"attachments,omitempty"` // Author of the post - Author string `protobuf:"bytes,6,opt,name=author,proto3" json:"author,omitempty"` + Author string `protobuf:"bytes,7,opt,name=author,proto3" json:"author,omitempty"` // (optional) Id of the original post of the conversation - ConversationID uint64 `protobuf:"varint,7,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"` + ConversationID uint64 `protobuf:"varint,8,opt,name=conversation_id,json=conversationId,proto3" json:"conversation_id,omitempty"` // Reply settings of this post - ReplySettings ReplySetting `protobuf:"varint,8,opt,name=reply_settings,json=replySettings,proto3,enum=desmos.posts.v1.ReplySetting" json:"reply_settings,omitempty"` + ReplySettings ReplySetting `protobuf:"varint,9,opt,name=reply_settings,json=replySettings,proto3,enum=desmos.posts.v1.ReplySetting" json:"reply_settings,omitempty"` // A list this posts references (either as a reply, repost or quote) - ReferencedPosts []PostReference `protobuf:"bytes,9,rep,name=referenced_posts,json=referencedPosts,proto3" json:"referenced_posts"` + ReferencedPosts []PostReference `protobuf:"bytes,10,rep,name=referenced_posts,json=referencedPosts,proto3" json:"referenced_posts"` } func (m *MsgCreatePost) Reset() { *m = MsgCreatePost{} } @@ -95,6 +98,13 @@ func (m *MsgCreatePost) GetSubspaceID() uint64 { return 0 } +func (m *MsgCreatePost) GetSectionID() uint32 { + if m != nil { + return m.SectionID + } + return 0 +} + func (m *MsgCreatePost) GetExternalID() string { if m != nil { return m.ExternalID @@ -824,63 +834,66 @@ func init() { func init() { proto.RegisterFile("desmos/posts/v1/msgs.proto", fileDescriptor_d9b1165b51f80014) } var fileDescriptor_d9b1165b51f80014 = []byte{ - // 888 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xbd, 0x6f, 0xdb, 0x46, - 0x14, 0xf7, 0x59, 0xb2, 0x2c, 0x3f, 0x59, 0x72, 0xca, 0xba, 0x8e, 0x42, 0xb8, 0xa2, 0xa0, 0x7e, - 0x69, 0x09, 0xd9, 0x28, 0x48, 0x97, 0x4e, 0x52, 0x64, 0xa0, 0x1c, 0xd4, 0x06, 0x8c, 0x87, 0xa2, - 0x8b, 0x41, 0x89, 0x2f, 0x34, 0x01, 0x8a, 0x27, 0xf0, 0xce, 0xaa, 0x3d, 0x74, 0xee, 0x9a, 0xb1, - 0x7f, 0x48, 0xd1, 0xb1, 0x63, 0x11, 0xa0, 0x4b, 0xc6, 0x4e, 0x6a, 0x20, 0xff, 0x23, 0xc5, 0x1d, - 0x3f, 0x1d, 0xd2, 0x81, 0x6b, 0xc4, 0xd9, 0xee, 0xee, 0xf7, 0x7b, 0x77, 0xef, 0xfd, 0xde, 0x07, - 0x09, 0xaa, 0x83, 0x6c, 0x4e, 0x99, 0xb1, 0xa0, 0x8c, 0x33, 0x63, 0xf9, 0xc8, 0x98, 0x33, 0x97, - 0xe9, 0x8b, 0x90, 0x72, 0xaa, 0xec, 0x45, 0x98, 0x2e, 0x31, 0x7d, 0xf9, 0x48, 0xdd, 0x77, 0xa9, - 0x4b, 0x25, 0x66, 0x88, 0x55, 0x44, 0x53, 0x1f, 0xb8, 0x94, 0xba, 0x3e, 0x1a, 0x72, 0x37, 0x3d, - 0x7b, 0x61, 0xd8, 0xc1, 0x45, 0x0c, 0x69, 0x6f, 0x43, 0xdc, 0x9b, 0x23, 0xe3, 0xf6, 0x7c, 0x11, - 0x13, 0x0e, 0x0b, 0xcf, 0x53, 0x07, 0xfd, 0xd8, 0x81, 0xde, 0x9b, 0x0a, 0x34, 0x27, 0xcc, 0x7d, - 0x1a, 0xa2, 0xcd, 0xf1, 0x19, 0x65, 0x5c, 0x31, 0xa0, 0xc1, 0xce, 0xa6, 0x6c, 0x61, 0xcf, 0xf0, - 0xc4, 0x73, 0xda, 0xa4, 0x4b, 0xfa, 0xd5, 0x51, 0x6b, 0xbd, 0xd2, 0xe0, 0x79, 0x7c, 0x6c, 0x8e, - 0x2d, 0x48, 0x28, 0xa6, 0x23, 0x0c, 0xf0, 0x9c, 0x63, 0x18, 0xd8, 0xbe, 0x30, 0xd8, 0xec, 0x92, - 0xfe, 0x4e, 0x64, 0x70, 0x14, 0x1f, 0x0b, 0x83, 0x84, 0x62, 0x3a, 0x8a, 0x02, 0x55, 0x8e, 0xe7, - 0xbc, 0x5d, 0x11, 0x4c, 0x4b, 0xae, 0x95, 0x27, 0x50, 0xc7, 0x80, 0x7b, 0xdc, 0x43, 0xd6, 0xae, - 0x76, 0x49, 0xbf, 0x31, 0x78, 0xa0, 0xbf, 0xa5, 0x8d, 0x7e, 0x14, 0x13, 0xac, 0x94, 0xaa, 0x7c, - 0x03, 0x0d, 0x9b, 0x73, 0x7b, 0x76, 0x3a, 0xc7, 0x80, 0xb3, 0xf6, 0x56, 0xb7, 0xd2, 0x6f, 0x0c, - 0xf6, 0xf5, 0x48, 0x13, 0x3d, 0xd1, 0x44, 0x1f, 0x06, 0x17, 0x56, 0x9e, 0xa8, 0x1c, 0x40, 0xcd, - 0x3e, 0xe3, 0xa7, 0x34, 0x6c, 0xd7, 0xa4, 0x13, 0xf1, 0x4e, 0xf9, 0x16, 0xf6, 0x66, 0x34, 0x58, - 0x62, 0xc8, 0x6c, 0xee, 0xd1, 0x40, 0xc4, 0xb3, 0x2d, 0x05, 0x50, 0xd6, 0x2b, 0xad, 0xf5, 0x34, - 0x07, 0x99, 0x63, 0xab, 0x95, 0xa7, 0x9a, 0x8e, 0x32, 0x86, 0x56, 0x88, 0x0b, 0xff, 0xe2, 0x84, - 0x21, 0xe7, 0x5e, 0xe0, 0xb2, 0x76, 0xbd, 0x4b, 0xfa, 0xad, 0xc1, 0xa7, 0x85, 0x48, 0x2c, 0x41, - 0x7b, 0x1e, 0xb1, 0xac, 0x66, 0x98, 0xdb, 0x31, 0xe5, 0x07, 0xb8, 0x17, 0xe2, 0x0b, 0x0c, 0x31, - 0x98, 0xa1, 0x73, 0x22, 0x4d, 0xda, 0x3b, 0x32, 0xae, 0x4e, 0xe1, 0x1e, 0x91, 0x30, 0x2b, 0x21, - 0x8f, 0xaa, 0xaf, 0x56, 0xda, 0x86, 0xb5, 0x97, 0x59, 0x0b, 0x98, 0xf5, 0x7e, 0x25, 0xf0, 0xc9, - 0x95, 0x14, 0x5b, 0xc8, 0x16, 0x34, 0x60, 0xa8, 0x7c, 0x06, 0xdb, 0xe2, 0xaa, 0x2c, 0xcd, 0xb0, - 0x5e, 0x69, 0x35, 0x41, 0x31, 0xc7, 0x56, 0x4d, 0x40, 0xa6, 0xa3, 0x98, 0xd0, 0x9c, 0x09, 0x53, - 0x21, 0x87, 0x63, 0x73, 0x94, 0x09, 0x6e, 0x0c, 0xd4, 0x82, 0xc8, 0xc7, 0x49, 0xe1, 0x8d, 0xea, - 0xc2, 0x91, 0x97, 0xff, 0x6a, 0xc4, 0xda, 0x4d, 0x4c, 0xc7, 0x36, 0xc7, 0xde, 0x5f, 0x04, 0x1a, - 0x13, 0xe6, 0x1e, 0x39, 0x1e, 0xbf, 0x5d, 0xa9, 0xe5, 0x1c, 0xde, 0xbc, 0xd6, 0xe1, 0xf7, 0x58, - 0x5e, 0x07, 0x50, 0x43, 0xc7, 0xe3, 0x34, 0x6c, 0x6f, 0x45, 0x65, 0x12, 0xed, 0x7a, 0x3f, 0xc2, - 0xc7, 0xb9, 0x38, 0x52, 0x3d, 0x87, 0xb0, 0x23, 0x08, 0x91, 0x4c, 0xe4, 0x7f, 0xc8, 0x54, 0x17, - 0x66, 0x52, 0xa2, 0x5f, 0x64, 0x3b, 0x8e, 0xd1, 0xc7, 0xdb, 0xb6, 0xe3, 0x8d, 0x34, 0x3a, 0x80, - 0x1a, 0xf3, 0xdc, 0x00, 0xc3, 0x58, 0xa5, 0x78, 0xd7, 0xbb, 0x2f, 0x4b, 0x25, 0x7b, 0x3e, 0x09, - 0xad, 0xf7, 0x3b, 0x81, 0xfd, 0x09, 0x73, 0x87, 0x8e, 0x2c, 0xaa, 0x61, 0xda, 0x4a, 0x77, 0xe4, - 0x9f, 0x0e, 0xdb, 0x33, 0x1a, 0x70, 0x0c, 0xa2, 0x34, 0x5e, 0xd7, 0xd3, 0x09, 0x29, 0x97, 0xa8, - 0xea, 0x95, 0x44, 0xfd, 0x46, 0xe0, 0xb0, 0xcc, 0xed, 0x34, 0x65, 0x4f, 0xa0, 0x99, 0xcd, 0x85, - 0x24, 0x80, 0xe6, 0xe8, 0xde, 0x7a, 0xa5, 0xed, 0x66, 0x74, 0x73, 0x6c, 0xed, 0x66, 0x34, 0xd3, - 0xb9, 0x9a, 0xe9, 0xcd, 0x5b, 0x65, 0xfa, 0x4f, 0x02, 0xf7, 0x27, 0xcc, 0xb5, 0x70, 0x4e, 0x97, - 0xf8, 0x41, 0x44, 0x2d, 0xc4, 0x5a, 0xb9, 0x51, 0xac, 0xd7, 0x69, 0xeb, 0x80, 0x76, 0x8d, 0xff, - 0xef, 0xb3, 0x21, 0xfe, 0x26, 0xb2, 0x23, 0x86, 0x01, 0xfb, 0x19, 0xc3, 0x67, 0xd4, 0xf7, 0xef, - 0x48, 0x1c, 0x49, 0xf2, 0xfd, 0x4c, 0x96, 0x98, 0xe4, 0xfb, 0x11, 0xc9, 0x17, 0x5f, 0xae, 0xaf, - 0x60, 0xcf, 0x96, 0x8e, 0xb0, 0x13, 0x2f, 0x70, 0xf0, 0x5c, 0x4e, 0x93, 0x4a, 0xbf, 0x69, 0xb5, - 0xe2, 0x63, 0x33, 0x3a, 0xcd, 0xf5, 0xd7, 0x56, 0x49, 0x7f, 0x65, 0xc1, 0x24, 0x4a, 0x0d, 0xfe, - 0xa8, 0x42, 0x65, 0xc2, 0x5c, 0xe5, 0x18, 0x20, 0xf7, 0x2d, 0x2e, 0x4e, 0xfc, 0x2b, 0x83, 0x5c, - 0xfd, 0xf2, 0xdd, 0x78, 0x9a, 0x87, 0xef, 0xa1, 0x9e, 0x0e, 0xdd, 0xc3, 0x32, 0x9b, 0x04, 0x55, - 0x3f, 0x7f, 0x17, 0x9a, 0xde, 0x77, 0x0c, 0x90, 0x1b, 0x51, 0xa5, 0x5e, 0x66, 0x78, 0xb9, 0x97, - 0xc5, 0x19, 0xa3, 0x78, 0xf0, 0x51, 0x71, 0xbe, 0x7c, 0x51, 0x66, 0x5c, 0xa0, 0xa9, 0x0f, 0x6f, - 0x44, 0x4b, 0x9f, 0x0a, 0x61, 0xbf, 0xb4, 0xf1, 0xfa, 0x65, 0xd7, 0x94, 0x31, 0xd5, 0xaf, 0x6f, - 0xca, 0xcc, 0x8b, 0x96, 0xab, 0xe2, 0x52, 0xd1, 0x32, 0xbc, 0x5c, 0xb4, 0x62, 0xe1, 0x8c, 0xbe, - 0x7b, 0xb5, 0xee, 0x90, 0xd7, 0xeb, 0x0e, 0x79, 0xb3, 0xee, 0x90, 0x97, 0x97, 0x9d, 0x8d, 0xd7, - 0x97, 0x9d, 0x8d, 0x7f, 0x2e, 0x3b, 0x1b, 0x3f, 0xe9, 0xae, 0xc7, 0x4f, 0xcf, 0xa6, 0xfa, 0x8c, - 0xce, 0x8d, 0xe8, 0xae, 0x87, 0xbe, 0x3d, 0x65, 0xf1, 0xda, 0x58, 0x3e, 0x36, 0xce, 0xe3, 0x9f, - 0x42, 0x7e, 0xb1, 0x40, 0x36, 0xad, 0xc9, 0x8e, 0x7c, 0xfc, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x07, 0x0c, 0x91, 0x4e, 0xb0, 0x0a, 0x00, 0x00, + // 935 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xbf, 0x6f, 0xdb, 0xc6, + 0x17, 0x37, 0x2d, 0x45, 0x96, 0x9e, 0x2c, 0x39, 0x5f, 0x7e, 0x5d, 0x47, 0x21, 0x5c, 0x51, 0x50, + 0x7f, 0x69, 0x68, 0xc8, 0x46, 0x41, 0xba, 0x74, 0x92, 0x22, 0x03, 0xe5, 0xa0, 0x36, 0x38, 0x7b, + 0x28, 0xba, 0x18, 0x94, 0xf8, 0x42, 0x13, 0xa0, 0x78, 0x02, 0xef, 0xac, 0xda, 0x43, 0xe7, 0x6e, + 0x45, 0xc6, 0xfe, 0x21, 0x45, 0xc7, 0x8e, 0x45, 0x80, 0x2e, 0x19, 0x3b, 0xa9, 0x85, 0xfc, 0x8f, + 0x14, 0x77, 0x24, 0x45, 0x3a, 0xa4, 0x02, 0xd5, 0x68, 0xba, 0xf1, 0xee, 0xf3, 0x79, 0xef, 0xde, + 0xfb, 0xbc, 0x1f, 0x12, 0x68, 0x0e, 0xb2, 0x19, 0x65, 0xe6, 0x9c, 0x32, 0xce, 0xcc, 0xc5, 0x63, + 0x73, 0xc6, 0x5c, 0x66, 0xcc, 0x43, 0xca, 0xa9, 0x7a, 0x10, 0x61, 0x86, 0xc4, 0x8c, 0xc5, 0x63, + 0xed, 0xd0, 0xa5, 0x2e, 0x95, 0x98, 0x29, 0xbe, 0x22, 0x9a, 0xf6, 0xd0, 0xa5, 0xd4, 0xf5, 0xd1, + 0x94, 0xa7, 0xc9, 0xe5, 0x0b, 0xd3, 0x0e, 0xae, 0x63, 0x48, 0x7f, 0x13, 0xe2, 0xde, 0x0c, 0x19, + 0xb7, 0x67, 0xf3, 0x98, 0xd0, 0x89, 0x9f, 0x67, 0x97, 0x13, 0x36, 0xb7, 0xa7, 0xc8, 0xcc, 0x45, + 0xdf, 0x9c, 0x51, 0x07, 0xfd, 0x38, 0x08, 0xed, 0x38, 0x17, 0x60, 0x06, 0xed, 0xfe, 0x58, 0x86, + 0xc6, 0x98, 0xb9, 0xcf, 0x42, 0xb4, 0x39, 0x3e, 0xa7, 0x8c, 0xab, 0x26, 0xd4, 0x13, 0x67, 0xe7, + 0x9e, 0xd3, 0x52, 0x3a, 0x4a, 0xaf, 0x3c, 0x6c, 0xae, 0x96, 0x3a, 0x9c, 0xc6, 0xd7, 0xd6, 0x88, + 0x40, 0x42, 0xb1, 0x1c, 0xf5, 0x53, 0x00, 0x86, 0x53, 0xee, 0xd1, 0x40, 0xf0, 0x77, 0x3b, 0x4a, + 0xaf, 0x31, 0x6c, 0xac, 0x96, 0x7a, 0xed, 0x34, 0xba, 0xb5, 0x46, 0xa4, 0x16, 0x13, 0x2c, 0x47, + 0xb8, 0xc7, 0x2b, 0x8e, 0x61, 0x60, 0xfb, 0x82, 0x5e, 0xea, 0x28, 0xbd, 0x5a, 0xe4, 0xfe, 0x24, + 0xbe, 0x16, 0xee, 0x13, 0x8a, 0xe5, 0xa8, 0x2a, 0x94, 0x39, 0x5e, 0xf1, 0x56, 0x59, 0x30, 0x89, + 0xfc, 0x56, 0x9f, 0x42, 0x15, 0x03, 0xee, 0x71, 0x0f, 0x59, 0xeb, 0x5e, 0x47, 0xe9, 0xd5, 0xfb, + 0x0f, 0x8d, 0x37, 0xb4, 0x36, 0x4e, 0x62, 0x02, 0x59, 0x53, 0xd5, 0xcf, 0xa1, 0x6e, 0x73, 0x6e, + 0x4f, 0x2f, 0x66, 0x18, 0x70, 0xd6, 0xaa, 0x74, 0x4a, 0xbd, 0x7a, 0xff, 0xd0, 0x88, 0x34, 0x36, + 0x12, 0x8d, 0x8d, 0x41, 0x70, 0x4d, 0xb2, 0x44, 0xf5, 0x08, 0x2a, 0xf6, 0x25, 0xbf, 0xa0, 0x61, + 0x6b, 0x4f, 0x06, 0x11, 0x9f, 0xd4, 0x2f, 0xe0, 0x60, 0x4a, 0x83, 0x05, 0x86, 0xcc, 0x4e, 0xd2, + 0xaf, 0x4a, 0xb9, 0xd4, 0xd5, 0x52, 0x6f, 0x3e, 0xcb, 0x40, 0xd6, 0x88, 0x34, 0xb3, 0x54, 0xcb, + 0x51, 0x47, 0xd0, 0x0c, 0x71, 0xee, 0x5f, 0x9f, 0x33, 0xe4, 0xdc, 0x0b, 0x5c, 0xd6, 0xaa, 0x75, + 0x94, 0x5e, 0xb3, 0xff, 0x7e, 0x2e, 0x13, 0x22, 0x68, 0xa7, 0x11, 0x8b, 0x34, 0xc2, 0xcc, 0x89, + 0xa9, 0x5f, 0xc3, 0xfd, 0x10, 0x5f, 0x60, 0x88, 0xc1, 0x14, 0x9d, 0x73, 0x69, 0xd2, 0x02, 0x99, + 0x57, 0x3b, 0xe7, 0x47, 0x94, 0x97, 0x24, 0xe4, 0x61, 0xf9, 0xd5, 0x52, 0xdf, 0x21, 0x07, 0xa9, + 0xb5, 0x80, 0x59, 0xf7, 0x07, 0x05, 0xde, 0xbb, 0xd5, 0x10, 0x04, 0xd9, 0x9c, 0x06, 0x0c, 0xd5, + 0x0f, 0x60, 0x4f, 0xb8, 0x4a, 0x9b, 0x02, 0x56, 0x4b, 0xbd, 0x22, 0x28, 0xd6, 0x88, 0x54, 0x04, + 0x64, 0x39, 0xaa, 0x05, 0x8d, 0xa9, 0x30, 0x15, 0x72, 0x38, 0x36, 0x47, 0xd9, 0x0f, 0xf5, 0xbe, + 0x96, 0x13, 0xf9, 0x2c, 0x69, 0xe4, 0x61, 0x55, 0x04, 0xf2, 0xf2, 0x4f, 0x5d, 0x21, 0xfb, 0x89, + 0xe9, 0xc8, 0xe6, 0xd8, 0xfd, 0x4d, 0x81, 0xfa, 0x98, 0xb9, 0x27, 0x8e, 0xc7, 0xef, 0xd6, 0x98, + 0x99, 0x80, 0x77, 0x37, 0x06, 0x9c, 0xb4, 0x57, 0x69, 0x43, 0x7b, 0x95, 0xb7, 0x6f, 0xaf, 0x23, + 0xa8, 0xa0, 0xe3, 0x71, 0x1a, 0xca, 0x9e, 0xac, 0x91, 0xf8, 0xd4, 0xfd, 0x06, 0xfe, 0x9f, 0xc9, + 0x63, 0xad, 0xe7, 0x00, 0x6a, 0x82, 0x10, 0xc9, 0xa4, 0xfc, 0x03, 0x99, 0xaa, 0xc2, 0x4c, 0x4a, + 0xf4, 0xbd, 0x1c, 0xde, 0x11, 0xfa, 0x78, 0xd7, 0xe1, 0xdd, 0x4a, 0xa3, 0x23, 0xa8, 0x30, 0xcf, + 0x0d, 0x30, 0x8c, 0x55, 0x8a, 0x4f, 0xdd, 0x07, 0xb2, 0x55, 0xd2, 0xe7, 0x93, 0xd4, 0xba, 0x3f, + 0x2b, 0x70, 0x38, 0x66, 0xee, 0xc0, 0x91, 0x4d, 0x35, 0x58, 0x8f, 0xd2, 0x3b, 0x8a, 0xcf, 0x80, + 0xbd, 0x29, 0x0d, 0x38, 0x06, 0x51, 0x19, 0x37, 0xcd, 0x74, 0x42, 0xca, 0x14, 0xaa, 0x7c, 0xab, + 0x50, 0x3f, 0x29, 0x70, 0x5c, 0x14, 0xf6, 0xba, 0x64, 0x4f, 0xa1, 0x91, 0xee, 0x85, 0x24, 0x81, + 0xc6, 0xf0, 0xfe, 0x6a, 0xa9, 0xef, 0xa7, 0x74, 0x6b, 0x44, 0xf6, 0x53, 0x9a, 0xe5, 0xdc, 0xae, + 0xf4, 0xee, 0x9d, 0x2a, 0xfd, 0xab, 0x02, 0x0f, 0xc6, 0xcc, 0x25, 0x38, 0xa3, 0x0b, 0xfc, 0x4f, + 0x44, 0xcd, 0xe5, 0x5a, 0xda, 0x2a, 0xd7, 0x4d, 0xda, 0x3a, 0xa0, 0x6f, 0x88, 0xff, 0xdf, 0x1c, + 0x88, 0xdf, 0x15, 0x39, 0x11, 0x83, 0x80, 0x7d, 0x87, 0xe1, 0x73, 0xea, 0xfb, 0xef, 0x48, 0x1c, + 0x49, 0xf2, 0xfd, 0x54, 0x96, 0x98, 0xe4, 0xfb, 0x11, 0xc9, 0x17, 0xbf, 0x5c, 0x9f, 0xc0, 0x81, + 0x2d, 0x03, 0x61, 0xe7, 0x5e, 0xe0, 0xe0, 0x95, 0xdc, 0x26, 0xa5, 0x5e, 0x83, 0x34, 0xe3, 0x6b, + 0x2b, 0xba, 0xcd, 0xcc, 0xd7, 0xbd, 0x82, 0xf9, 0x4a, 0x93, 0x49, 0x94, 0xea, 0xff, 0x52, 0x86, + 0xd2, 0x98, 0xb9, 0xea, 0x19, 0x40, 0xe6, 0x97, 0x3b, 0xbf, 0xf1, 0x6f, 0x2d, 0x72, 0xed, 0xe3, + 0xb7, 0xe3, 0xeb, 0x3a, 0x7c, 0x05, 0xd5, 0xf5, 0xd2, 0x3d, 0x2e, 0xb2, 0x49, 0x50, 0xed, 0xc3, + 0xb7, 0xa1, 0x6b, 0x7f, 0x67, 0x00, 0x99, 0x15, 0x55, 0x18, 0x65, 0x8a, 0x17, 0x47, 0x99, 0xdf, + 0x31, 0xaa, 0x07, 0xff, 0xcb, 0xef, 0x97, 0x8f, 0x8a, 0x8c, 0x73, 0x34, 0xed, 0xd1, 0x56, 0xb4, + 0xf5, 0x53, 0x21, 0x1c, 0x16, 0x0e, 0x5e, 0xaf, 0xc8, 0x4d, 0x11, 0x53, 0xfb, 0x6c, 0x5b, 0x66, + 0x56, 0xb4, 0x4c, 0x17, 0x17, 0x8a, 0x96, 0xe2, 0xc5, 0xa2, 0xe5, 0x1b, 0x67, 0xf8, 0xe5, 0xab, + 0x55, 0x5b, 0x79, 0xbd, 0x6a, 0x2b, 0x7f, 0xad, 0xda, 0xca, 0xcb, 0x9b, 0xf6, 0xce, 0xeb, 0x9b, + 0xf6, 0xce, 0x1f, 0x37, 0xed, 0x9d, 0x6f, 0x0d, 0xd7, 0xe3, 0x17, 0x97, 0x13, 0x63, 0x4a, 0x67, + 0x66, 0xe4, 0xeb, 0x91, 0x6f, 0x4f, 0x58, 0xfc, 0x6d, 0x2e, 0x9e, 0x98, 0x57, 0xf1, 0x5f, 0x48, + 0x7e, 0x3d, 0x47, 0x36, 0xa9, 0xc8, 0x89, 0x7c, 0xf2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x56, + 0x6a, 0xc0, 0x8a, 0x00, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1186,25 +1199,25 @@ func (m *MsgCreatePost) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintMsgs(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } } if m.ReplySettings != 0 { i = encodeVarintMsgs(dAtA, i, uint64(m.ReplySettings)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x48 } if m.ConversationID != 0 { i = encodeVarintMsgs(dAtA, i, uint64(m.ConversationID)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if len(m.Author) > 0 { i -= len(m.Author) copy(dAtA[i:], m.Author) i = encodeVarintMsgs(dAtA, i, uint64(len(m.Author))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if len(m.Attachments) > 0 { for iNdEx := len(m.Attachments) - 1; iNdEx >= 0; iNdEx-- { @@ -1217,7 +1230,7 @@ func (m *MsgCreatePost) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintMsgs(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } } if m.Entities != nil { @@ -1230,21 +1243,26 @@ func (m *MsgCreatePost) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintMsgs(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.Text) > 0 { i -= len(m.Text) copy(dAtA[i:], m.Text) i = encodeVarintMsgs(dAtA, i, uint64(len(m.Text))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if len(m.ExternalID) > 0 { i -= len(m.ExternalID) copy(dAtA[i:], m.ExternalID) i = encodeVarintMsgs(dAtA, i, uint64(len(m.ExternalID))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 } if m.SubspaceID != 0 { i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) @@ -1713,6 +1731,9 @@ func (m *MsgCreatePost) Size() (n int) { if m.SubspaceID != 0 { n += 1 + sovMsgs(uint64(m.SubspaceID)) } + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } l = len(m.ExternalID) if l > 0 { n += 1 + l + sovMsgs(uint64(l)) @@ -1993,6 +2014,25 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExternalID", wireType) } @@ -2024,7 +2064,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { } m.ExternalID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) } @@ -2056,7 +2096,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { } m.Text = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Entities", wireType) } @@ -2092,7 +2132,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Attachments", wireType) } @@ -2126,7 +2166,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Author", wireType) } @@ -2158,7 +2198,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { } m.Author = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ConversationID", wireType) } @@ -2177,7 +2217,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ReplySettings", wireType) } @@ -2196,7 +2236,7 @@ func (m *MsgCreatePost) Unmarshal(dAtA []byte) error { break } } - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ReferencedPosts", wireType) } diff --git a/x/posts/types/msgs_test.go b/x/posts/types/msgs_test.go index 07418b5137..3597612797 100644 --- a/x/posts/types/msgs_test.go +++ b/x/posts/types/msgs_test.go @@ -29,6 +29,7 @@ var attachments = []types.AttachmentContent{ } var msgCreatePost = types.NewMsgCreatePost( + 1, 1, "External ID", "This is a text", @@ -70,6 +71,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { name: "invalid subspace id returns error", msg: types.NewMsgCreatePost( 0, + msgCreatePost.SectionID, msgCreatePost.ExternalID, msgCreatePost.Text, msgCreatePost.ConversationID, @@ -85,6 +87,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { name: "invalid reply settings returns error", msg: types.NewMsgCreatePost( msgCreatePost.SubspaceID, + msgCreatePost.SectionID, msgCreatePost.ExternalID, msgCreatePost.Text, msgCreatePost.ConversationID, @@ -100,6 +103,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { name: "invalid entities returns error", msg: types.NewMsgCreatePost( msgCreatePost.SubspaceID, + msgCreatePost.SectionID, msgCreatePost.ExternalID, msgCreatePost.Text, msgCreatePost.ConversationID, @@ -118,6 +122,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { name: "invalid attachments returns error", msg: types.NewMsgCreatePost( msgCreatePost.SubspaceID, + msgCreatePost.SectionID, msgCreatePost.ExternalID, msgCreatePost.Text, msgCreatePost.ConversationID, @@ -135,6 +140,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { name: "invalid post reference returns error", msg: types.NewMsgCreatePost( msgCreatePost.SubspaceID, + msgCreatePost.SectionID, msgCreatePost.ExternalID, msgCreatePost.Text, msgCreatePost.ConversationID, @@ -152,6 +158,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { name: "invalid author returns error", msg: types.NewMsgCreatePost( msgCreatePost.SubspaceID, + msgCreatePost.SectionID, msgCreatePost.ExternalID, msgCreatePost.Text, msgCreatePost.ConversationID, @@ -183,7 +190,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) { } func TestMsgCreatePost_GetSignBytes(t *testing.T) { - expected := `{"type":"desmos/MsgCreatePost","value":{"attachments":[{"type":"desmos/Media","value":{"mime_type":"image/png","uri":"ftp://user:password@example.com/image.png"}},{"type":"desmos/Poll","value":{"end_date":"2020-01-01T12:00:00Z","provided_answers":[{"attachments":null,"text":"Cat"},{"attachments":null,"text":"Dog"}],"question":"What animal is best?"}}],"author":"cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd","conversation_id":"1","entities":{"hashtags":[{"end":"3","start":"1","tag":"tag"}],"mentions":[{"end":"6","start":"4","tag":"tag"}],"urls":[{"display_url":"Display URL","end":"9","start":"7","url":"URL"}]},"external_id":"External ID","referenced_posts":[{"post_id":"1","type":2}],"reply_settings":1,"subspace_id":"1","text":"This is a text"}}` + expected := `{"type":"desmos/MsgCreatePost","value":{"attachments":[{"type":"desmos/Media","value":{"mime_type":"image/png","uri":"ftp://user:password@example.com/image.png"}},{"type":"desmos/Poll","value":{"end_date":"2020-01-01T12:00:00Z","provided_answers":[{"attachments":null,"text":"Cat"},{"attachments":null,"text":"Dog"}],"question":"What animal is best?"}}],"author":"cosmos13t6y2nnugtshwuy0zkrq287a95lyy8vzleaxmd","conversation_id":"1","entities":{"hashtags":[{"end":"3","start":"1","tag":"tag"}],"mentions":[{"end":"6","start":"4","tag":"tag"}],"urls":[{"display_url":"Display URL","end":"9","start":"7","url":"URL"}]},"external_id":"External ID","referenced_posts":[{"post_id":"1","type":2}],"reply_settings":1,"section_id":1,"subspace_id":"1","text":"This is a text"}}` require.Equal(t, expected, string(msgCreatePost.GetSignBytes())) } diff --git a/x/posts/types/query.go b/x/posts/types/query.go index aaec0e736e..6108ccd736 100644 --- a/x/posts/types/query.go +++ b/x/posts/types/query.go @@ -7,14 +7,23 @@ import ( query "github.com/cosmos/cosmos-sdk/types/query" ) -// NewQueryPostsRequest returns a new QueryPostsRequest instance -func NewQueryPostsRequest(subspaceID uint64, pagination *query.PageRequest) *QueryPostsRequest { - return &QueryPostsRequest{ +// 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{ diff --git a/x/posts/types/query.pb.go b/x/posts/types/query.pb.go index 77c56384bf..1b749d27f7 100644 --- a/x/posts/types/query.pb.go +++ b/x/posts/types/query.pb.go @@ -30,26 +30,27 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryPostsRequest is the request type for the Query/Posts RPC method -type QueryPostsRequest struct { +// QuerySubspacePostsRequest is the request type for the Query/SubspacePosts RPC +// method +type QuerySubspacePostsRequest struct { // Id of the subspace to query the posts for SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` // pagination defines an optional pagination for the request. Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryPostsRequest) Reset() { *m = QueryPostsRequest{} } -func (m *QueryPostsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryPostsRequest) ProtoMessage() {} -func (*QueryPostsRequest) Descriptor() ([]byte, []int) { +func (m *QuerySubspacePostsRequest) Reset() { *m = QuerySubspacePostsRequest{} } +func (m *QuerySubspacePostsRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySubspacePostsRequest) ProtoMessage() {} +func (*QuerySubspacePostsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_8109ee6901cf86f4, []int{0} } -func (m *QueryPostsRequest) XXX_Unmarshal(b []byte) error { +func (m *QuerySubspacePostsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPostsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QuerySubspacePostsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPostsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QuerySubspacePostsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -59,50 +60,51 @@ func (m *QueryPostsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *QueryPostsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPostsRequest.Merge(m, src) +func (m *QuerySubspacePostsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySubspacePostsRequest.Merge(m, src) } -func (m *QueryPostsRequest) XXX_Size() int { +func (m *QuerySubspacePostsRequest) XXX_Size() int { return m.Size() } -func (m *QueryPostsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPostsRequest.DiscardUnknown(m) +func (m *QuerySubspacePostsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySubspacePostsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryPostsRequest proto.InternalMessageInfo +var xxx_messageInfo_QuerySubspacePostsRequest proto.InternalMessageInfo -func (m *QueryPostsRequest) GetSubspaceId() uint64 { +func (m *QuerySubspacePostsRequest) GetSubspaceId() uint64 { if m != nil { return m.SubspaceId } return 0 } -func (m *QueryPostsRequest) GetPagination() *query.PageRequest { +func (m *QuerySubspacePostsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -// QueryPostsResponse is the response type for the Query/Posts RPC method -type QueryPostsResponse struct { +// QuerySubspacePostsResponse is the response type for the Query/SubspacePosts +// RPC method +type QuerySubspacePostsResponse struct { Posts []Post `protobuf:"bytes,1,rep,name=posts,proto3" json:"posts"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryPostsResponse) Reset() { *m = QueryPostsResponse{} } -func (m *QueryPostsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPostsResponse) ProtoMessage() {} -func (*QueryPostsResponse) Descriptor() ([]byte, []int) { +func (m *QuerySubspacePostsResponse) Reset() { *m = QuerySubspacePostsResponse{} } +func (m *QuerySubspacePostsResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySubspacePostsResponse) ProtoMessage() {} +func (*QuerySubspacePostsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_8109ee6901cf86f4, []int{1} } -func (m *QueryPostsResponse) XXX_Unmarshal(b []byte) error { +func (m *QuerySubspacePostsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPostsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QuerySubspacePostsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPostsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QuerySubspacePostsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -112,26 +114,145 @@ func (m *QueryPostsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryPostsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPostsResponse.Merge(m, src) +func (m *QuerySubspacePostsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySubspacePostsResponse.Merge(m, src) } -func (m *QueryPostsResponse) XXX_Size() int { +func (m *QuerySubspacePostsResponse) XXX_Size() int { return m.Size() } -func (m *QueryPostsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPostsResponse.DiscardUnknown(m) +func (m *QuerySubspacePostsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySubspacePostsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryPostsResponse proto.InternalMessageInfo +var xxx_messageInfo_QuerySubspacePostsResponse proto.InternalMessageInfo -func (m *QueryPostsResponse) GetPosts() []Post { +func (m *QuerySubspacePostsResponse) GetPosts() []Post { if m != nil { return m.Posts } return nil } -func (m *QueryPostsResponse) GetPagination() *query.PageResponse { +func (m *QuerySubspacePostsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QuerySectionPostsRequest is the request type for the Query/SectionPosts RPC +// method +type QuerySectionPostsRequest struct { + // Id of the subspace to query the posts for + SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Id of the section to query the posts for + SectionId uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySectionPostsRequest) Reset() { *m = QuerySectionPostsRequest{} } +func (m *QuerySectionPostsRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySectionPostsRequest) ProtoMessage() {} +func (*QuerySectionPostsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8109ee6901cf86f4, []int{2} +} +func (m *QuerySectionPostsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySectionPostsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySectionPostsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySectionPostsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySectionPostsRequest.Merge(m, src) +} +func (m *QuerySectionPostsRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySectionPostsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySectionPostsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySectionPostsRequest proto.InternalMessageInfo + +func (m *QuerySectionPostsRequest) GetSubspaceId() uint64 { + if m != nil { + return m.SubspaceId + } + return 0 +} + +func (m *QuerySectionPostsRequest) GetSectionId() uint32 { + if m != nil { + return m.SectionId + } + return 0 +} + +func (m *QuerySectionPostsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QuerySectionPostsResponse is the response type for the Query/SectionPosts RPC +// method +type QuerySectionPostsResponse struct { + Posts []Post `protobuf:"bytes,1,rep,name=posts,proto3" json:"posts"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySectionPostsResponse) Reset() { *m = QuerySectionPostsResponse{} } +func (m *QuerySectionPostsResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySectionPostsResponse) ProtoMessage() {} +func (*QuerySectionPostsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8109ee6901cf86f4, []int{3} +} +func (m *QuerySectionPostsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySectionPostsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySectionPostsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySectionPostsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySectionPostsResponse.Merge(m, src) +} +func (m *QuerySectionPostsResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySectionPostsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySectionPostsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySectionPostsResponse proto.InternalMessageInfo + +func (m *QuerySectionPostsResponse) GetPosts() []Post { + if m != nil { + return m.Posts + } + return nil +} + +func (m *QuerySectionPostsResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -150,7 +271,7 @@ func (m *QueryPostRequest) Reset() { *m = QueryPostRequest{} } func (m *QueryPostRequest) String() string { return proto.CompactTextString(m) } func (*QueryPostRequest) ProtoMessage() {} func (*QueryPostRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{2} + return fileDescriptor_8109ee6901cf86f4, []int{4} } func (m *QueryPostRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -202,7 +323,7 @@ func (m *QueryPostResponse) Reset() { *m = QueryPostResponse{} } func (m *QueryPostResponse) String() string { return proto.CompactTextString(m) } func (*QueryPostResponse) ProtoMessage() {} func (*QueryPostResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{3} + return fileDescriptor_8109ee6901cf86f4, []int{5} } func (m *QueryPostResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -253,7 +374,7 @@ func (m *QueryPostAttachmentsRequest) Reset() { *m = QueryPostAttachment func (m *QueryPostAttachmentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPostAttachmentsRequest) ProtoMessage() {} func (*QueryPostAttachmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{4} + return fileDescriptor_8109ee6901cf86f4, []int{6} } func (m *QueryPostAttachmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -314,7 +435,7 @@ func (m *QueryPostAttachmentsResponse) Reset() { *m = QueryPostAttachmen func (m *QueryPostAttachmentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPostAttachmentsResponse) ProtoMessage() {} func (*QueryPostAttachmentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{5} + return fileDescriptor_8109ee6901cf86f4, []int{7} } func (m *QueryPostAttachmentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -376,7 +497,7 @@ func (m *QueryPollAnswersRequest) Reset() { *m = QueryPollAnswersRequest func (m *QueryPollAnswersRequest) String() string { return proto.CompactTextString(m) } func (*QueryPollAnswersRequest) ProtoMessage() {} func (*QueryPollAnswersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{6} + return fileDescriptor_8109ee6901cf86f4, []int{8} } func (m *QueryPollAnswersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -451,7 +572,7 @@ func (m *QueryPollAnswersResponse) Reset() { *m = QueryPollAnswersRespon func (m *QueryPollAnswersResponse) String() string { return proto.CompactTextString(m) } func (*QueryPollAnswersResponse) ProtoMessage() {} func (*QueryPollAnswersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{7} + return fileDescriptor_8109ee6901cf86f4, []int{9} } func (m *QueryPollAnswersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -502,7 +623,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{8} + return fileDescriptor_8109ee6901cf86f4, []int{10} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -540,7 +661,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8109ee6901cf86f4, []int{9} + return fileDescriptor_8109ee6901cf86f4, []int{11} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -577,8 +698,10 @@ func (m *QueryParamsResponse) GetParams() Params { } func init() { - proto.RegisterType((*QueryPostsRequest)(nil), "desmos.posts.v1.QueryPostsRequest") - proto.RegisterType((*QueryPostsResponse)(nil), "desmos.posts.v1.QueryPostsResponse") + proto.RegisterType((*QuerySubspacePostsRequest)(nil), "desmos.posts.v1.QuerySubspacePostsRequest") + proto.RegisterType((*QuerySubspacePostsResponse)(nil), "desmos.posts.v1.QuerySubspacePostsResponse") + proto.RegisterType((*QuerySectionPostsRequest)(nil), "desmos.posts.v1.QuerySectionPostsRequest") + proto.RegisterType((*QuerySectionPostsResponse)(nil), "desmos.posts.v1.QuerySectionPostsResponse") proto.RegisterType((*QueryPostRequest)(nil), "desmos.posts.v1.QueryPostRequest") proto.RegisterType((*QueryPostResponse)(nil), "desmos.posts.v1.QueryPostResponse") proto.RegisterType((*QueryPostAttachmentsRequest)(nil), "desmos.posts.v1.QueryPostAttachmentsRequest") @@ -592,52 +715,57 @@ func init() { func init() { proto.RegisterFile("desmos/posts/v1/query.proto", fileDescriptor_8109ee6901cf86f4) } var fileDescriptor_8109ee6901cf86f4 = []byte{ - // 715 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4f, 0x4f, 0x13, 0x4f, - 0x18, 0xc7, 0x3b, 0xd0, 0x96, 0xfc, 0x9e, 0xe6, 0x17, 0x74, 0xc4, 0xb4, 0x16, 0x52, 0xea, 0x4a, - 0xb0, 0x1a, 0xd8, 0xb1, 0x10, 0x3d, 0xa8, 0x17, 0xd0, 0x20, 0x24, 0xc4, 0x60, 0x13, 0x2f, 0x5e, - 0xcc, 0xb4, 0x9d, 0x2c, 0x4d, 0xb6, 0x3b, 0x4b, 0x67, 0x5b, 0x25, 0x88, 0x07, 0x13, 0xef, 0x24, - 0xbe, 0x00, 0x7d, 0x01, 0x9e, 0x78, 0x15, 0x1c, 0x49, 0xbc, 0x78, 0x32, 0x06, 0xbc, 0xfb, 0x16, - 0xcc, 0xfc, 0x59, 0x58, 0x76, 0x29, 0x14, 0xc2, 0xad, 0x3b, 0xcf, 0xbf, 0xcf, 0xf3, 0x9d, 0xe7, - 0x99, 0x14, 0xc6, 0x9b, 0x4c, 0xb4, 0xb9, 0x20, 0x3e, 0x17, 0x81, 0x20, 0xbd, 0x2a, 0xd9, 0xe8, - 0xb2, 0xce, 0xa6, 0xed, 0x77, 0x78, 0xc0, 0xf1, 0xa8, 0x36, 0xda, 0xca, 0x68, 0xf7, 0xaa, 0xc5, - 0x31, 0x87, 0x3b, 0x5c, 0xd9, 0x88, 0xfc, 0xa5, 0xdd, 0x8a, 0x13, 0x0e, 0xe7, 0x8e, 0xcb, 0x08, - 0xf5, 0x5b, 0x84, 0x7a, 0x1e, 0x0f, 0x68, 0xd0, 0xe2, 0x9e, 0x30, 0xd6, 0xfb, 0x0d, 0xae, 0x2a, - 0xd4, 0xa9, 0x60, 0x3a, 0x3b, 0xe9, 0x55, 0xeb, 0x2c, 0xa0, 0x55, 0xe2, 0x53, 0xa7, 0xe5, 0x29, - 0xe7, 0x30, 0x53, 0x9c, 0xa6, 0xcd, 0x9b, 0xcc, 0x35, 0x99, 0xac, 0x0f, 0x70, 0xfd, 0x95, 0x8c, - 0x5f, 0x93, 0xd6, 0x1a, 0xdb, 0xe8, 0x32, 0x11, 0xe0, 0x49, 0xc8, 0x89, 0x6e, 0x5d, 0xf8, 0xb4, - 0xc1, 0xde, 0xb6, 0x9a, 0x05, 0x54, 0x46, 0x95, 0x74, 0x0d, 0xc2, 0xa3, 0x95, 0x26, 0x5e, 0x02, - 0x38, 0xae, 0x53, 0x18, 0x2a, 0xa3, 0x4a, 0x6e, 0x6e, 0xda, 0xd6, 0x50, 0xb6, 0x84, 0xb2, 0x75, - 0xcb, 0x06, 0xca, 0x5e, 0xa3, 0x0e, 0x33, 0xc9, 0x6b, 0x91, 0x48, 0x6b, 0x07, 0x01, 0x8e, 0x96, - 0x17, 0x3e, 0xf7, 0x04, 0xc3, 0x55, 0xc8, 0x28, 0xda, 0x02, 0x2a, 0x0f, 0x57, 0x72, 0x73, 0x37, - 0xed, 0x98, 0x66, 0xb6, 0x74, 0x5f, 0x4c, 0xef, 0xfd, 0x9a, 0x4c, 0xd5, 0xb4, 0x27, 0x7e, 0x71, - 0x0a, 0xd1, 0xdd, 0x73, 0x89, 0x74, 0xbd, 0x13, 0x48, 0xab, 0x70, 0xed, 0x88, 0x68, 0x60, 0x3d, - 0xf2, 0x30, 0x22, 0x31, 0xa4, 0x71, 0x48, 0x19, 0xb3, 0xf2, 0x73, 0xa5, 0x69, 0x3d, 0x8f, 0xc8, - 0x7b, 0xd4, 0x1e, 0x81, 0xb4, 0x34, 0xab, 0x3c, 0xe7, 0x74, 0xa7, 0x1c, 0xad, 0xaf, 0x08, 0xc6, - 0x8f, 0xd2, 0x2c, 0x04, 0x01, 0x6d, 0xac, 0xb7, 0x99, 0x77, 0x81, 0xfb, 0xea, 0xc7, 0x17, 0xbb, - 0xc8, 0xe1, 0x4b, 0x5f, 0xe4, 0x77, 0x04, 0x13, 0xa7, 0x13, 0x9a, 0x9e, 0x9f, 0x41, 0x8e, 0x1e, - 0x1f, 0x9b, 0x8b, 0x1d, 0x4f, 0xb4, 0x7e, 0x1c, 0x6a, 0x04, 0x88, 0x46, 0x5d, 0xdd, 0x25, 0xef, - 0x21, 0xc8, 0x1b, 0x5c, 0xd7, 0x5d, 0xf0, 0xc4, 0x3b, 0xd6, 0xb9, 0x02, 0x31, 0x95, 0xc1, 0x75, - 0xa5, 0x41, 0x2a, 0xf9, 0xbf, 0x34, 0xb8, 0xee, 0x4a, 0x13, 0x63, 0x48, 0x77, 0x05, 0xeb, 0x14, - 0xd2, 0x65, 0x54, 0xf9, 0xaf, 0xa6, 0x7e, 0xc7, 0x94, 0xcf, 0x5c, 0x5a, 0xf9, 0x6f, 0x08, 0x0a, - 0xc9, 0x56, 0x8c, 0xea, 0x4f, 0x60, 0x84, 0xea, 0xa3, 0xbe, 0x8a, 0xbf, 0x16, 0xac, 0xa3, 0xc3, - 0x8c, 0xe2, 0x61, 0xc4, 0xd5, 0xa9, 0x3d, 0x16, 0x2e, 0x39, 0xed, 0xd0, 0x76, 0xa8, 0xb3, 0xb5, - 0x0a, 0x37, 0x4e, 0x9c, 0x1a, 0xe4, 0x87, 0x90, 0xf5, 0xd5, 0x89, 0x59, 0x8f, 0x7c, 0x72, 0x3d, - 0x94, 0xd9, 0xd0, 0x1a, 0xe7, 0xb9, 0xbf, 0x19, 0xc8, 0xa8, 0x74, 0xf8, 0x23, 0x64, 0xd4, 0x6b, - 0x82, 0xad, 0x44, 0x64, 0xe2, 0xa5, 0x2b, 0xde, 0x39, 0xd3, 0x47, 0x23, 0x59, 0x33, 0x9f, 0x7e, - 0xfc, 0xf9, 0x32, 0x34, 0x8d, 0xa7, 0x48, 0xfc, 0x29, 0xdd, 0x8a, 0x4c, 0xca, 0xb6, 0x3e, 0xc6, - 0x9f, 0x11, 0xa4, 0x65, 0x3c, 0xbe, 0xdd, 0x3f, 0x77, 0x58, 0xde, 0x3a, 0xcb, 0xc5, 0x54, 0x7f, - 0xa4, 0xaa, 0x3f, 0xc0, 0xf6, 0x20, 0xd5, 0xc9, 0x96, 0x19, 0xcd, 0x6d, 0xbc, 0x8b, 0x60, 0x34, - 0xb6, 0x8d, 0x78, 0xa6, 0x7f, 0xbd, 0xe4, 0xb3, 0x52, 0x9c, 0x1d, 0xd0, 0xdb, 0x80, 0x2e, 0x2a, - 0xd0, 0xa7, 0xf8, 0xf1, 0xc5, 0x40, 0x49, 0x74, 0xc3, 0x77, 0x11, 0xe4, 0x22, 0x83, 0x8c, 0x2b, - 0xfd, 0x10, 0xe2, 0x6b, 0x5b, 0xbc, 0x37, 0x80, 0xa7, 0x01, 0x7d, 0xa9, 0x40, 0x97, 0xf1, 0xd2, - 0x05, 0x41, 0xe5, 0x36, 0xab, 0x6f, 0xb5, 0xe3, 0xdb, 0x24, 0x5c, 0x94, 0x00, 0xb2, 0x7a, 0x26, - 0x71, 0xbf, 0x71, 0x8a, 0x0e, 0x7e, 0x71, 0xea, 0x6c, 0x27, 0x03, 0x39, 0xa9, 0x20, 0x6f, 0xe1, - 0x7c, 0x02, 0x52, 0x4f, 0xfc, 0xe2, 0xf2, 0xde, 0x41, 0x09, 0xed, 0x1f, 0x94, 0xd0, 0xef, 0x83, - 0x12, 0xda, 0x39, 0x2c, 0xa5, 0xf6, 0x0f, 0x4b, 0xa9, 0x9f, 0x87, 0xa5, 0xd4, 0x1b, 0xdb, 0x69, - 0x05, 0xeb, 0xdd, 0xba, 0xdd, 0xe0, 0x6d, 0x13, 0x3c, 0xeb, 0xd2, 0xba, 0x08, 0x13, 0xf5, 0xe6, - 0xc9, 0x7b, 0x93, 0x2d, 0xd8, 0xf4, 0x99, 0xa8, 0x67, 0xd5, 0x5f, 0x81, 0xf9, 0x7f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xfe, 0x82, 0xb0, 0xa2, 0xb8, 0x08, 0x00, 0x00, + // 794 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0x4d, 0x4f, 0x53, 0x4b, + 0x18, 0xc7, 0x3b, 0x50, 0x4a, 0x78, 0x7a, 0x09, 0xf7, 0xce, 0xe5, 0xa6, 0xe5, 0xc0, 0x2d, 0xb5, + 0x12, 0x2c, 0x08, 0x67, 0x2c, 0x44, 0x13, 0x5f, 0x36, 0xa0, 0x41, 0x48, 0x88, 0xc1, 0x1a, 0x37, + 0x6e, 0xcc, 0xb4, 0x9d, 0x94, 0x26, 0x6d, 0xe7, 0xd0, 0x39, 0xad, 0x12, 0xc2, 0xc6, 0xe8, 0xde, + 0xc4, 0x44, 0xdd, 0x49, 0xdc, 0xea, 0x8a, 0x4f, 0xc1, 0x92, 0xc4, 0x8d, 0x2b, 0x63, 0xc0, 0x0f, + 0x62, 0xe6, 0xe5, 0xd0, 0xd3, 0x37, 0x68, 0x49, 0x17, 0xee, 0xce, 0x79, 0x5e, 0x7f, 0xf3, 0x9f, + 0x3e, 0xcf, 0x29, 0x4c, 0xe6, 0x98, 0x28, 0x71, 0x41, 0x1c, 0x2e, 0x5c, 0x41, 0x6a, 0x29, 0xb2, + 0x53, 0x65, 0x95, 0x5d, 0xdb, 0xa9, 0x70, 0x97, 0xe3, 0x31, 0xed, 0xb4, 0x95, 0xd3, 0xae, 0xa5, + 0xac, 0xf1, 0x3c, 0xcf, 0x73, 0xe5, 0x23, 0xf2, 0x49, 0x87, 0x59, 0x53, 0x79, 0xce, 0xf3, 0x45, + 0x46, 0xa8, 0x53, 0x20, 0xb4, 0x5c, 0xe6, 0x2e, 0x75, 0x0b, 0xbc, 0x2c, 0x8c, 0x77, 0x3e, 0xcb, + 0x55, 0x87, 0x0c, 0x15, 0x4c, 0x57, 0x27, 0xb5, 0x54, 0x86, 0xb9, 0x34, 0x45, 0x1c, 0x9a, 0x2f, + 0x94, 0x55, 0xb0, 0x57, 0xa9, 0x99, 0xa6, 0xc4, 0x73, 0xac, 0x68, 0x2a, 0x25, 0x5e, 0x23, 0x98, + 0x78, 0x2c, 0x0b, 0x3c, 0xa9, 0x66, 0x84, 0x43, 0xb3, 0x6c, 0x4b, 0x86, 0xa5, 0xd9, 0x4e, 0x95, + 0x09, 0x17, 0x4f, 0x43, 0x58, 0x18, 0xfb, 0xf3, 0x42, 0x2e, 0x8a, 0xe2, 0x28, 0x19, 0x4c, 0x83, + 0x67, 0xda, 0xc8, 0xe1, 0x35, 0x80, 0x7a, 0xc3, 0xe8, 0x40, 0x1c, 0x25, 0xc3, 0x4b, 0xb3, 0xb6, + 0xa6, 0xb3, 0x25, 0x9d, 0xad, 0xcf, 0x6e, 0xe8, 0xec, 0x2d, 0x9a, 0x67, 0xa6, 0x78, 0xda, 0x97, + 0x99, 0xf8, 0x88, 0xc0, 0x6a, 0x87, 0x21, 0x1c, 0x5e, 0x16, 0x0c, 0xa7, 0x60, 0x48, 0xe1, 0x47, + 0x51, 0x7c, 0x30, 0x19, 0x5e, 0xfa, 0xcf, 0x6e, 0x12, 0xd1, 0x96, 0xe1, 0xab, 0xc1, 0xa3, 0x1f, + 0xd3, 0x81, 0xb4, 0x8e, 0xc4, 0x0f, 0xdb, 0x90, 0x5d, 0xbb, 0x90, 0x4c, 0xf7, 0x6b, 0x40, 0xfb, + 0x8c, 0x20, 0xaa, 0xd1, 0x58, 0x56, 0x1a, 0x7a, 0x13, 0xe8, 0x7f, 0x00, 0xa1, 0xf3, 0xa4, 0x5f, + 0x62, 0x8c, 0xa6, 0x47, 0x8c, 0xa5, 0x45, 0xbf, 0xc1, 0x4b, 0xeb, 0xf7, 0xe1, 0xec, 0x1a, 0x1b, + 0x20, 0xff, 0x00, 0xf9, 0x36, 0xe1, 0x6f, 0x05, 0x26, 0x5b, 0x74, 0xad, 0x5a, 0x04, 0x86, 0x25, + 0x86, 0x27, 0x59, 0x30, 0x1d, 0x92, 0xaf, 0x1b, 0xb9, 0xc4, 0x03, 0xf8, 0xc7, 0x57, 0xcd, 0x1c, + 0x8f, 0x40, 0x50, 0xba, 0x55, 0x9d, 0x0b, 0x4e, 0xa7, 0x02, 0x13, 0x9f, 0x10, 0x4c, 0x9e, 0x95, + 0x59, 0x71, 0x5d, 0x9a, 0xdd, 0x2e, 0xb1, 0x72, 0x0f, 0xb7, 0xda, 0x89, 0xaf, 0x6f, 0xf7, 0xf9, + 0x15, 0xc1, 0x54, 0x7b, 0x42, 0x73, 0xe6, 0xfb, 0x10, 0xa6, 0x75, 0xb3, 0xb9, 0xd8, 0xc9, 0x96, + 0xa3, 0xd7, 0x53, 0x8d, 0x00, 0xfe, 0xac, 0xfe, 0x5d, 0xf2, 0x11, 0x82, 0x88, 0xc1, 0x2d, 0x16, + 0x57, 0xca, 0xe2, 0x05, 0xab, 0xf4, 0x41, 0x4c, 0xe5, 0x28, 0x16, 0xa5, 0x63, 0x50, 0x0d, 0x4e, + 0x48, 0xbe, 0x6e, 0xe4, 0x30, 0x86, 0x60, 0x55, 0xb0, 0x4a, 0x34, 0x18, 0x47, 0xc9, 0x91, 0xb4, + 0x7a, 0x6e, 0x52, 0x7e, 0xe8, 0xd2, 0xca, 0x1f, 0x78, 0xe3, 0xde, 0x70, 0x14, 0xa3, 0xfa, 0x5d, + 0x18, 0xa6, 0xda, 0xd4, 0x51, 0xf1, 0xa7, 0x82, 0x55, 0x74, 0x9a, 0x51, 0xdc, 0xcb, 0xe8, 0x9f, + 0xda, 0xe3, 0x80, 0x35, 0x21, 0xad, 0xd0, 0x92, 0xa7, 0x73, 0x62, 0x13, 0xfe, 0x6d, 0xb0, 0x1a, + 0xe4, 0x9b, 0x10, 0x72, 0x94, 0xc5, 0x8c, 0x47, 0xa4, 0x75, 0x3c, 0x94, 0xdb, 0xd0, 0x9a, 0xe0, + 0xa5, 0x2f, 0xc3, 0x30, 0xa4, 0xca, 0xe1, 0xf7, 0x08, 0x46, 0x1b, 0xb6, 0x32, 0x9e, 0x6f, 0x29, + 0xd1, 0xf1, 0x0b, 0x62, 0x5d, 0xef, 0x2a, 0x56, 0xb3, 0x26, 0x16, 0x5e, 0x7d, 0xfb, 0xf5, 0x6e, + 0x60, 0x16, 0xcf, 0x90, 0xe6, 0x6f, 0xd6, 0x9e, 0xef, 0x27, 0xb4, 0xaf, 0xcd, 0xf8, 0x00, 0xc1, + 0x5f, 0xfe, 0x75, 0x87, 0xe7, 0x3a, 0xf4, 0x6a, 0xdd, 0xdb, 0xd6, 0x7c, 0x37, 0xa1, 0x86, 0xea, + 0xb6, 0xa2, 0x5a, 0xc6, 0xa9, 0x0b, 0xa8, 0xf6, 0xea, 0x8b, 0xde, 0x43, 0x7c, 0x83, 0x20, 0x28, + 0x8b, 0xe1, 0x2b, 0xed, 0xfb, 0xf9, 0x96, 0xa2, 0x95, 0x38, 0x2f, 0xc4, 0xa0, 0xdc, 0x52, 0x28, + 0x37, 0xb0, 0xdd, 0x8d, 0x40, 0x64, 0xcf, 0x8c, 0xd5, 0x3e, 0x3e, 0x44, 0x30, 0xd6, 0xb4, 0x49, + 0xf0, 0x42, 0xe7, 0x7e, 0xad, 0x2b, 0xd1, 0x5a, 0xec, 0x32, 0xda, 0x80, 0xae, 0x2a, 0xd0, 0x7b, + 0xf8, 0x4e, 0x6f, 0xa0, 0xc4, 0xbf, 0x9d, 0x0e, 0x11, 0x84, 0x7d, 0x43, 0x88, 0x93, 0x9d, 0x10, + 0x9a, 0x57, 0x8e, 0x35, 0xd7, 0x45, 0xa4, 0x01, 0x7d, 0xa4, 0x40, 0xd7, 0xf1, 0x5a, 0x8f, 0xa0, + 0x72, 0x13, 0xa9, 0x77, 0xb5, 0x9f, 0xf6, 0x89, 0x37, 0xe4, 0x2e, 0x84, 0xf4, 0x3c, 0xe1, 0xab, + 0x1d, 0x20, 0xfc, 0x43, 0x6b, 0xcd, 0x9c, 0x1f, 0x64, 0x20, 0xa7, 0x15, 0xe4, 0x04, 0x8e, 0xb4, + 0x40, 0xea, 0x69, 0x5d, 0x5d, 0x3f, 0x3a, 0x89, 0xa1, 0xe3, 0x93, 0x18, 0xfa, 0x79, 0x12, 0x43, + 0x6f, 0x4f, 0x63, 0x81, 0xe3, 0xd3, 0x58, 0xe0, 0xfb, 0x69, 0x2c, 0xf0, 0xcc, 0xce, 0x17, 0xdc, + 0xed, 0x6a, 0xc6, 0xce, 0xf2, 0x92, 0x49, 0x5e, 0x2c, 0xd2, 0x8c, 0xf0, 0x0a, 0xd5, 0x96, 0xc9, + 0x4b, 0x53, 0xcd, 0xdd, 0x75, 0x98, 0xc8, 0x84, 0xd4, 0xdf, 0xc2, 0xe5, 0xdf, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x27, 0x4e, 0x44, 0x54, 0xc4, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -652,8 +780,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Posts queries all the posts inside a given subspace - Posts(ctx context.Context, in *QueryPostsRequest, opts ...grpc.CallOption) (*QueryPostsResponse, error) + // SubspacePosts queries all the posts inside a given subspace + SubspacePosts(ctx context.Context, in *QuerySubspacePostsRequest, opts ...grpc.CallOption) (*QuerySubspacePostsResponse, error) + // SectionPosts queries all the posts inside a given section + SectionPosts(ctx context.Context, in *QuerySectionPostsRequest, opts ...grpc.CallOption) (*QuerySectionPostsResponse, error) // Post queries for a single post inside a given subspace Post(ctx context.Context, in *QueryPostRequest, opts ...grpc.CallOption) (*QueryPostResponse, error) // PostAttachments queries the attachments of the post having the given id @@ -672,9 +802,18 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Posts(ctx context.Context, in *QueryPostsRequest, opts ...grpc.CallOption) (*QueryPostsResponse, error) { - out := new(QueryPostsResponse) - err := c.cc.Invoke(ctx, "/desmos.posts.v1.Query/Posts", in, out, opts...) +func (c *queryClient) SubspacePosts(ctx context.Context, in *QuerySubspacePostsRequest, opts ...grpc.CallOption) (*QuerySubspacePostsResponse, error) { + out := new(QuerySubspacePostsResponse) + err := c.cc.Invoke(ctx, "/desmos.posts.v1.Query/SubspacePosts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) SectionPosts(ctx context.Context, in *QuerySectionPostsRequest, opts ...grpc.CallOption) (*QuerySectionPostsResponse, error) { + out := new(QuerySectionPostsResponse) + err := c.cc.Invoke(ctx, "/desmos.posts.v1.Query/SectionPosts", in, out, opts...) if err != nil { return nil, err } @@ -719,8 +858,10 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . // QueryServer is the server API for Query service. type QueryServer interface { - // Posts queries all the posts inside a given subspace - Posts(context.Context, *QueryPostsRequest) (*QueryPostsResponse, error) + // SubspacePosts queries all the posts inside a given subspace + SubspacePosts(context.Context, *QuerySubspacePostsRequest) (*QuerySubspacePostsResponse, error) + // SectionPosts queries all the posts inside a given section + SectionPosts(context.Context, *QuerySectionPostsRequest) (*QuerySectionPostsResponse, error) // Post queries for a single post inside a given subspace Post(context.Context, *QueryPostRequest) (*QueryPostResponse, error) // PostAttachments queries the attachments of the post having the given id @@ -735,8 +876,11 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Posts(ctx context.Context, req *QueryPostsRequest) (*QueryPostsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Posts not implemented") +func (*UnimplementedQueryServer) SubspacePosts(ctx context.Context, req *QuerySubspacePostsRequest) (*QuerySubspacePostsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubspacePosts not implemented") +} +func (*UnimplementedQueryServer) SectionPosts(ctx context.Context, req *QuerySectionPostsRequest) (*QuerySectionPostsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SectionPosts not implemented") } func (*UnimplementedQueryServer) Post(ctx context.Context, req *QueryPostRequest) (*QueryPostResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Post not implemented") @@ -755,20 +899,38 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Posts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPostsRequest) +func _Query_SubspacePosts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySubspacePostsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Posts(ctx, in) + return srv.(QueryServer).SubspacePosts(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.posts.v1.Query/Posts", + FullMethod: "/desmos.posts.v1.Query/SubspacePosts", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Posts(ctx, req.(*QueryPostsRequest)) + return srv.(QueryServer).SubspacePosts(ctx, req.(*QuerySubspacePostsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_SectionPosts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySectionPostsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SectionPosts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.posts.v1.Query/SectionPosts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SectionPosts(ctx, req.(*QuerySectionPostsRequest)) } return interceptor(ctx, in, info, handler) } @@ -850,8 +1012,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Posts", - Handler: _Query_Posts_Handler, + MethodName: "SubspacePosts", + Handler: _Query_SubspacePosts_Handler, + }, + { + MethodName: "SectionPosts", + Handler: _Query_SectionPosts_Handler, }, { MethodName: "Post", @@ -874,7 +1040,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "desmos/posts/v1/query.proto", } -func (m *QueryPostsRequest) Marshal() (dAtA []byte, err error) { +func (m *QuerySubspacePostsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -884,12 +1050,12 @@ func (m *QueryPostsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPostsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QuerySubspacePostsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPostsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QuerySubspacePostsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -914,7 +1080,7 @@ func (m *QueryPostsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryPostsResponse) Marshal() (dAtA []byte, err error) { +func (m *QuerySubspacePostsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -924,12 +1090,106 @@ func (m *QueryPostsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPostsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QuerySubspacePostsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPostsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QuerySubspacePostsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Posts) > 0 { + for iNdEx := len(m.Posts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Posts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QuerySectionPostsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySectionPostsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySectionPostsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.SectionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SectionId)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SubspaceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QuerySectionPostsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySectionPostsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySectionPostsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1296,7 +1556,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryPostsRequest) Size() (n int) { +func (m *QuerySubspacePostsRequest) Size() (n int) { if m == nil { return 0 } @@ -1312,7 +1572,45 @@ func (m *QueryPostsRequest) Size() (n int) { return n } -func (m *QueryPostsResponse) Size() (n int) { +func (m *QuerySubspacePostsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Posts) > 0 { + for _, e := range m.Posts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySectionPostsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceId != 0 { + n += 1 + sovQuery(uint64(m.SubspaceId)) + } + if m.SectionId != 0 { + n += 1 + sovQuery(uint64(m.SectionId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySectionPostsResponse) Size() (n int) { if m == nil { return 0 } @@ -1466,7 +1764,232 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryPostsRequest) Unmarshal(dAtA []byte) error { +func (m *QuerySubspacePostsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySubspacePostsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySubspacePostsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceId", wireType) + } + m.SubspaceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySubspacePostsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySubspacePostsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySubspacePostsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Posts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Posts = append(m.Posts, Post{}) + if err := m.Posts[len(m.Posts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySectionPostsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1489,10 +2012,10 @@ func (m *QueryPostsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPostsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySectionPostsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPostsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySectionPostsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1515,6 +2038,25 @@ func (m *QueryPostsRequest) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionId", wireType) + } + m.SectionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } @@ -1571,7 +2113,7 @@ func (m *QueryPostsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPostsResponse) Unmarshal(dAtA []byte) error { +func (m *QuerySectionPostsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1594,10 +2136,10 @@ func (m *QueryPostsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPostsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySectionPostsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPostsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySectionPostsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/posts/types/query.pb.gw.go b/x/posts/types/query.pb.gw.go index f6e5d99505..095d64d845 100644 --- a/x/posts/types/query.pb.gw.go +++ b/x/posts/types/query.pb.gw.go @@ -32,11 +32,11 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var ( - filter_Query_Posts_0 = &utilities.DoubleArray{Encoding: map[string]int{"subspace_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_SubspacePosts_0 = &utilities.DoubleArray{Encoding: map[string]int{"subspace_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) -func request_Query_Posts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPostsRequest +func request_Query_SubspacePosts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySubspacePostsRequest var metadata runtime.ServerMetadata var ( @@ -60,17 +60,17 @@ func request_Query_Posts_0(ctx context.Context, marshaler runtime.Marshaler, cli if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Posts_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SubspacePosts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.Posts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.SubspacePosts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Posts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPostsRequest +func local_request_Query_SubspacePosts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySubspacePostsRequest var metadata runtime.ServerMetadata var ( @@ -94,11 +94,105 @@ func local_request_Query_Posts_0(ctx context.Context, marshaler runtime.Marshale if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Posts_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SubspacePosts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Posts(ctx, &protoReq) + msg, err := server.SubspacePosts(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_SectionPosts_0 = &utilities.DoubleArray{Encoding: map[string]int{"subspace_id": 0, "section_id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Query_SectionPosts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySectionPostsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subspace_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subspace_id") + } + + protoReq.SubspaceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subspace_id", err) + } + + val, ok = pathParams["section_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "section_id") + } + + protoReq.SectionId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "section_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SectionPosts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SectionPosts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SectionPosts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySectionPostsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subspace_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subspace_id") + } + + protoReq.SubspaceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subspace_id", err) + } + + val, ok = pathParams["section_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "section_id") + } + + protoReq.SectionId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "section_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SectionPosts_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SectionPosts(ctx, &protoReq) return msg, metadata, err } @@ -413,7 +507,27 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Posts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_SubspacePosts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_SubspacePosts_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SubspacePosts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_SectionPosts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -422,14 +536,14 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Posts_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_SectionPosts_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Posts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_SectionPosts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -554,7 +668,27 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Posts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_SubspacePosts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_SubspacePosts_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SubspacePosts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_SectionPosts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -563,14 +697,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Posts_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_SectionPosts_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Posts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_SectionPosts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -658,7 +792,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Posts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 1}, []string{"desmos", "posts", "v1", "subspace_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_SubspacePosts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 1}, []string{"desmos", "posts", "v1", "subspace_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_SectionPosts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 1}, []string{"desmos", "posts", "v1", "subspace_id", "section_id"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_Post_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 1, 1, 0, 4, 1, 5, 4}, []string{"desmos", "posts", "v1", "subspace_id", "post_id"}, "", runtime.AssumeColonVerbOpt(true))) @@ -670,7 +806,9 @@ var ( ) var ( - forward_Query_Posts_0 = runtime.ForwardResponseMessage + forward_Query_SubspacePosts_0 = runtime.ForwardResponseMessage + + forward_Query_SectionPosts_0 = runtime.ForwardResponseMessage forward_Query_Post_0 = runtime.ForwardResponseMessage diff --git a/x/profiles/simulation/operations_dtag_transfers.go b/x/profiles/simulation/operations_dtag_transfers.go index 8d80366af7..06f1f5e3b8 100644 --- a/x/profiles/simulation/operations_dtag_transfers.go +++ b/x/profiles/simulation/operations_dtag_transfers.go @@ -167,24 +167,28 @@ func randomRefuseDTagTransferFields( return simtypes.Account{}, simtypes.Account{}, true } - // Get random accounts - sender, _ := simtypes.RandomAcc(r, accs) - receiver, _ := simtypes.RandomAcc(r, accs) + // Get a random request + requests := k.GetDTagTransferRequests(ctx) + if len(requests) == 0 { + return simtypes.Account{}, simtypes.Account{}, true + } + request := RandomDTagTransferRequest(r, requests) - // skip if the two addresses are equals - if sender.Equals(receiver) { + // Get the sender account + senderAddr, _ := sdk.AccAddressFromBech32(request.Sender) + senderAcc := GetSimAccount(senderAddr, accs) + if senderAcc == nil { return simtypes.Account{}, simtypes.Account{}, true } + sender := *senderAcc - req := types.NewDTagTransferRequest( - "dtag", - sender.Address.String(), - receiver.Address.String(), - ) - err := k.SaveDTagTransferRequest(ctx, req) - if err != nil { + // Get the receiver account + receiverAddr, _ := sdk.AccAddressFromBech32(request.Receiver) + receiverAcc := GetSimAccount(receiverAddr, accs) + if receiverAcc == nil { return simtypes.Account{}, simtypes.Account{}, true } + receiver := *receiverAcc return sender, receiver, false } @@ -226,20 +230,28 @@ func randomCancelDTagTransferFields( return simtypes.Account{}, simtypes.Account{}, true } - // Get random accounts - sender, _ := simtypes.RandomAcc(r, accs) - receiver, _ := simtypes.RandomAcc(r, accs) + // Get a random request + requests := k.GetDTagTransferRequests(ctx) + if len(requests) == 0 { + return simtypes.Account{}, simtypes.Account{}, true + } + request := RandomDTagTransferRequest(r, requests) - // skip if the two addresses are equals - if receiver.Equals(sender) { + // Get the sender account + senderAddr, _ := sdk.AccAddressFromBech32(request.Sender) + senderAcc := GetSimAccount(senderAddr, accs) + if senderAcc == nil { return simtypes.Account{}, simtypes.Account{}, true } + sender := *senderAcc - req := types.NewDTagTransferRequest("dtag", sender.Address.String(), receiver.Address.String()) - err := k.SaveDTagTransferRequest(ctx, req) - if err != nil { + // Get the receiver account + receiverAddr, _ := sdk.AccAddressFromBech32(request.Receiver) + receiverAcc := GetSimAccount(receiverAddr, accs) + if receiverAcc == nil { return simtypes.Account{}, simtypes.Account{}, true } + receiver := *receiverAcc return sender, receiver, false } diff --git a/x/relationships/keeper/hooks.go b/x/relationships/keeper/hooks.go index 10ed0984b2..93409628c8 100644 --- a/x/relationships/keeper/hooks.go +++ b/x/relationships/keeper/hooks.go @@ -41,10 +41,12 @@ func (h Hooks) AfterSubspaceDeleted(ctx sdk.Context, subspaceID uint64) { } } -func (h Hooks) AfterSubspaceGroupSaved(sdk.Context, uint64, uint32) {} -func (h Hooks) AfterSubspaceGroupMemberAdded(sdk.Context, uint64, uint32, sdk.AccAddress) {} -func (h Hooks) AfterSubspaceGroupMemberRemoved(sdk.Context, uint64, uint32, sdk.AccAddress) {} -func (h Hooks) AfterSubspaceGroupDeleted(sdk.Context, uint64, uint32) {} -func (h Hooks) AfterUserPermissionSet(sdk.Context, uint64, sdk.AccAddress, subspacestypes.Permission) { +func (h Hooks) AfterSubspaceSectionSaved(sdk.Context, uint64, uint32) {} +func (h Hooks) AfterSubspaceSectionDeleted(sdk.Context, uint64, uint32) {} +func (h Hooks) AfterSubspaceGroupSaved(sdk.Context, uint64, uint32) {} +func (h Hooks) AfterSubspaceGroupMemberAdded(sdk.Context, uint64, uint32, string) {} +func (h Hooks) AfterSubspaceGroupMemberRemoved(sdk.Context, uint64, uint32, string) {} +func (h Hooks) AfterSubspaceGroupDeleted(sdk.Context, uint64, uint32) {} +func (h Hooks) AfterUserPermissionSet(sdk.Context, uint64, uint32, string, subspacestypes.Permission) { } -func (h Hooks) AfterUserPermissionRemoved(sdk.Context, uint64, sdk.AccAddress) {} +func (h Hooks) AfterUserPermissionRemoved(sdk.Context, uint64, uint32, string) {} diff --git a/x/relationships/simulation/genesis.go b/x/relationships/simulation/genesis.go index 738f667efb..75c41f7505 100644 --- a/x/relationships/simulation/genesis.go +++ b/x/relationships/simulation/genesis.go @@ -57,7 +57,7 @@ func RandomizedGenState(simsState *module.SimulationState) { // randomRelationships returns randomly generated genesis relationships and their associated users - IDs map func randomRelationships( - r *rand.Rand, accounts []authtypes.GenesisAccount, subspaces []subspacestypes.GenesisSubspace, number int, + r *rand.Rand, accounts []authtypes.GenesisAccount, subspaces []subspacestypes.Subspace, number int, ) []types.Relationship { relationships := make([]types.Relationship, number) for index := 0; index < number; { @@ -69,11 +69,11 @@ func randomRelationships( continue } - subspace := subspacessim.RandomGenesisSubspace(r, subspaces) + subspace := subspacessim.RandomSubspace(r, subspaces) relationship := types.NewRelationship( user.GetAddress().String(), counterparty.GetAddress().String(), - subspace.Subspace.ID, + subspace.ID, ) if !containsRelationship(relationships, relationship) { @@ -100,7 +100,7 @@ func containsRelationship(slice []types.Relationship, relationship types.Relatio // randomUsersBlocks func randomUsersBlocks( - r *rand.Rand, accounts []authtypes.GenesisAccount, subspaces []subspacestypes.GenesisSubspace, number int, + r *rand.Rand, accounts []authtypes.GenesisAccount, subspaces []subspacestypes.Subspace, number int, ) []types.UserBlock { usersBlocks := make([]types.UserBlock, number) for index := 0; index < number; { @@ -112,12 +112,12 @@ func randomUsersBlocks( continue } - subspace := subspacessim.RandomGenesisSubspace(r, subspaces) + subspace := subspacessim.RandomSubspace(r, subspaces) block := types.NewUserBlock( blocker.GetAddress().String(), blocked.GetAddress().String(), "", - subspace.Subspace.ID, + subspace.ID, ) if !containsUserBlock(usersBlocks, block) { diff --git a/x/subspaces/client/cli/cli_test.go b/x/subspaces/client/cli/cli_test.go index 63f500b5e5..9141846121 100644 --- a/x/subspaces/client/cli/cli_test.go +++ b/x/subspaces/client/cli/cli_test.go @@ -41,62 +41,70 @@ func (s *IntegrationTestSuite) SetupSuite() { // Initialize the module genesis data genesis := types.NewGenesisState( - 3, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), + 4, + []types.SubspaceData{ + types.NewSubspaceData(1, 3, 2), + types.NewSubspaceData(2, 1, 3), + types.NewSubspaceData(3, 1, 1), + }, + []types.Subspace{ + types.NewSubspace( 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), ), - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), + types.NewSubspace( + 2, + "Another test subspace", + "This is another test subspace", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), + ), + types.NewSubspace( 3, + "Subspace to delete", + "This is a test subspace that will be deleted", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), ), - types.NewGenesisSubspace( - types.NewSubspace( - 3, - "Subspace to delete", - "This is a test subspace that will be deleted", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), + }, + []types.Section{ + types.NewSection( + 1, 1, + 0, + "Test section", + "Test section", + ), + types.NewSection( + 1, + 2, + 0, + "Another test section", + "Another test section", ), }, - []types.ACLEntry{ - types.NewACLEntry(1, "cosmos1xw69y2z3yf00rgfnly99628gn5c0x7fryyfv5e", types.PermissionWrite), - types.NewACLEntry(2, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionManageGroups), + []types.UserPermission{ + types.NewUserPermission(1, 0, "cosmos1xw69y2z3yf00rgfnly99628gn5c0x7fryyfv5e", types.PermissionWrite), + types.NewUserPermission(2, 0, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionManageGroups), }, []types.UserGroup{ - types.NewUserGroup(1, 1, "Test group", "", types.PermissionWrite), - types.NewUserGroup(2, 1, "Another test group", "", types.PermissionManageGroups), - types.NewUserGroup(2, 2, "Third group", "", types.PermissionWrite), + types.NewUserGroup(1, 0, 1, "Test group", "", types.PermissionWrite), + types.NewUserGroup(2, 0, 1, "Another test group", "", types.PermissionManageGroups), + types.NewUserGroup(2, 0, 2, "Third group", "", types.PermissionWrite), }, - []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 1, []string{ - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - }), - types.NewUserGroupMembersEntry(2, 1, []string{ - "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - }), + []types.UserGroupMemberEntry{ + types.NewUserGroupMemberEntry(1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm"), + types.NewUserGroupMemberEntry(2, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), + types.NewUserGroupMemberEntry(2, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), }, ) @@ -231,6 +239,114 @@ func (s *IntegrationTestSuite) TestCmdQuerySubspaces() { } } +func (s *IntegrationTestSuite) TestCmdQuerySection() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + expResponse types.QuerySectionResponse + }{ + { + name: "non existing section returns error", + args: []string{ + "1", "10", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + shouldErr: true, + }, + { + name: "existing section is returned correctly", + args: []string{ + "1", "1", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + shouldErr: false, + expResponse: types.QuerySectionResponse{ + Section: types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + ), + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQuerySection() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + var response types.QuerySectionResponse + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().Equal(response.Section, tc.expResponse.Section) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdQuerySections() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + expResponse types.QuerySectionsResponse + }{ + { + name: "sections are returned correctly", + args: []string{ + "1", + fmt.Sprintf("--%s=%d", flags.FlagLimit, 1), + fmt.Sprintf("--%s=%d", flags.FlagPage, 2), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + shouldErr: false, + expResponse: types.QuerySectionsResponse{ + Sections: []types.Section{ + types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + ), + }, + }, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQuerySections() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + var response types.QuerySectionsResponse + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), &response), out.String()) + s.Require().Equal(tc.expResponse.Sections, response.Sections) + } + }) + } +} + func (s *IntegrationTestSuite) TestCmdQueryUserGroups() { val := s.network.Validators[0] testCases := []struct { @@ -249,8 +365,8 @@ func (s *IntegrationTestSuite) TestCmdQueryUserGroups() { expResponse: types.QueryUserGroupsResponse{ Groups: []types.UserGroup{ types.DefaultUserGroup(2), - types.NewUserGroup(2, 1, "Another test group", "", types.PermissionManageGroups), - types.NewUserGroup(2, 2, "Third group", "", types.PermissionWrite), + types.NewUserGroup(2, 0, 1, "Another test group", "", types.PermissionManageGroups), + types.NewUserGroup(2, 0, 2, "Third group", "", types.PermissionWrite), }, }, }, @@ -349,7 +465,7 @@ func (s *IntegrationTestSuite) TestCmdQueryUserGroupMembers() { shouldErr: false, expResponse: types.QueryUserGroupMembersResponse{ Members: []string{ - "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", }, }, }, @@ -402,8 +518,8 @@ func (s *IntegrationTestSuite) TestCmdQueryUserPermissions() { expResponse: types.QueryUserPermissionsResponse{ Permissions: types.PermissionManageGroups, Details: []types.PermissionDetail{ - types.NewPermissionDetailGroup(0, types.PermissionNothing), - types.NewPermissionDetailGroup(1, types.PermissionManageGroups), + types.NewPermissionDetailGroup(2, 0, 0, types.PermissionNothing), + types.NewPermissionDetailGroup(2, 0, 1, types.PermissionManageGroups), }, }, }, @@ -598,6 +714,222 @@ func (s *IntegrationTestSuite) TestCmdDeleteSubspace() { } } +func (s *IntegrationTestSuite) TestCmdCreateSection() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + respType proto.Message + }{ + { + name: "invalid subspace id returns error", + args: []string{ + "0", "This is a new section", + }, + shouldErr: true, + }, + { + name: "invalid name returns error", + args: []string{ + "1", "", + }, + shouldErr: true, + }, + { + name: "valid data returns no error", + args: []string{ + "1", "Test section", + fmt.Sprintf("--%s=%s", cli.FlagDescription, "This is a test section"), + fmt.Sprintf("--%s=%s", cli.FlagParent, "1"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + shouldErr: false, + respType: &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdCreateSection() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdEditSection() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + respType proto.Message + }{ + { + name: "invalid subspace id returns error", + args: []string{ + "0", "1", + }, + shouldErr: true, + }, + { + name: "invalid name returns error", + args: []string{ + "1", "1", + fmt.Sprintf("--%s=%s", cli.FlagName, ""), + }, + shouldErr: true, + }, + { + name: "valid data returns no error", + args: []string{ + "1", "1", + fmt.Sprintf("--%s=%s", cli.FlagName, "Edited name"), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + shouldErr: false, + respType: &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdEditSection() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdMoveSection() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + respType proto.Message + }{ + { + name: "invalid subspace id returns error", + args: []string{ + "0", "1", "2", + }, + shouldErr: true, + }, + { + name: "invalid section id returns error", + args: []string{ + "1", "0", "2", + }, + shouldErr: true, + }, + { + name: "valid data returns no error", + args: []string{ + "1", "1", "2", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + shouldErr: false, + respType: &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdMoveSection() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdDeleteSection() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + respType proto.Message + }{ + { + name: "invalid subspace id returns error", + args: []string{ + "0", "1", + }, + shouldErr: true, + }, + { + name: "invalid section id returns error", + args: []string{ + "1", "0", + }, + shouldErr: true, + }, + { + name: "valid data returns no error", + args: []string{ + "1", "1", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + shouldErr: false, + respType: &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdDeleteSection() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} + func (s *IntegrationTestSuite) TestCmdCreateUserGroup() { val := s.network.Validators[0] testCases := []struct { @@ -710,6 +1042,52 @@ func (s *IntegrationTestSuite) TestCmdEditUserGroup() { } } +func (s *IntegrationTestSuite) TestCmdMoveUserGroup() { + val := s.network.Validators[0] + testCases := []struct { + name string + args []string + shouldErr bool + respType proto.Message + }{ + { + name: "invalid subspace id returns error", + args: []string{ + "0", "1", "2", + }, + shouldErr: true, + }, + { + name: "valid data returns no error", + args: []string{ + "1", "1", "2", + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + shouldErr: false, + respType: &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdMoveUserGroup() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.shouldErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().NoError(clientCtx.JSONCodec.UnmarshalJSON(out.Bytes(), tc.respType), out.String()) + } + }) + } +} + func (s *IntegrationTestSuite) TestCmdSetUserGroupPermissions() { val := s.network.Validators[0] testCases := []struct { diff --git a/x/subspaces/client/cli/query.go b/x/subspaces/client/cli/query.go index 946ddc1711..ad0516b404 100644 --- a/x/subspaces/client/cli/query.go +++ b/x/subspaces/client/cli/query.go @@ -26,7 +26,7 @@ func GetQueryCmd() *cobra.Command { subspaceQueryCmd.AddCommand( GetCmdQuerySubspace(), GetCmdQuerySubspaces(), - + GetSectionsQueryCmd(), GetGroupsQueryCmd(), GetCmdQueryUserPermissions(), ) @@ -102,6 +102,109 @@ func GetCmdQuerySubspaces() *cobra.Command { // ------------------------------------------------------------------------------------------------------------------- +// GetSectionsQueryCmd returns a new command to perform queries for sections +func GetSectionsQueryCmd() *cobra.Command { + groupsQueryCmd := &cobra.Command{ + Use: "sections", + Short: "Querying commands for subspace sections", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + groupsQueryCmd.AddCommand( + GetCmdQuerySection(), + GetCmdQuerySections(), + ) + + return groupsQueryCmd +} + +// GetCmdQuerySection returns the command to query a specific section of a subspace +func GetCmdQuerySection() *cobra.Command { + cmd := &cobra.Command{ + Use: "section [subspace-id] [section-id]", + Short: "Query the section with the given id in the given subspace", + Example: fmt.Sprintf(`%s query subspaces sections section 1 2`, version.AppName), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + sectionID, err := types.ParseSectionID(args[1]) + if err != nil { + return err + } + + res, err := queryClient.Section( + context.Background(), + types.NewQuerySectionRequest(subspaceID, sectionID), + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQuerySections returns the command to query the sections of a subspace +func GetCmdQuerySections() *cobra.Command { + cmd := &cobra.Command{ + Use: "list [subspace-id]", + Short: "Query sections in the given subspace with optional pagination", + Example: fmt.Sprintf(`%s query subspaces sections list 1 --page=2 --limit=100`, version.AppName), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + res, err := queryClient.Sections( + context.Background(), + types.NewQuerySectionsRequest(subspaceID, pageReq), + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "sections") + + return cmd +} + +// ------------------------------------------------------------------------------------------------------------------- + // GetGroupsQueryCmd returns a new command to perform queries for user groups func GetGroupsQueryCmd() *cobra.Command { groupsQueryCmd := &cobra.Command{ @@ -145,9 +248,14 @@ func GetCmdQueryUserGroups() *cobra.Command { return err } + sectionID, err := cmd.Flags().GetUint32(FlagSection) + if err != nil { + return err + } + res, err := queryClient.UserGroups( context.Background(), - types.NewQueryUserGroupsRequest(subspaceID, pageReq), + types.NewQueryUserGroupsRequest(subspaceID, sectionID, pageReq), ) if err != nil { return err @@ -157,6 +265,8 @@ func GetCmdQueryUserGroups() *cobra.Command { }, } + cmd.Flags().Uint32(FlagSection, 0, "Section for which to query the groups") + flags.AddQueryFlagsToCmd(cmd) flags.AddPaginationFlagsToCmd(cmd, "user groups") diff --git a/x/subspaces/client/cli/tx.go b/x/subspaces/client/cli/tx.go index 56cbee2e77..cfb3b1f3d7 100644 --- a/x/subspaces/client/cli/tx.go +++ b/x/subspaces/client/cli/tx.go @@ -18,6 +18,8 @@ import ( const ( FlagName = "name" FlagDescription = "description" + FlagParent = "parent" + FlagSection = "section" FlagTreasury = "treasury" FlagOwner = "owner" FlagPermissions = "permissions" @@ -37,9 +39,8 @@ func NewTxCmd() *cobra.Command { GetCmdCreateSubspace(), GetCmdEditSubspace(), GetCmdDeleteSubspace(), - + NewSectionsTxCmd(), NewGroupsTxCmd(), - GetCmdSetUserPermissions(), ) @@ -200,6 +201,216 @@ func GetCmdDeleteSubspace() *cobra.Command { // ------------------------------------------------------------------------------------------------------------------- +// NewSectionsTxCmd returns a new command to perform subspaces sections transactions +func NewSectionsTxCmd() *cobra.Command { + groupsTxCmd := &cobra.Command{ + Use: "sections", + Short: "Subspace sections transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + groupsTxCmd.AddCommand( + GetCmdCreateSection(), + GetCmdEditSection(), + GetCmdMoveSection(), + GetCmdDeleteSection(), + ) + + return groupsTxCmd +} + +// GetCmdCreateSection returns the command used to create a subspace section +func GetCmdCreateSection() *cobra.Command { + cmd := &cobra.Command{ + Use: "create [subspace-id] [name]", + Args: cobra.ExactArgs(2), + Short: "Create a new section within a subspace", + Long: `Create a new section within the subspace with the provided id. +The name must be a human readable name.`, + Example: fmt.Sprintf(` +%s tx subspaces sections create 1 "Custom section" \ + --description "This is my custom section" \ + --parent 1 \ + --from alice +`, version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + name := args[0] + + description, err := cmd.Flags().GetString(FlagDescription) + if err != nil { + return err + } + + parentID, err := cmd.Flags().GetUint32(FlagParent) + if err != nil { + return err + } + + msg := types.NewMsgCreateSection(subspaceID, name, description, parentID, clientCtx.FromAddress.String()) + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(FlagDescription, "", "Description of the section") + cmd.Flags().Uint32(FlagParent, 0, "Id of the parent section") + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdEditSection returns the command to edit a subspace section +func GetCmdEditSection() *cobra.Command { + cmd := &cobra.Command{ + Use: "edit [subspace-id] [section-id]", + Args: cobra.ExactArgs(2), + Short: "Edit the subspace section with the given id", + Example: fmt.Sprintf(` +%s tx subspaces edit 1 1 \ + --name "Desmos - Democratizing social networks" + --description "The official subspace of Desmos" \ + --from alice +`, version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + sectionID, err := types.ParseSectionID(args[1]) + if err != nil { + return err + } + + name, err := cmd.Flags().GetString(FlagName) + if err != nil { + return err + } + + description, err := cmd.Flags().GetString(FlagDescription) + if err != nil { + return err + } + + msg := types.NewMsgEditSection(subspaceID, sectionID, name, description, clientCtx.FromAddress.String()) + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(FlagName, types.DoNotModify, "New human readable name of the section") + cmd.Flags().String(FlagDescription, types.DoNotModify, "New description of the section") + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdMoveSection returns the command to delete a subspace section +func GetCmdMoveSection() *cobra.Command { + cmd := &cobra.Command{ + Use: "move [subspace-id] [section-id] [new-parent-id]", + Args: cobra.ExactArgs(3), + Short: "Move the subspace section with the given id to the new parent", + Example: fmt.Sprintf(`%s tx subspaces delete 1 1 2 --from alice`, version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + sectionID, err := types.ParseSectionID(args[1]) + if err != nil { + return err + } + + newParentID, err := types.ParseSectionID(args[2]) + if err != nil { + return err + } + + msg := types.NewMsgMoveSection(subspaceID, sectionID, newParentID, clientCtx.FromAddress.String()) + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdDeleteSection returns the command to delete a subspace section +func GetCmdDeleteSection() *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [subspace-id] [section-id]", + Args: cobra.ExactArgs(2), + Short: "Deletes the subspace section with the given id", + Example: fmt.Sprintf(`%s tx subspaces delete 1 1 --from alice`, version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + sectionID, err := types.ParseSectionID(args[1]) + if err != nil { + return err + } + + msg := types.NewMsgDeleteSection(subspaceID, sectionID, clientCtx.FromAddress.String()) + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// ------------------------------------------------------------------------------------------------------------------- + // NewGroupsTxCmd returns a new command to perform subspaces groups transactions func NewGroupsTxCmd() *cobra.Command { groupsTxCmd := &cobra.Command{ @@ -213,6 +424,7 @@ func NewGroupsTxCmd() *cobra.Command { groupsTxCmd.AddCommand( GetCmdCreateUserGroup(), GetCmdEditUserGroup(), + GetCmdMoveUserGroup(), GetCmdSetUserGroupPermissions(), GetCmdDeleteUserGroup(), GetCmdAddUserToUserGroup(), @@ -226,7 +438,7 @@ func NewGroupsTxCmd() *cobra.Command { func GetCmdCreateUserGroup() *cobra.Command { cmd := &cobra.Command{ Use: "create [subspace-id] [group-name]", - Args: cobra.MinimumNArgs(2), + Args: cobra.ExactArgs(2), Short: "Create a new user group within a subspace", Long: fmt.Sprintf(`Create a new user group within the subspace having the provided id. @@ -259,6 +471,11 @@ Multiple permissions must be specified separating them with a comma (,).`, FlagD return err } + sectionID, err := cmd.Flags().GetUint32(FlagSection) + if err != nil { + return err + } + permissions, err := cmd.Flags().GetStringSlice(FlagPermissions) if err != nil { return err @@ -273,7 +490,7 @@ Multiple permissions must be specified separating them with a comma (,).`, FlagD permission = types.CombinePermissions(permission, perm) } - msg := types.NewMsgCreateUserGroup(subspaceID, name, description, permission, clientCtx.FromAddress.String()) + msg := types.NewMsgCreateUserGroup(subspaceID, sectionID, name, description, permission, clientCtx.FromAddress.String()) if err = msg.ValidateBasic(); err != nil { return fmt.Errorf("message validation failed: %w", err) } @@ -282,6 +499,7 @@ Multiple permissions must be specified separating them with a comma (,).`, FlagD }, } + cmd.Flags().Uint32(FlagSection, 0, "Id of the section inside which to create the group") cmd.Flags().String(FlagDescription, "", "Description of the group") cmd.Flags().StringSlice(FlagPermissions, []string{types.SerializePermission(types.PermissionNothing)}, "Permissions of the group") flags.AddTxFlagsToCmd(cmd) @@ -344,6 +562,48 @@ func GetCmdEditUserGroup() *cobra.Command { return cmd } +// GetCmdMoveUserGroup returns the command to move a user group to another section +func GetCmdMoveUserGroup() *cobra.Command { + cmd := &cobra.Command{ + Use: "move [subspace-id] [group-id] [new-section-id]", + Args: cobra.ExactArgs(3), + Short: "Move a user group to a new section", + Example: fmt.Sprintf(`%s tx subspaces groups move 1 1 2 --from alice`, version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + subspaceID, err := types.ParseSubspaceID(args[0]) + if err != nil { + return err + } + + groupID, err := types.ParseGroupID(args[1]) + if err != nil { + return err + } + + newSectionID, err := types.ParseSectionID(args[2]) + if err != nil { + return err + } + + msg := types.NewMsgMoveUserGroup(subspaceID, groupID, newSectionID, clientCtx.FromAddress.String()) + if err = msg.ValidateBasic(); err != nil { + return fmt.Errorf("message validation failed: %w", err) + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + // GetCmdSetUserGroupPermissions returns the command to set the permissions for a user group func GetCmdSetUserGroupPermissions() *cobra.Command { cmd := &cobra.Command{ @@ -545,6 +805,11 @@ When specifying multiple permissions, they must be separated by a comma (,).`, return err } + sectionID, err := cmd.Flags().GetUint32(FlagSection) + if err != nil { + return err + } + user := args[1] permission := types.PermissionNothing @@ -556,7 +821,7 @@ When specifying multiple permissions, they must be separated by a comma (,).`, permission = types.CombinePermissions(permission, perm) } - msg := types.NewMsgSetUserPermissions(subspaceID, user, permission, clientCtx.FromAddress.String()) + msg := types.NewMsgSetUserPermissions(subspaceID, sectionID, user, permission, clientCtx.FromAddress.String()) if err = msg.ValidateBasic(); err != nil { return fmt.Errorf("message validation failed: %w", err) } @@ -565,6 +830,7 @@ When specifying multiple permissions, they must be separated by a comma (,).`, }, } + cmd.Flags().Uint32(FlagSection, 0, "Id of the section inside which to set the permissions") flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/subspaces/keeper/alias_functions.go b/x/subspaces/keeper/alias_functions.go index 15fb77a5e0..c8155a1f71 100644 --- a/x/subspaces/keeper/alias_functions.go +++ b/x/subspaces/keeper/alias_functions.go @@ -9,27 +9,25 @@ import ( ) // IterateSubspaces iterates through the subspaces set and performs the given function -func (k Keeper) IterateSubspaces(ctx sdk.Context, fn func(index int64, subspace types.Subspace) (stop bool)) { +func (k Keeper) IterateSubspaces(ctx sdk.Context, fn func(subspace types.Subspace) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.SubspacePrefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var subspace types.Subspace k.cdc.MustUnmarshal(iterator.Value(), &subspace) - stop := fn(i, subspace) + stop := fn(subspace) if stop { break } - i++ } } // GetAllSubspaces returns a list of all the subspaces that have been store inside the given context func (k Keeper) GetAllSubspaces(ctx sdk.Context) []types.Subspace { var subspaces []types.Subspace - k.IterateSubspaces(ctx, func(_ int64, subspace types.Subspace) (stop bool) { + k.IterateSubspaces(ctx, func(subspace types.Subspace) (stop bool) { subspaces = append(subspaces, subspace) return false }) @@ -39,80 +37,211 @@ func (k Keeper) GetAllSubspaces(ctx sdk.Context) []types.Subspace { // -------------------------------------------------------------------------------------------------------------------- +// IterateSections iterates over all the sections stored and performs the provided function +func (k Keeper) IterateSections(ctx sdk.Context, fn func(section types.Section) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.SectionsPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var section types.Section + k.cdc.MustUnmarshal(iterator.Value(), §ion) + stop := fn(section) + if stop { + break + } + } +} + +// GetAllSections returns all the stored sections +func (k Keeper) GetAllSections(ctx sdk.Context) []types.Section { + var sections []types.Section + k.IterateSections(ctx, func(section types.Section) (stop bool) { + sections = append(sections, section) + return false + }) + return sections +} + +// IterateSubspaceSections iterates over all the sections for the given subspace and performs the provided function +func (k Keeper) IterateSubspaceSections(ctx sdk.Context, subspaceID uint64, fn func(section types.Section) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.SubspaceSectionsPrefix(subspaceID)) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var section types.Section + k.cdc.MustUnmarshal(iterator.Value(), §ion) + stop := fn(section) + if stop { + break + } + } +} + +// GetSubspaceSections returns all the sections for the given subspace +func (k Keeper) GetSubspaceSections(ctx sdk.Context, subspaceID uint64) []types.Section { + var sections []types.Section + k.IterateSubspaceSections(ctx, subspaceID, func(section types.Section) (stop bool) { + sections = append(sections, section) + return false + }) + return sections +} + +// IterateSectionPath iterates the path that leads from the section having the given id up towards the root section +// and performs the provided function on all the sections that are encountered over the path (including +// the initial section having the specified id). +func (k Keeper) IterateSectionPath(ctx sdk.Context, subspaceID uint64, sectionID uint32, fn func(section types.Section) (stop bool)) { + section, found := k.GetSection(ctx, subspaceID, sectionID) + if !found { + return + } + + stop := fn(section) + if section.ID == types.RootSectionID || stop { + // End the iteration only if the user has told us to stop, or if we reached the root + return + } + + // Continue to follow the path from the parent section up to the root + k.IterateSectionPath(ctx, section.SubspaceID, section.ParentID, fn) +} + +// IterateSectionChildren iterates over all the children of the given section and performs the provided function +func (k Keeper) IterateSectionChildren(ctx sdk.Context, subspaceID uint64, sectionID uint32, fn func(section types.Section) (stop bool)) { + k.IterateSubspaceSections(ctx, subspaceID, func(section types.Section) (stop bool) { + stop = false + if section.ID != sectionID && section.ParentID == sectionID { + stop = fn(section) + } + return stop + }) +} + +// -------------------------------------------------------------------------------------------------------------------- + // IterateUserGroups iterates over all the users groups stored -func (k Keeper) IterateUserGroups(ctx sdk.Context, fn func(index int64, group types.UserGroup) (stop bool)) { +func (k Keeper) IterateUserGroups(ctx sdk.Context, fn func(group types.UserGroup) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.GroupsPrefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var group types.UserGroup k.cdc.MustUnmarshal(iterator.Value(), &group) - stop := fn(i, group) + stop := fn(group) if stop { break } - i++ } } -// IterateSubspaceGroups allows iterating over all the groups that are part of the subspace having the given id -func (k Keeper) IterateSubspaceGroups( - ctx sdk.Context, subspaceID uint64, fn func(index int64, group types.UserGroup) (stop bool), -) { +// GetAllUserGroups returns the information (name and members) for all the groups of all the subspaces +func (k Keeper) GetAllUserGroups(ctx sdk.Context) []types.UserGroup { + var groups []types.UserGroup + k.IterateUserGroups(ctx, func(group types.UserGroup) (stop bool) { + groups = append(groups, group) + return false + }) + return groups +} + +// IterateSubspaceUserGroups allows iterating over all the groups that are part of the subspace having the given id +func (k Keeper) IterateSubspaceUserGroups(ctx sdk.Context, subspaceID uint64, fn func(group types.UserGroup) (stop bool)) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.GroupsStoreKey(subspaceID)) + iterator := sdk.KVStorePrefixIterator(store, types.SubspaceGroupsPrefix(subspaceID)) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { var group types.UserGroup k.cdc.MustUnmarshal(iterator.Value(), &group) - stop := fn(i, group) + stop := fn(group) if stop { break } - i++ } } -// GetSubspaceGroups returns the list of all groups present inside a given subspace -func (k Keeper) GetSubspaceGroups(ctx sdk.Context, subspaceID uint64) []types.UserGroup { +// GetSubspaceUserGroups returns the list of all groups present inside a given subspace +func (k Keeper) GetSubspaceUserGroups(ctx sdk.Context, subspaceID uint64) []types.UserGroup { var groups []types.UserGroup - k.IterateSubspaceGroups(ctx, subspaceID, func(index int64, group types.UserGroup) (stop bool) { + k.IterateSubspaceUserGroups(ctx, subspaceID, func(group types.UserGroup) (stop bool) { groups = append(groups, group) return false }) return groups } -// IterateGroupMembers iterates over all the members of the group with the given name present inside the given subspace -func (k Keeper) IterateGroupMembers( - ctx sdk.Context, subspaceID uint64, groupID uint32, fn func(index int64, member sdk.AccAddress) (stop bool), -) { +// IterateSectionUserGroups iterates over all the user groups for the given section and performs the provided function +func (k Keeper) IterateSectionUserGroups(ctx sdk.Context, subspaceID uint64, sectionID uint32, fn func(group types.UserGroup) (stop bool)) { store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.SectionGroupsPrefix(subspaceID, sectionID)) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var group types.UserGroup + k.cdc.MustUnmarshal(iterator.Value(), &group) - prefix := types.GroupMembersStoreKey(subspaceID, groupID) + // Perform the function only on + stop := fn(group) + if stop { + break + } + } +} + +// GetSectionUserGroups returns all the user groups present inside the given section +func (k Keeper) GetSectionUserGroups(ctx sdk.Context, subspaceID uint64, sectionID uint32) []types.UserGroup { + var groups []types.UserGroup + k.IterateSectionUserGroups(ctx, subspaceID, sectionID, func(group types.UserGroup) (stop bool) { + groups = append(groups, group) + return false + }) + return groups +} + +// -------------------------------------------------------------------------------------------------------------------- + +// IterateUserGroupsMembers iterates over all the group member entries and performs the provided function +func (k Keeper) IterateUserGroupsMembers(ctx sdk.Context, fn func(entry types.UserGroupMemberEntry) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + prefix := types.GroupsMembersPrefix + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + subspaceID, groupID, user := types.SplitGroupMemberStoreKey(iterator.Key()) + stop := fn(types.NewUserGroupMemberEntry(subspaceID, groupID, user)) + if stop { + break + } + } +} + +// IterateUserGroupMembers iterates over all the members of the group with the given id present inside the given subspace +func (k Keeper) IterateUserGroupMembers(ctx sdk.Context, subspaceID uint64, groupID uint32, fn func(member string) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + prefix := types.GroupMembersPrefix(subspaceID, groupID) iterator := sdk.KVStorePrefixIterator(store, prefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { member := types.GetAddressFromBytes(bytes.TrimPrefix(iterator.Key(), prefix)) - stop := fn(i, member) + stop := fn(member) if stop { break } - i++ } } -// GetGroupMembers iterates returns all the members of a group inside a specific subspace -func (k Keeper) GetGroupMembers(ctx sdk.Context, subspaceID uint64, groupID uint32) []sdk.AccAddress { - var members []sdk.AccAddress - k.IterateGroupMembers(ctx, subspaceID, groupID, func(index int64, member sdk.AccAddress) (stop bool) { +// GetUserGroupMembers returns all the members of a group inside a specific subspace +func (k Keeper) GetUserGroupMembers(ctx sdk.Context, subspaceID uint64, groupID uint32) []string { + var members []string + k.IterateUserGroupMembers(ctx, subspaceID, groupID, func(member string) (stop bool) { members = append(members, member) return false }) @@ -121,25 +250,79 @@ func (k Keeper) GetGroupMembers(ctx sdk.Context, subspaceID uint64, groupID uint // -------------------------------------------------------------------------------------------------------------------- -// IterateSubspacePermissions iterates over all the permissions set for the subspace with the given id -func (k Keeper) IterateSubspacePermissions( - ctx sdk.Context, subspaceID uint64, fn func(index int64, user sdk.AccAddress, permission types.Permission) (stop bool), -) { +// IterateUserPermissions iterates over all the stored user permissions +func (k Keeper) IterateUserPermissions(ctx sdk.Context, fn func(entry types.UserPermission) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + prefix := types.UserPermissionsStorePrefix + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + subspaceID, sectionID, user := types.SplitUserAddressPermissionKey(iterator.Key()) + permission := types.UnmarshalPermission(iterator.Value()) + + stop := fn(types.NewUserPermission(subspaceID, sectionID, user, permission)) + if stop { + break + } + } +} + +// IterateSubspaceUserPermissions iterates over all the user permissions set for the subspace with the given id +func (k Keeper) IterateSubspaceUserPermissions(ctx sdk.Context, subspaceID uint64, fn func(entry types.UserPermission) (stop bool)) { store := ctx.KVStore(k.storeKey) - prefix := types.PermissionsStoreKey(subspaceID) + prefix := types.SubspacePermissionsPrefix(subspaceID) iterator := sdk.KVStorePrefixIterator(store, prefix) defer iterator.Close() - i := int64(0) for ; iterator.Valid(); iterator.Next() { - user := types.GetAddressFromBytes(bytes.TrimPrefix(iterator.Key(), prefix)) + subspaceID, sectionID, user := types.SplitUserAddressPermissionKey(iterator.Key()) permission := types.UnmarshalPermission(iterator.Value()) - stop := fn(i, user, permission) + stop := fn(types.NewUserPermission(subspaceID, sectionID, user, permission)) if stop { break } - i++ } } + +// GetSubspaceUserPermissions returns all the user permissions set for the given subspace +func (k Keeper) GetSubspaceUserPermissions(ctx sdk.Context, subspaceID uint64) []types.UserPermission { + var entries []types.UserPermission + k.IterateSubspaceUserPermissions(ctx, subspaceID, func(entry types.UserPermission) (stop bool) { + entries = append(entries, entry) + return false + }) + return entries +} + +// IterateSectionUserPermissions iterates over all the permissions set for the given section and performs the provided function +func (k Keeper) IterateSectionUserPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32, fn func(entry types.UserPermission) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + prefix := types.SectionPermissionsPrefix(subspaceID, sectionID) + iterator := sdk.KVStorePrefixIterator(store, prefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + subspaceID, sectionID, user := types.SplitUserAddressPermissionKey(iterator.Key()) + permission := types.UnmarshalPermission(iterator.Value()) + + stop := fn(types.NewUserPermission(subspaceID, sectionID, user, permission)) + if stop { + break + } + } +} + +// GetSectionUserPermissions returns all the user permissions set inside the specific section +func (k Keeper) GetSectionUserPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32) []types.UserPermission { + var entries []types.UserPermission + k.IterateSectionUserPermissions(ctx, subspaceID, sectionID, func(entry types.UserPermission) (stop bool) { + entries = append(entries, entry) + return false + }) + return entries +} diff --git a/x/subspaces/keeper/genesis.go b/x/subspaces/keeper/genesis.go index e730a4b630..4c6fa9116d 100644 --- a/x/subspaces/keeper/genesis.go +++ b/x/subspaces/keeper/genesis.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - "github.com/desmos-labs/desmos/v3/x/subspaces/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,71 +15,56 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return types.NewGenesisState( subspaceID, - k.GetGenesisSubspaces(ctx, k.GetAllSubspaces(ctx)), - k.GetAllPermissions(ctx), + k.getSubspacesData(ctx), + k.GetAllSubspaces(ctx), + k.GetAllSections(ctx), + k.getAllUserPermissions(ctx), k.GetAllUserGroups(ctx), - k.GetUserAllGroupsMembers(ctx), + k.getAllUserGroupsMembers(ctx), ) } -// GetGenesisSubspaces maps the given subspaces to the corresponding GenesisSubspace instance -func (k Keeper) GetGenesisSubspaces(ctx sdk.Context, subspaces []types.Subspace) []types.GenesisSubspace { - if subspaces == nil { - return nil - } +// getSubspacesData returns all the stored information for all subspaces +func (k Keeper) getSubspacesData(ctx sdk.Context) []types.SubspaceData { + var data []types.SubspaceData + k.IterateSubspaces(ctx, func(subspace types.Subspace) (stop bool) { + nextSectionID, err := k.GetNextSectionID(ctx, subspace.ID) + if err != nil { + panic(err) + } - genesisSubspaces := make([]types.GenesisSubspace, len(subspaces)) - for i, subspace := range subspaces { - groupID, err := k.GetGroupID(ctx, subspace.ID) + nextGroupID, err := k.GetNextGroupID(ctx, subspace.ID) if err != nil { panic(err) } - genesisSubspaces[i] = types.NewGenesisSubspace(subspace, groupID) - } - return genesisSubspaces -} + data = append(data, types.NewSubspaceData(subspace.ID, nextSectionID, nextGroupID)) -// GetAllPermissions returns all the stored permissions for all subspaces -func (k Keeper) GetAllPermissions(ctx sdk.Context) []types.ACLEntry { - var entries []types.ACLEntry - k.IterateSubspaces(ctx, func(index int64, subspace types.Subspace) (stop bool) { - k.IterateSubspacePermissions(ctx, subspace.ID, func(index int64, user sdk.AccAddress, permission types.Permission) (stop bool) { - entries = append(entries, types.NewACLEntry(subspace.ID, user.String(), permission)) - return false - }) return false }) - return entries + return data } -// GetAllUserGroups returns the information (name and members) for all the groups of all the subspaces -func (k Keeper) GetAllUserGroups(ctx sdk.Context) []types.UserGroup { - var groups []types.UserGroup - k.IterateUserGroups(ctx, func(index int64, group types.UserGroup) (stop bool) { - groups = append(groups, group) +// getAllUserPermissions returns all the stored user permissions for all subspaces +func (k Keeper) getAllUserPermissions(ctx sdk.Context) []types.UserPermission { + var entries []types.UserPermission + k.IterateUserPermissions(ctx, func(entry types.UserPermission) (stop bool) { + entries = append(entries, entry) return false }) - return groups + return entries } -// GetUserAllGroupsMembers returns all the UserGroupMembersEntry -func (k Keeper) GetUserAllGroupsMembers(ctx sdk.Context) []types.UserGroupMembersEntry { - var entries []types.UserGroupMembersEntry - k.IterateUserGroups(ctx, func(index int64, group types.UserGroup) (stop bool) { +// getAllUserGroupsMembers returns all the stored user group members +func (k Keeper) getAllUserGroupsMembers(ctx sdk.Context) []types.UserGroupMemberEntry { + var entries []types.UserGroupMemberEntry + k.IterateUserGroupsMembers(ctx, func(entry types.UserGroupMemberEntry) (stop bool) { // Skip group ID 0 to avoid exporting any member - if group.ID == 0 { + if entry.GroupID == 0 { return false } - // Get the group members - members := k.GetGroupMembers(ctx, group.SubspaceID, group.ID) - membersAddr := make([]string, len(members)) - for i, member := range members { - membersAddr[i] = member.String() - } - - entries = append(entries, types.NewUserGroupMembersEntry(group.SubspaceID, group.ID, membersAddr)) + entries = append(entries, entry) return false }) return entries @@ -91,48 +74,37 @@ func (k Keeper) GetUserAllGroupsMembers(ctx sdk.Context) []types.UserGroupMember // InitGenesis initializes the chain state based on the given GenesisState func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { + // Initialize the subspace id setting it to be the max id found + 1 + k.SetSubspaceID(ctx, data.InitialSubspaceID) + + // Initialize the subspaces data + for _, entry := range data.SubspacesData { + k.SetNextGroupID(ctx, entry.SubspaceID, entry.NextGroupID) + k.SetNextSectionID(ctx, entry.SubspaceID, entry.NextSectionID) + } + // Initialize the subspaces - for _, subspaceData := range data.Subspaces { - k.SaveSubspace(ctx, subspaceData.Subspace) - k.SetGroupID(ctx, subspaceData.Subspace.ID, subspaceData.InitialGroupID) + for _, subspace := range data.Subspaces { + k.SaveSubspace(ctx, subspace) } - // Initialize the subspace id setting it to be the max id found + 1 - k.SetSubspaceID(ctx, data.InitialSubspaceID) + // Initialize the sections + for _, section := range data.Sections { + k.SaveSection(ctx, section) + } // Initialize the groups with default permission PermissionNothing - // The real permission will be set later when initializing the various permissions for _, group := range data.UserGroups { k.SaveUserGroup(ctx, group) } // Initialize the group members for _, entry := range data.UserGroupsMembers { - // Skip group ID 0 since it's the default group and no user should be here - if entry.GroupID == 0 { - continue - } - - // Initialize the members - for _, member := range entry.Members { - userAddr, err := sdk.AccAddressFromBech32(member) - if err != nil { - panic(err) - } - - err = k.AddUserToGroup(ctx, entry.SubspaceID, entry.GroupID, userAddr) - if err != nil { - panic(err) - } - } + k.AddUserToGroup(ctx, entry.SubspaceID, entry.GroupID, entry.User) } // Initialize the permissions - for _, entry := range data.ACL { - userAddr, err := sdk.AccAddressFromBech32(entry.User) - if err != nil { - panic(fmt.Errorf("invalid user address: %s", entry.User)) - } - k.SetUserPermissions(ctx, entry.SubspaceID, userAddr, entry.Permissions) + for _, entry := range data.UserPermissions { + k.SetUserPermissions(ctx, entry.SubspaceID, entry.SectionID, entry.User, entry.Permissions) } } diff --git a/x/subspaces/keeper/genesis_test.go b/x/subspaces/keeper/genesis_test.go index eb1dd5eaa6..b7a19b3460 100644 --- a/x/subspaces/keeper/genesis_test.go +++ b/x/subspaces/keeper/genesis_test.go @@ -19,10 +19,10 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { store: func(ctx sdk.Context) { suite.k.SetSubspaceID(ctx, 1) }, - expGenesis: types.NewGenesisState(1, nil, nil, nil, nil), + expGenesis: types.NewGenesisState(1, nil, nil, nil, nil, nil, nil), }, { - name: "subspaces are exported correctly", + name: "subspaces and their data are exported correctly", store: func(ctx sdk.Context) { suite.k.SetSubspaceID(ctx, 3) suite.k.SaveSubspace(ctx, types.NewSubspace( @@ -34,6 +34,9 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) + suite.k.SetNextSectionID(ctx, 1, 2) + suite.k.SetNextGroupID(ctx, 1, 3) + suite.k.SaveSubspace(ctx, types.NewSubspace( 2, "Another test subspace", @@ -43,35 +46,39 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), )) + suite.k.SetNextSectionID(ctx, 2, 10) + suite.k.SetNextGroupID(ctx, 2, 11) }, expGenesis: types.NewGenesisState( 3, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Test subspace", - "This is a test subspace", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), + []types.SubspaceData{ + types.NewSubspaceData(1, 2, 3), + types.NewSubspaceData(2, 10, 11), + }, + []types.Subspace{ + types.NewSubspace( 1, + "Test subspace", + "This is a test subspace", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), ), - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), - 1, + types.NewSubspace( + 2, + "Another test subspace", + "This is another test subspace", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), ), }, + []types.Section{ + types.DefaultSection(1), + types.DefaultSection(2), + }, nil, []types.UserGroup{ types.DefaultUserGroup(1), @@ -81,7 +88,45 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { ), }, { - name: "permissions are exported correctly", + name: "sections are exported properly", + store: func(ctx sdk.Context) { + suite.k.SetSubspaceID(ctx, 1) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) + + suite.k.SaveSection(ctx, types.NewSection( + 2, + 3, + 1, + "Another test section", + "This is another test section", + )) + }, + expGenesis: types.NewGenesisState(1, nil, nil, []types.Section{ + types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), + types.NewSection( + 2, + 3, + 1, + "Another test section", + "This is another test section", + ), + }, nil, nil, nil), + }, + { + name: "user permissions are exported correctly", store: func(ctx sdk.Context) { suite.k.SetSubspaceID(ctx, 3) suite.k.SaveSubspace(ctx, types.NewSubspace( @@ -94,28 +139,29 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 2, sdkAddr, types.PermissionSetPermissions) + suite.k.SetUserPermissions(ctx, 2, 0, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", types.PermissionSetPermissions) }, expGenesis: types.NewGenesisState( 3, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), - 1, + []types.SubspaceData{ + types.NewSubspaceData(2, 1, 1), + }, + []types.Subspace{ + types.NewSubspace( + 2, + "Another test subspace", + "This is another test subspace", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), ), }, - []types.ACLEntry{ - types.NewACLEntry(2, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", types.PermissionSetPermissions), + []types.Section{ + types.DefaultSection(2), + }, + []types.UserPermission{ + types.NewUserPermission(2, 0, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", types.PermissionSetPermissions), }, []types.UserGroup{ types.DefaultUserGroup(2), @@ -124,7 +170,7 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { ), }, { - name: "user groups are exported properly", + name: "user groups and members are exported properly", store: func(ctx sdk.Context) { suite.k.SetSubspaceID(ctx, 3) suite.k.SaveSubspace(ctx, types.NewSubspace( @@ -136,18 +182,17 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - suite.k.SetGroupID(ctx, 1, 2) + suite.k.SetNextGroupID(ctx, 1, 2) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") suite.k.SaveSubspace(ctx, types.NewSubspace( 2, @@ -158,56 +203,55 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), )) - suite.k.SetGroupID(ctx, 2, 2) + suite.k.SetNextGroupID(ctx, 2, 2) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 2, + 0, 1, "Another test group", "This is another test group", types.PermissionWrite, )) - userAddr, err = sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 2, 1, userAddr) - - userAddr, err = sdk.AccAddressFromBech32("cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 2, 1, userAddr) + suite.k.AddUserToGroup(ctx, 2, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5") + suite.k.AddUserToGroup(ctx, 2, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") }, expGenesis: types.NewGenesisState( 3, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Test subspace", - "This is a test subspace", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 2, + []types.SubspaceData{ + types.NewSubspaceData(1, 1, 2), + types.NewSubspaceData(2, 1, 2), + }, + []types.Subspace{ + types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), ), - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), + types.NewSubspace( 2, + "Another test subspace", + "This is another test subspace", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), ), }, + []types.Section{ + types.DefaultSection(1), + types.DefaultSection(2), + }, nil, []types.UserGroup{ types.DefaultUserGroup(1), types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -216,20 +260,17 @@ func (suite *KeeperTestsuite) TestKeeper_ExportGenesis() { types.DefaultUserGroup(2), types.NewUserGroup( 2, + 0, 1, "Another test group", "This is another test group", types.PermissionWrite, ), }, - []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 1, []string{ - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - }), - types.NewUserGroupMembersEntry(2, 1, []string{ - "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - }), + []types.UserGroupMemberEntry{ + types.NewUserGroupMemberEntry(1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm"), + types.NewUserGroupMemberEntry(2, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm"), + types.NewUserGroupMemberEntry(2, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), }, ), }, @@ -256,133 +297,136 @@ func (suite *KeeperTestsuite) TestKeeper_InitGenesis() { check func(ctx sdk.Context) }{ { - name: "all data is imported properly", + name: "initial subspace id is imported properly", genesis: types.GenesisState{ - InitialSubspaceID: 3, - Subspaces: []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Test subspace", - "This is a test subspace", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 2, - ), - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), - 14, - ), - }, - ACL: []types.ACLEntry{ - types.NewACLEntry(2, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", types.PermissionSetPermissions), + InitialSubspaceID: 2, + }, + check: func(ctx sdk.Context) { + stored, err := suite.k.GetSubspaceID(ctx) + suite.Require().NoError(err) + suite.Require().Equal(uint64(2), stored) + }, + }, + { + name: "subspaces data are imported properly", + genesis: types.GenesisState{ + SubspacesData: []types.SubspaceData{ + types.NewSubspaceData(1, 10, 20), }, - UserGroups: []types.UserGroup{ - types.NewUserGroup( - 1, + }, + check: func(ctx sdk.Context) { + nextSectionID, err := suite.k.GetNextSectionID(ctx, 1) + suite.Require().NoError(err) + suite.Require().Equal(uint32(10), nextSectionID) + + nextGroupID, err := suite.k.GetNextGroupID(ctx, 1) + suite.Require().NoError(err) + suite.Require().Equal(uint32(20), nextGroupID) + }, + }, + { + name: "subspaces are imported properly", + genesis: types.GenesisState{ + Subspaces: []types.Subspace{ + types.NewSubspace( 1, - "Test group", - "This is a test group", - types.PermissionWrite, + "Test subspace", + "This is a test subspace", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), ), - types.NewUserGroup( - 2, + }, + }, + check: func(ctx sdk.Context) { + stored, found := suite.k.GetSubspace(ctx, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + ), stored) + }, + }, + { + name: "sections are imported properly", + genesis: types.GenesisState{ + Sections: []types.Section{ + types.NewSection( 1, - "Another test group", - "This is another test group", - types.PermissionWrite, - ), - types.NewUserGroup( 2, - 13, - "High id test group", - "This is another test group", - types.PermissionWrite, + 0, + "Test section", + "This is a test section", ), }, - UserGroupsMembers: []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 1, []string{ - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - }), - types.NewUserGroupMembersEntry(2, 1, []string{ - "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - }), - }, }, check: func(ctx sdk.Context) { - subspaceID, err := suite.k.GetSubspaceID(ctx) - suite.Require().NoError(err) - suite.Require().Equal(uint64(3), subspaceID) - - subspaces := suite.k.GetAllSubspaces(ctx) - suite.Require().Len(subspaces, 2) - - // Check the fist subspace data - firstSubspaceGroupID, err := suite.k.GetGroupID(ctx, 1) - suite.Require().NoError(err) - suite.Require().Equal(uint32(2), firstSubspaceGroupID) - - expectedFirstSubspaceGroups := []types.UserGroup{ - types.DefaultUserGroup(1), + stored, found := suite.k.GetSection(ctx, 1, 2) + suite.Require().True(found) + suite.Equal(types.NewSection( + 1, + 2, + 0, + "Test section", + "This is a test section", + ), stored) + }, + }, + { + name: "user groups are imported properly", + genesis: types.GenesisState{ + UserGroups: []types.UserGroup{ types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, ), - } - storedFirstSubspacesGroups := suite.k.GetSubspaceGroups(ctx, 1) - suite.Require().Equal(expectedFirstSubspaceGroups, storedFirstSubspacesGroups) - - groupMembers := suite.k.GetGroupMembers(ctx, 1, 1) - suite.Require().Len(groupMembers, 1) - - // Check the second subspace data - secondSubspaceGroupID, err := suite.k.GetGroupID(ctx, 2) - suite.Require().NoError(err) - suite.Require().Equal(uint32(14), secondSubspaceGroupID) - - expectedSecondSubspaceGroups := []types.UserGroup{ - types.DefaultUserGroup(2), - types.NewUserGroup( - 2, - 1, - "Another test group", - "This is another test group", - types.PermissionWrite, - ), - types.NewUserGroup( - 2, - 13, - "High id test group", - "This is another test group", - types.PermissionWrite, - ), - } - storedSecondSubspaceGroups := suite.k.GetSubspaceGroups(ctx, 2) - suite.Require().Equal(expectedSecondSubspaceGroups, storedSecondSubspaceGroups) - - anotherGroupMembers := suite.k.GetGroupMembers(ctx, 2, 1) - suite.Require().Len(anotherGroupMembers, 2) - - // Check user permissions - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - storedUserPermissions := suite.k.GetUserPermissions(ctx, 2, userAddr) + }, + }, + check: func(ctx sdk.Context) { + stored, found := suite.k.GetUserGroup(ctx, 1, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + ), stored) + }, + }, + { + name: "user group members are imported properly", + genesis: types.GenesisState{ + UserGroupsMembers: []types.UserGroupMemberEntry{ + types.NewUserGroupMemberEntry(2, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm"), + types.NewUserGroupMemberEntry(2, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), + }, + }, + check: func(ctx sdk.Context) { + groupMembers := suite.k.GetUserGroupMembers(ctx, 2, 1) + suite.Require().Len(groupMembers, 2) + }, + }, + { + name: "user permissions are imported properly", + genesis: types.GenesisState{ + UserPermissions: []types.UserPermission{ + types.NewUserPermission(2, 0, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", types.PermissionSetPermissions), + }, + }, + check: func(ctx sdk.Context) { + storedUserPermissions := suite.k.GetUserPermissions(ctx, 2, 0, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") suite.Require().Equal(types.PermissionSetPermissions, storedUserPermissions) }, }, @@ -398,7 +442,6 @@ func (suite *KeeperTestsuite) TestKeeper_InitGenesis() { if tc.check != nil { tc.check(ctx) } - }) } } diff --git a/x/subspaces/keeper/groups.go b/x/subspaces/keeper/groups.go index 8a4cbce71b..5d1e8e2071 100644 --- a/x/subspaces/keeper/groups.go +++ b/x/subspaces/keeper/groups.go @@ -7,16 +7,22 @@ import ( "github.com/desmos-labs/desmos/v3/x/subspaces/types" ) -// SetGroupID sets the new group id for the specific subspace to the store -func (k Keeper) SetGroupID(ctx sdk.Context, subspaceID uint64, groupID uint32) { +// SetNextGroupID sets the new group id for the specific subspace to the store +func (k Keeper) SetNextGroupID(ctx sdk.Context, subspaceID uint64, groupID uint32) { store := ctx.KVStore(k.storeKey) - store.Set(types.GroupIDStoreKey(subspaceID), types.GetGroupIDBytes(groupID)) + store.Set(types.NextGroupIDStoreKey(subspaceID), types.GetGroupIDBytes(groupID)) } -// GetGroupID gets the highest group id for the subspace with the given id -func (k Keeper) GetGroupID(ctx sdk.Context, subspaceID uint64) (groupID uint32, err error) { +// HasNextGroupID tells whether the next group id key exists for the given subspace +func (k Keeper) HasNextGroupID(ctx sdk.Context, subspaceID uint64) bool { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.GroupIDStoreKey(subspaceID)) + return store.Has(types.NextGroupIDStoreKey(subspaceID)) +} + +// GetNextGroupID gets the highest group id for the subspace with the given id +func (k Keeper) GetNextGroupID(ctx sdk.Context, subspaceID uint64) (groupID uint32, err error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.NextGroupIDStoreKey(subspaceID)) if bz == nil { return 0, sdkerrors.Wrap(types.ErrInvalidGenesis, "initial group ID hasn't been set") } @@ -25,74 +31,90 @@ func (k Keeper) GetGroupID(ctx sdk.Context, subspaceID uint64) (groupID uint32, return groupID, nil } +// DeleteNextGroupID deletes the next group id key for the given subspace +func (k Keeper) DeleteNextGroupID(ctx sdk.Context, subspaceID uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.NextGroupIDStoreKey(subspaceID)) +} + // -------------------------------------------------------------------------------------------------------------------- -// SaveUserGroup saves within the subspace having the given id the provided group +// SaveUserGroup saves the given user group func (k Keeper) SaveUserGroup(ctx sdk.Context, group types.UserGroup) { store := ctx.KVStore(k.storeKey) + // Remove the existing group key, if the section id has changed + stored, found := k.GetUserGroup(ctx, group.SubspaceID, group.ID) + if found && group.SectionID != stored.SectionID { + store.Delete(types.GroupStoreKey(stored.SubspaceID, stored.SectionID, stored.ID)) + } + // Save the group - store.Set(types.GroupStoreKey(group.SubspaceID, group.ID), k.cdc.MustMarshal(&group)) + store.Set(types.GroupStoreKey(group.SubspaceID, group.SectionID, group.ID), k.cdc.MustMarshal(&group)) - k.Logger(ctx).Info("group saved", "subspace_id", group.SubspaceID, "group_id", group.ID) + k.Logger(ctx).Info("group saved", "subspace id", group.SubspaceID, "group id", group.ID) k.AfterSubspaceGroupSaved(ctx, group.SubspaceID, group.ID) } -// HasUserGroup returns whether the given subspace has a group with the specified id or not +// HasUserGroup tells whether the given subspace has a group with the specified id or not func (k Keeper) HasUserGroup(ctx sdk.Context, subspaceID uint64, groupID uint32) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.GroupStoreKey(subspaceID, groupID)) + found := false + k.IterateSubspaceUserGroups(ctx, subspaceID, func(group types.UserGroup) (stop bool) { + if group.ID == groupID { + found = true + } + return found + }) + return found } // GetUserGroup returns the group associated with the given id inside the subspace with the provided id. // If there is no group associated with the given id the function will return an empty group and false. func (k Keeper) GetUserGroup(ctx sdk.Context, subspaceID uint64, groupID uint32) (group types.UserGroup, found bool) { - store := ctx.KVStore(k.storeKey) - key := types.GroupStoreKey(subspaceID, groupID) - if !store.Has(key) { - return group, false - } - - k.cdc.MustUnmarshal(store.Get(key), &group) - return group, true + k.IterateSubspaceUserGroups(ctx, subspaceID, func(g types.UserGroup) (stop bool) { + if g.ID == groupID { + group = g + found = true + } + return found + }) + return group, found } // DeleteUserGroup deletes the group with the given id from the subspace with the provided id func (k Keeper) DeleteUserGroup(ctx sdk.Context, subspaceID uint64, groupID uint32) { - store := ctx.KVStore(k.storeKey) + group, found := k.GetUserGroup(ctx, subspaceID, groupID) + if !found { + return + } // Remove all the members from this group - for _, member := range k.GetGroupMembers(ctx, subspaceID, groupID) { + k.IterateUserGroupMembers(ctx, subspaceID, groupID, func(member string) (stop bool) { k.RemoveUserFromGroup(ctx, subspaceID, groupID, member) - } + return false + }) // Delete the group - store.Delete(types.GroupStoreKey(subspaceID, groupID)) + store := ctx.KVStore(k.storeKey) + store.Delete(types.GroupStoreKey(subspaceID, group.SectionID, group.ID)) - k.Logger(ctx).Info("group deleted", "subspace_id", subspaceID, "group_id", groupID) + k.Logger(ctx).Info("group deleted", "subspace id", subspaceID, "group id", groupID) k.AfterSubspaceGroupDeleted(ctx, subspaceID, groupID) } // -------------------------------------------------------------------------------------------------------------------- // AddUserToGroup adds the given user to the group having the provided id inside the specified subspace. -// If the group does not exist inside the subspace, it returns an error. -func (k Keeper) AddUserToGroup(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) error { - if !k.HasUserGroup(ctx, subspaceID, groupID) { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "group with id %d does not exist", groupID) - } - +func (k Keeper) AddUserToGroup(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) { store := ctx.KVStore(k.storeKey) store.Set(types.GroupMemberStoreKey(subspaceID, groupID, user), []byte{0x01}) k.AfterSubspaceGroupMemberAdded(ctx, subspaceID, groupID, user) - - return nil } // IsMemberOfGroup returns whether the given user is part of the group with // the specified id inside the provided subspace -func (k Keeper) IsMemberOfGroup(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) bool { +func (k Keeper) IsMemberOfGroup(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) bool { // The group with ID 0 represents the default group, so everyone is part of it if groupID == 0 { return true @@ -103,7 +125,7 @@ func (k Keeper) IsMemberOfGroup(ctx sdk.Context, subspaceID uint64, groupID uint } // RemoveUserFromGroup removes the specified user from the subspace group having the given id. -func (k Keeper) RemoveUserFromGroup(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) { +func (k Keeper) RemoveUserFromGroup(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) { store := ctx.KVStore(k.storeKey) store.Delete(types.GroupMemberStoreKey(subspaceID, groupID, user)) diff --git a/x/subspaces/keeper/groups_test.go b/x/subspaces/keeper/groups_test.go index e1a6b4dce8..84172d001f 100644 --- a/x/subspaces/keeper/groups_test.go +++ b/x/subspaces/keeper/groups_test.go @@ -6,7 +6,7 @@ import ( "github.com/desmos-labs/desmos/v3/x/subspaces/types" ) -func (suite *KeeperTestsuite) TestKeeper_SetGroupID() { +func (suite *KeeperTestsuite) TestKeeper_SetNextGroupID() { testCases := []struct { name string subspaceID uint64 @@ -19,7 +19,7 @@ func (suite *KeeperTestsuite) TestKeeper_SetGroupID() { groupID: 0, check: func(ctx sdk.Context) { store := ctx.KVStore(suite.storeKey) - groupID := types.GetGroupIDFromBytes(store.Get(types.GroupIDStoreKey(1))) + groupID := types.GetGroupIDFromBytes(store.Get(types.NextGroupIDStoreKey(1))) suite.Require().Equal(uint32(0), groupID) }, }, @@ -29,7 +29,7 @@ func (suite *KeeperTestsuite) TestKeeper_SetGroupID() { groupID: 5, check: func(ctx sdk.Context) { store := ctx.KVStore(suite.storeKey) - groupID := types.GetGroupIDFromBytes(store.Get(types.GroupIDStoreKey(1))) + groupID := types.GetGroupIDFromBytes(store.Get(types.NextGroupIDStoreKey(1))) suite.Require().Equal(uint32(5), groupID) }, }, @@ -40,7 +40,7 @@ func (suite *KeeperTestsuite) TestKeeper_SetGroupID() { suite.Run(tc.name, func() { ctx, _ := suite.ctx.CacheContext() - suite.k.SetGroupID(ctx, tc.subspaceID, tc.groupID) + suite.k.SetNextGroupID(ctx, tc.subspaceID, tc.groupID) if tc.check != nil { tc.check(ctx) } @@ -48,7 +48,43 @@ func (suite *KeeperTestsuite) TestKeeper_SetGroupID() { } } -func (suite *KeeperTestsuite) TestKeeper_GetGroupID() { +func (suite *KeeperTestsuite) TestKeeper_HasNextGroupID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + expResult bool + }{ + { + name: "not found next group id returns false", + subspaceID: 1, + expResult: false, + }, + { + name: "found next group id returns true", + store: func(ctx sdk.Context) { + suite.k.SetNextGroupID(ctx, 1, 1) + }, + subspaceID: 1, + expResult: true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + result := suite.k.HasNextGroupID(ctx, tc.subspaceID) + suite.Require().Equal(tc.expResult, result) + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_GetNextGroupID() { testCases := []struct { name string store func(ctx sdk.Context) @@ -65,7 +101,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetGroupID() { name: "group id set", store: func(ctx sdk.Context) { store := ctx.KVStore(suite.storeKey) - store.Set(types.GroupIDStoreKey(1), types.GetGroupIDBytes(1)) + store.Set(types.NextGroupIDStoreKey(1), types.GetGroupIDBytes(1)) }, subspaceID: 1, shouldErr: false, @@ -81,7 +117,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetGroupID() { tc.store(ctx) } - id, err := suite.k.GetGroupID(ctx, tc.subspaceID) + id, err := suite.k.GetNextGroupID(ctx, tc.subspaceID) if tc.shouldErr { suite.Require().Error(err) } else { @@ -92,6 +128,48 @@ func (suite *KeeperTestsuite) TestKeeper_GetGroupID() { } } +func (suite *KeeperTestsuite) TestKeeper_DeleteNextGroupID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + check func(ctx sdk.Context) + }{ + { + name: "non existing next group id is deleted properly", + subspaceID: 1, + check: func(ctx sdk.Context) { + suite.Require().False(suite.k.HasNextGroupID(ctx, 1)) + }, + }, + { + name: "existing next group id is deleted properly", + store: func(ctx sdk.Context) { + suite.k.SetNextGroupID(ctx, 1, 1) + }, + subspaceID: 1, + check: func(ctx sdk.Context) { + suite.Require().False(suite.k.HasNextGroupID(ctx, 1)) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + suite.k.DeleteNextGroupID(ctx, tc.subspaceID) + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + // -------------------------------------------------------------------------------------------------------------------- func (suite *KeeperTestsuite) TestKeeper_SaveUserGroup() { @@ -106,6 +184,7 @@ func (suite *KeeperTestsuite) TestKeeper_SaveUserGroup() { name: "non existing group is stored properly", group: types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -117,6 +196,7 @@ func (suite *KeeperTestsuite) TestKeeper_SaveUserGroup() { suite.Require().True(found) suite.Require().Equal(types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -129,6 +209,7 @@ func (suite *KeeperTestsuite) TestKeeper_SaveUserGroup() { store: func(ctx sdk.Context) { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -137,6 +218,7 @@ func (suite *KeeperTestsuite) TestKeeper_SaveUserGroup() { }, group: types.NewUserGroup( 1, + 0, 1, "Edited test group", "This is an edited test group", @@ -148,6 +230,7 @@ func (suite *KeeperTestsuite) TestKeeper_SaveUserGroup() { suite.Require().True(found) suite.Require().Equal(types.NewUserGroup( 1, + 0, 1, "Edited test group", "This is an edited test group", @@ -192,6 +275,7 @@ func (suite *KeeperTestsuite) TestKeeper_HasUserGroup() { store: func(ctx sdk.Context) { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -238,6 +322,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetUserGroup() { store: func(ctx sdk.Context) { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -249,6 +334,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetUserGroup() { expFound: true, expGroup: types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -296,21 +382,15 @@ func (suite *KeeperTestsuite) TestKeeper_DeleteUserGroup() { store: func(ctx sdk.Context) { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) - - userAddr, err = sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") }, subspaceID: 1, groupID: 1, @@ -318,7 +398,7 @@ func (suite *KeeperTestsuite) TestKeeper_DeleteUserGroup() { hasGroup := suite.k.HasUserGroup(ctx, 1, 1) suite.Require().False(hasGroup) - members := suite.k.GetGroupMembers(ctx, 1, 1) + members := suite.k.GetUserGroupMembers(ctx, 1, 1) suite.Require().Empty(members) }, }, @@ -349,21 +429,14 @@ func (suite *KeeperTestsuite) TestKeeper_AddUserToGroup() { subspaceID uint64 groupID uint32 user string - shouldErr bool check func(ctx sdk.Context) }{ - { - name: "non existing group returns error", - subspaceID: 1, - groupID: 1, - user: "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - shouldErr: true, - }, { name: "user is added properly to group", store: func(ctx sdk.Context) { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -373,12 +446,8 @@ func (suite *KeeperTestsuite) TestKeeper_AddUserToGroup() { subspaceID: 1, groupID: 1, user: "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - shouldErr: false, check: func(ctx sdk.Context) { - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - isMember := suite.k.IsMemberOfGroup(ctx, 1, 1, userAddr) + isMember := suite.k.IsMemberOfGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") suite.Require().True(isMember) }, }, @@ -392,19 +461,11 @@ func (suite *KeeperTestsuite) TestKeeper_AddUserToGroup() { tc.store(ctx) } - userAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, tc.subspaceID, tc.groupID, userAddr) - if tc.shouldErr { - suite.Require().Error(err) - } else { - suite.Require().NoError(err) - - if tc.check != nil { - tc.check(ctx) - } + suite.k.AddUserToGroup(ctx, tc.subspaceID, tc.groupID, tc.user) + if tc.check != nil { + tc.check(ctx) } + }) } } @@ -438,16 +499,14 @@ func (suite *KeeperTestsuite) TestKeeper_IsMemberOfGroup() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") }, subspaceID: 1, groupID: 1, @@ -464,10 +523,7 @@ func (suite *KeeperTestsuite) TestKeeper_IsMemberOfGroup() { tc.store(ctx) } - userAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - result := suite.k.IsMemberOfGroup(ctx, tc.subspaceID, tc.groupID, userAddr) + result := suite.k.IsMemberOfGroup(ctx, tc.subspaceID, tc.groupID, tc.user) suite.Require().Equal(tc.expResult, result) }) } @@ -488,10 +544,7 @@ func (suite *KeeperTestsuite) TestKeeper_RemoveUserFromGroup() { groupID: 1, user: "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", check: func(ctx sdk.Context) { - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - isMember := suite.k.IsMemberOfGroup(ctx, 1, 1, userAddr) + isMember := suite.k.IsMemberOfGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") suite.Require().False(isMember) }, }, @@ -500,25 +553,20 @@ func (suite *KeeperTestsuite) TestKeeper_RemoveUserFromGroup() { store: func(ctx sdk.Context) { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") }, subspaceID: 1, groupID: 1, user: "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", check: func(ctx sdk.Context) { - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - isMember := suite.k.IsMemberOfGroup(ctx, 1, 1, userAddr) + isMember := suite.k.IsMemberOfGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") suite.Require().False(isMember) }, }, @@ -532,10 +580,7 @@ func (suite *KeeperTestsuite) TestKeeper_RemoveUserFromGroup() { tc.store(ctx) } - userAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - suite.k.RemoveUserFromGroup(ctx, tc.subspaceID, tc.groupID, userAddr) + suite.k.RemoveUserFromGroup(ctx, tc.subspaceID, tc.groupID, tc.user) if tc.check != nil { tc.check(ctx) } diff --git a/x/subspaces/keeper/grpc_query.go b/x/subspaces/keeper/grpc_query.go index fee9cc3e59..fa3ea88068 100644 --- a/x/subspaces/keeper/grpc_query.go +++ b/x/subspaces/keeper/grpc_query.go @@ -53,6 +53,54 @@ func (k Keeper) Subspace(ctx context.Context, request *types.QuerySubspaceReques return &types.QuerySubspaceResponse{Subspace: subspace}, nil } +// Sections implements the Query/Sections gRPC method +func (k Keeper) Sections(ctx context.Context, request *types.QuerySectionsRequest) (*types.QuerySectionsResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // Check if the subspace exists + if !k.HasSubspace(sdkCtx, request.SubspaceId) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", request.SubspaceId) + } + + store := sdkCtx.KVStore(k.storeKey) + storePrefix := types.SubspaceSectionsPrefix(request.SubspaceId) + sectionsStore := prefix.NewStore(store, storePrefix) + + var sections []types.Section + pageRes, err := query.Paginate(sectionsStore, request.Pagination, func(key []byte, value []byte) error { + var section types.Section + if err := k.cdc.Unmarshal(value, §ion); err != nil { + return status.Error(codes.Internal, err.Error()) + } + + sections = append(sections, section) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QuerySectionsResponse{Sections: sections, Pagination: pageRes}, nil +} + +// Section implements the Query/Section gRPC method +func (k Keeper) Section(ctx context.Context, request *types.QuerySectionRequest) (*types.QuerySectionResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // Check if the subspace exists + if !k.HasSubspace(sdkCtx, request.SubspaceId) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", request.SubspaceId) + } + + section, found := k.GetSection(sdkCtx, request.SubspaceId, request.SectionId) + if !found { + return nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "section with id %d not found inside subspace %d", request.SectionId, request.SubspaceId) + } + + return &types.QuerySectionResponse{Section: section}, nil +} + // UserGroups implements the Query/UserGroups gRPC method func (k Keeper) UserGroups(ctx context.Context, request *types.QueryUserGroupsRequest) (*types.QueryUserGroupsResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -63,7 +111,10 @@ func (k Keeper) UserGroups(ctx context.Context, request *types.QueryUserGroupsRe } store := sdkCtx.KVStore(k.storeKey) - storePrefix := types.GroupsStoreKey(request.SubspaceId) + storePrefix := types.SubspaceGroupsPrefix(request.SubspaceId) + if request.SectionId != types.RootSectionID { + storePrefix = types.SectionGroupsPrefix(request.SubspaceId, request.SectionId) + } groupsStore := prefix.NewStore(store, storePrefix) var groups []types.UserGroup @@ -118,13 +169,13 @@ func (k Keeper) UserGroupMembers(ctx context.Context, request *types.QueryUserGr } store := sdkCtx.KVStore(k.storeKey) - storePrefix := types.GroupMembersStoreKey(request.SubspaceId, request.GroupId) + storePrefix := types.GroupMembersPrefix(request.SubspaceId, request.GroupId) membersStore := prefix.NewStore(store, storePrefix) var members []string pageRes, err := query.Paginate(membersStore, request.Pagination, func(key []byte, value []byte) error { member := types.GetAddressFromBytes(bytes.TrimPrefix(key, storePrefix)) - members = append(members, member.String()) + members = append(members, member) return nil }) @@ -144,25 +195,20 @@ func (k Keeper) UserPermissions(ctx context.Context, request *types.QueryUserPer return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", request.SubspaceId) } - sdkAddr, err := sdk.AccAddressFromBech32(request.User) - if err != nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid user address: %s", request.User) - } - // Get the user specific permissions - userPermission := k.GetUserPermissions(sdkCtx, request.SubspaceId, sdkAddr) - groupPermissions := k.GetGroupsInheritedPermissions(sdkCtx, request.SubspaceId, sdkAddr) + userPermission := k.GetUserPermissions(sdkCtx, request.SubspaceId, request.SectionId, request.User) + groupPermissions := k.GetGroupsInheritedPermissions(sdkCtx, request.SubspaceId, request.SectionId, request.User) permissionResult := types.CombinePermissions(userPermission, groupPermissions) // Get the details of all the permissions var details []types.PermissionDetail if userPermission != types.PermissionNothing { - details = append(details, types.NewPermissionDetailUser(request.User, userPermission)) + details = append(details, types.NewPermissionDetailUser(request.SubspaceId, request.SectionId, request.User, userPermission)) } - k.IterateSubspaceGroups(sdkCtx, request.SubspaceId, func(index int64, group types.UserGroup) (stop bool) { - if k.IsMemberOfGroup(sdkCtx, request.SubspaceId, group.ID, sdkAddr) { - details = append(details, types.NewPermissionDetailGroup(group.ID, group.Permissions)) + k.IterateSubspaceUserGroups(sdkCtx, request.SubspaceId, func(group types.UserGroup) (stop bool) { + if k.IsMemberOfGroup(sdkCtx, request.SubspaceId, group.ID, request.User) { + details = append(details, types.NewPermissionDetailGroup(group.SubspaceID, group.SectionID, group.ID, group.Permissions)) } return false }) diff --git a/x/subspaces/keeper/grpc_query_test.go b/x/subspaces/keeper/grpc_query_test.go index 0b50f0a042..fc33f8750c 100644 --- a/x/subspaces/keeper/grpc_query_test.go +++ b/x/subspaces/keeper/grpc_query_test.go @@ -144,6 +144,214 @@ func (suite *KeeperTestsuite) TestQueryServer_Subspace() { } } +func (suite *KeeperTestsuite) TestQueryServer_Sections() { + testCases := []struct { + name string + store func(ctx sdk.Context) + req *types.QuerySectionsRequest + shouldErr bool + expSections []types.Section + }{ + { + name: "not found subspace returns error", + req: types.NewQuerySectionsRequest(1, nil), + shouldErr: true, + }, + { + name: "request without pagination returns correct data", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 0, + "Another test section", + "Another test section", + )) + }, + req: types.NewQuerySectionsRequest(1, nil), + shouldErr: false, + expSections: []types.Section{ + types.DefaultSection(1), + types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + ), + types.NewSection( + 1, + 2, + 0, + "Another test section", + "Another test section", + ), + }, + }, + { + name: "request with pagination works properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 0, + "Another test section", + "Another test section", + )) + }, + req: types.NewQuerySectionsRequest(1, &query.PageRequest{ + Limit: 1, + Offset: 1, // Skip the default section + }), + shouldErr: false, + expSections: []types.Section{ + types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + ), + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + res, err := suite.k.Sections(sdk.WrapSDKContext(ctx), tc.req) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expSections, res.Sections) + } + }) + } +} + +func (suite *KeeperTestsuite) TestQueryServer_Section() { + testCases := []struct { + name string + store func(ctx sdk.Context) + req *types.QuerySectionRequest + shouldErr bool + expSection types.Section + }{ + { + name: "non existing subspace returns error", + req: types.NewQuerySectionRequest(1, 1), + shouldErr: true, + }, + { + name: "non existing section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + req: types.NewQuerySectionRequest(1, 1), + shouldErr: true, + }, + { + name: "existing section is returned properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + }, + req: types.NewQuerySectionRequest(1, 1), + shouldErr: false, + expSection: types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + ), + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + res, err := suite.k.Section(sdk.WrapSDKContext(ctx), tc.req) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expSection, res.Section) + } + }) + } +} + func (suite *KeeperTestsuite) TestQueryServer_UserGroups() { testCases := []struct { name string @@ -154,11 +362,11 @@ func (suite *KeeperTestsuite) TestQueryServer_UserGroups() { }{ { name: "non existing subspace returns error", - req: types.NewQueryUserGroupsRequest(1, nil), + req: types.NewQueryUserGroupsRequest(1, 0, nil), shouldErr: true, }, { - name: "existing groups are returned properly", + name: "existing groups are returned properly with section id ≠ 0", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -172,12 +380,14 @@ func (suite *KeeperTestsuite) TestQueryServer_UserGroups() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "First test group", "This is a test group", types.PermissionWrite, )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, 1, 2, "Second test group", @@ -186,32 +396,86 @@ func (suite *KeeperTestsuite) TestQueryServer_UserGroups() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 3, "Third test group", "This is a test group", types.PermissionWrite, )) }, - req: types.NewQueryUserGroupsRequest(1, &query.PageRequest{ - Offset: 2, - Limit: 2, - }), + req: types.NewQueryUserGroupsRequest(1, 1, nil), shouldErr: false, expGroups: []types.UserGroup{ types.NewUserGroup( + 1, 1, 2, "Second test group", "This is a test group", types.PermissionWrite, ), + }, + }, + { + name: "existing groups are returned properly with section id = 0", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "First test group", + "This is a test group", + types.PermissionWrite, + )) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 2, + "Second test group", + "This is a test group", + types.PermissionWrite, + )) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 3, + "Third test group", + "This is a test group", + types.PermissionWrite, + )) + }, + req: types.NewQueryUserGroupsRequest(1, 0, &query.PageRequest{ + Offset: 2, // Skip default user group and the first custom one + Limit: 2, + }), + shouldErr: false, + expGroups: []types.UserGroup{ types.NewUserGroup( 1, + 0, 3, "Third test group", "This is a test group", types.PermissionWrite, ), + types.NewUserGroup( + 1, + 1, + 2, + "Second test group", + "This is a test group", + types.PermissionWrite, + ), }, }, } @@ -263,6 +527,7 @@ func (suite *KeeperTestsuite) TestQueryServer_UserGroup() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -273,6 +538,7 @@ func (suite *KeeperTestsuite) TestQueryServer_UserGroup() { shouldErr: false, expGroup: types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -344,29 +610,16 @@ func (suite *KeeperTestsuite) TestQueryServer_UserGroupMembers() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) - - userAddr, err = sdk.AccAddressFromBech32("cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) - - userAddr, err = sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5") + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") }, req: types.NewQueryUserGroupMembersRequest(1, 1, &query.PageRequest{ Offset: 1, @@ -433,16 +686,13 @@ func (suite *KeeperTestsuite) TestQueryServer_UserPermissions() { expResponse: types.QueryUserPermissionsResponse{ Permissions: types.PermissionNothing, Details: []types.PermissionDetail{ - types.NewPermissionDetailGroup(0, types.PermissionNothing), + types.NewPermissionDetailGroup(1, 0, 0, types.PermissionNothing), }, }, }, { name: "existing permissions are returned correctly", store: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") - suite.Require().NoError(err) - suite.k.SaveSubspace(ctx, types.NewSubspace( 1, "Test subspace", @@ -455,25 +705,25 @@ func (suite *KeeperTestsuite) TestQueryServer_UserPermissions() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionChangeInfo, )) - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 2, "Another test group", "This is another test group", types.PermissionSetPermissions, )) - err = suite.k.AddUserToGroup(ctx, 1, 2, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 2, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionWrite) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", types.PermissionWrite) }, req: types.NewQueryUserPermissionsRequest( 1, @@ -483,10 +733,10 @@ func (suite *KeeperTestsuite) TestQueryServer_UserPermissions() { expResponse: types.QueryUserPermissionsResponse{ Permissions: types.PermissionWrite | types.PermissionChangeInfo | types.PermissionSetPermissions, Details: []types.PermissionDetail{ - types.NewPermissionDetailUser("cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", types.PermissionWrite), - types.NewPermissionDetailGroup(0, types.PermissionNothing), - types.NewPermissionDetailGroup(1, types.PermissionChangeInfo), - types.NewPermissionDetailGroup(2, types.PermissionSetPermissions), + types.NewPermissionDetailUser(1, 0, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", types.PermissionWrite), + types.NewPermissionDetailGroup(1, 0, 0, types.PermissionNothing), + types.NewPermissionDetailGroup(1, 0, 1, types.PermissionChangeInfo), + types.NewPermissionDetailGroup(1, 0, 2, types.PermissionSetPermissions), }, }, }, diff --git a/x/subspaces/keeper/hooks.go b/x/subspaces/keeper/hooks.go index 38111061f3..f36705775b 100644 --- a/x/subspaces/keeper/hooks.go +++ b/x/subspaces/keeper/hooks.go @@ -25,6 +25,20 @@ func (k Keeper) AfterSubspaceDeleted(ctx sdk.Context, subspaceID uint64) { } } +// AfterSubspaceSectionSaved - call if hook is registered +func (k Keeper) AfterSubspaceSectionSaved(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + if k.hooks != nil { + k.hooks.AfterSubspaceSectionSaved(ctx, subspaceID, sectionID) + } +} + +// AfterSubspaceSectionDeleted - call if hook is registered +func (k Keeper) AfterSubspaceSectionDeleted(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + if k.hooks != nil { + k.hooks.AfterSubspaceSectionDeleted(ctx, subspaceID, sectionID) + } +} + // AfterSubspaceGroupSaved - call if hook is registered func (k Keeper) AfterSubspaceGroupSaved(ctx sdk.Context, subspaceID uint64, groupID uint32) { if k.hooks != nil { @@ -33,14 +47,14 @@ func (k Keeper) AfterSubspaceGroupSaved(ctx sdk.Context, subspaceID uint64, grou } // AfterSubspaceGroupMemberAdded - call if hook is registered -func (k Keeper) AfterSubspaceGroupMemberAdded(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) { +func (k Keeper) AfterSubspaceGroupMemberAdded(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) { if k.hooks != nil { k.hooks.AfterSubspaceGroupMemberAdded(ctx, subspaceID, groupID, user) } } // AfterSubspaceGroupMemberRemoved - call if hook is registered -func (k Keeper) AfterSubspaceGroupMemberRemoved(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) { +func (k Keeper) AfterSubspaceGroupMemberRemoved(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) { if k.hooks != nil { k.hooks.AfterSubspaceGroupMemberRemoved(ctx, subspaceID, groupID, user) } @@ -54,15 +68,15 @@ func (k Keeper) AfterSubspaceGroupDeleted(ctx sdk.Context, subspaceID uint64, gr } // AfterUserPermissionSet - call if hook is registered -func (k Keeper) AfterUserPermissionSet(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permissions types.Permission) { +func (k Keeper) AfterUserPermissionSet(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permissions types.Permission) { if k.hooks != nil { - k.hooks.AfterUserPermissionSet(ctx, subspaceID, user, permissions) + k.hooks.AfterUserPermissionSet(ctx, subspaceID, sectionID, user, permissions) } } // AfterUserPermissionRemoved - call if hook is registered -func (k Keeper) AfterUserPermissionRemoved(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress) { +func (k Keeper) AfterUserPermissionRemoved(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) { if k.hooks != nil { - k.hooks.AfterUserPermissionRemoved(ctx, subspaceID, user) + k.hooks.AfterUserPermissionRemoved(ctx, subspaceID, sectionID, user) } } diff --git a/x/subspaces/keeper/invariants.go b/x/subspaces/keeper/invariants.go index fd25d92b17..c356eacb45 100644 --- a/x/subspaces/keeper/invariants.go +++ b/x/subspaces/keeper/invariants.go @@ -12,25 +12,14 @@ import ( func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper) { ir.RegisterRoute(types.ModuleName, "valid-subspaces", ValidSubspacesInvariant(keeper)) + ir.RegisterRoute(types.ModuleName, "valid-sections", + ValidSectionsInvariant(keeper)) ir.RegisterRoute(types.ModuleName, "valid-user-groups", ValidUserGroupsInvariant(keeper)) -} - -// AllInvariants runs all invariants of the module -func AllInvariants(k Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - res, broken := ValidSubspacesInvariant(k)(ctx) - if broken { - return res, true - } - - res, broken = ValidUserGroupsInvariant(k)(ctx) - if broken { - return res, true - } - - return "Every invariant condition is fulfilled correctly", false - } + ir.RegisterRoute(types.ModuleName, "valid-user-groups-members", + ValidUserGroupMembersInvariant(keeper)) + ir.RegisterRoute(types.ModuleName, "valid-user-permissions", + ValidUserPermissionsInvariant(keeper)) } // -------------------------------------------------------------------------------------------------------------------- @@ -39,21 +28,49 @@ func AllInvariants(k Keeper) sdk.Invariant { func ValidSubspacesInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { var invalidSubspaces []types.Subspace - k.IterateSubspaces(ctx, func(_ int64, subspace types.Subspace) (stop bool) { - err := subspace.Validate() + k.IterateSubspaces(ctx, func(subspace types.Subspace) (stop bool) { + invalid := false + + nextSubspaceID, err := k.GetSubspaceID(ctx) + if err != nil { + invalid = true + } + + // Make sure the subspace id is never higher than the next one + if subspace.ID >= nextSubspaceID { + invalid = true + } + + // Check next section id + if !k.HasNextSectionID(ctx, subspace.ID) { + invalid = true + } + + // Check the next group id + if !k.HasNextGroupID(ctx, subspace.ID) { + invalid = true + } + + // Validate the subspace + err = subspace.Validate() if err != nil { + invalid = true + } + + if invalid { invalidSubspaces = append(invalidSubspaces, subspace) } + return false }) return sdk.FormatInvariant(types.ModuleName, "invalid subspaces", - fmt.Sprintf("the following subspaces are invalid:\n %s", formatOutputSubspaces(invalidSubspaces)), + fmt.Sprintf("the following subspaces are invalid:\n%s", formatOutputSubspaces(invalidSubspaces)), ), invalidSubspaces != nil } } -// formatOutputSubspaces concatenate the subspaces given into a unique string +// formatOutputSubspaces concatenates the given subspaces info into a string func formatOutputSubspaces(subspaces []types.Subspace) (outputSubspaces string) { for _, subspace := range subspaces { outputSubspaces += fmt.Sprintf("%d\n", subspace.ID) @@ -63,19 +80,97 @@ func formatOutputSubspaces(subspaces []types.Subspace) (outputSubspaces string) // -------------------------------------------------------------------------------------------------------------------- +// ValidSectionsInvariant checks that all the sections are valid +func ValidSectionsInvariant(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + var invalidSections []types.Section + + k.IterateSections(ctx, func(section types.Section) (stop bool) { + invalid := false + + // Check the subspace existence + if !k.HasSubspace(ctx, section.SubspaceID) { + invalid = true + } + + nextSectionID, err := k.GetNextSectionID(ctx, section.SubspaceID) + if err != nil { + invalid = true + } + + // Make sure the section id is never equal or higher than the next section id + if section.ID >= nextSectionID { + invalid = true + } + + // Check the parent section + if !k.HasSection(ctx, section.SubspaceID, section.ParentID) { + invalid = true + } + + // Validate the section + err = section.Validate() + if err != nil { + invalid = true + } + + if invalid { + invalidSections = append(invalidSections, section) + } + + return false + }) + + return sdk.FormatInvariant(types.ModuleName, "invalid sections", + fmt.Sprintf("the following sections are invalid:\n%s", formatOutputSections(invalidSections)), + ), invalidSections != nil + } +} + +// formatOutputSections concatenates the given sections info into a string +func formatOutputSections(sections []types.Section) (output string) { + for _, section := range sections { + output += fmt.Sprintf("SubspaceID: %d, SectionID: %d\n", section.SubspaceID, section.ID) + } + return output +} + +// -------------------------------------------------------------------------------------------------------------------- + // ValidUserGroupsInvariant checks that all the subspaces are valid func ValidUserGroupsInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { var invalidUserGroups []types.UserGroup - k.IterateUserGroups(ctx, func(_ int64, group types.UserGroup) (stop bool) { - err := group.Validate() + k.IterateUserGroups(ctx, func(group types.UserGroup) (stop bool) { + invalid := false + + // Check subspace existence + if !k.HasSubspace(ctx, group.SubspaceID) { + invalid = true + } + + // Check section existence + if !k.HasSection(ctx, group.SubspaceID, group.SectionID) { + invalid = true + } + + nextGroupID, err := k.GetNextGroupID(ctx, group.SubspaceID) if err != nil { - // The group is not valid - invalidUserGroups = append(invalidUserGroups, group) + invalid = true } - if !k.HasSubspace(ctx, group.SubspaceID) { - // The subspace for this group does not exist anymore + // Make sure the group id is always lower than the next one + if group.ID >= nextGroupID { + invalid = true + } + + // Validate the group + err = group.Validate() + if err != nil { + invalid = true + } + + if invalid { invalidUserGroups = append(invalidUserGroups, group) } @@ -88,10 +183,102 @@ func ValidUserGroupsInvariant(k Keeper) sdk.Invariant { } } -// formatOutputUserGroups concatenate the subspaces given into a unique string +// formatOutputUserGroups concatenates the given subspaces info given into a string func formatOutputUserGroups(groups []types.UserGroup) (outputUserGroups string) { for _, group := range groups { - outputUserGroups += fmt.Sprintf("%d\n", group.ID) + outputUserGroups += fmt.Sprintf("SubspaceID: %d, GroupID: %d\n", group.SubspaceID, group.ID) } return outputUserGroups } + +// -------------------------------------------------------------------------------------------------------------------- + +// ValidUserGroupMembersInvariant checks that all the user group members are valid +func ValidUserGroupMembersInvariant(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + var invalidMembers []types.UserGroupMemberEntry + k.IterateUserGroupsMembers(ctx, func(entry types.UserGroupMemberEntry) (stop bool) { + invalid := false + + // Check subspace existence + if !k.HasSubspace(ctx, entry.SubspaceID) { + invalid = true + } + + // Check the group existence + if !k.HasUserGroup(ctx, entry.SubspaceID, entry.GroupID) { + invalid = true + } + + // Validate the entry only if the group id is not 0, as this will return an error + err := entry.Validate() + if err != nil { + invalid = true + } + + if invalid { + invalidMembers = append(invalidMembers, entry) + } + + return false + }) + + return sdk.FormatInvariant(types.ModuleName, "invalid user group members", + fmt.Sprintf("the following user group members entries are invalid:\n%s", formatOutputUserGroupsMembers(invalidMembers)), + ), invalidMembers != nil + } +} + +// formatOutputUserGroupsMembers concatenates the given user group members data into a string +func formatOutputUserGroupsMembers(members []types.UserGroupMemberEntry) (output string) { + for _, entry := range members { + output += fmt.Sprintf("SubspaceID: %d, GroupID: %d, Member: %s\n", entry.SubspaceID, entry.GroupID, entry.User) + } + return output +} + +// -------------------------------------------------------------------------------------------------------------------- + +// ValidUserPermissionsInvariant checks that all the user permission entries are valid +func ValidUserPermissionsInvariant(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + var invalidPermissionsEntries []types.UserPermission + k.IterateUserPermissions(ctx, func(entry types.UserPermission) (stop bool) { + invalid := false + + // Check subspace existence + if !k.HasSubspace(ctx, entry.SubspaceID) { + invalid = true + } + + // Check section existence + if !k.HasSection(ctx, entry.SubspaceID, entry.SectionID) { + invalid = true + } + + // Validate the entry + err := entry.Validate() + if err != nil { + invalid = true + } + + if invalid { + invalidPermissionsEntries = append(invalidPermissionsEntries, entry) + } + + return false + }) + + return sdk.FormatInvariant(types.ModuleName, "invalid user permissions", + fmt.Sprintf("the following user permissions are invalid:\n%s", formatOutputUserPermissions(invalidPermissionsEntries)), + ), invalidPermissionsEntries != nil + } +} + +// formatOutputUserPermissions concatenates the given permission entries into a string +func formatOutputUserPermissions(entries []types.UserPermission) (output string) { + for _, entry := range entries { + output += fmt.Sprintf("SubspaceID: %d, SectionID: %d, User: %s, Permission: %d\n", entry.SubspaceID, entry.SectionID, entry.User, entry.Permissions) + } + return output +} diff --git a/x/subspaces/keeper/invariants_test.go b/x/subspaces/keeper/invariants_test.go index 91851d83d2..4cbddf5cf4 100644 --- a/x/subspaces/keeper/invariants_test.go +++ b/x/subspaces/keeper/invariants_test.go @@ -9,44 +9,419 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (suite *KeeperTestsuite) TestInvariants() { - tests := []struct { +func (suite *KeeperTestsuite) TestValidSubspacesInvariant() { + testCases := []struct { name string store func(ctx sdk.Context) expBroken bool }{ { - name: "valid subspace invariant violated", + name: "non existing next subspace id breaks invariant", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, - "", - "This is a test subspace", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + expBroken: true, + }, + { + name: "invalid subspace id compared to next subspace id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetSubspaceID(ctx, 1) + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + expBroken: true, + }, + { + name: "missing next section id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetSubspaceID(ctx, 2) + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.DeleteNextSectionID(ctx, 1) + }, + expBroken: true, + }, + { + name: "missing next group id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetSubspaceID(ctx, 2) + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.DeleteNextGroupID(ctx, 1) + }, + expBroken: true, + }, + { + name: "invalid subspace breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetSubspaceID(ctx, 2) + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Time{}, + )) + suite.k.SetNextSectionID(ctx, 1, 1) + suite.k.SetNextGroupID(ctx, 1, 1) + }, + expBroken: true, + }, + { + name: "valid data does not break invariant", + store: func(ctx sdk.Context) { + suite.k.SetSubspaceID(ctx, 2) + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) + suite.k.SetNextSectionID(ctx, 1, 1) + suite.k.SetNextGroupID(ctx, 1, 1) + }, + expBroken: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + _, broken := keeper.ValidSubspacesInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) + }) + } +} + +func (suite *KeeperTestsuite) TestValidSectionsInvariant() { + testCases := []struct { + name string + store func(ctx sdk.Context) + expBroken bool + }{ + { + name: "missing subspace breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) }, expBroken: true, }, { - name: "valid user groups invariant violated - invalid data", + name: "missing next section id returns error", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + }, + expBroken: true, + }, + { + name: "invalid section id compared to next section id returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextSectionID(ctx, 1, 1) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + }, + expBroken: true, + }, + { + name: "missing parent section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextSectionID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 3, + 2, + "Test section", + "Test section", + )) + }, + expBroken: true, + }, + { + name: "invalid section breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextSectionID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, "", - "This is a test subspace", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "Test section", + )) + }, + expBroken: true, + }, + { + name: "valid data does not break invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextSectionID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + }, + expBroken: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + _, broken := keeper.ValidSectionsInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) + }) + } +} + +func (suite *KeeperTestsuite) TestValidUserGroupsInvariant() { + testCases := []struct { + name string + store func(ctx sdk.Context) + expBroken bool + }{ + { + name: "non existing subspace breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + }, + expBroken: true, + }, + { + name: "non existing section breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + }, + expBroken: true, + }, + { + name: "non existing next group id returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + }, + expBroken: true, + }, + { + name: "invalid group id compared to next group id breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextGroupID(ctx, 1, 1) + + suite.k.SaveSection(ctx, types.NewSection( + 1, 1, 0, + "Test section", + "Test section", + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 1, + "Test group", "This is a test group", + types.PermissionWrite, + )) + }, + expBroken: true, + }, + { + name: "invalid group breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextGroupID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 1, + "", "This is a test group", types.PermissionWrite, )) @@ -54,45 +429,235 @@ func (suite *KeeperTestsuite) TestInvariants() { expBroken: true, }, { - name: "valid user groups invariant violated - missing associated subspace", + name: "valid data does not break invariant", store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextGroupID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, 1, + 1, + "Test group", "This is a test group", + types.PermissionWrite, + )) + }, + expBroken: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + _, broken := keeper.ValidUserGroupsInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) + }) + } +} + +func (suite *KeeperTestsuite) TestValidUserGroupMembersInvariant() { + testCases := []struct { + name string + store func(ctx sdk.Context) + expBroken bool + }{ + { + name: "non existing subspace breaks invariant", + store: func(ctx sdk.Context) { + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4") + }, + expBroken: true, + }, + { + name: "non existing user group breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4") + }, + expBroken: true, + }, + { + name: "invalid data breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.AddUserToGroup(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4") + }, + expBroken: true, + }, + { + name: "valid data does not break invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 1, + "Test group", "This is a test group", types.PermissionWrite, )) + + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4") + }, + expBroken: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + _, broken := keeper.ValidUserGroupMembersInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) + }) + } +} + +func (suite *KeeperTestsuite) TestValidUserPermissionsInvariant() { + testCases := []struct { + name string + store func(ctx sdk.Context) + expBroken bool + }{ + { + name: "non existing subspace breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionWrite) + }, + expBroken: true, + }, + { + name: "non existing section breaks invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionWrite) }, expBroken: true, }, { - name: "no invariant is violated", + name: "invalid entry breaks invariant", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, - "Test subspace", - "This is a test subspace", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", 0b11111111111111111) + }, + expBroken: true, + }, + { + name: "valid data does not break invariant", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "Test section", + )) + + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionWrite) }, expBroken: false, }, } - for _, test := range tests { - test := test - suite.Run(test.name, func() { + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { ctx, _ := suite.ctx.CacheContext() - if test.store != nil { - test.store(ctx) + if tc.store != nil { + tc.store(ctx) } - _, broken := keeper.AllInvariants(suite.k)(ctx) - suite.Require().Equal(test.expBroken, broken) + _, broken := keeper.ValidUserPermissionsInvariant(suite.k)(ctx) + suite.Require().Equal(tc.expBroken, broken) }) } } diff --git a/x/subspaces/keeper/migrations.go b/x/subspaces/keeper/migrations.go index 45b0d72d56..027efa6270 100644 --- a/x/subspaces/keeper/migrations.go +++ b/x/subspaces/keeper/migrations.go @@ -3,6 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + v3 "github.com/desmos-labs/desmos/v3/x/subspaces/legacy/v3" + v2 "github.com/desmos-labs/desmos/v3/x/subspaces/legacy/v2" ) @@ -24,3 +26,8 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } + +// Migrate2to3 migrates from version 2 to 3. +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v3.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) +} diff --git a/x/subspaces/keeper/msg_server.go b/x/subspaces/keeper/msg_server.go index 6b88584a2a..3947b310b6 100644 --- a/x/subspaces/keeper/msg_server.go +++ b/x/subspaces/keeper/msg_server.go @@ -70,7 +70,7 @@ func (k msgServer) CreateSubspace(goCtx context.Context, msg *types.MsgCreateSub func (k msgServer) EditSubspace(goCtx context.Context, msg *types.MsgEditSubspace) (*types.MsgEditSubspaceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists subspace, exists := k.GetSubspace(ctx, msg.SubspaceID) if !exists { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) @@ -82,7 +82,7 @@ func (k msgServer) EditSubspace(goCtx context.Context, msg *types.MsgEditSubspac } // Check the permission to edit - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionChangeInfo) { + if !k.HasPermission(ctx, msg.SubspaceID, types.RootSectionID, signer.String(), types.PermissionChangeInfo) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage this subspace") } @@ -116,7 +116,7 @@ func (k msgServer) EditSubspace(goCtx context.Context, msg *types.MsgEditSubspac func (k msgServer) DeleteSubspace(goCtx context.Context, msg *types.MsgDeleteSubspace) (*types.MsgDeleteSubspaceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Check the if the subspace exists + // Check if the subspace exists if !k.HasSubspace(ctx, msg.SubspaceID) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } @@ -127,7 +127,7 @@ func (k msgServer) DeleteSubspace(goCtx context.Context, msg *types.MsgDeleteSub } // Check the permission to edit - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionDeleteSubspace) { + if !k.HasPermission(ctx, msg.SubspaceID, types.RootSectionID, signer.String(), types.PermissionDeleteSubspace) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage this subspace") } @@ -150,6 +150,227 @@ func (k msgServer) DeleteSubspace(goCtx context.Context, msg *types.MsgDeleteSub return &types.MsgDeleteSubspaceResponse{}, nil } +// CreateSection defines a rpc method for MsgCreateSection +func (k msgServer) CreateSection(goCtx context.Context, msg *types.MsgCreateSection) (*types.MsgCreateSectionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the subspace exists + if !k.HasSubspace(ctx, msg.SubspaceID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) + } + + // Check the parent section + if !k.HasSection(ctx, msg.SubspaceID, msg.ParentID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "section with id %d not found inside subspace %d", msg.ParentID, msg.SubspaceID) + } + + signer, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address: %s", msg.Creator) + } + + // Check the permission to manage sections + if !k.HasPermission(ctx, msg.SubspaceID, types.RootSectionID, signer.String(), types.PermissionManageSections) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage sections within this subspace") + } + + // Get the next section ID + sectionID, err := k.GetNextSectionID(ctx, msg.SubspaceID) + if err != nil { + return nil, err + } + + // Create and validate the section + section := types.NewSection(msg.SubspaceID, sectionID, msg.ParentID, msg.Name, msg.Description) + err = section.Validate() + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) + } + + // Save the section + k.SaveSection(ctx, section) + + // Update the section id for the next one + k.SetNextSectionID(ctx, section.SubspaceID, section.ID+1) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(msg)), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Creator), + ), + sdk.NewEvent( + types.EventTypeCreateSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", section.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", section.ID)), + ), + }) + + return &types.MsgCreateSectionResponse{ + SectionID: section.ID, + }, nil +} + +// EditSection defines a rpc method for MsgEditSection +func (k msgServer) EditSection(goCtx context.Context, msg *types.MsgEditSection) (*types.MsgEditSectionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the subspace exists + if !k.HasSubspace(ctx, msg.SubspaceID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) + } + + // Check if the section exists + section, found := k.GetSection(ctx, msg.SubspaceID, msg.SectionID) + if !found { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "section with id %d not found inside subspace %d", msg.SectionID, msg.SubspaceID) + } + + signer, err := sdk.AccAddressFromBech32(msg.Editor) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid editor address: %s", msg.Editor) + } + + // Check the permission to manage sections + if !k.HasPermission(ctx, msg.SubspaceID, types.RootSectionID, signer.String(), types.PermissionManageSections) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage sections within this subspace") + } + + // Update the section and validate it + update := types.NewSectionUpdate(msg.Name, msg.Description) + updated := section.Update(update) + err = updated.Validate() + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + + // Save the section + k.SaveSection(ctx, updated) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(msg)), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Editor), + ), + sdk.NewEvent( + types.EventTypeEditSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", section.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", section.ID)), + ), + }) + + return &types.MsgEditSectionResponse{}, nil +} + +// MoveSection defines a rpc method for MsgMoveSection +func (k msgServer) MoveSection(goCtx context.Context, msg *types.MsgMoveSection) (*types.MsgMoveSectionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the subspace exists + if !k.HasSubspace(ctx, msg.SubspaceID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) + } + + // Check if the section exists + section, found := k.GetSection(ctx, msg.SubspaceID, msg.SectionID) + if !found { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "section with id %d not found inside subspace %d", msg.SectionID, msg.SubspaceID) + } + + // Check if the destination section exists + if !k.HasSection(ctx, msg.SubspaceID, msg.NewParentID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "section with id %d does not exist inside subspace %d", msg.NewParentID, msg.SubspaceID) + } + + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address: %s", msg.Signer) + } + + // Check the permission to manage sections + if !k.HasPermission(ctx, msg.SubspaceID, types.RootSectionID, signer.String(), types.PermissionManageSections) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage sections within this subspace") + } + + // Update the section parent id and validate it + section.ParentID = msg.NewParentID + err = section.Validate() + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + + // Save the section + k.SaveSection(ctx, section) + + // Make sure the section path is valid + if !k.IsSectionPathValid(ctx, section.SubspaceID, section.ID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid section path") + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(msg)), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer), + ), + sdk.NewEvent( + types.EventTypeMoveSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), + ), + }) + + return &types.MsgMoveSectionResponse{}, nil +} + +// DeleteSection defines a rpc method for MsgDeleteSection +func (k msgServer) DeleteSection(goCtx context.Context, msg *types.MsgDeleteSection) (*types.MsgDeleteSectionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the subspace exists + if !k.HasSubspace(ctx, msg.SubspaceID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) + } + + // Check if the section exists + if !k.HasSection(ctx, msg.SubspaceID, msg.SectionID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "section with id %d not found inside subspace %d", msg.SectionID, msg.SubspaceID) + } + + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address: %s", msg.Signer) + } + + // Check the permission to manage sections + if !k.HasPermission(ctx, msg.SubspaceID, types.RootSectionID, signer.String(), types.PermissionManageSections) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage sections within this subspace") + } + + // Delete the section + k.Keeper.DeleteSection(ctx, msg.SubspaceID, msg.SectionID) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(msg)), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer), + ), + sdk.NewEvent( + types.EventTypeDeleteSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeySectionID, fmt.Sprintf("%d", msg.SectionID)), + ), + }) + + return &types.MsgDeleteSectionResponse{}, nil +} + // CreateUserGroup defines a rpc method for MsgCreateUserGroup func (k msgServer) CreateUserGroup(goCtx context.Context, msg *types.MsgCreateUserGroup) (*types.MsgCreateUserGroupResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -165,10 +386,10 @@ func (k msgServer) CreateUserGroup(goCtx context.Context, msg *types.MsgCreateUs } // Check the permissions to create a group - if !k.HasPermission(ctx, msg.SubspaceID, creator, types.PermissionManageGroups) { + if !k.HasPermission(ctx, msg.SubspaceID, msg.SectionID, creator.String(), types.PermissionManageGroups) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage user groups in this subspace") } - if !k.HasPermission(ctx, msg.SubspaceID, creator, types.PermissionSetPermissions) { + if !k.HasPermission(ctx, msg.SubspaceID, msg.SectionID, creator.String(), types.PermissionSetPermissions) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage permissions in this subspace") } @@ -178,13 +399,13 @@ func (k msgServer) CreateUserGroup(goCtx context.Context, msg *types.MsgCreateUs } // Get the next group ID - groupID, err := k.GetGroupID(ctx, msg.SubspaceID) + groupID, err := k.GetNextGroupID(ctx, msg.SubspaceID) if err != nil { return nil, err } // Create and validate the group - group := types.NewUserGroup(msg.SubspaceID, groupID, msg.Name, msg.Description, msg.DefaultPermissions) + group := types.NewUserGroup(msg.SubspaceID, msg.SectionID, groupID, msg.Name, msg.Description, msg.DefaultPermissions) if err := group.Validate(); err != nil { return nil, err } @@ -193,7 +414,7 @@ func (k msgServer) CreateUserGroup(goCtx context.Context, msg *types.MsgCreateUs k.SaveUserGroup(ctx, group) // Update the id for the next group - k.SetGroupID(ctx, msg.SubspaceID, group.ID+1) + k.SetNextGroupID(ctx, msg.SubspaceID, group.ID+1) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -233,7 +454,7 @@ func (k msgServer) EditUserGroup(goCtx context.Context, msg *types.MsgEditUserGr } // Check the permission to create a group - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionManageGroups) { + if !k.HasPermission(ctx, group.SubspaceID, group.SectionID, signer.String(), types.PermissionManageGroups) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage user groups in this subspace") } @@ -264,6 +485,67 @@ func (k msgServer) EditUserGroup(goCtx context.Context, msg *types.MsgEditUserGr return &types.MsgEditUserGroupResponse{}, nil } +// MoveUserGroup defines a rpc method for MsgMoveUserGroup +func (k msgServer) MoveUserGroup(goCtx context.Context, msg *types.MsgMoveUserGroup) (*types.MsgMoveUserGroupResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the subspace exists + if !k.HasSubspace(ctx, msg.SubspaceID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "group with id %d not found", msg.SubspaceID) + } + + // Check if the destination section exists + if !k.HasSection(ctx, msg.SubspaceID, msg.NewSectionID) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "section with id %d not found inside subspace %d", msg.NewSectionID, msg.SubspaceID) + } + + // Check if the group exists + group, found := k.GetUserGroup(ctx, msg.SubspaceID, msg.GroupID) + if !found { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "group with id %d not found", msg.GroupID) + } + + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address: %s", msg.Signer) + } + + // Check the permissions to manage the current section groups + if !k.HasPermission(ctx, group.SubspaceID, group.SectionID, signer.String(), types.PermissionManageGroups) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage user groups in this section") + } + + // Check the permissions to manage the destination section groups + if !k.HasPermission(ctx, msg.SubspaceID, msg.NewSectionID, signer.String(), types.PermissionManageGroups) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage user groups in the destination section") + } + if !k.HasPermission(ctx, msg.SubspaceID, msg.NewSectionID, signer.String(), types.PermissionSetPermissions) { + return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage permissions in the destination section") + } + + // Update the group section + group.SectionID = msg.NewSectionID + + // Save the group + k.SaveUserGroup(ctx, group) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(msg)), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer), + ), + sdk.NewEvent( + types.EvenTypeMoveUserGroup, + sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), + sdk.NewAttribute(types.AttributeKeyUserGroupID, fmt.Sprintf("%d", msg.GroupID)), + ), + }) + + return &types.MsgMoveUserGroupResponse{}, nil +} + // SetUserGroupPermissions defines a rpc method for MsgSetUserGroupPermissions func (k msgServer) SetUserGroupPermissions(goCtx context.Context, msg *types.MsgSetUserGroupPermissions) (*types.MsgSetUserGroupPermissionsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -286,7 +568,7 @@ func (k msgServer) SetUserGroupPermissions(goCtx context.Context, msg *types.Msg } // Check the permissions - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionSetPermissions) { + if !k.HasPermission(ctx, group.SubspaceID, group.SectionID, signer.String(), types.PermissionSetPermissions) { return nil, sdkerrors.Wrapf(types.ErrPermissionDenied, "you cannot manage permissions in this subspace") } @@ -296,7 +578,7 @@ func (k msgServer) SetUserGroupPermissions(goCtx context.Context, msg *types.Msg } // Make sure that the user is not part of the group they want to change the permissions for, unless they are the owner - if subspace.Owner != msg.Signer && k.IsMemberOfGroup(ctx, msg.SubspaceID, msg.GroupID, signer) { + if subspace.Owner != msg.Signer && k.IsMemberOfGroup(ctx, msg.SubspaceID, msg.GroupID, signer.String()) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "cannot set the permissions for a group you are part of") } @@ -331,7 +613,8 @@ func (k msgServer) DeleteUserGroup(goCtx context.Context, msg *types.MsgDeleteUs } // Check if the group exists - if !k.HasUserGroup(ctx, msg.SubspaceID, msg.GroupID) { + group, found := k.GetUserGroup(ctx, msg.SubspaceID, msg.GroupID) + if !found { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "group %d could not be found", msg.GroupID) } @@ -341,7 +624,7 @@ func (k msgServer) DeleteUserGroup(goCtx context.Context, msg *types.MsgDeleteUs } // Check for permissions - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionManageGroups) { + if !k.HasPermission(ctx, group.SubspaceID, group.SectionID, signer.String(), types.PermissionManageGroups) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot delete user groups in this subspace") } @@ -375,7 +658,8 @@ func (k msgServer) AddUserToUserGroup(goCtx context.Context, msg *types.MsgAddUs } // Check if the group exists - if !k.HasUserGroup(ctx, msg.SubspaceID, msg.GroupID) { + group, found := k.GetUserGroup(ctx, msg.SubspaceID, msg.GroupID) + if !found { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "group %d could not be found", msg.GroupID) } @@ -385,7 +669,7 @@ func (k msgServer) AddUserToUserGroup(goCtx context.Context, msg *types.MsgAddUs } // Check the permissions - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionSetPermissions) { + if !k.HasPermission(ctx, group.SubspaceID, group.SectionID, signer.String(), types.PermissionSetPermissions) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage user group members in this subspace") } @@ -395,15 +679,12 @@ func (k msgServer) AddUserToUserGroup(goCtx context.Context, msg *types.MsgAddUs } // Check if the user is already part of the group - if k.IsMemberOfGroup(ctx, msg.SubspaceID, msg.GroupID, user) { + if k.IsMemberOfGroup(ctx, msg.SubspaceID, msg.GroupID, user.String()) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "user is already part of group %d", msg.GroupID) } // Set the user group - err = k.AddUserToGroup(ctx, msg.SubspaceID, msg.GroupID, user) - if err != nil { - return nil, err - } + k.AddUserToGroup(ctx, msg.SubspaceID, msg.GroupID, user.String()) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -433,7 +714,8 @@ func (k msgServer) RemoveUserFromUserGroup(goCtx context.Context, msg *types.Msg } // Check if the group exists - if !k.HasUserGroup(ctx, msg.SubspaceID, msg.GroupID) { + group, found := k.GetUserGroup(ctx, msg.SubspaceID, msg.GroupID) + if !found { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "group %d could not be found", msg.GroupID) } @@ -443,22 +725,17 @@ func (k msgServer) RemoveUserFromUserGroup(goCtx context.Context, msg *types.Msg } // Check the permissions - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionSetPermissions) { + if !k.HasPermission(ctx, group.SubspaceID, group.SectionID, signer.String(), types.PermissionSetPermissions) { return nil, sdkerrors.Wrap(types.ErrPermissionDenied, "you cannot manage user group members in this subspace") } - user, err := sdk.AccAddressFromBech32(msg.User) - if err != nil { - return nil, err - } - // Check if the user is already part of the group - if !k.IsMemberOfGroup(ctx, msg.SubspaceID, msg.GroupID, user) { + if !k.IsMemberOfGroup(ctx, msg.SubspaceID, msg.GroupID, msg.User) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "user is not part of group %d", msg.GroupID) } // Remove the user group - k.RemoveUserFromGroup(ctx, msg.SubspaceID, msg.GroupID, user) + k.RemoveUserFromGroup(ctx, msg.SubspaceID, msg.GroupID, msg.User) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( @@ -487,18 +764,13 @@ func (k msgServer) SetUserPermissions(goCtx context.Context, msg *types.MsgSetUs return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "subspace with id %d not found", msg.SubspaceID) } - user, err := sdk.AccAddressFromBech32(msg.User) - if err != nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid user address: %s", msg.User) - } - signer, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address: %s", msg.Signer) } // Check the permissions - if !k.HasPermission(ctx, msg.SubspaceID, signer, types.PermissionSetPermissions) { + if !k.HasPermission(ctx, msg.SubspaceID, msg.SectionID, signer.String(), types.PermissionSetPermissions) { return nil, sdkerrors.Wrapf(types.ErrPermissionDenied, "you cannot manage permissions in this subspace") } @@ -510,9 +782,9 @@ func (k msgServer) SetUserPermissions(goCtx context.Context, msg *types.MsgSetUs // Set the permissions if msg.Permissions == types.PermissionNothing { // Remove the permission to clear the store if PermissionNothing is used - k.RemoveUserPermissions(ctx, msg.SubspaceID, user) + k.RemoveUserPermissions(ctx, msg.SubspaceID, msg.SectionID, msg.User) } else { - k.Keeper.SetUserPermissions(ctx, msg.SubspaceID, user, msg.Permissions) + k.Keeper.SetUserPermissions(ctx, msg.SubspaceID, msg.SectionID, msg.User, msg.Permissions) } ctx.EventManager().EmitEvents(sdk.Events{ @@ -525,7 +797,7 @@ func (k msgServer) SetUserPermissions(goCtx context.Context, msg *types.MsgSetUs sdk.NewEvent( types.EventTypeSetUserPermissions, sdk.NewAttribute(types.AttributeKeySubspaceID, fmt.Sprintf("%d", msg.SubspaceID)), - sdk.NewAttribute(types.AttributeKeyUser, user.String()), + sdk.NewAttribute(types.AttributeKeyUser, msg.User), ), }) diff --git a/x/subspaces/keeper/msg_server_test.go b/x/subspaces/keeper/msg_server_test.go index 212b04a351..b39219324e 100644 --- a/x/subspaces/keeper/msg_server_test.go +++ b/x/subspaces/keeper/msg_server_test.go @@ -357,9 +357,7 @@ func (suite *KeeperTestsuite) TestMsgServer_EditSubspace() { blockTime, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionChangeInfo) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", types.PermissionChangeInfo) }, msg: types.NewMsgEditSubspace( 1, @@ -486,9 +484,7 @@ func (suite *KeeperTestsuite) TestMsgServer_DeleteSubspace() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionDeleteSubspace) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", types.PermissionDeleteSubspace) }, msg: types.NewMsgDeleteSubspace(1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), shouldErr: false, @@ -496,17 +492,1001 @@ func (suite *KeeperTestsuite) TestMsgServer_DeleteSubspace() { sdk.NewEvent( sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeleteSubspace{})), - sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeleteSubspace{})), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), + ), + sdk.NewEvent( + types.EventTypeDeleteSubspace, + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + ), + }, + check: func(ctx sdk.Context) { + exists := suite.k.HasSubspace(ctx, 1) + suite.Require().False(exists) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + // Run the message + service := keeper.NewMsgServerImpl(suite.k) + _, err := service.DeleteSubspace(sdk.WrapSDKContext(ctx), tc.msg) + + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expEvents, ctx.EventManager().Events()) + + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} + +func (suite *KeeperTestsuite) TestMsgServer_CreateSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + msg *types.MsgCreateSection + shouldErr bool + expResponse *types.MsgCreateSectionResponse + expEvent sdk.Events + check func(ctx sdk.Context) + }{ + { + name: "non existing subspace returns error", + msg: types.NewMsgCreateSection( + 1, + "Test section", + "This is a test section", + 0, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "missing parent section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + msg: types.NewMsgCreateSection( + 1, + "Test section", + "This is a test section", + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "user without permission returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "", + )) + }, + msg: types.NewMsgCreateSection( + 1, + "Test section", + "This is a test section", + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "missing next section id returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.DeleteNextSectionID(ctx, 1) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgCreateSection( + 1, + "Test section", + "This is a test section", + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "invalid data returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextSectionID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgCreateSection( + 1, + "", + "This is a test section", + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "section is created properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SetNextSectionID(ctx, 1, 2) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgCreateSection( + 1, + "Test section", + "This is a test section", + 0, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: false, + expResponse: &types.MsgCreateSectionResponse{SectionID: 2}, + expEvent: sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgCreateSection{})), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4"), + ), + sdk.NewEvent( + types.EventTypeCreateSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeySectionID, "2"), + ), + }, + check: func(ctx sdk.Context) { + // Check the next section id + storedID, err := suite.k.GetNextSectionID(ctx, 1) + suite.Require().NoError(err) + suite.Require().Equal(uint32(3), storedID) + + // Check the section data + stored, found := suite.k.GetSection(ctx, 1, 2) + suite.Require().True(found) + suite.Require().Equal(types.NewSection( + 1, + 2, + 0, + "Test section", + "This is a test section", + ), stored) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + msgServer := keeper.NewMsgServerImpl(suite.k) + res, err := msgServer.CreateSection(sdk.WrapSDKContext(ctx), tc.msg) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expResponse, res) + suite.Require().Equal(tc.expEvent, ctx.EventManager().Events()) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} + +func (suite *KeeperTestsuite) TestMsgServer_EditSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + msg *types.MsgEditSection + shouldErr bool + expEvents sdk.Events + check func(ctx sdk.Context) + }{ + { + name: "non existing subspace returns error", + msg: types.NewMsgEditSection( + 1, + 1, + "Edited section", + "This is an edited section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "non existing section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + msg: types.NewMsgEditSection( + 1, + 1, + "Edited section", + "This is an edited section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "user without permission returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "", + )) + }, + msg: types.NewMsgEditSection( + 1, + 1, + "Edited section", + "This is an edited section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "invalid update data returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgEditSection( + 1, + 1, + "", + "This is an edited section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "section is updated properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Child section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgEditSection( + 1, + 1, + "Edited section", + "This is an edited section", + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: false, + expEvents: sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgEditSection{})), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4"), + ), + sdk.NewEvent( + types.EventTypeEditSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeySectionID, "1"), + ), + }, + check: func(ctx sdk.Context) { + stored, found := suite.k.GetSection(ctx, 1, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewSection( + 1, + 1, + 0, + "Edited section", + "This is an edited section", + ), stored) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + msgServer := keeper.NewMsgServerImpl(suite.k) + _, err := msgServer.EditSection(sdk.WrapSDKContext(ctx), tc.msg) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expEvents, ctx.EventManager().Events()) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} + +func (suite *KeeperTestsuite) TestMsgServer_MoveSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + msg *types.MsgMoveSection + shouldErr bool + expEvents sdk.Events + check func(ctx sdk.Context) + }{ + { + name: "non existing subspace returns error", + msg: types.NewMsgMoveSection( + 1, + 1, + 0, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "non existing section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + msg: types.NewMsgMoveSection( + 1, + 1, + 0, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "non existing destination section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 1, + "Child section", + "", + )) + }, + msg: types.NewMsgMoveSection( + 1, + 2, + 3, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "user without permission returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SaveSection(ctx, types.NewSection(1, 1, 0, "Child section", "")) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 1, + "Child section", + "", + )) + }, + msg: types.NewMsgMoveSection( + 1, + 2, + 0, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "moving section to be its own parent returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 1, + "Child section", + "", + )) + }, + msg: types.NewMsgMoveSection( + 1, + 2, + 2, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "moving section to create a circular path returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + // Create the following subspaces sections + // A + // | + // B - C + // + // We will then move A to be a child of C to create the following path + // A + // / \ + // B - C + suite.k.SaveSection(ctx, types.NewSection(1, 1, types.RootSectionID, "A", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 2, 1, "B", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 3, 2, "C", "")) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgMoveSection( + 1, + 1, + 3, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "section is moved properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SaveSection(ctx, types.NewSection(1, 1, 0, "Child section", "")) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 1, + "Child section", + "This is child section", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgMoveSection( + 1, + 2, + 0, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: false, + expEvents: sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgMoveSection{})), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4"), + ), + sdk.NewEvent( + types.EventTypeMoveSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeySectionID, "2"), + ), + }, + check: func(ctx sdk.Context) { + stored, found := suite.k.GetSection(ctx, 1, 2) + suite.Require().True(found) + suite.Require().Equal(types.NewSection( + 1, + 2, + 0, + "Child section", + "This is child section", + ), stored) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + msgServer := keeper.NewMsgServerImpl(suite.k) + _, err := msgServer.MoveSection(sdk.WrapSDKContext(ctx), tc.msg) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expEvents, ctx.EventManager().Events()) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} + +func (suite *KeeperTestsuite) TestMsgServer_DeleteSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + msg *types.MsgDeleteSection + shouldErr bool + expEvents sdk.Events + check func(ctx sdk.Context) + }{ + { + name: "non existing subspace returns error", + msg: types.NewMsgDeleteSection( + 1, + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "non existing section returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + msg: types.NewMsgDeleteSection( + 1, + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "user without permission returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) + }, + msg: types.NewMsgDeleteSection( + 1, + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: true, + }, + { + name: "section is deleted properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace with another name and owner", + "This is a test subspace with a changed description", + "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", types.PermissionManageSections) + }, + msg: types.NewMsgDeleteSection( + 1, + 1, + "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4", + ), + shouldErr: false, + expEvents: sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgDeleteSection{})), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1wq7mruftxd03qrrf9f7xnnzyqda9rkq5sshnr4"), + ), + sdk.NewEvent( + types.EventTypeDeleteSection, + sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeySectionID, "1"), + ), + }, + check: func(ctx sdk.Context) { + result := suite.k.HasSection(ctx, 1, 1) + suite.Require().False(result) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + msgServer := keeper.NewMsgServerImpl(suite.k) + _, err := msgServer.DeleteSection(sdk.WrapSDKContext(ctx), tc.msg) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expEvents, ctx.EventManager().Events()) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} + +func (suite *KeeperTestsuite) TestMsgServer_CreateUserGroup() { + testCases := []struct { + name string + store func(ctx sdk.Context) + msg *types.MsgCreateUserGroup + shouldErr bool + expResponse *types.MsgCreateUserGroupResponse + expEvents sdk.Events + check func(ctx sdk.Context) + }{ + { + name: "non existing subspace returns error", + msg: types.NewMsgCreateUserGroup( + 1, + + 0, + "group", + "description", + types.PermissionWrite, + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + ), + shouldErr: true, + }, + { + name: "user without PermissionManageGroups returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + }, + msg: types.NewMsgCreateUserGroup( + 1, + 0, + "group", + "description", + types.PermissionWrite, + "cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll", + ), + shouldErr: true, + }, + { + name: "user without PermissionSetPermissions returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll", types.PermissionManageGroups) + }, + msg: types.NewMsgCreateUserGroup( + 1, + 0, + "group", + "description", + types.PermissionWrite, + "cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll", + ), + shouldErr: true, + }, + { + name: "invalid permissions value returns error", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + suite.k.SetNextGroupID(ctx, 1, 2) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.CombinePermissions(types.PermissionManageGroups, types.PermissionSetPermissions)) + }, + msg: types.NewMsgCreateUserGroup( + 1, + 0, + "another group", + "another description", + 9999999, + "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", + ), + shouldErr: true, + }, + { + name: "group is created properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + suite.k.SetNextGroupID(ctx, 1, 2) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.CombinePermissions(types.PermissionManageGroups, types.PermissionSetPermissions)) + }, + msg: types.NewMsgCreateUserGroup( + 1, + 0, + "another group", + "another description", + types.PermissionWrite, + "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", + ), + shouldErr: false, + expResponse: &types.MsgCreateUserGroupResponse{GroupID: 2}, + expEvents: sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgCreateUserGroup{})), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), ), sdk.NewEvent( - types.EventTypeDeleteSubspace, + types.EventTypeCreateUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), + sdk.NewAttribute(types.AttributeKeyUserGroupID, "2"), ), }, check: func(ctx sdk.Context) { - exists := suite.k.HasSubspace(ctx, 1) - suite.Require().False(exists) + suite.Require().True(suite.k.HasUserGroup(ctx, 1, 1)) + suite.Require().True(suite.k.HasUserGroup(ctx, 1, 2)) }, }, } @@ -521,12 +1501,13 @@ func (suite *KeeperTestsuite) TestMsgServer_DeleteSubspace() { // Run the message service := keeper.NewMsgServerImpl(suite.k) - _, err := service.DeleteSubspace(sdk.WrapSDKContext(ctx), tc.msg) + res, err := service.CreateUserGroup(sdk.WrapSDKContext(ctx), tc.msg) if tc.shouldErr { suite.Require().Error(err) } else { suite.Require().NoError(err) + suite.Require().Equal(tc.expResponse, res) suite.Require().Equal(tc.expEvents, ctx.EventManager().Events()) if tc.check != nil { @@ -537,77 +1518,80 @@ func (suite *KeeperTestsuite) TestMsgServer_DeleteSubspace() { } } -func (suite *KeeperTestsuite) TestMsgServer_CreateUserGroup() { +func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { testCases := []struct { - name string - store func(ctx sdk.Context) - msg *types.MsgCreateUserGroup - shouldErr bool - expResponse *types.MsgCreateUserGroupResponse - expEvents sdk.Events - check func(ctx sdk.Context) + name string + store func(ctx sdk.Context) + msg *types.MsgEditUserGroup + shouldErr bool + expEvents sdk.Events + check func(ctx sdk.Context) }{ { name: "non existing subspace returns error", - msg: types.NewMsgCreateUserGroup( + msg: types.NewMsgEditUserGroup( 1, - "group", - "description", - types.PermissionWrite, + 1, + "Test group", + "This is a test group", "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", ), shouldErr: true, }, { - name: "user without PermissionManageGroups returns error", + name: "group not found returns error", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, "Test subspace", "This is a test subspace", "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) }, - msg: types.NewMsgCreateUserGroup( + msg: types.NewMsgEditUserGroup( 1, - "group", - "description", - types.PermissionWrite, - "cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll", + 1, + "Test group", + "This is a test group", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", ), shouldErr: true, }, { - name: "user without PermissionSetPermissions returns error", + name: "no permission returns error", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, "Test subspace", "This is a test subspace", "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", - "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionManageGroups) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) }, - msg: types.NewMsgCreateUserGroup( + msg: types.NewMsgEditUserGroup( 1, - "group", - "description", - types.PermissionWrite, - "cosmos1y4emx0mm4ncva9mnv9yvjrm7nrq3psvmwhk9ll", + 1, + "Test group new name", + "This is a test group with a new name", + "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: true, }, { - name: "invalid permissions value returns error", + name: "invalid update returns error", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -618,31 +1602,28 @@ func (suite *KeeperTestsuite) TestMsgServer_CreateUserGroup() { "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - suite.k.SetGroupID(ctx, 1, 2) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.CombinePermissions(types.PermissionManageGroups, types.PermissionSetPermissions)) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) }, - msg: types.NewMsgCreateUserGroup( + msg: types.NewMsgEditUserGroup( 1, - "another group", - "another description", - 256, + 1, + "", + "", "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: true, }, { - name: "group is created properly", + name: "existing group is edited properly", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -653,45 +1634,50 @@ func (suite *KeeperTestsuite) TestMsgServer_CreateUserGroup() { "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - suite.k.SetGroupID(ctx, 1, 2) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.CombinePermissions(types.PermissionManageGroups, types.PermissionSetPermissions)) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) }, - msg: types.NewMsgCreateUserGroup( + msg: types.NewMsgEditUserGroup( 1, - "another group", - "another description", - types.PermissionWrite, + 1, + "Admins", + "Group of the admins of th subspace", "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), - shouldErr: false, - expResponse: &types.MsgCreateUserGroupResponse{GroupID: 2}, + shouldErr: false, expEvents: sdk.Events{ sdk.NewEvent( sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgCreateUserGroup{})), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgEditUserGroup{})), sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), ), sdk.NewEvent( - types.EventTypeCreateUserGroup, + types.EventTypeEditUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), - sdk.NewAttribute(types.AttributeKeyUserGroupID, "2"), + sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), ), }, check: func(ctx sdk.Context) { - suite.Require().True(suite.k.HasUserGroup(ctx, 1, 1)) - suite.Require().True(suite.k.HasUserGroup(ctx, 1, 2)) + group, found := suite.k.GetUserGroup(ctx, 1, 1) + suite.Require().True(found) + + suite.Require().Equal(types.NewUserGroup( + 1, + 0, + 1, + "Admins", + "Group of the admins of th subspace", + types.PermissionWrite, + ), group) }, }, } @@ -706,13 +1692,12 @@ func (suite *KeeperTestsuite) TestMsgServer_CreateUserGroup() { // Run the message service := keeper.NewMsgServerImpl(suite.k) - res, err := service.CreateUserGroup(sdk.WrapSDKContext(ctx), tc.msg) + _, err := service.EditUserGroup(sdk.WrapSDKContext(ctx), tc.msg) if tc.shouldErr { suite.Require().Error(err) } else { suite.Require().NoError(err) - suite.Require().Equal(tc.expResponse, res) suite.Require().Equal(tc.expEvents, ctx.EventManager().Events()) if tc.check != nil { @@ -723,22 +1708,21 @@ func (suite *KeeperTestsuite) TestMsgServer_CreateUserGroup() { } } -func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { +func (suite *KeeperTestsuite) TestMsgServer_MoveUserGroup() { testCases := []struct { name string store func(ctx sdk.Context) - msg *types.MsgEditUserGroup + msg *types.MsgMoveUserGroup shouldErr bool expEvents sdk.Events check func(ctx sdk.Context) }{ { name: "non existing subspace returns error", - msg: types.NewMsgEditUserGroup( + msg: types.NewMsgMoveUserGroup( + 1, 1, 1, - "Test group", - "This is a test group", "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", ), shouldErr: true, @@ -756,17 +1740,16 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) }, - msg: types.NewMsgEditUserGroup( + msg: types.NewMsgMoveUserGroup( + 1, 1, 1, - "Test group", - "This is a test group", "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", ), shouldErr: true, }, { - name: "no permission returns error", + name: "non existing destination section returns error", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -779,23 +1762,59 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) }, - msg: types.NewMsgEditUserGroup( + msg: types.NewMsgMoveUserGroup( + 1, 1, 1, - "Test group new name", - "This is a test group with a new name", "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: true, }, { - name: "invalid update returns error", + name: "no permission returns error - PermissionManageGroups inside current section", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + }, + msg: types.NewMsgMoveUserGroup( + 1, + 1, + 1, + "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", + ), + shouldErr: true, + }, + { + name: "no permission returns error - PermissionManageGroups inside destination section", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -806,29 +1825,34 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) }, - msg: types.NewMsgEditUserGroup( + msg: types.NewMsgMoveUserGroup( + 1, 1, 1, - "", - "", "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: true, }, { - name: "existing group is edited properly", + name: "no permission returns error - PermissionSetPermissions inside destination section", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -839,23 +1863,69 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) }, - msg: types.NewMsgEditUserGroup( + msg: types.NewMsgMoveUserGroup( + 1, + 1, + 1, + "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", + ), + shouldErr: true, + }, + { + name: "existing group is moved properly", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + "cosmos1qzskhrcjnkdz2ln4yeafzsdwht8ch08j4wed69", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 0, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionSetPermissions) + }, + msg: types.NewMsgMoveUserGroup( + 1, 1, 1, - "Admins", - "Group of the admins of th subspace", "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: false, @@ -863,11 +1933,11 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { sdk.NewEvent( sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgEditUserGroup{})), + sdk.NewAttribute(sdk.AttributeKeyAction, sdk.MsgTypeURL(&types.MsgMoveUserGroup{})), sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53"), ), sdk.NewEvent( - types.EventTypeEditUserGroup, + types.EvenTypeMoveUserGroup, sdk.NewAttribute(types.AttributeKeySubspaceID, "1"), sdk.NewAttribute(types.AttributeKeyUserGroupID, "1"), ), @@ -879,8 +1949,9 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { suite.Require().Equal(types.NewUserGroup( 1, 1, - "Admins", - "Group of the admins of th subspace", + 1, + "Test group", + "This is a test group", types.PermissionWrite, ), group) }, @@ -897,7 +1968,7 @@ func (suite *KeeperTestsuite) TestMsgServer_EditUserGroup() { // Run the message service := keeper.NewMsgServerImpl(suite.k) - _, err := service.EditUserGroup(sdk.WrapSDKContext(ctx), tc.msg) + _, err := service.MoveUserGroup(sdk.WrapSDKContext(ctx), tc.msg) if tc.shouldErr { suite.Require().Error(err) @@ -967,6 +2038,7 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserGroupPermissions() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -995,20 +2067,19 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserGroupPermissions() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionSetPermissions) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionSetPermissions) }, msg: types.NewMsgSetUserGroupPermissions( 1, 1, - 256, + 9999999, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: true, @@ -1027,17 +2098,14 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserGroupPermissions() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionSetPermissions, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") }, msg: types.NewMsgSetUserGroupPermissions( 1, @@ -1061,17 +2129,14 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserGroupPermissions() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionSetPermissions, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") }, msg: types.NewMsgSetUserGroupPermissions( 1, @@ -1114,15 +2179,14 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserGroupPermissions() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionSetPermissions) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionSetPermissions) }, msg: types.NewMsgSetUserGroupPermissions( 1, @@ -1231,6 +2295,7 @@ func (suite *KeeperTestsuite) TestMsgServer_DeleteUserGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -1258,15 +2323,14 @@ func (suite *KeeperTestsuite) TestMsgServer_DeleteUserGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionManageGroups) }, msg: types.NewMsgDeleteUserGroup( 1, @@ -1374,6 +2438,7 @@ func (suite *KeeperTestsuite) TestMsgServer_AddUserToGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -1402,17 +2467,14 @@ func (suite *KeeperTestsuite) TestMsgServer_AddUserToGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") }, msg: types.NewMsgAddUserToUserGroup( 1, @@ -1436,15 +2498,14 @@ func (suite *KeeperTestsuite) TestMsgServer_AddUserToGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionSetPermissions) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionSetPermissions) }, msg: types.NewMsgAddUserToUserGroup( 1, @@ -1468,10 +2529,7 @@ func (suite *KeeperTestsuite) TestMsgServer_AddUserToGroup() { ), }, check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - result := suite.k.IsMemberOfGroup(ctx, 1, 1, sdkAddr) + result := suite.k.IsMemberOfGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") suite.Require().True(result) }, }, @@ -1557,6 +2615,7 @@ func (suite *KeeperTestsuite) TestMsgServer_RemoveUserFromGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -1585,6 +2644,7 @@ func (suite *KeeperTestsuite) TestMsgServer_RemoveUserFromGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -1613,21 +2673,15 @@ func (suite *KeeperTestsuite) TestMsgServer_RemoveUserFromGroup() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionSetPermissions) - - sdkAddr, err = sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionSetPermissions) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") }, msg: types.NewMsgRemoveUserFromUserGroup( 1, @@ -1651,10 +2705,7 @@ func (suite *KeeperTestsuite) TestMsgServer_RemoveUserFromGroup() { ), }, check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") - suite.Require().NoError(err) - - result := suite.k.IsMemberOfGroup(ctx, 1, 1, sdkAddr) + result := suite.k.IsMemberOfGroup(ctx, 1, 1, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm") suite.Require().False(result) }, }, @@ -1699,6 +2750,7 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserPermissions() { name: "subspace not found returns error", msg: types.NewMsgSetUserPermissions( 1, + 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionWrite, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", @@ -1720,6 +2772,7 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserPermissions() { }, msg: types.NewMsgSetUserPermissions( 1, + 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionWrite, "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", @@ -1739,14 +2792,13 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserPermissions() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionSetPermissions) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionSetPermissions) }, msg: types.NewMsgSetUserPermissions( 1, + 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", - 256, + 9999999, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", ), shouldErr: true, @@ -1764,12 +2816,11 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserPermissions() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos17ua98rre5j9ce7hfude0y5y3rh4gtqkygm8hru") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionSetPermissions) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos17ua98rre5j9ce7hfude0y5y3rh4gtqkygm8hru", types.PermissionSetPermissions) }, msg: types.NewMsgSetUserPermissions( 1, + 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionWrite, "cosmos17ua98rre5j9ce7hfude0y5y3rh4gtqkygm8hru", @@ -1789,9 +2840,7 @@ func (suite *KeeperTestsuite) TestMsgServer_SetUserPermissions() { ), }, check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") - suite.Require().NoError(err) - permissions := suite.k.GetUserPermissions(ctx, 1, sdkAddr) + permissions := suite.k.GetUserPermissions(ctx, 1, 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53") suite.Require().Equal(types.PermissionWrite, permissions) }, }, diff --git a/x/subspaces/keeper/permissions.go b/x/subspaces/keeper/permissions.go index 3c07c42a94..55612f6077 100644 --- a/x/subspaces/keeper/permissions.go +++ b/x/subspaces/keeper/permissions.go @@ -7,86 +7,107 @@ import ( ) // SetUserPermissions sets the given permission for the specific user inside a single subspace -func (k Keeper) SetUserPermissions(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permissions types.Permission) { +func (k Keeper) SetUserPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permissions types.Permission) { store := ctx.KVStore(k.storeKey) - store.Set(types.UserPermissionStoreKey(subspaceID, user), types.MarshalPermission(permissions)) + store.Set(types.UserPermissionStoreKey(subspaceID, sectionID, user), types.MarshalPermission(permissions)) - k.AfterUserPermissionSet(ctx, subspaceID, user, permissions) + k.AfterUserPermissionSet(ctx, subspaceID, sectionID, user, permissions) } // HasPermission checks whether the specific user has the given permission inside a specific subspace -func (k Keeper) HasPermission(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permission types.Permission) bool { +func (k Keeper) HasPermission(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permission types.Permission) bool { // Get the subspace to make sure the request is valid subspace, found := k.GetSubspace(ctx, subspaceID) if !found { return false } - specificPermissions := k.GetUserPermissions(ctx, subspaceID, user) - // The owner of the subspaces has all the permissions by default - if subspace.Owner == user.String() { + if subspace.Owner == user { return true } + // Get the permissions set to the specific user + specificPermissions := k.GetUserPermissions(ctx, subspaceID, sectionID, user) + // Get the group permissions - groupPermissions := k.GetGroupsInheritedPermissions(ctx, subspaceID, user) + groupPermissions := k.GetGroupsInheritedPermissions(ctx, subspaceID, sectionID, user) // Check the combination of the permissions return types.CheckPermission(types.CombinePermissions(specificPermissions, groupPermissions), permission) } +// getSectionPermissions gets the permissions for the given user set inside the specified section only +func (k Keeper) getSectionPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) types.Permission { + store := ctx.KVStore(k.storeKey) + return types.UnmarshalPermission(store.Get(types.UserPermissionStoreKey(subspaceID, sectionID, user))) +} + // GetUserPermissions returns the permissions that are currently set inside // the subspace with the given id for the given user -func (k Keeper) GetUserPermissions(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress) types.Permission { - store := ctx.KVStore(k.storeKey) - return types.UnmarshalPermission(store.Get(types.UserPermissionStoreKey(subspaceID, user))) +func (k Keeper) GetUserPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) types.Permission { + if sectionID == types.RootSectionID { + return k.getSectionPermissions(ctx, subspaceID, sectionID, user) + } + + sectionPermissions := k.getSectionPermissions(ctx, subspaceID, sectionID, user) + + // Get the parent permissions + parentPermissions := types.PermissionNothing + section, found := k.GetSection(ctx, subspaceID, sectionID) + if found { + parentPermissions = k.GetUserPermissions(ctx, subspaceID, section.ParentID, user) + } + + return types.CombinePermissions(parentPermissions, sectionPermissions) } // GetGroupsInheritedPermissions returns the permissions that the specified user // has inherited from all the groups that they are part of. -func (k Keeper) GetGroupsInheritedPermissions(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress) types.Permission { +func (k Keeper) GetGroupsInheritedPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) types.Permission { var permissions []types.Permission - k.IterateSubspaceGroups(ctx, subspaceID, func(index int64, group types.UserGroup) (stop bool) { - if k.IsMemberOfGroup(ctx, subspaceID, group.ID, user) { - permissions = append(permissions, group.Permissions) - } + + // Iterate over the section ancestors and get all the user groups for each ancestor + // to check if the user is part of a group + k.IterateSectionPath(ctx, subspaceID, sectionID, func(section types.Section) (stop bool) { + k.IterateSectionUserGroups(ctx, section.SubspaceID, section.ID, func(group types.UserGroup) (stop bool) { + if k.IsMemberOfGroup(ctx, subspaceID, group.ID, user) { + permissions = append(permissions, group.Permissions) + } + return false + }) return false }) + return types.CombinePermissions(permissions...) } -// GetUsersWithPermission returns all the users that have a given permission inside the specified subspace -func (k Keeper) GetUsersWithPermission(ctx sdk.Context, subspaceID uint64, permission types.Permission) ([]sdk.AccAddress, error) { +// GetUsersWithRootPermission returns all the users that have a given permission inside the specified subspace +func (k Keeper) GetUsersWithRootPermission(ctx sdk.Context, subspaceID uint64, permission types.Permission) ([]string, error) { subspace, found := k.GetSubspace(ctx, subspaceID) if !found { return nil, nil } // The owner must always be included as they have all the permissions - ownerAddr, err := sdk.AccAddressFromBech32(subspace.Owner) - if err != nil { - return nil, err - } - - users := []sdk.AccAddress{ownerAddr} + users := []string{subspace.Owner} // Iterate over the various groups - k.IterateSubspaceGroups(ctx, subspaceID, func(index int64, group types.UserGroup) (stop bool) { + k.IterateSectionUserGroups(ctx, subspaceID, types.RootSectionID, func(group types.UserGroup) (stop bool) { if !types.CheckPermission(group.Permissions, permission) { // Return early if the group does not have the permission. We will check other groups anyway return false } // If the group has the permission, get all the members - users = append(users, k.GetGroupMembers(ctx, subspaceID, group.ID)...) + users = append(users, k.GetUserGroupMembers(ctx, subspaceID, group.ID)...) return false }) // Iterate over the various individually-set permissions - k.IterateSubspacePermissions(ctx, subspaceID, func(index int64, user sdk.AccAddress, userPerm types.Permission) (stop bool) { - if types.CheckPermission(userPerm, permission) { - users = append(users, user) + k.IterateSectionUserPermissions(ctx, subspaceID, types.RootSectionID, func(entry types.UserPermission) (stop bool) { + if types.CheckPermission(entry.Permissions, permission) { + users = append(users, entry.User) } return false @@ -96,9 +117,9 @@ func (k Keeper) GetUsersWithPermission(ctx sdk.Context, subspaceID uint64, permi } // RemoveUserPermissions removes the permission for the given user inside the provided subspace -func (k Keeper) RemoveUserPermissions(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress) { +func (k Keeper) RemoveUserPermissions(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.UserPermissionStoreKey(subspaceID, user)) + store.Delete(types.UserPermissionStoreKey(subspaceID, sectionID, user)) - k.AfterUserPermissionRemoved(ctx, subspaceID, user) + k.AfterUserPermissionRemoved(ctx, subspaceID, sectionID, user) } diff --git a/x/subspaces/keeper/permissions_test.go b/x/subspaces/keeper/permissions_test.go index 885692f88e..760bce27c6 100644 --- a/x/subspaces/keeper/permissions_test.go +++ b/x/subspaces/keeper/permissions_test.go @@ -8,11 +8,12 @@ import ( "github.com/desmos-labs/desmos/v3/x/subspaces/types" ) -func (suite *KeeperTestsuite) TestKeeper_SetPermissions() { +func (suite *KeeperTestsuite) TestKeeper_SetUserPermissions() { testCases := []struct { name string store func(ctx sdk.Context) subspaceID uint64 + sectionID uint32 user string permission types.Permission check func(ctx sdk.Context) @@ -20,32 +21,25 @@ func (suite *KeeperTestsuite) TestKeeper_SetPermissions() { { name: "permission is set properly for user", subspaceID: 1, + sectionID: 1, user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", permission: types.PermissionChangeInfo, check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - permission := suite.k.GetUserPermissions(ctx, 1, sdkAddr) + permission := suite.k.GetUserPermissions(ctx, 1, 1, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") suite.Require().Equal(types.PermissionChangeInfo, permission) }, }, { name: "existing permission is overridden", store: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", types.PermissionManageGroups) }, subspaceID: 1, + sectionID: 0, user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", permission: types.PermissionWrite, check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - permission := suite.k.GetUserPermissions(ctx, 1, sdkAddr) + permission := suite.k.GetUserPermissions(ctx, 1, 0, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") suite.Require().Equal(types.PermissionWrite, permission) }, }, @@ -59,10 +53,7 @@ func (suite *KeeperTestsuite) TestKeeper_SetPermissions() { tc.store(ctx) } - sdkAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, tc.subspaceID, sdkAddr, tc.permission) + suite.k.SetUserPermissions(ctx, tc.subspaceID, tc.sectionID, tc.user, tc.permission) if tc.check != nil { tc.check(ctx) @@ -76,6 +67,7 @@ func (suite *KeeperTestsuite) TestKeeper_HasPermission() { name string store func(ctx sdk.Context) subspaceID uint64 + sectionID uint32 user string permission types.Permission expResult bool @@ -83,6 +75,7 @@ func (suite *KeeperTestsuite) TestKeeper_HasPermission() { { name: "subspace not found returns false", subspaceID: 1, + sectionID: 0, user: "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", expResult: false, }, @@ -100,12 +93,13 @@ func (suite *KeeperTestsuite) TestKeeper_HasPermission() { )) }, subspaceID: 1, + sectionID: 0, user: "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", permission: types.PermissionEverything, expResult: true, }, { - name: "user with inherited permission returns true", + name: "user with custom permission returns true", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -119,25 +113,23 @@ func (suite *KeeperTestsuite) TestKeeper_HasPermission() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite|types.PermissionChangeInfo, )) - - userAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", types.PermissionManageGroups) }, subspaceID: 1, + sectionID: 0, user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", - permission: types.PermissionWrite, + permission: types.PermissionManageGroups, expResult: true, }, { - name: "user with custom permission returns true", + name: "user with inherited permission returns true", store: func(ctx sdk.Context) { suite.k.SaveSubspace(ctx, types.NewSubspace( 1, @@ -151,23 +143,19 @@ func (suite *KeeperTestsuite) TestKeeper_HasPermission() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite|types.PermissionChangeInfo, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, 1, userAddr, types.PermissionManageGroups) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") }, subspaceID: 1, + sectionID: 0, user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", - permission: types.PermissionManageGroups, + permission: types.PermissionWrite, expResult: true, }, } @@ -180,10 +168,7 @@ func (suite *KeeperTestsuite) TestKeeper_HasPermission() { tc.store(ctx) } - sdkAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - result := suite.k.HasPermission(ctx, tc.subspaceID, sdkAddr, tc.permission) + result := suite.k.HasPermission(ctx, tc.subspaceID, tc.sectionID, tc.user, tc.permission) suite.Require().Equal(tc.expResult, result) }) } @@ -194,26 +179,49 @@ func (suite *KeeperTestsuite) TestKeeper_GetUserPermissions() { name string store func(ctx sdk.Context) subspaceID uint64 + sectionID uint32 user string expPermissions types.Permission }{ { name: "not found user returns PermissionNothing", subspaceID: 1, + sectionID: 0, user: "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", expPermissions: types.PermissionNothing, }, { name: "found user returns the correct permission", store: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionWrite|types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", types.PermissionWrite|types.PermissionManageGroups) }, subspaceID: 1, - user: "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + sectionID: 0, + user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", expPermissions: types.PermissionWrite | types.PermissionManageGroups, }, + { + name: "found user inside parent section returns correct permission", + store: func(ctx sdk.Context) { + // Store the section tree as follows + // root + // / \ + // A B + // | + // C + suite.k.SaveSection(ctx, types.DefaultSection(1)) + suite.k.SaveSection(ctx, types.NewSection(1, 1, 0, "A", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 2, 0, "B", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 3, 1, "C", "")) + + // Set the permission inside root + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", types.PermissionManageGroups) + }, + subspaceID: 1, + sectionID: 3, + user: "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + expPermissions: types.PermissionManageGroups, + }, } for _, tc := range testCases { @@ -224,10 +232,7 @@ func (suite *KeeperTestsuite) TestKeeper_GetUserPermissions() { tc.store(ctx) } - sdkAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - permission := suite.k.GetUserPermissions(ctx, tc.subspaceID, sdkAddr) + permission := suite.k.GetUserPermissions(ctx, tc.subspaceID, tc.sectionID, tc.user) suite.Require().Equal(tc.expPermissions, permission) }) } @@ -238,40 +243,44 @@ func (suite *KeeperTestsuite) TestKeeper_GetGroupsInheritedPermissions() { name string store func(ctx sdk.Context) subspaceID uint64 + sectionID uint32 user string expPermissions types.Permission }{ { name: "user in no group returns PermissionNothing", subspaceID: 1, + sectionID: 0, user: "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", expPermissions: types.PermissionNothing, }, { name: "user inside one group returns that group's permission", store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.DefaultSection(1)) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") - suite.Require().NoError(err) - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") }, subspaceID: 1, + sectionID: 0, user: "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", expPermissions: types.PermissionWrite, }, { name: "user inside multiple groups returns the combination of the various permissions", store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.DefaultSection(1)) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -279,22 +288,43 @@ func (suite *KeeperTestsuite) TestKeeper_GetGroupsInheritedPermissions() { )) suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 2, "Permission group", "This is a permissions group", types.PermissionSetPermissions|types.PermissionChangeInfo, )) - userAddr, err := sdk.AccAddressFromBech32("cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, userAddr) - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 2, userAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") + suite.k.AddUserToGroup(ctx, 1, 2, "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") }, subspaceID: 1, + sectionID: 0, + user: "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", + expPermissions: types.PermissionWrite | types.PermissionChangeInfo | types.PermissionSetPermissions, + }, + { + name: "user inside group of ancestor section returns correct permissions", + store: func(ctx sdk.Context) { + // Store the section tree as follows + // G1 -> root + // / \ + // G2 -> A B + // | + // C + suite.k.SaveSection(ctx, types.DefaultSection(1)) + suite.k.SaveSection(ctx, types.NewSection(1, 1, 0, "A", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 2, 0, "B", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 3, 1, "C", "")) + + suite.k.SaveUserGroup(ctx, types.NewUserGroup(1, 0, 1, "G1", "", types.PermissionWrite)) + suite.k.SaveUserGroup(ctx, types.NewUserGroup(1, 1, 2, "G2", "", types.PermissionSetPermissions|types.PermissionChangeInfo)) + + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") + suite.k.AddUserToGroup(ctx, 1, 2, "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm") + }, + subspaceID: 1, + sectionID: 3, user: "cosmos1fgppppwfjszpts4shpsfv7n2xtchcdwhycuvvm", expPermissions: types.PermissionWrite | types.PermissionChangeInfo | types.PermissionSetPermissions, }, @@ -308,16 +338,13 @@ func (suite *KeeperTestsuite) TestKeeper_GetGroupsInheritedPermissions() { tc.store(ctx) } - userAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - permissions := suite.k.GetGroupsInheritedPermissions(ctx, tc.subspaceID, userAddr) + permissions := suite.k.GetGroupsInheritedPermissions(ctx, tc.subspaceID, tc.sectionID, tc.user) suite.Require().Equal(tc.expPermissions, permissions) }) } } -func (suite *KeeperTestsuite) TestKeeper_GetUsersWithPermissions() { +func (suite *KeeperTestsuite) TestKeeper_GetUsersWithRootPermissions() { testCases := []struct { name string store func(ctx sdk.Context) @@ -358,24 +385,20 @@ func (suite *KeeperTestsuite) TestKeeper_GetUsersWithPermissions() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - - sdkAddr, err := sdk.AccAddressFromBech32("cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd") }, subspaceID: 1, permissions: types.PermissionWrite, shouldErr: false, expUsers: []string{ - "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", // Owner is always included + "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", }, }, { @@ -391,17 +414,14 @@ func (suite *KeeperTestsuite) TestKeeper_GetUsersWithPermissions() { time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd") - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionWrite) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite) }, subspaceID: 1, permissions: types.PermissionWrite, shouldErr: false, expUsers: []string{ - "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", // Owner is always included + "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", }, }, { @@ -419,49 +439,34 @@ func (suite *KeeperTestsuite) TestKeeper_GetUsersWithPermissions() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite|types.PermissionSetPermissions, )) - - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1xw69y2z3yf00rgfnly99628gn5c0x7fryyfv5e") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 1, sdkAddr) - suite.Require().NoError(err) + suite.k.AddUserToGroup(ctx, 1, 1, "cosmos1xw69y2z3yf00rgfnly99628gn5c0x7fryyfv5e") suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 2, "Another test group", "This is a second test group", types.PermissionSetPermissions, )) - sdkAddr, err = sdk.AccAddressFromBech32("cosmos1e32dfqu7k9e5wj85cjtalqdd2zs6z7adgswnrn") - suite.Require().NoError(err) - - err = suite.k.AddUserToGroup(ctx, 1, 2, sdkAddr) - suite.Require().NoError(err) - - sdkAddr, err = sdk.AccAddressFromBech32("cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd") - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionWrite|types.PermissionChangeInfo) - - sdkAddr, err = sdk.AccAddressFromBech32("cosmos1f3e5dhpg3afanddld0kp6lkayz2qvuetf6hmv3") - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionChangeInfo) + suite.k.AddUserToGroup(ctx, 1, 2, "cosmos1e32dfqu7k9e5wj85cjtalqdd2zs6z7adgswnrn") + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite|types.PermissionChangeInfo) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1f3e5dhpg3afanddld0kp6lkayz2qvuetf6hmv3", types.PermissionChangeInfo) }, subspaceID: 1, permissions: types.PermissionWrite, shouldErr: false, expUsers: []string{ - "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", - "cosmos1xw69y2z3yf00rgfnly99628gn5c0x7fryyfv5e", "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", // Owner is always included + "cosmos1xw69y2z3yf00rgfnly99628gn5c0x7fryyfv5e", + "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", }, }, } @@ -474,16 +479,12 @@ func (suite *KeeperTestsuite) TestKeeper_GetUsersWithPermissions() { tc.store(ctx) } - users, err := suite.k.GetUsersWithPermission(ctx, tc.subspaceID, tc.permissions) + users, err := suite.k.GetUsersWithRootPermission(ctx, tc.subspaceID, tc.permissions) if tc.shouldErr { suite.Require().Error(err) } else { suite.Require().NoError(err) - suite.Require().Len(users, len(tc.expUsers)) - - for _, user := range users { - suite.Require().Contains(tc.expUsers, user.String()) - } + suite.Require().Equal(tc.expUsers, users) } }) } @@ -494,36 +495,30 @@ func (suite *KeeperTestsuite) TestKeeper_RemoveUserPermissions() { name string store func(ctx sdk.Context) subspaceID uint64 + sectionID uint32 user string check func(ctx sdk.Context) }{ { name: "permission is deleted for non existing user", subspaceID: 1, + sectionID: 0, user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - permission := suite.k.GetUserPermissions(ctx, 1, sdkAddr) + permission := suite.k.GetUserPermissions(ctx, 1, 0, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") suite.Require().Equal(types.PermissionNothing, permission) }, }, { name: "permission is deleted for existing user", store: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionManageGroups) + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", types.PermissionManageGroups) }, subspaceID: 1, + sectionID: 1, user: "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn", check: func(ctx sdk.Context) { - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") - suite.Require().NoError(err) - - permission := suite.k.GetUserPermissions(ctx, 1, sdkAddr) + permission := suite.k.GetUserPermissions(ctx, 1, 1, "cosmos1fz49f2njk28ue8geqm63g4zzsm97lahqa9vmwn") suite.Require().Equal(types.PermissionNothing, permission) }, }, @@ -537,10 +532,7 @@ func (suite *KeeperTestsuite) TestKeeper_RemoveUserPermissions() { tc.store(ctx) } - sdkAddr, err := sdk.AccAddressFromBech32(tc.user) - suite.Require().NoError(err) - - suite.k.RemoveUserPermissions(ctx, tc.subspaceID, sdkAddr) + suite.k.RemoveUserPermissions(ctx, tc.subspaceID, tc.sectionID, tc.user) if tc.check != nil { tc.check(ctx) diff --git a/x/subspaces/keeper/sections.go b/x/subspaces/keeper/sections.go new file mode 100644 index 0000000000..f8a87cda67 --- /dev/null +++ b/x/subspaces/keeper/sections.go @@ -0,0 +1,114 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/desmos-labs/desmos/v3/x/subspaces/types" +) + +// SetNextSectionID sets the next section id for the specific subspace +func (k Keeper) SetNextSectionID(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + store := ctx.KVStore(k.storeKey) + store.Set(types.NextSectionIDStoreKey(subspaceID), types.GetSectionIDBytes(sectionID)) +} + +// HasNextSectionID tells whether the next section id key exists for the given subspace +func (k Keeper) HasNextSectionID(ctx sdk.Context, subspaceID uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.NextSectionIDStoreKey(subspaceID)) +} + +// GetNextSectionID gets the next section id for the subspace having the given id +func (k Keeper) GetNextSectionID(ctx sdk.Context, subspaceID uint64) (sectionID uint32, err error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.NextSectionIDStoreKey(subspaceID)) + if bz == nil { + return 0, sdkerrors.Wrapf(types.ErrInvalidGenesis, "initial section id hasn't been set for subspace %d", subspaceID) + } + + sectionID = types.GetSectionIDFromBytes(bz) + return sectionID, nil +} + +// DeleteNextSectionID deletes the next section id key for the given subspace from the store +func (k Keeper) DeleteNextSectionID(ctx sdk.Context, subspaceID uint64) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.NextSectionIDStoreKey(subspaceID)) +} + +// -------------------------------------------------------------------------------------------------------------------- + +// SaveSection saves the given section inside the current context +func (k Keeper) SaveSection(ctx sdk.Context, section types.Section) { + store := ctx.KVStore(k.storeKey) + + // Save the section + store.Set(types.SectionStoreKey(section.SubspaceID, section.ID), k.cdc.MustMarshal(§ion)) + + k.Logger(ctx).Info("section saved", "subspace id", section.SubspaceID, "section id", section.ID) + k.AfterSubspaceSectionSaved(ctx, section.SubspaceID, section.ID) +} + +// IsSectionPathValid tells whether the given path of the given section is valid or not. +// A path is considered to be valid if it's possible to reach the RootSection starting from a section. +func (k Keeper) IsSectionPathValid(ctx sdk.Context, subspaceID uint64, sectionID uint32) bool { + // To make sure a path is valid we can simply iterate over all the section path, and count how many times we visit + // the same section. If we visit it more than once, it means that the path is actually circular. + visitsCount := 0 + k.IterateSectionPath(ctx, subspaceID, sectionID, func(node types.Section) (stop bool) { + if node.SubspaceID == subspaceID && node.ID == sectionID { + visitsCount++ + } + return visitsCount > 1 + }) + return visitsCount == 1 +} + +// HasSection tells whether the section having the given id exists inside the provided subspace +func (k Keeper) HasSection(ctx sdk.Context, subspaceID uint64, sectionID uint32) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.SectionStoreKey(subspaceID, sectionID)) +} + +// GetSection returns the section having the given id from the subspace with the provided id. +// If there is no section associated with the given id the function will return an empty section and false. +func (k Keeper) GetSection(ctx sdk.Context, subspaceID uint64, sectionID uint32) (section types.Section, found bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.SectionStoreKey(subspaceID, sectionID)) + if bz == nil { + return types.Section{}, false + } + + k.cdc.MustUnmarshal(bz, §ion) + return section, true +} + +// DeleteSection deletes the section having the given id from the subspace with the provided id +func (k Keeper) DeleteSection(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + store := ctx.KVStore(k.storeKey) + + // Remove all the groups within this section + k.IterateSectionUserGroups(ctx, subspaceID, sectionID, func(group types.UserGroup) (stop bool) { + k.DeleteUserGroup(ctx, group.SubspaceID, group.ID) + return false + }) + + // Remove all the permissions set inside the section + k.IterateSectionUserPermissions(ctx, subspaceID, sectionID, func(entry types.UserPermission) (stop bool) { + k.RemoveUserPermissions(ctx, entry.SubspaceID, entry.SectionID, entry.User) + return false + }) + + // Remove all the children sections + k.IterateSectionChildren(ctx, subspaceID, sectionID, func(section types.Section) (stop bool) { + k.DeleteSection(ctx, section.SubspaceID, section.ID) + return false + }) + + // Delete the section + store.Delete(types.SectionStoreKey(subspaceID, sectionID)) + + k.Logger(ctx).Info("section deleted", "subspace id", subspaceID, "section id", sectionID) + k.AfterSubspaceSectionDeleted(ctx, subspaceID, sectionID) +} diff --git a/x/subspaces/keeper/sections_test.go b/x/subspaces/keeper/sections_test.go new file mode 100644 index 0000000000..57afa7f341 --- /dev/null +++ b/x/subspaces/keeper/sections_test.go @@ -0,0 +1,547 @@ +package keeper_test + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/desmos-labs/desmos/v3/x/subspaces/types" +) + +func (suite *KeeperTestsuite) TestKeeper_SetNextSectionID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + sectionID uint32 + check func(ctx sdk.Context) + }{ + { + name: "non existing next section id is set properly", + subspaceID: 1, + sectionID: 1, + check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) + stored := types.GetSectionIDFromBytes(store.Get(types.NextSectionIDStoreKey(1))) + suite.Require().Equal(uint32(1), stored) + }, + }, + { + name: "existing next section id is overridden properly", + store: func(ctx sdk.Context) { + suite.k.SetNextSectionID(ctx, 1, 1) + }, + subspaceID: 1, + sectionID: 2, + check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) + stored := types.GetSectionIDFromBytes(store.Get(types.NextSectionIDStoreKey(1))) + suite.Require().Equal(uint32(2), stored) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + suite.k.SetNextSectionID(ctx, tc.subspaceID, tc.sectionID) + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_HasNextSectionID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + expResult bool + }{ + { + name: "non existing next section id returns false", + subspaceID: 1, + expResult: false, + }, + { + name: "existing next section id returns true", + store: func(ctx sdk.Context) { + suite.k.SetNextSectionID(ctx, 1, 1) + }, + subspaceID: 1, + expResult: true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + result := suite.k.HasNextSectionID(ctx, tc.subspaceID) + suite.Require().Equal(tc.expResult, result) + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_GetNextSectionID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + shouldErr bool + expNextSectionID uint32 + }{ + { + name: "non existing next section id returns error", + subspaceID: 1, + shouldErr: true, + }, + { + name: "existing next section id is returned properly", + store: func(ctx sdk.Context) { + suite.k.SetNextSectionID(ctx, 1, 1) + }, + subspaceID: 1, + shouldErr: false, + expNextSectionID: 1, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + nextSectionID, err := suite.k.GetNextSectionID(ctx, tc.subspaceID) + if tc.shouldErr { + suite.Require().Error(err) + } else { + suite.Require().NoError(err) + suite.Require().Equal(tc.expNextSectionID, nextSectionID) + } + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_DeleteNextSectionID() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + check func(ctx sdk.Context) + }{ + { + name: "non existing next section id is deleted properly", + subspaceID: 1, + check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) + suite.Require().False(store.Has(types.NextSectionIDStoreKey(1))) + }, + }, + { + name: "existing next section is is deleted properly", + store: func(ctx sdk.Context) { + suite.k.SetNextSectionID(ctx, 1, 1) + }, + subspaceID: 1, + check: func(ctx sdk.Context) { + store := ctx.KVStore(suite.storeKey) + suite.Require().False(store.Has(types.NextSectionIDStoreKey(1))) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + suite.k.DeleteNextSectionID(ctx, tc.subspaceID) + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + +// -------------------------------------------------------------------------------------------------------------------- + +func (suite *KeeperTestsuite) TestKeeper_SaveSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + section types.Section + check func(ctx sdk.Context) + }{ + { + name: "non existing section is stored properly", + section: types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), + check: func(ctx sdk.Context) { + stored, found := suite.k.GetSection(ctx, 1, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), stored) + }, + }, + { + name: "existing section is overridden properly", + store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + )) + }, + section: types.NewSection( + 1, + 1, + 1, + "Edited section", + "This is an edited section", + ), + check: func(ctx sdk.Context) { + stored, found := suite.k.GetSection(ctx, 1, 1) + suite.Require().True(found) + suite.Require().Equal(types.NewSection( + 1, + 1, + 1, + "Edited section", + "This is an edited section", + ), stored) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + suite.k.SaveSection(ctx, tc.section) + if tc.check != nil { + tc.check(ctx) + } + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_IsSectionPathValid() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + sectionID uint32 + expResult bool + }{ + { + name: "section with circular path returns false", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + // Create the following subspaces sections + // Root + // + // A + // / \ + // B - C + suite.k.SaveSection(ctx, types.DefaultSection(1)) + suite.k.SaveSection(ctx, types.NewSection(1, 1, 3, "A", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 2, 1, "B", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 3, 2, "C", "")) + }, + subspaceID: 1, + sectionID: 3, + expResult: false, + }, + { + name: "section with relative path returns false", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + // Create the following subspaces sections + // Root + // + // A - B + suite.k.SaveSection(ctx, types.DefaultSection(1)) + suite.k.SaveSection(ctx, types.NewSection(1, 1, 2, "A", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 2, 1, "B", "")) + }, + subspaceID: 1, + sectionID: 2, + expResult: false, + }, + { + name: "section with valid path returns true", + store: func(ctx sdk.Context) { + suite.k.SaveSubspace(ctx, types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + )) + + // Create the following subspaces sections + // Root + // / \ + // A B + // | + // C + suite.k.SaveSection(ctx, types.DefaultSection(1)) + suite.k.SaveSection(ctx, types.NewSection(1, 1, types.RootSectionID, "A", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 2, types.RootSectionID, "B", "")) + suite.k.SaveSection(ctx, types.NewSection(1, 3, 1, "C", "")) + }, + subspaceID: 1, + sectionID: 3, + expResult: true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + result := suite.k.IsSectionPathValid(ctx, tc.subspaceID, tc.sectionID) + suite.Require().Equal(tc.expResult, result) + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_HasSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + sectionID uint32 + expResult bool + }{ + { + name: "non existing section returns false", + subspaceID: 1, + sectionID: 1, + expResult: false, + }, + { + name: "existing section returns true", + store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 1, + "Edited section", + "This is an edited section", + )) + }, + subspaceID: 1, + sectionID: 1, + expResult: true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + result := suite.k.HasSection(ctx, tc.subspaceID, tc.sectionID) + suite.Require().Equal(tc.expResult, result) + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_GetSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + sectionID uint32 + expSection types.Section + expFound bool + }{ + { + name: "non existing section returns empty section and false", + subspaceID: 1, + sectionID: 1, + expSection: types.Section{}, + expFound: false, + }, + { + name: "existing section returns correct data and true", + store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 1, + "Edited section", + "This is an edited section", + )) + }, + subspaceID: 1, + sectionID: 1, + expSection: types.NewSection( + 1, + 1, + 1, + "Edited section", + "This is an edited section", + ), + expFound: true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + section, found := suite.k.GetSection(ctx, tc.subspaceID, tc.sectionID) + suite.Require().Equal(tc.expSection, section) + suite.Require().Equal(tc.expFound, found) + }) + } +} + +func (suite *KeeperTestsuite) TestKeeper_DeleteSection() { + testCases := []struct { + name string + store func(ctx sdk.Context) + subspaceID uint64 + sectionID uint32 + check func(ctx sdk.Context) + }{ + { + name: "non existing section is deleted properly", + subspaceID: 1, + sectionID: 1, + check: func(ctx sdk.Context) { + suite.Require().False(suite.k.HasSection(ctx, 1, 1)) + }, + }, + { + name: "existing section is deleted properly along all the related data", + store: func(ctx sdk.Context) { + suite.k.SaveSection(ctx, types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test edited section", + )) + + // User groups + suite.k.SaveUserGroup(ctx, types.NewUserGroup( + 1, + 1, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + )) + + // Permissions + suite.k.SetUserPermissions(ctx, 1, 1, "cosmos1p7vudy57pw08w6plujlpqpuqea2hkqusfq5zjc", types.PermissionManageSections) + + // Children section + suite.k.SaveSection(ctx, types.NewSection( + 1, + 2, + 1, + "Child section", + "This is a child section", + )) + }, + subspaceID: 1, + sectionID: 1, + check: func(ctx sdk.Context) { + // Make sure the section and its children have been deleted + sections := suite.k.GetSubspaceSections(ctx, 1) + suite.Require().Empty(sections) + + // Make sure user groups have been deleted + groups := suite.k.GetSectionUserGroups(ctx, 1, 1) + suite.Require().Empty(groups) + + // Make sure all user group members have been deleted + permissions := suite.k.GetSectionUserPermissions(ctx, 1, 1) + suite.Require().Empty(permissions) + }, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + ctx, _ := suite.ctx.CacheContext() + if tc.store != nil { + tc.store(ctx) + } + + suite.k.DeleteSection(ctx, tc.subspaceID, tc.sectionID) + if tc.check != nil { + tc.check(ctx) + } + }) + } +} diff --git a/x/subspaces/keeper/subspaces.go b/x/subspaces/keeper/subspaces.go index 6dc8dbf9c8..0ecec5fcdc 100644 --- a/x/subspaces/keeper/subspaces.go +++ b/x/subspaces/keeper/subspaces.go @@ -32,12 +32,21 @@ func (k Keeper) SaveSubspace(ctx sdk.Context, subspace types.Subspace) { store := ctx.KVStore(k.storeKey) // Store the subspace - store.Set(types.SubspaceKey(subspace.ID), k.cdc.MustMarshal(&subspace)) + store.Set(types.SubspaceStoreKey(subspace.ID), k.cdc.MustMarshal(&subspace)) + + // If the initial section id does not exist, create it now + if !k.HasNextSectionID(ctx, subspace.ID) { + k.SetNextSectionID(ctx, subspace.ID, 1) + } + + // If the subspace does not have the default section, create it now + if !k.HasSection(ctx, subspace.ID, 0) { + k.SaveSection(ctx, types.DefaultSection(subspace.ID)) + } // If the initial group id does not exist, create it now - groupIDKey := types.GroupIDStoreKey(subspace.ID) - if !store.Has(groupIDKey) { - store.Set(groupIDKey, types.GetGroupIDBytes(1)) + if !k.HasNextGroupID(ctx, subspace.ID) { + k.SetNextGroupID(ctx, subspace.ID, 1) } // If the subspace does not have the default group, create it now @@ -52,7 +61,7 @@ func (k Keeper) SaveSubspace(ctx sdk.Context, subspace types.Subspace) { // HasSubspace tells whether the given subspace exists or not func (k Keeper) HasSubspace(ctx sdk.Context, subspaceID uint64) bool { store := ctx.KVStore(k.storeKey) - return store.Has(types.SubspaceKey(subspaceID)) + return store.Has(types.SubspaceStoreKey(subspaceID)) } // GetSubspace returns the subspace associated with the given id. @@ -60,7 +69,7 @@ func (k Keeper) HasSubspace(ctx sdk.Context, subspaceID uint64) bool { func (k Keeper) GetSubspace(ctx sdk.Context, subspaceID uint64) (subspace types.Subspace, found bool) { store := ctx.KVStore(k.storeKey) - key := types.SubspaceKey(subspaceID) + key := types.SubspaceStoreKey(subspaceID) if !store.Has(key) { return types.Subspace{}, false } @@ -73,26 +82,23 @@ func (k Keeper) GetSubspace(ctx sdk.Context, subspaceID uint64) (subspace types. func (k Keeper) DeleteSubspace(ctx sdk.Context, subspaceID uint64) { // Delete the subspace store := ctx.KVStore(k.storeKey) - store.Delete(types.SubspaceKey(subspaceID)) + store.Delete(types.SubspaceStoreKey(subspaceID)) - // Delete the group id - store.Delete(types.GroupIDStoreKey(subspaceID)) + // Delete the section and group id + k.DeleteNextSectionID(ctx, subspaceID) + k.DeleteNextGroupID(ctx, subspaceID) - // Delete all user groups - for _, group := range k.GetSubspaceGroups(ctx, subspaceID) { - k.DeleteUserGroup(ctx, subspaceID, group.ID) - } - - // Delete all the permissions for this subspace - var usersWithPermissions []sdk.AccAddress - k.IterateSubspacePermissions(ctx, subspaceID, func(_ int64, user sdk.AccAddress, _ types.Permission) (stop bool) { - usersWithPermissions = append(usersWithPermissions, user) + // Delete all sections + k.IterateSubspaceSections(ctx, subspaceID, func(section types.Section) (stop bool) { + k.DeleteSection(ctx, section.SubspaceID, section.ID) return false }) - for _, member := range usersWithPermissions { - k.RemoveUserPermissions(ctx, subspaceID, member) - } + // Delete all user groups + k.IterateSubspaceUserGroups(ctx, subspaceID, func(group types.UserGroup) (stop bool) { + k.DeleteUserGroup(ctx, group.SubspaceID, group.ID) + return false + }) // Log the subspace deletion k.Logger(ctx).Info("subspace deleted", "id", subspaceID) diff --git a/x/subspaces/keeper/subspaces_test.go b/x/subspaces/keeper/subspaces_test.go index 9e79208ff6..d7007d7891 100644 --- a/x/subspaces/keeper/subspaces_test.go +++ b/x/subspaces/keeper/subspaces_test.go @@ -120,7 +120,8 @@ func (suite *KeeperTestsuite) TestKeeper_SaveSubspace() { ), subspace) store := ctx.KVStore(suite.storeKey) - suite.Require().True(store.Has(types.GroupIDStoreKey(subspace.ID))) + suite.Require().True(store.Has(types.NextSectionIDStoreKey(subspace.ID))) + suite.Require().True(store.Has(types.NextGroupIDStoreKey(subspace.ID))) suite.Require().True(suite.k.HasUserGroup(ctx, subspace.ID, 0)) }, }, @@ -310,28 +311,36 @@ func (suite *KeeperTestsuite) TestKeeper_DeleteSubspace() { suite.k.SaveUserGroup(ctx, types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, )) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") - suite.Require().NoError(err) - suite.k.SetUserPermissions(ctx, 1, sdkAddr, types.PermissionWrite) + suite.k.SetUserPermissions(ctx, 1, 0, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", types.PermissionWrite) }, subspaceID: 1, check: func(ctx sdk.Context) { + // Make sure subspace is deleted found := suite.k.HasSubspace(ctx, 1) suite.Require().False(found) - groups := suite.k.GetSubspaceGroups(ctx, 1) + // Make sure the subspace data are deleted + suite.Require().False(suite.k.HasNextSectionID(ctx, 1)) + suite.Require().False(suite.k.HasNextGroupID(ctx, 1)) + + // Make sure sections are deleted + sections := suite.k.GetSubspaceSections(ctx, 1) + suite.Require().Empty(sections) + + // Make sure user groups are deleted + groups := suite.k.GetSubspaceUserGroups(ctx, 1) suite.Require().Empty(groups) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") - suite.Require().NoError(err) - permission := suite.k.GetUserPermissions(ctx, 1, sdkAddr) - suite.Require().Equal(types.PermissionNothing, permission) + // Make sure the permissions are deleted + permissions := suite.k.GetSubspaceUserPermissions(ctx, 1) + suite.Require().Empty(permissions) }, }, } diff --git a/x/subspaces/legacy/v2/keys.go b/x/subspaces/legacy/v2/keys.go new file mode 100644 index 0000000000..7c16a59432 --- /dev/null +++ b/x/subspaces/legacy/v2/keys.go @@ -0,0 +1,94 @@ +package v2 + +import ( + "encoding/binary" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// DONTCOVER + +var ( + SubspacePrefix = []byte{0x01} + GroupIDPrefix = []byte{0x02} + GroupsPrefix = []byte{0x03} + GroupMembersStorePrefix = []byte{0x04} + UserPermissionsStorePrefix = []byte{0x05} +) + +// GetSubspaceIDBytes returns the byte representation of the subspaceID +func GetSubspaceIDBytes(subspaceID uint64) (subspaceIDBz []byte) { + subspaceIDBz = make([]byte, 8) + binary.BigEndian.PutUint64(subspaceIDBz, subspaceID) + return +} + +// GetSubspaceIDFromBytes returns subspaceID in uint64 format from a byte array +func GetSubspaceIDFromBytes(bz []byte) (subspaceID uint64) { + return binary.BigEndian.Uint64(bz) +} + +// SubspaceKey returns the key for a specific subspace +func SubspaceKey(subspaceID uint64) []byte { + return append(SubspacePrefix, GetSubspaceIDBytes(subspaceID)...) +} + +// PermissionsStoreKey returns the key used to store the entire ACL for a given subspace +func PermissionsStoreKey(subspaceID uint64) []byte { + return append(UserPermissionsStorePrefix, GetSubspaceIDBytes(subspaceID)...) +} + +func GetAddressBytes(user sdk.AccAddress) []byte { + return user +} + +func GetAddressFromBytes(bz []byte) sdk.AccAddress { + return bz +} + +// -------------------------------------------------------------------------------------------------------------------- + +// GroupIDStoreKey returns the store key that is used to store the group id to be used next for the given subspace +func GroupIDStoreKey(subspaceID uint64) []byte { + return append(GroupIDPrefix, GetSubspaceIDBytes(subspaceID)...) +} + +// GetGroupIDBytes returns the byte representation of the groupID +func GetGroupIDBytes(groupID uint32) (groupIDBz []byte) { + groupIDBz = make([]byte, 4) + binary.BigEndian.PutUint32(groupIDBz, groupID) + return +} + +// GetGroupIDFromBytes returns groupID in uint32 format from a byte array +func GetGroupIDFromBytes(bz []byte) (subspaceID uint32) { + return binary.BigEndian.Uint32(bz) +} + +// GroupsStoreKey returns the key used to store all the groups of a given subspace +func GroupsStoreKey(subspaceID uint64) []byte { + return append(GroupsPrefix, GetSubspaceIDBytes(subspaceID)...) +} + +// GroupStoreKey returns the key used to store a group for a subspace +func GroupStoreKey(subspaceID uint64, groupID uint32) []byte { + return append(GroupsStoreKey(subspaceID), GetGroupIDBytes(groupID)...) +} + +// GroupMembersStoreKey returns the key used to store all the members of the given group inside the given subspace +func GroupMembersStoreKey(subspaceID uint64, groupID uint32) []byte { + return append(append(GroupMembersStorePrefix, GetSubspaceIDBytes(subspaceID)...), GetGroupIDBytes(groupID)...) +} + +// GroupMemberStoreKey returns the key used to store the membership of the given user to the +// specified group inside the provided subspace +func GroupMemberStoreKey(subspaceID uint64, groupID uint32, user sdk.AccAddress) []byte { + return append(GroupMembersStoreKey(subspaceID, groupID), GetAddressBytes(user)...) +} + +// -------------------------------------------------------------------------------------------------------------------- + +// UserPermissionStoreKey returns the key used to store the permission for the given user inside the given subspace +func UserPermissionStoreKey(subspaceID uint64, user sdk.AccAddress) []byte { + return append(PermissionsStoreKey(subspaceID), GetAddressBytes(user)...) +} diff --git a/x/subspaces/legacy/v2/models.go b/x/subspaces/legacy/v2/models.go new file mode 100644 index 0000000000..ee3d6d1878 --- /dev/null +++ b/x/subspaces/legacy/v2/models.go @@ -0,0 +1,38 @@ +package v2 + +// NewUserGroup returns a new UserGroup instance +func NewUserGroup(subspaceID uint64, id uint32, name, description string, permissions Permission) UserGroup { + return UserGroup{ + SubspaceID: subspaceID, + ID: id, + Name: name, + Description: description, + Permissions: permissions, + } +} + +// -------------------------------------------------------------------------------------------------------------------- + +// NewPermissionDetailUser returns a new PermissionDetail for the user with the given address and permission value +func NewPermissionDetailUser(user string, permission Permission) PermissionDetail { + return PermissionDetail{ + Sum: &PermissionDetail_User_{ + User: &PermissionDetail_User{ + User: user, + Permission: permission, + }, + }, + } +} + +// NewPermissionDetailGroup returns a new PermissionDetail for the user with the given id and permission value +func NewPermissionDetailGroup(groupID uint32, permission Permission) PermissionDetail { + return PermissionDetail{ + Sum: &PermissionDetail_Group_{ + Group: &PermissionDetail_Group{ + GroupID: groupID, + Permission: permission, + }, + }, + } +} diff --git a/x/subspaces/legacy/v2/models.pb.go b/x/subspaces/legacy/v2/models.pb.go new file mode 100644 index 0000000000..b6a10042a7 --- /dev/null +++ b/x/subspaces/legacy/v2/models.pb.go @@ -0,0 +1,1883 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: desmos/subspaces/v1/models.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Subspace contains all the data of a Desmos subspace +type Subspace struct { + // Unique id that identifies the subspace + ID uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + // Human-readable name of the subspace + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // Optional description of this subspace + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // Represents the account that is associated with the subspace and + // should be used to connect external applications to verify this subspace + Treasury string `protobuf:"bytes,4,opt,name=treasury,proto3" json:"treasury,omitempty" yaml:"treasury"` + // Address of the user that owns the subspace + Owner string `protobuf:"bytes,5,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` + // Address of the subspace creator + Creator string `protobuf:"bytes,6,opt,name=creator,proto3" json:"creator,omitempty" yaml:"creator"` + // the creation time of the subspace + CreationTime time.Time `protobuf:"bytes,7,opt,name=creation_time,json=creationTime,proto3,stdtime" json:"creation_time" yaml:"creation_time"` +} + +func (m *Subspace) Reset() { *m = Subspace{} } +func (m *Subspace) String() string { return proto.CompactTextString(m) } +func (*Subspace) ProtoMessage() {} +func (*Subspace) Descriptor() ([]byte, []int) { + return fileDescriptor_58f218b6c9069791, []int{0} +} +func (m *Subspace) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Subspace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Subspace.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Subspace) XXX_Merge(src proto.Message) { + xxx_messageInfo_Subspace.Merge(m, src) +} +func (m *Subspace) XXX_Size() int { + return m.Size() +} +func (m *Subspace) XXX_DiscardUnknown() { + xxx_messageInfo_Subspace.DiscardUnknown(m) +} + +var xxx_messageInfo_Subspace proto.InternalMessageInfo + +func (m *Subspace) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Subspace) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Subspace) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Subspace) GetTreasury() string { + if m != nil { + return m.Treasury + } + return "" +} + +func (m *Subspace) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *Subspace) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *Subspace) GetCreationTime() time.Time { + if m != nil { + return m.CreationTime + } + return time.Time{} +} + +// UserGroup represents a group of users +type UserGroup struct { + // ID of the subspace inside which this group exists + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Unique id that identifies the group + ID uint32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + // Human-readable name of the user group + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // Optional description of this group + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // Permissions that will be granted to all the users part of this group + Permissions uint32 `protobuf:"varint,5,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` +} + +func (m *UserGroup) Reset() { *m = UserGroup{} } +func (m *UserGroup) String() string { return proto.CompactTextString(m) } +func (*UserGroup) ProtoMessage() {} +func (*UserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_58f218b6c9069791, []int{1} +} +func (m *UserGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UserGroup.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserGroup.Merge(m, src) +} +func (m *UserGroup) XXX_Size() int { + return m.Size() +} +func (m *UserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_UserGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_UserGroup proto.InternalMessageInfo + +func (m *UserGroup) GetSubspaceID() uint64 { + if m != nil { + return m.SubspaceID + } + return 0 +} + +func (m *UserGroup) GetID() uint32 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *UserGroup) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *UserGroup) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *UserGroup) GetPermissions() uint32 { + if m != nil { + return m.Permissions + } + return 0 +} + +// PermissionDetail contains the details data of a permission +type PermissionDetail struct { + // sum is the oneof that specifies whether this represents a user or + // group permission detail + // + // Types that are valid to be assigned to Sum: + // *PermissionDetail_User_ + // *PermissionDetail_Group_ + Sum isPermissionDetail_Sum `protobuf_oneof:"sum"` +} + +func (m *PermissionDetail) Reset() { *m = PermissionDetail{} } +func (m *PermissionDetail) String() string { return proto.CompactTextString(m) } +func (*PermissionDetail) ProtoMessage() {} +func (*PermissionDetail) Descriptor() ([]byte, []int) { + return fileDescriptor_58f218b6c9069791, []int{2} +} +func (m *PermissionDetail) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PermissionDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PermissionDetail.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PermissionDetail) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDetail.Merge(m, src) +} +func (m *PermissionDetail) XXX_Size() int { + return m.Size() +} +func (m *PermissionDetail) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDetail.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDetail proto.InternalMessageInfo + +type isPermissionDetail_Sum interface { + isPermissionDetail_Sum() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type PermissionDetail_User_ struct { + User *PermissionDetail_User `protobuf:"bytes,1,opt,name=user,proto3,oneof" json:"user,omitempty"` +} +type PermissionDetail_Group_ struct { + Group *PermissionDetail_Group `protobuf:"bytes,2,opt,name=group,proto3,oneof" json:"group,omitempty"` +} + +func (*PermissionDetail_User_) isPermissionDetail_Sum() {} +func (*PermissionDetail_Group_) isPermissionDetail_Sum() {} + +func (m *PermissionDetail) GetSum() isPermissionDetail_Sum { + if m != nil { + return m.Sum + } + return nil +} + +func (m *PermissionDetail) GetUser() *PermissionDetail_User { + if x, ok := m.GetSum().(*PermissionDetail_User_); ok { + return x.User + } + return nil +} + +func (m *PermissionDetail) GetGroup() *PermissionDetail_Group { + if x, ok := m.GetSum().(*PermissionDetail_Group_); ok { + return x.Group + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*PermissionDetail) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*PermissionDetail_User_)(nil), + (*PermissionDetail_Group_)(nil), + } +} + +// User is a permission that has been set to a specific user +type PermissionDetail_User struct { + // User for which the permission was set + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` + // Permission set to the user + Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty" yaml:"permission"` +} + +func (m *PermissionDetail_User) Reset() { *m = PermissionDetail_User{} } +func (m *PermissionDetail_User) String() string { return proto.CompactTextString(m) } +func (*PermissionDetail_User) ProtoMessage() {} +func (*PermissionDetail_User) Descriptor() ([]byte, []int) { + return fileDescriptor_58f218b6c9069791, []int{2, 0} +} +func (m *PermissionDetail_User) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PermissionDetail_User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PermissionDetail_User.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PermissionDetail_User) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDetail_User.Merge(m, src) +} +func (m *PermissionDetail_User) XXX_Size() int { + return m.Size() +} +func (m *PermissionDetail_User) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDetail_User.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDetail_User proto.InternalMessageInfo + +// Group is a permission that has been set to a user group +type PermissionDetail_Group struct { + // Unique id of the group + GroupID uint32 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // Permission set to the group + Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty"` +} + +func (m *PermissionDetail_Group) Reset() { *m = PermissionDetail_Group{} } +func (m *PermissionDetail_Group) String() string { return proto.CompactTextString(m) } +func (*PermissionDetail_Group) ProtoMessage() {} +func (*PermissionDetail_Group) Descriptor() ([]byte, []int) { + return fileDescriptor_58f218b6c9069791, []int{2, 1} +} +func (m *PermissionDetail_Group) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PermissionDetail_Group) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PermissionDetail_Group.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PermissionDetail_Group) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDetail_Group.Merge(m, src) +} +func (m *PermissionDetail_Group) XXX_Size() int { + return m.Size() +} +func (m *PermissionDetail_Group) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDetail_Group.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDetail_Group proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Subspace)(nil), "desmos.subspaces.v1.Subspace") + proto.RegisterType((*UserGroup)(nil), "desmos.subspaces.v1.UserGroup") + proto.RegisterType((*PermissionDetail)(nil), "desmos.subspaces.v1.PermissionDetail") + proto.RegisterType((*PermissionDetail_User)(nil), "desmos.subspaces.v1.PermissionDetail.User") + proto.RegisterType((*PermissionDetail_Group)(nil), "desmos.subspaces.v1.PermissionDetail.Group") +} + +func init() { proto.RegisterFile("desmos/subspaces/v1/models.proto", fileDescriptor_58f218b6c9069791) } + +var fileDescriptor_58f218b6c9069791 = []byte{ + // 639 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x3f, 0x6f, 0xd3, 0x4e, + 0x1c, 0xc6, 0xed, 0xfc, 0x69, 0xd2, 0x73, 0xf3, 0x6b, 0x7f, 0xd7, 0x82, 0xac, 0x0c, 0xbe, 0xe8, + 0x8a, 0x50, 0xc5, 0x1f, 0x5b, 0x4d, 0x05, 0x2a, 0x9d, 0x50, 0x28, 0xa2, 0xdd, 0xaa, 0x03, 0x16, + 0x96, 0xca, 0x89, 0x0f, 0x63, 0xc9, 0xce, 0x45, 0x3e, 0x3b, 0xd0, 0x95, 0x01, 0x31, 0x76, 0x44, + 0x4c, 0x7d, 0x39, 0x1d, 0x3b, 0x32, 0x1d, 0x28, 0x59, 0x98, 0xfd, 0x0a, 0x90, 0xef, 0xec, 0xd4, + 0x94, 0x4a, 0x94, 0xed, 0xeb, 0x7b, 0x3e, 0xcf, 0x9d, 0xf3, 0x3c, 0xbe, 0x80, 0x9e, 0x47, 0x79, + 0xc4, 0xb8, 0xc3, 0xd3, 0x21, 0x9f, 0xb8, 0x23, 0xca, 0x9d, 0xe9, 0xb6, 0x13, 0x31, 0x8f, 0x86, + 0xdc, 0x9e, 0xc4, 0x2c, 0x61, 0x70, 0x5d, 0x11, 0xf6, 0x82, 0xb0, 0xa7, 0xdb, 0xdd, 0x0d, 0x9f, + 0xf9, 0x4c, 0xea, 0x4e, 0x3e, 0x29, 0xb4, 0x8b, 0x7c, 0xc6, 0xfc, 0x90, 0x3a, 0xf2, 0x69, 0x98, + 0xbe, 0x75, 0x92, 0x20, 0xa2, 0x3c, 0x71, 0xa3, 0x89, 0x02, 0xf0, 0xc7, 0x3a, 0x68, 0xbf, 0x2c, + 0xf6, 0x81, 0x9b, 0xa0, 0x16, 0x78, 0xa6, 0xde, 0xd3, 0xb7, 0x1a, 0x83, 0xf5, 0x99, 0x40, 0xb5, + 0xc3, 0xfd, 0x4c, 0xa0, 0xe5, 0x13, 0x37, 0x0a, 0xf7, 0x70, 0xe0, 0x61, 0x52, 0x0b, 0x3c, 0xb8, + 0x09, 0x1a, 0x63, 0x37, 0xa2, 0x66, 0xad, 0xa7, 0x6f, 0x2d, 0x0f, 0x56, 0x33, 0x81, 0x0c, 0x05, + 0xe4, 0xab, 0x98, 0x48, 0x11, 0xee, 0x02, 0xc3, 0xa3, 0x7c, 0x14, 0x07, 0x93, 0x24, 0x60, 0x63, + 0xb3, 0x2e, 0xd9, 0xdb, 0x99, 0x40, 0x50, 0xb1, 0x15, 0x11, 0x93, 0x2a, 0x0a, 0x1d, 0xd0, 0x4e, + 0x62, 0xea, 0xf2, 0x34, 0x3e, 0x31, 0x1b, 0xd2, 0xb6, 0x9e, 0x09, 0xb4, 0xaa, 0x6c, 0xa5, 0x82, + 0xc9, 0x02, 0x82, 0x77, 0x41, 0x93, 0xbd, 0x1f, 0xd3, 0xd8, 0x6c, 0x4a, 0x7a, 0x2d, 0x13, 0x68, + 0x45, 0xd1, 0x72, 0x19, 0x13, 0x25, 0xc3, 0x07, 0xa0, 0x35, 0x8a, 0xa9, 0x9b, 0xb0, 0xd8, 0x5c, + 0x92, 0x24, 0xcc, 0x04, 0xfa, 0x4f, 0x91, 0x85, 0x80, 0x49, 0x89, 0x40, 0x17, 0x74, 0xe4, 0x18, + 0xb0, 0xf1, 0x71, 0x9e, 0x99, 0xd9, 0xea, 0xe9, 0x5b, 0x46, 0xbf, 0x6b, 0xab, 0x40, 0xed, 0x32, + 0x50, 0xfb, 0x55, 0x19, 0xe8, 0xa0, 0x77, 0x2e, 0x90, 0x96, 0x09, 0xb4, 0x51, 0xd9, 0xb3, 0xb4, + 0xe3, 0xd3, 0xef, 0x48, 0x27, 0x2b, 0xe5, 0x5a, 0x6e, 0xda, 0x6b, 0x7f, 0x39, 0x43, 0xfa, 0xcf, + 0x33, 0xa4, 0xe3, 0xaf, 0x35, 0xb0, 0xfc, 0x9a, 0xd3, 0xf8, 0x45, 0xcc, 0xd2, 0x09, 0x7c, 0x0e, + 0x8c, 0xb2, 0xd9, 0xe3, 0x45, 0x1d, 0x77, 0x66, 0x02, 0x81, 0xb2, 0x28, 0x59, 0x4b, 0x91, 0x64, + 0x05, 0xc5, 0x04, 0x94, 0x4f, 0x87, 0x5e, 0x51, 0x66, 0xde, 0x52, 0xe7, 0xef, 0x65, 0xd6, 0xff, + 0xa1, 0xcc, 0xc6, 0xcd, 0xcb, 0xdc, 0x05, 0xc6, 0x84, 0xc6, 0x51, 0xc0, 0x79, 0xc0, 0xc6, 0x5c, + 0x36, 0xd4, 0xa9, 0x3a, 0x2b, 0x22, 0x26, 0x55, 0xb4, 0x12, 0xce, 0xa7, 0x3a, 0x58, 0x3b, 0x5a, + 0x28, 0xfb, 0x34, 0x71, 0x83, 0x10, 0x3e, 0x05, 0x8d, 0x94, 0xd3, 0x58, 0x86, 0x63, 0xf4, 0xef, + 0xd9, 0xd7, 0xdc, 0x08, 0xfb, 0xaa, 0xc9, 0xce, 0x23, 0x3e, 0xd0, 0x88, 0x74, 0xc2, 0x67, 0xa0, + 0xe9, 0xe7, 0x71, 0xcb, 0x84, 0x8c, 0xfe, 0xfd, 0x9b, 0x6d, 0x21, 0x1b, 0x3a, 0xd0, 0x88, 0xf2, + 0x76, 0x43, 0xd0, 0xc8, 0x37, 0xcd, 0x63, 0x5c, 0xbc, 0xce, 0x6f, 0x31, 0xe6, 0xab, 0xb8, 0x38, + 0xf1, 0x11, 0x00, 0x97, 0xbf, 0xb0, 0x28, 0xe6, 0x56, 0x26, 0xd0, 0xff, 0x57, 0xb3, 0xc0, 0xa4, + 0x02, 0xee, 0xb5, 0x3f, 0x9f, 0x21, 0x2d, 0x4f, 0xa2, 0x1b, 0x82, 0xa6, 0xfa, 0x42, 0x9e, 0x80, + 0xb6, 0x3c, 0xbf, 0xfc, 0x3c, 0x3a, 0x03, 0x6b, 0x26, 0x50, 0x4b, 0x8a, 0xb2, 0xe5, 0xe2, 0xba, + 0x94, 0x10, 0x26, 0x2d, 0x39, 0x1e, 0x7a, 0xd0, 0xfa, 0xf3, 0x25, 0xae, 0x3f, 0xed, 0x72, 0x1a, + 0x34, 0x41, 0x9d, 0xa7, 0xd1, 0xe0, 0xe8, 0x7c, 0x66, 0xe9, 0x17, 0x33, 0x4b, 0xff, 0x31, 0xb3, + 0xf4, 0xd3, 0xb9, 0xa5, 0x5d, 0xcc, 0x2d, 0xed, 0xdb, 0xdc, 0xd2, 0xde, 0x3c, 0xf6, 0x83, 0xe4, + 0x5d, 0x3a, 0xb4, 0x47, 0x2c, 0x72, 0x54, 0x8c, 0x0f, 0x43, 0x77, 0xc8, 0x8b, 0xd9, 0x99, 0xee, + 0x38, 0x1f, 0x2a, 0x7f, 0x67, 0x21, 0xf5, 0xdd, 0xd1, 0x89, 0x33, 0xed, 0x0f, 0x97, 0xe4, 0x2d, + 0xda, 0xf9, 0x15, 0x00, 0x00, 0xff, 0xff, 0x00, 0x05, 0x60, 0x11, 0xf3, 0x04, 0x00, 0x00, +} + +func (this *Subspace) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Subspace) + if !ok { + that2, ok := that.(Subspace) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ID != that1.ID { + return false + } + if this.Name != that1.Name { + return false + } + if this.Description != that1.Description { + return false + } + if this.Treasury != that1.Treasury { + return false + } + if this.Owner != that1.Owner { + return false + } + if this.Creator != that1.Creator { + return false + } + if !this.CreationTime.Equal(that1.CreationTime) { + return false + } + return true +} +func (this *UserGroup) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UserGroup) + if !ok { + that2, ok := that.(UserGroup) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.SubspaceID != that1.SubspaceID { + return false + } + if this.ID != that1.ID { + return false + } + if this.Name != that1.Name { + return false + } + if this.Description != that1.Description { + return false + } + if this.Permissions != that1.Permissions { + return false + } + return true +} +func (this *PermissionDetail) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail) + if !ok { + that2, ok := that.(PermissionDetail) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if that1.Sum == nil { + if this.Sum != nil { + return false + } + } else if this.Sum == nil { + return false + } else if !this.Sum.Equal(that1.Sum) { + return false + } + return true +} +func (this *PermissionDetail_User_) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_User_) + if !ok { + that2, ok := that.(PermissionDetail_User_) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.User.Equal(that1.User) { + return false + } + return true +} +func (this *PermissionDetail_Group_) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_Group_) + if !ok { + that2, ok := that.(PermissionDetail_Group_) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Group.Equal(that1.Group) { + return false + } + return true +} +func (this *PermissionDetail_User) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_User) + if !ok { + that2, ok := that.(PermissionDetail_User) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.User != that1.User { + return false + } + if this.Permission != that1.Permission { + return false + } + return true +} +func (this *PermissionDetail_Group) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_Group) + if !ok { + that2, ok := that.(PermissionDetail_Group) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.GroupID != that1.GroupID { + return false + } + if this.Permission != that1.Permission { + return false + } + return true +} +func (m *Subspace) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Subspace) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Subspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CreationTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CreationTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintModels(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x3a + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintModels(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x32 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintModels(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x2a + } + if len(m.Treasury) > 0 { + i -= len(m.Treasury) + copy(dAtA[i:], m.Treasury) + i = encodeVarintModels(dAtA, i, uint64(len(m.Treasury))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintModels(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.ID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *UserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Permissions != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Permissions)) + i-- + dAtA[i] = 0x28 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintModels(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a + } + if m.ID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PermissionDetail) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PermissionDetail) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *PermissionDetail_User_) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_User_) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.User != nil { + { + size, err := m.User.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintModels(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *PermissionDetail_Group_) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_Group_) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Group != nil { + { + size, err := m.Group.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintModels(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *PermissionDetail_User) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PermissionDetail_User) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_User) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Permission != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Permission)) + i-- + dAtA[i] = 0x10 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintModels(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PermissionDetail_Group) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PermissionDetail_Group) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_Group) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Permission != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Permission)) + i-- + dAtA[i] = 0x10 + } + if m.GroupID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintModels(dAtA []byte, offset int, v uint64) int { + offset -= sovModels(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Subspace) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovModels(uint64(m.ID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Treasury) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CreationTime) + n += 1 + l + sovModels(uint64(l)) + return n +} + +func (m *UserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovModels(uint64(m.SubspaceID)) + } + if m.ID != 0 { + n += 1 + sovModels(uint64(m.ID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + if m.Permissions != 0 { + n += 1 + sovModels(uint64(m.Permissions)) + } + return n +} + +func (m *PermissionDetail) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sum != nil { + n += m.Sum.Size() + } + return n +} + +func (m *PermissionDetail_User_) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.User != nil { + l = m.User.Size() + n += 1 + l + sovModels(uint64(l)) + } + return n +} +func (m *PermissionDetail_Group_) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Group != nil { + l = m.Group.Size() + n += 1 + l + sovModels(uint64(l)) + } + return n +} +func (m *PermissionDetail_User) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.User) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + if m.Permission != 0 { + n += 1 + sovModels(uint64(m.Permission)) + } + return n +} + +func (m *PermissionDetail_Group) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupID != 0 { + n += 1 + sovModels(uint64(m.GroupID)) + } + if m.Permission != 0 { + n += 1 + sovModels(uint64(m.Permission)) + } + return n +} + +func sovModels(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModels(x uint64) (n int) { + return sovModels(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Subspace) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Subspace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Subspace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Treasury = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreationTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CreationTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UserGroup) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UserGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UserGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + } + m.SubspaceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PermissionDetail) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PermissionDetail: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PermissionDetail: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &PermissionDetail_User{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &PermissionDetail_User_{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &PermissionDetail_Group{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &PermissionDetail_Group_{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PermissionDetail_User) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: User: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: User: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + } + m.Permission = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permission |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PermissionDetail_Group) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Group: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Group: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupID", wireType) + } + m.GroupID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + } + m.Permission = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permission |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModels(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModels + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModels + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModels + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthModels + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModels + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModels + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModels = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModels = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModels = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/subspaces/legacy/v2/permissions.go b/x/subspaces/legacy/v2/permissions.go new file mode 100644 index 0000000000..ee3a0b0f72 --- /dev/null +++ b/x/subspaces/legacy/v2/permissions.go @@ -0,0 +1,63 @@ +package v2 + +// Permission represents a permission that can be set to a user or user group +type Permission = uint32 + +const ( + // PermissionNothing represents the permission to do nothing + PermissionNothing = Permission(0b000000) + + // PermissionWrite identifies users that can create content inside the subspace + PermissionWrite = Permission(0b000001) + + // PermissionModerateContent allows users to moderate contents of other users (e.g. deleting it) + PermissionModerateContent = Permission(0b000010) + + // PermissionChangeInfo allows to change the information of the subspace + PermissionChangeInfo = Permission(0b000100) + + // PermissionManageGroups allows users to manage user groups and members + PermissionManageGroups = Permission(0b001000) + + // PermissionSetPermissions allows users to set other users' permissions (except PermissionSetPermissions). + // This includes managing user groups and the associated permissions + PermissionSetPermissions = Permission(0b010000) + + // PermissionDeleteSubspace allows users to delete the subspace. + PermissionDeleteSubspace = Permission(0b100000) + + // PermissionEverything allows to do everything. + // This should usually be reserved only to the owner (which has it by default) + PermissionEverything = Permission(0b111111) +) + +var ( + permissionsMap = map[Permission]string{ + PermissionNothing: "Nothing", + PermissionWrite: "Write", + PermissionModerateContent: "ModerateContent", + PermissionChangeInfo: "ChangeInfo", + PermissionManageGroups: "ManageGroups", + PermissionSetPermissions: "SetUserPermissions", + PermissionEverything: "Everything", + } +) + +// CombinePermissions combines all the given permissions into a single Permission object using the OR operator +func CombinePermissions(permissions ...Permission) Permission { + result := PermissionNothing + for _, permission := range permissions { + result |= permission + } + return result +} + +// SanitizePermission sanitizes the given permission to remove any unwanted bits set to 1 +func SanitizePermission(permission Permission) Permission { + mask := PermissionNothing + for perm := range permissionsMap { + mask = CombinePermissions(mask, perm) + } + + return permission & mask +} diff --git a/x/subspaces/legacy/v2/store.go b/x/subspaces/legacy/v2/store.go index ec9df98078..eedfc913e6 100644 --- a/x/subspaces/legacy/v2/store.go +++ b/x/subspaces/legacy/v2/store.go @@ -8,6 +8,8 @@ import ( "github.com/desmos-labs/desmos/v3/x/subspaces/types" ) +// MigrateStore migrates the store from version 1 to version 2. +// The migration process will fix all user and group permissions sanitizing their values. func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error { store := ctx.KVStore(storeKey) @@ -21,20 +23,21 @@ func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) return nil } +// fixGroupsPermissions iterates over all the group permissions and sanitizes their values func fixGroupsPermissions(store sdk.KVStore, cdc codec.BinaryCodec) error { - groupsStore := prefix.NewStore(store, types.GroupsPrefix) + groupsStore := prefix.NewStore(store, GroupsPrefix) iterator := groupsStore.Iterator(nil, nil) - var groups []types.UserGroup + var groups []UserGroup for ; iterator.Valid(); iterator.Next() { - var group types.UserGroup + var group UserGroup err := cdc.Unmarshal(iterator.Value(), &group) if err != nil { return err } // Sanitize the permissions - group.Permissions = types.SanitizePermission(group.Permissions) + group.Permissions = SanitizePermission(group.Permissions) groups = append(groups, group) } @@ -47,7 +50,7 @@ func fixGroupsPermissions(store sdk.KVStore, cdc codec.BinaryCodec) error { return err } - store.Set(types.GroupStoreKey(group.SubspaceID, group.ID), bz) + store.Set(GroupStoreKey(group.SubspaceID, group.ID), bz) } return nil @@ -59,8 +62,9 @@ type userPermissionDetails struct { permissions types.Permission } +// fixUsersPermissions iterates over all the users permissions and sanitizes their values func fixUsersPermissions(store sdk.KVStore) { - permissionsStore := prefix.NewStore(store, types.UserPermissionsStorePrefix) + permissionsStore := prefix.NewStore(store, UserPermissionsStorePrefix) iterator := permissionsStore.Iterator(nil, nil) var permissions []userPermissionDetails @@ -70,11 +74,11 @@ func fixUsersPermissions(store sdk.KVStore) { subspaceBz, addressBz := iterator.Key()[:8], iterator.Key()[8:] permissions = append(permissions, userPermissionDetails{ - subspaceID: types.GetSubspaceIDFromBytes(subspaceBz), - user: types.GetAddressBytes(addressBz), + subspaceID: GetSubspaceIDFromBytes(subspaceBz), + user: GetAddressBytes(addressBz), // Sanitize the permission - permissions: types.SanitizePermission(types.UnmarshalPermission(iterator.Value())), + permissions: SanitizePermission(types.UnmarshalPermission(iterator.Value())), }) } @@ -82,6 +86,6 @@ func fixUsersPermissions(store sdk.KVStore) { // Store the new permissions for _, entry := range permissions { - store.Set(types.UserPermissionStoreKey(entry.subspaceID, entry.user), types.MarshalPermission(entry.permissions)) + store.Set(UserPermissionStoreKey(entry.subspaceID, entry.user), types.MarshalPermission(entry.permissions)) } } diff --git a/x/subspaces/legacy/v2/store_test.go b/x/subspaces/legacy/v2/store_test.go index 1b7e348931..d27ca5e543 100644 --- a/x/subspaces/legacy/v2/store_test.go +++ b/x/subspaces/legacy/v2/store_test.go @@ -33,15 +33,15 @@ func TestMigrateStore(t *testing.T) { store: func(ctx sdk.Context) { kvStore := ctx.KVStore(keys[types.StoreKey]) - group := types.NewUserGroup(11, 11, "Test group", "", 0b11111111111111111111111100000001) - kvStore.Set(types.GroupStoreKey(group.SubspaceID, group.ID), cdc.MustMarshal(&group)) + group := v2.NewUserGroup(11, 11, "Test group", "", 0b11111111111111111111111111000001) + kvStore.Set(v2.GroupStoreKey(group.SubspaceID, group.ID), cdc.MustMarshal(&group)) }, check: func(ctx sdk.Context) { kvStore := ctx.KVStore(keys[types.StoreKey]) // Check the permissions - var group types.UserGroup - cdc.MustUnmarshal(kvStore.Get(types.GroupStoreKey(11, 11)), &group) + var group v2.UserGroup + cdc.MustUnmarshal(kvStore.Get(v2.GroupStoreKey(11, 11)), &group) require.Equal(t, types.PermissionWrite, group.Permissions) }, }, @@ -53,7 +53,7 @@ func TestMigrateStore(t *testing.T) { addr, err := sdk.AccAddressFromBech32("cosmos12e7ejq92sma437d3svemgfvl8sul8lxfs69mjv") require.NoError(t, err) - kvStore.Set(types.UserPermissionStoreKey(11, addr), types.MarshalPermission(0b11111111111111111111111100000001)) + kvStore.Set(v2.UserPermissionStoreKey(11, addr), types.MarshalPermission(0b1111111111111111111111111000001)) }, check: func(ctx sdk.Context) { kvStore := ctx.KVStore(keys[types.StoreKey]) @@ -62,7 +62,7 @@ func TestMigrateStore(t *testing.T) { require.NoError(t, err) // Check the permissions - stored := types.UnmarshalPermission(kvStore.Get(types.UserPermissionStoreKey(11, addr))) + stored := types.UnmarshalPermission(kvStore.Get(v2.UserPermissionStoreKey(11, addr))) require.Equal(t, types.PermissionWrite, stored) }, }, diff --git a/x/subspaces/legacy/v3/store.go b/x/subspaces/legacy/v3/store.go new file mode 100644 index 0000000000..055268a078 --- /dev/null +++ b/x/subspaces/legacy/v3/store.go @@ -0,0 +1,46 @@ +package v3 + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/desmos-labs/desmos/v3/x/subspaces/types" +) + +// MigrateStore migrates the store to version 3. +// The migration process includes the following operations: +// - set the NextSectionID to 1 for all the existing subspaces +// - create the default section for all the existing subspaces +func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + + err := setupSubspacesSections(store, cdc) + if err != nil { + return err + } + + return nil +} + +// setupSubspacesSections sets the NextSectionID to 1 for all the current subspaces and creates the default sections +func setupSubspacesSections(store sdk.KVStore, cdc codec.BinaryCodec) error { + subspacesStore := prefix.NewStore(store, types.SubspacePrefix) + iterator := subspacesStore.Iterator(nil, nil) + + for ; iterator.Valid(); iterator.Next() { + var subspace types.Subspace + if err := cdc.Unmarshal(iterator.Value(), &subspace); err != nil { + return err + } + + // Set the initial section id + store.Set(types.NextSectionIDStoreKey(subspace.ID), types.GetSectionIDBytes(1)) + + // Create the default section + defaultSection := types.DefaultSection(subspace.ID) + store.Set(types.SectionStoreKey(subspace.ID, 0), cdc.MustMarshal(&defaultSection)) + } + + return nil +} diff --git a/x/subspaces/legacy/v3/store_test.go b/x/subspaces/legacy/v3/store_test.go new file mode 100644 index 0000000000..71d4049025 --- /dev/null +++ b/x/subspaces/legacy/v3/store_test.go @@ -0,0 +1,82 @@ +package v3_test + +import ( + "testing" + "time" + + v3 "github.com/desmos-labs/desmos/v3/x/subspaces/legacy/v3" + + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" + + "github.com/desmos-labs/desmos/v3/app" + "github.com/desmos-labs/desmos/v3/testutil" + "github.com/desmos-labs/desmos/v3/x/subspaces/types" +) + +func TestMigrateStore(t *testing.T) { + cdc, _ := app.MakeCodecs() + + // Build all the necessary keys + keys := sdk.NewKVStoreKeys(types.StoreKey) + tKeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + testCases := []struct { + name string + store func(ctx sdk.Context) + shouldErr bool + check func(ctx sdk.Context) + }{ + { + name: "section data are set properly", + store: func(ctx sdk.Context) { + kvStore := ctx.KVStore(keys[types.StoreKey]) + + subspace := types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + ) + kvStore.Set(types.SubspaceStoreKey(1), cdc.MustMarshal(&subspace)) + }, + check: func(ctx sdk.Context) { + kvStore := ctx.KVStore(keys[types.StoreKey]) + + // Check the next section id + initialSectionID := types.GetSectionIDFromBytes(kvStore.Get(types.NextSectionIDStoreKey(1))) + require.Equal(t, uint32(1), initialSectionID) + + var section types.Section + cdc.MustUnmarshal(kvStore.Get(types.SectionStoreKey(1, 0)), §ion) + require.Equal(t, types.DefaultSection(1), section) + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + ctx := testutil.BuildContext(keys, tKeys, memKeys) + if tc.store != nil { + tc.store(ctx) + } + + err := v3.MigrateStore(ctx, keys[types.StoreKey], cdc) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + if tc.check != nil { + tc.check(ctx) + } + } + }) + } +} diff --git a/x/subspaces/module.go b/x/subspaces/module.go index 390ce98678..abbcc924dc 100644 --- a/x/subspaces/module.go +++ b/x/subspaces/module.go @@ -30,7 +30,7 @@ import ( ) const ( - consensusVersion = 2 + consensusVersion = 3 ) // type check to ensure the interface is properly implemented @@ -113,6 +113,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } + err = cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3) + if err != nil { + panic(err) + } } // NewAppModule creates a new AppModule Object diff --git a/x/subspaces/simulation/decoder.go b/x/subspaces/simulation/decoder.go index 653e423f60..e937417050 100644 --- a/x/subspaces/simulation/decoder.go +++ b/x/subspaces/simulation/decoder.go @@ -39,7 +39,7 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { cdc.MustUnmarshal(kvB.Value, &groupB) return fmt.Sprintf("GroupA: %s\nGroupB: %s\n", &groupA, &groupB) - case bytes.HasPrefix(kvA.Key, types.GroupMembersStorePrefix): + case bytes.HasPrefix(kvA.Key, types.GroupsMembersPrefix): return fmt.Sprintf("GroupMemberKeyA: %s\nGroupMemberKeyB: %s\n", kvA.Key, kvB.Key) case bytes.HasPrefix(kvA.Key, types.UserPermissionsStorePrefix): @@ -48,6 +48,18 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { permissionB = types.UnmarshalPermission(kvB.Value) return fmt.Sprintf("PermissionKeyA: %d\nPermissionKeyB: %d\n", permissionA, permissionB) + case bytes.HasPrefix(kvA.Key, types.SectionIDPrefix): + var sectionIDA, sectionIDB uint32 + sectionIDA = types.GetSectionIDFromBytes(kvA.Value) + sectionIDB = types.GetSectionIDFromBytes(kvB.Value) + return fmt.Sprintf("SectionIDA: %d\nSectionIDB: %d\n", sectionIDA, sectionIDB) + + case bytes.HasPrefix(kvA.Key, types.SectionsPrefix): + var sectionA, sectionB types.Section + cdc.MustUnmarshal(kvA.Value, §ionA) + cdc.MustUnmarshal(kvB.Value, §ionB) + return fmt.Sprintf("SectionA: %s\nSectionB: %s\n", §ionA, §ionB) + default: panic(fmt.Sprintf("unexpected %s key %X (%s)", types.ModuleName, kvA.Key, kvA.Key)) } diff --git a/x/subspaces/simulation/decoder_test.go b/x/subspaces/simulation/decoder_test.go index 1585913b93..2e58894c6a 100644 --- a/x/subspaces/simulation/decoder_test.go +++ b/x/subspaces/simulation/decoder_test.go @@ -10,8 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/kv" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/desmos-labs/desmos/v3/app" "github.com/desmos-labs/desmos/v3/x/subspaces/types" ) @@ -20,9 +18,6 @@ func TestDecodeStore(t *testing.T) { cdc, _ := app.MakeCodecs() decoder := simulation.NewDecodeStore(cdc) - sdkAddr, err := sdk.AccAddressFromBech32("cosmos19r59nc7wfgc5gjnu5ga5yztkvr5qssj24krx2f") - require.NoError(t, err) - subspace := types.NewSubspace( 1, "Test subspace", @@ -34,14 +29,20 @@ func TestDecodeStore(t *testing.T) { ) group := types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", types.PermissionWrite, ) - userAddr, err := sdk.AccAddressFromBech32("cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e") - require.NoError(t, err) + section := types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ) kvPairs := kv.Pairs{Pairs: []kv.Pair{ { @@ -49,25 +50,33 @@ func TestDecodeStore(t *testing.T) { Value: types.GetSubspaceIDBytes(1), }, { - Key: types.SubspaceKey(subspace.ID), + Key: types.SubspaceStoreKey(subspace.ID), Value: cdc.MustMarshal(&subspace), }, { - Key: types.GroupIDStoreKey(1), + Key: types.NextGroupIDStoreKey(1), Value: types.GetGroupIDBytes(1), }, { - Key: types.GroupStoreKey(1, 1), + Key: types.GroupStoreKey(1, 0, 1), Value: cdc.MustMarshal(&group), }, { - Key: types.GroupMemberStoreKey(1, 1, sdkAddr), + Key: types.GroupMemberStoreKey(1, 1, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e"), Value: []byte{0x01}, }, { - Key: types.UserPermissionStoreKey(1, userAddr), + Key: types.UserPermissionStoreKey(1, 0, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e"), Value: types.MarshalPermission(types.PermissionWrite), }, + { + Key: types.NextSectionIDStoreKey(1), + Value: types.GetSectionIDBytes(1), + }, + { + Key: types.SectionStoreKey(1, 1), + Value: cdc.MustMarshal(§ion), + }, { Key: []byte("Unknown key"), Value: nil, @@ -87,9 +96,11 @@ func TestDecodeStore(t *testing.T) { {"Group", fmt.Sprintf("GroupA: %s\nGroupB: %s\n", group.String(), group.String())}, {"Group member", fmt.Sprintf("GroupMemberKeyA: %s\nGroupMemberKeyB: %s\n", - types.GroupMemberStoreKey(1, 1, sdkAddr), types.GroupMemberStoreKey(1, 1, sdkAddr))}, + types.GroupMemberStoreKey(1, 1, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e"), types.GroupMemberStoreKey(1, 1, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e"))}, {"Permission", fmt.Sprintf("PermissionKeyA: %d\nPermissionKeyB: %d\n", types.PermissionWrite, types.PermissionWrite)}, + {"Section ID", fmt.Sprintf("SectionIDA: %d\nSectionIDB: %d\n", 1, 1)}, + {"Section", fmt.Sprintf("SectionA: %s\nSectionB: %s\n", §ion, §ion)}, {"other", ""}, } diff --git a/x/subspaces/simulation/genesis.go b/x/subspaces/simulation/genesis.go index 080ccadff7..9499432b41 100644 --- a/x/subspaces/simulation/genesis.go +++ b/x/subspaces/simulation/genesis.go @@ -17,18 +17,20 @@ import ( // RandomizeGenState generates a random GenesisState for subspaces func RandomizeGenState(simState *module.SimulationState) { subspaces := randomSubspaces(simState.Rand, simState.Accounts) - groups, members := randomUserGroups(simState.Rand, simState.Accounts, subspaces) + sections := randomSections(simState.Rand, subspaces) + groups := randomUserGroups(simState.Rand, subspaces) + members := randomUserGroupsMembers(simState.Rand, simState.Accounts, groups) acl := randomACL(simState.Rand, simState.Accounts, subspaces) - initialSubspaceID, genSubspaces := getInitialIDs(subspaces, groups) + initialSubspaceID, subspacesData := getSubspacesDataEntries(subspaces, sections, groups) // Create the genesis and sanitize it - subspacesGenesis := types.NewGenesisState(initialSubspaceID, genSubspaces, acl, groups, members) + subspacesGenesis := types.NewGenesisState(initialSubspaceID, subspacesData, subspaces, sections, acl, groups, members) subspacesGenesis = sanitizeGenesis(subspacesGenesis) simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(subspacesGenesis) } -// randomSubspaces returns randomly generated genesis account +// randomSubspaces generates a random slice of subspaces func randomSubspaces(r *rand.Rand, accs []simtypes.Account) (subspaces []types.Subspace) { subspacesNumber := r.Intn(100) subspaces = make([]types.Subspace, subspacesNumber) @@ -47,15 +49,34 @@ func randomSubspaces(r *rand.Rand, accs []simtypes.Account) (subspaces []types.S return subspaces } -// randomUserGroups generates random slice of user group details -func randomUserGroups( - r *rand.Rand, accounts []simtypes.Account, subspaces []types.Subspace, -) (groups []types.UserGroup, membersEntries []types.UserGroupMembersEntry) { - groupsNumber := r.Intn(30) +// randomSections generates a random slice of sections +func randomSections(r *rand.Rand, subspaces []types.Subspace) (sections []types.Section) { + sectionsNumer := r.Intn(20) + sections = make([]types.Section, sectionsNumer) + for i := 0; i < sectionsNumer; i++ { + subspace := RandomSubspace(r, subspaces) + + // Generate a random section + sections[i] = types.NewSection( + subspace.ID, + uint32(i)+1, + 0, + RandomSectionName(r), + RandomSectionDescription(r), + ) + } + return sections +} - groups = make([]types.UserGroup, groupsNumber) - membersEntries = make([]types.UserGroupMembersEntry, groupsNumber) +// randomUserGroups generates a random slice of user group details +func randomUserGroups(r *rand.Rand, subspaces []types.Subspace) []types.UserGroup { + if len(subspaces) == 0 { + return nil + } + groupsNumber := r.Intn(30) + + groups := make([]types.UserGroup, groupsNumber) for i := 0; i < groupsNumber; i++ { subspace := RandomSubspace(r, subspaces) groupID := uint32(i + 1) @@ -64,33 +85,48 @@ func randomUserGroups( permission := RandomPermission(r, validPermissions) // Build the group details - groups[i] = types.NewUserGroup(subspace.ID, groupID, RandomName(r), RandomDescription(r), permission) + groups[i] = types.NewUserGroup(subspace.ID, 0, groupID, RandomName(r), RandomDescription(r), permission) + } - // Get a random number of members - membersNumber := r.Intn(5) - members := make([]string, membersNumber) - for j := 0; j < membersNumber; j++ { - account, _ := simtypes.RandomAcc(r, accounts) - members[j] = account.Address.String() - } - members = sanitizeStrings(members) + return groups +} - // Build the members details - membersEntries[i] = types.NewUserGroupMembersEntry(subspace.ID, groupID, members) +// randomUserGroupsMembers generates a random slice of user group members +func randomUserGroupsMembers(r *rand.Rand, accounts []simtypes.Account, groups []types.UserGroup) []types.UserGroupMemberEntry { + if len(groups) == 0 { + return nil } - return groups, membersEntries + var membersEntries []types.UserGroupMemberEntry + for _, group := range groups { + for i := 0; i < r.Intn(10); i++ { + account, _ := simtypes.RandomAcc(r, accounts) + membersEntries = append(membersEntries, types.NewUserGroupMemberEntry(group.SubspaceID, group.ID, account.Address.String())) + } + } + return membersEntries } -// getInitialIDs returns the initial subspace id and various initial group ids given the slice of subspaces and groups -func getInitialIDs( - subspaces []types.Subspace, groups []types.UserGroup, -) (initialSubspaceID uint64, genSubspaces []types.GenesisSubspace) { +// getSubspacesDataEntries returns the subspace data entries based on the given data +func getSubspacesDataEntries( + subspaces []types.Subspace, sections []types.Section, groups []types.UserGroup, +) (initialSubspaceID uint64, subspacesData []types.SubspaceData) { + maxSubspaceID := uint64(0) + initialSectionID := map[uint64]uint32{} initialGroupIDS := map[uint64]uint32{} for _, subspace := range subspaces { if subspace.ID > initialSubspaceID { - initialSubspaceID = subspace.ID + maxSubspaceID = subspace.ID + } + + // Get the max section id + maxSectionID := uint32(0) + for _, section := range sections { + if section.SubspaceID == subspace.ID && section.ID > maxSectionID { + maxSectionID = section.ID + } } + initialSectionID[subspace.ID] = maxSectionID + 1 // Get the max group id maxGroupID := uint32(0) @@ -99,33 +135,30 @@ func getInitialIDs( maxGroupID = group.ID } } - - // Get the initial group id for this subspace initialGroupIDS[subspace.ID] = maxGroupID + 1 } - genSubspaces = make([]types.GenesisSubspace, len(subspaces)) + subspacesData = make([]types.SubspaceData, len(subspaces)) for i, subspace := range subspaces { - genSubspaces[i] = types.NewGenesisSubspace(subspace, initialGroupIDS[subspace.ID]) + subspacesData[i] = types.NewSubspaceData(subspace.ID, initialSectionID[subspace.ID], initialGroupIDS[subspace.ID]) } - return initialSubspaceID, genSubspaces + return maxSubspaceID + 1, subspacesData } // randomACL generates a random slice of ACL entries -func randomACL(r *rand.Rand, accounts []simtypes.Account, subspaces []types.Subspace) (entries []types.ACLEntry) { +func randomACL(r *rand.Rand, accounts []simtypes.Account, subspaces []types.Subspace) (entries []types.UserPermission) { aclEntriesNumber := r.Intn(40) - entries = make([]types.ACLEntry, aclEntriesNumber) + entries = make([]types.UserPermission, aclEntriesNumber) for index := 0; index < aclEntriesNumber; index++ { subspace := RandomSubspace(r, subspaces) account, _ := simtypes.RandomAcc(r, accounts) - target := account.Address.String() // Get a random permission permission := RandomPermission(r, validPermissions) // Crete the entry - entries[index] = types.NewACLEntry(subspace.ID, target, permission) + entries[index] = types.NewUserPermission(subspace.ID, 0, account.Address.String(), permission) } return entries @@ -138,34 +171,15 @@ func randomACL(r *rand.Rand, accounts []simtypes.Account, subspaces []types.Subs func sanitizeGenesis(genesis *types.GenesisState) *types.GenesisState { return types.NewGenesisState( genesis.InitialSubspaceID, - sanitizeSubspaces(genesis.Subspaces), - sanitizeACLEntry(genesis.ACL), + genesis.SubspacesData, + genesis.Subspaces, + genesis.Sections, + sanitizeUserPermissions(genesis.UserPermissions), sanitizeUserGroups(genesis.UserGroups), genesis.UserGroupsMembers, ) } -// sanitizeSubspaces sanitizes the given slice by removing all the double subspaces -func sanitizeSubspaces(slice []types.GenesisSubspace) []types.GenesisSubspace { - ids := map[uint64]int{} - for _, value := range slice { - ids[value.Subspace.ID] = 1 - } - - var unique []types.GenesisSubspace - for id := range ids { - SubspaceLoop: - for _, subspace := range slice { - if id == subspace.Subspace.ID { - unique = append(unique, subspace) - break SubspaceLoop - } - } - } - - return unique -} - // sanitizeUserGroups sanitizes the given slice by removing all the double groups func sanitizeUserGroups(slice []types.UserGroup) []types.UserGroup { groups := map[string]bool{} @@ -188,13 +202,13 @@ func sanitizeUserGroups(slice []types.UserGroup) []types.UserGroup { } // sanitizeSubspaces sanitizes the given slice by removing all the double entries -func sanitizeACLEntry(slice []types.ACLEntry) []types.ACLEntry { +func sanitizeUserPermissions(slice []types.UserPermission) []types.UserPermission { entries := map[string]bool{} for _, value := range slice { entries[fmt.Sprintf("%d%s", value.SubspaceID, value.User)] = true } - var unique []types.ACLEntry + var unique []types.UserPermission for id := range entries { EntryLoop: for _, entry := range slice { @@ -207,20 +221,3 @@ func sanitizeACLEntry(slice []types.ACLEntry) []types.ACLEntry { return unique } - -// sanitizeStrings sanitizes the given slice by removing all duplicated values -func sanitizeStrings(slice []string) []string { - values := map[string]bool{} - for _, value := range slice { - values[value] = true - } - - count := 0 - unique := make([]string, len(values)) - for value := range values { - unique[count] = value - count++ - } - - return unique -} diff --git a/x/subspaces/simulation/operations.go b/x/subspaces/simulation/operations.go index b3e8d00b41..b0b3b8406f 100644 --- a/x/subspaces/simulation/operations.go +++ b/x/subspaces/simulation/operations.go @@ -23,8 +23,13 @@ const ( OpWeightMsgCreateSubspace = "op_weight_msg_create_subspace" OpWeightMsgEditSubspace = "op_weight_msg_edit_subspace" OpWeightMsgDeleteSubspace = "op_weight_msg_delete_subspace" + OpWeightMsgCreateSection = "op_weight_msg_create_section" + OpWeightMsgEditSection = "op_weight_msg_edit_section" + OpWeightMsgMoveSection = "op_weight_msg_move_section" + OpWeightMsgDeleteSection = "op_weight_msg_delete_section" OpWeightMsgCreateUserGroup = "op_weight_msg_create_user_group" OpWeightMsgEditUserGroup = "op_weight_msg_edit_user_group" + OpWeightMsgMoveUserGroup = "op_weight_msg_move_user_group" OpWeightMsgSetUserGroupPermissions = "op_weight_msg_set_user_group_permissions" OpWeightMsgDeleteUserGroup = "op_weight_msg_delete_user_group" OpWeightMsgAddUserToUserGroup = "op_weight_msg_add_user_to_user_group" @@ -61,6 +66,34 @@ func WeightedOperations( }, ) + var weightMsgCreateSection int + appParams.GetOrGenerate(cdc, OpWeightMsgCreateSection, &weightMsgCreateSection, nil, + func(_ *rand.Rand) { + weightMsgCreateSection = params.DefaultWeightMsgCreateSection + }, + ) + + var weightMsgEditSection int + appParams.GetOrGenerate(cdc, OpWeightMsgEditSection, &weightMsgEditSection, nil, + func(_ *rand.Rand) { + weightMsgEditSection = params.DefaultWeightMsgEditSection + }, + ) + + var weightMsgMoveSection int + appParams.GetOrGenerate(cdc, OpWeightMsgMoveSection, &weightMsgMoveSection, nil, + func(_ *rand.Rand) { + weightMsgMoveSection = params.DefaultWeightMsgMoveSection + }, + ) + + var weightMsgDeleteSection int + appParams.GetOrGenerate(cdc, OpWeightMsgDeleteSection, &weightMsgDeleteSection, nil, + func(_ *rand.Rand) { + weightMsgDeleteSection = params.DefaultWeightMsgDeleteSection + }, + ) + var weightMsgCreateUserGroup int appParams.GetOrGenerate(cdc, OpWeightMsgCreateUserGroup, &weightMsgCreateUserGroup, nil, func(_ *rand.Rand) { @@ -75,6 +108,12 @@ func WeightedOperations( }, ) + var weightMsgMoveUserGroup int + appParams.GetOrGenerate(cdc, OpWeightMsgMoveUserGroup, &weightMsgMoveUserGroup, nil, + func(_ *rand.Rand) { + weightMsgMoveUserGroup = params.DefaultWeightMsgMoveUserGroup + }) + var weightMsgSetUserGroupPermissions int appParams.GetOrGenerate(cdc, OpWeightMsgSetUserGroupPermissions, &weightMsgSetUserGroupPermissions, nil, func(_ *rand.Rand) { @@ -123,6 +162,22 @@ func WeightedOperations( weightMsgDeleteSubspace, SimulateMsgDeleteSubspace(k, ak, bk, fk), ), + sim.NewWeightedOperation( + weightMsgCreateSection, + SimulateMsgCreateSection(k, ak, bk, fk), + ), + sim.NewWeightedOperation( + weightMsgEditSection, + SimulateMsgEditSection(k, ak, bk, fk), + ), + sim.NewWeightedOperation( + weightMsgMoveSection, + SimulateMsgMoveSection(k, ak, bk, fk), + ), + sim.NewWeightedOperation( + weightMsgDeleteSection, + SimulateMsgDeleteSection(k, ak, bk, fk), + ), sim.NewWeightedOperation( weightMsgCreateUserGroup, SimulateMsgCreateUserGroup(k, ak, bk, fk), @@ -131,6 +186,10 @@ func WeightedOperations( weightMsgEditUserGroup, SimulateMsgEditUserGroup(k, ak, bk, fk), ), + sim.NewWeightedOperation( + weightMsgMoveUserGroup, + SimulateMsgMoveUserGroup(k, ak, bk, fk), + ), sim.NewWeightedOperation( weightMsgSetUserGroupPermissions, SimulateMsgSetUserGroupPermissions(k, ak, bk, fk), diff --git a/x/subspaces/simulation/operations_groups.go b/x/subspaces/simulation/operations_groups.go index f09426dc25..0a788c0aec 100644 --- a/x/subspaces/simulation/operations_groups.go +++ b/x/subspaces/simulation/operations_groups.go @@ -38,6 +38,7 @@ func SimulateMsgCreateUserGroup( // Build the message msg := types.NewMsgCreateUserGroup( subspaceID, + 0, update.Name, update.Description, permissions, @@ -57,7 +58,7 @@ func SimulateMsgCreateUserGroup( // randomCreateUserGroupFields returns the data used to build a random MsgCreateUserGroup func randomCreateUserGroupFields( r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, -) (subspaceID uint64, update *types.GroupUpdate, permissions types.Permission, account simtypes.Account, skip bool) { +) (subspaceID uint64, update types.GroupUpdate, permissions types.Permission, account simtypes.Account, skip bool) { // Get a subspace id subspaces := k.GetAllSubspaces(ctx) if len(subspaces) == 0 { @@ -80,7 +81,7 @@ func randomCreateUserGroupFields( }) // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspace.ID, types.CombinePermissions(types.PermissionManageGroups, types.PermissionSetPermissions)) + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.CombinePermissions(types.PermissionManageGroups, types.PermissionSetPermissions)) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -125,7 +126,7 @@ func SimulateMsgEditUserGroup( // randomEditUserGroupFields returns the data used to build a random MsgEditUserGroup func randomEditUserGroupFields( r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, -) (subspaceID uint64, groupID uint32, update *types.GroupUpdate, account simtypes.Account, skip bool) { +) (subspaceID uint64, groupID uint32, update types.GroupUpdate, account simtypes.Account, skip bool) { // Get a group groups := k.GetAllUserGroups(ctx) if len(groups) == 0 { @@ -149,7 +150,7 @@ func randomEditUserGroupFields( } // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspaceID, types.PermissionManageGroups) + signers, _ := k.GetUsersWithRootPermission(ctx, subspaceID, types.PermissionManageGroups) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -163,6 +164,78 @@ func randomEditUserGroupFields( // -------------------------------------------------------------------------------------------------------------------- +// SimulateMsgMoveUserGroup tests and runs a single MsgMoveUserGroup +func SimulateMsgMoveUserGroup( + k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper, +) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // Get the data + subspaceID, groupID, newSectionID, signer, skip := randomMoveUserGroupFields(r, ctx, accs, k) + if skip { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgMoveUserGroup"), nil, nil + } + + // Build the message + msg := types.NewMsgMoveUserGroup(subspaceID, groupID, newSectionID, signer.Address.String()) + + // Send the message + err := simtesting.SendMsg(r, app, ak, bk, fk, msg, ctx, chainID, DefaultGasValue, []cryptotypes.PrivKey{signer.PrivKey}) + if err != nil { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgMoveUserGroup"), nil, err + } + + return simtypes.NewOperationMsg(msg, true, "MsgMoveUserGroup", nil), nil, nil + } +} + +// randomMoveUserGroupFields returns the data used to build a random MsgMoveUserGroup +func randomMoveUserGroupFields( + r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, +) (subspaceID uint64, groupID uint32, newSectionID uint32, account simtypes.Account, skip bool) { + // Get a subspace id + subspaces := k.GetAllSubspaces(ctx) + if len(subspaces) == 0 { + // Skip because there are no subspaces + skip = true + return + } + subspace := RandomSubspace(r, subspaces) + subspaceID = subspace.ID + + // Get a group + groups := k.GetSubspaceUserGroups(ctx, subspaceID) + if len(groups) == 0 { + // Skip if there are no groups + skip = true + return + } + group := RandomGroup(r, groups) + groupID = group.ID + + // Get a section + sections := k.GetSubspaceSections(ctx, subspaceID) + section := RandomSection(r, sections) + newSectionID = section.ID + + // Get a signer + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionEverything) + acc := GetAccount(RandomAddress(r, signers), accs) + if acc == nil { + // Skip the operation without error as the account is not valid + skip = true + return + } + account = *acc + + return subspaceID, groupID, newSectionID, account, false +} + +// -------------------------------------------------------------------------------------------------------------------- + // SimulateMsgSetUserGroupPermissions tests and runs a single MsgSetUserGroupPermissions func SimulateMsgSetUserGroupPermissions( k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper, @@ -206,7 +279,7 @@ func randomSetUserGroupPermissionsFields( subspaceID = subspace.ID // Get a group - groups := k.GetSubspaceGroups(ctx, subspaceID) + groups := k.GetSubspaceUserGroups(ctx, subspaceID) if len(groups) == 0 { // Skip if there are no groups skip = true @@ -218,7 +291,7 @@ func randomSetUserGroupPermissionsFields( permissions = RandomPermission(r, validPermissions) // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspace.ID, types.PermissionSetPermissions) + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionSetPermissions) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -228,7 +301,7 @@ func randomSetUserGroupPermissionsFields( account = *acc // Make sure the user can change this group's validPermissions - if subspace.Owner != account.Address.String() && k.IsMemberOfGroup(ctx, subspaceID, groupID, account.Address) { + if subspace.Owner != account.Address.String() && k.IsMemberOfGroup(ctx, subspaceID, groupID, account.Address.String()) { // If the user is not the subspace owner and it's part of the user group they cannot edit the group validPermissions skip = true return @@ -289,7 +362,7 @@ func randomDeleteUserGroupFields( groupID = group.ID // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspaceID, types.PermissionManageGroups) + signers, _ := k.GetUsersWithRootPermission(ctx, subspaceID, types.PermissionManageGroups) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -355,7 +428,7 @@ func randomAddUserToUserGroupFields( // Get a user accounts := ak.GetAllAccounts(ctx) userAccount := RandomAuthAccount(r, accounts) - if k.IsMemberOfGroup(ctx, subspaceID, groupID, userAccount.GetAddress()) { + if k.IsMemberOfGroup(ctx, subspaceID, groupID, userAccount.GetAddress().String()) { // Skip if the user is already part of group skip = true return @@ -363,7 +436,7 @@ func randomAddUserToUserGroupFields( user = userAccount.GetAddress().String() // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspaceID, types.PermissionSetPermissions) + signers, _ := k.GetUsersWithRootPermission(ctx, subspaceID, types.PermissionSetPermissions) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -427,17 +500,17 @@ func randomRemoveUserFromUserGroupFields( groupID = group.ID // Get a user - members := k.GetGroupMembers(ctx, subspaceID, groupID) + members := k.GetUserGroupMembers(ctx, subspaceID, groupID) if len(members) == 0 { // Skip if there are no member groups to remove skip = true return } - user = RandomAddress(r, members).String() + user = RandomAddress(r, members) // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspaceID, types.PermissionSetPermissions) + signers, _ := k.GetUsersWithRootPermission(ctx, subspaceID, types.PermissionSetPermissions) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid diff --git a/x/subspaces/simulation/operations_permissions.go b/x/subspaces/simulation/operations_permissions.go index 89f358054d..9f2455312c 100644 --- a/x/subspaces/simulation/operations_permissions.go +++ b/x/subspaces/simulation/operations_permissions.go @@ -36,7 +36,7 @@ func SimulateMsgSetUserPermissions( } // Build the message - msg := types.NewMsgSetUserPermissions(subspaceID, user, permissions, creator.Address.String()) + msg := types.NewMsgSetUserPermissions(subspaceID, 0, user, permissions, creator.Address.String()) // Send the message err := simtesting.SendMsg(r, app, ak, bk, fk, msg, ctx, chainID, DefaultGasValue, []cryptotypes.PrivKey{creator.PrivKey}) @@ -70,7 +70,7 @@ func randomSetUserPermissionsFields( permissions = RandomPermission(r, validPermissions) // Get a signer - signers, _ := k.GetUsersWithPermission(ctx, subspace.ID, types.PermissionSetPermissions) + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionSetPermissions) acc := GetAccount(RandomAddress(r, signers), accs) if acc == nil { // Skip the operation without error as the account is not valid diff --git a/x/subspaces/simulation/operations_sections.go b/x/subspaces/simulation/operations_sections.go new file mode 100644 index 0000000000..9e05505dab --- /dev/null +++ b/x/subspaces/simulation/operations_sections.go @@ -0,0 +1,314 @@ +package simulation + +// DONTCOVER + +import ( + "math/rand" + + feeskeeper "github.com/desmos-labs/desmos/v3/x/fees/keeper" + + "github.com/desmos-labs/desmos/v3/testutil/simtesting" + + "github.com/cosmos/cosmos-sdk/baseapp" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + + "github.com/desmos-labs/desmos/v3/x/subspaces/keeper" + "github.com/desmos-labs/desmos/v3/x/subspaces/types" +) + +// SimulateMsgCreateSection tests and runs a single MsgCreateSection +func SimulateMsgCreateSection( + k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper, +) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // Get the data + subspaceID, update, parentID, creator, skip := randomCreateSectionFields(r, ctx, accs, k) + if skip { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgCreateSection"), nil, nil + } + + // Build the message + msg := types.NewMsgCreateSection( + subspaceID, + update.Name, + update.Description, + parentID, + creator.Address.String(), + ) + + // Send the message + err := simtesting.SendMsg(r, app, ak, bk, fk, msg, ctx, chainID, DefaultGasValue, []cryptotypes.PrivKey{creator.PrivKey}) + if err != nil { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgCreateSection"), nil, err + } + + return simtypes.NewOperationMsg(msg, true, "MsgCreateSection", nil), nil, nil + } +} + +// randomCreateSectionFields returns the data used to build a random MsgCreateSection +func randomCreateSectionFields( + r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, +) (subspaceID uint64, update types.SectionUpdate, parentID uint32, account simtypes.Account, skip bool) { + // Get a subspace id + subspaces := k.GetAllSubspaces(ctx) + if len(subspaces) == 0 { + // Skip because there are no subspaces + skip = true + return + } + subspace := RandomSubspace(r, subspaces) + subspaceID = subspace.ID + + // Get a parent section + sections := k.GetSubspaceSections(ctx, subspaceID) + parentSection := RandomSection(r, sections) + parentID = parentSection.ID + + // Get a random update + update = types.NewSectionUpdate( + RandomSectionName(r), + RandomSectionDescription(r), + ) + + // Get a signer + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionManageSections) + acc := GetAccount(RandomAddress(r, signers), accs) + if acc == nil { + // Skip the operation without error as the account is not valid + skip = true + return + } + account = *acc + + return subspaceID, update, parentID, account, false +} + +// -------------------------------------------------------------------------------------------------------------------- + +// SimulateMsgEditSection tests and runs a single MsgEditSection +func SimulateMsgEditSection( + k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper, +) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // Get the data + subspaceID, sectionID, update, creator, skip := randomEditSectionFields(r, ctx, accs, k) + if skip { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgEditSection"), nil, nil + } + + // Build the message + msg := types.NewMsgEditSection( + subspaceID, + sectionID, + update.Name, + update.Description, + creator.Address.String(), + ) + + // Send the message + err := simtesting.SendMsg(r, app, ak, bk, fk, msg, ctx, chainID, DefaultGasValue, []cryptotypes.PrivKey{creator.PrivKey}) + if err != nil { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgEditSection"), nil, err + } + + return simtypes.NewOperationMsg(msg, true, "MsgEditSection", nil), nil, nil + } +} + +// randomEditSectionFields returns the data used to build a random MsgEditSection +func randomEditSectionFields( + r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, +) (subspaceID uint64, sectionID uint32, update types.SectionUpdate, account simtypes.Account, skip bool) { + // Get a subspace id + subspaces := k.GetAllSubspaces(ctx) + if len(subspaces) == 0 { + // Skip because there are no subspaces + skip = true + return + } + subspace := RandomSubspace(r, subspaces) + subspaceID = subspace.ID + + // Get a random section + sections := k.GetSubspaceSections(ctx, subspaceID) + section := RandomSection(r, sections) + sectionID = section.ID + + // Get a random update + update = types.NewSectionUpdate( + RandomSectionName(r), + RandomSectionDescription(r), + ) + + // Get a signer + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionManageSections) + acc := GetAccount(RandomAddress(r, signers), accs) + if acc == nil { + // Skip the operation without error as the account is not valid + skip = true + return + } + account = *acc + + return subspaceID, sectionID, update, account, false +} + +// -------------------------------------------------------------------------------------------------------------------- + +// SimulateMsgMoveSection tests and runs a single MsgMoveSection +func SimulateMsgMoveSection( + k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper, +) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // Get the data + subspaceID, sectionID, newParentID, creator, skip := randomMoveSectionFields(r, ctx, accs, k) + if skip { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgMoveSection"), nil, nil + } + + // Build the message + msg := types.NewMsgMoveSection( + subspaceID, + sectionID, + newParentID, + creator.Address.String(), + ) + + // Send the message + err := simtesting.SendMsg(r, app, ak, bk, fk, msg, ctx, chainID, DefaultGasValue, []cryptotypes.PrivKey{creator.PrivKey}) + if err != nil { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgMoveSection"), nil, err + } + + return simtypes.NewOperationMsg(msg, true, "MsgMoveSection", nil), nil, nil + } +} + +// randomMoveSectionFields returns the data used to build a random MsgMoveSection +func randomMoveSectionFields( + r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, +) (subspaceID uint64, sectionID uint32, newParentID uint32, account simtypes.Account, skip bool) { + // Get a subspace id + subspaces := k.GetAllSubspaces(ctx) + if len(subspaces) == 0 { + // Skip because there are no subspaces + skip = true + return + } + subspace := RandomSubspace(r, subspaces) + subspaceID = subspace.ID + + // Get a random section + sections := k.GetSubspaceSections(ctx, subspaceID) + section := RandomSection(r, sections) + sectionID = section.ID + if sectionID == types.RootSectionID { + // Skip because we can't move the default section + skip = true + return + } + + // Get a random new parent + parent := RandomSection(r, sections) + newParentID = parent.ID + + // Get a signer + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionManageSections) + acc := GetAccount(RandomAddress(r, signers), accs) + if acc == nil { + // Skip the operation without error as the account is not valid + skip = true + return + } + account = *acc + + return subspaceID, sectionID, newParentID, account, false +} + +// -------------------------------------------------------------------------------------------------------------------- + +// SimulateMsgDeleteSection tests and runs a single MsgDeleteSection +func SimulateMsgDeleteSection( + k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper, +) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + + // Get the data + subspaceID, sectionID, creator, skip := randomDeleteFields(r, ctx, accs, k) + if skip { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgDeleteSection"), nil, nil + } + + // Build the message + msg := types.NewMsgDeleteSection( + subspaceID, + sectionID, + creator.Address.String(), + ) + + // Send the message + err := simtesting.SendMsg(r, app, ak, bk, fk, msg, ctx, chainID, DefaultGasValue, []cryptotypes.PrivKey{creator.PrivKey}) + if err != nil { + return simtypes.NoOpMsg(types.RouterKey, types.ModuleName, "MsgDeleteSection"), nil, err + } + + return simtypes.NewOperationMsg(msg, true, "MsgDeleteSection", nil), nil, nil + } +} + +// randomDeleteFields returns the data used to build a random MsgDeleteSection +func randomDeleteFields( + r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, +) (subspaceID uint64, sectionID uint32, account simtypes.Account, skip bool) { + // Get a subspace id + subspaces := k.GetAllSubspaces(ctx) + if len(subspaces) == 0 { + // Skip because there are no subspaces + skip = true + return + } + subspace := RandomSubspace(r, subspaces) + subspaceID = subspace.ID + + // Get a random section + sections := k.GetSubspaceSections(ctx, subspaceID) + section := RandomSection(r, sections) + sectionID = section.ID + if sectionID == types.RootSectionID { + // Skip because we can't delete the default section + skip = true + return + } + + // Get a signer + signers, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionManageSections) + acc := GetAccount(RandomAddress(r, signers), accs) + if acc == nil { + // Skip the operation without error as the account is not valid + skip = true + return + } + account = *acc + + return subspaceID, sectionID, account, false +} diff --git a/x/subspaces/simulation/operations_subspaces.go b/x/subspaces/simulation/operations_subspaces.go index faabe768dc..2db5c56b5a 100644 --- a/x/subspaces/simulation/operations_subspaces.go +++ b/x/subspaces/simulation/operations_subspaces.go @@ -113,7 +113,7 @@ func SimulateMsgEditSubspace( // randomEditSubspaceFields returns the data needed to edit a subspace func randomEditSubspaceFields( r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, k keeper.Keeper, -) (subspaceID uint64, update *types.SubspaceUpdate, account simtypes.Account, skip bool) { +) (subspaceID uint64, update types.SubspaceUpdate, account simtypes.Account, skip bool) { // Get a subspace id subspaces := k.GetAllSubspaces(ctx) if len(subspaces) == 0 { @@ -125,7 +125,7 @@ func randomEditSubspaceFields( subspaceID = subspace.ID // Get an editor - editors, _ := k.GetUsersWithPermission(ctx, subspace.ID, types.PermissionChangeInfo) + editors, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionChangeInfo) acc := GetAccount(RandomAddress(r, editors), accs) if acc == nil { // Skip the operation without error as the account is not valid @@ -206,7 +206,7 @@ func randomDeleteSubspaceFields( subspaceID = subspace.ID // Get an editor - editors, _ := k.GetUsersWithPermission(ctx, subspace.ID, types.PermissionDeleteSubspace) + editors, _ := k.GetUsersWithRootPermission(ctx, subspace.ID, types.PermissionDeleteSubspace) acc := GetAccount(RandomAddress(r, editors), accs) if acc == nil { // Skip the operation without error as the account is not valid diff --git a/x/subspaces/simulation/utils.go b/x/subspaces/simulation/utils.go index 265b521d92..18df47224b 100644 --- a/x/subspaces/simulation/utils.go +++ b/x/subspaces/simulation/utils.go @@ -8,7 +8,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/desmos-labs/desmos/v3/x/subspaces/types" @@ -24,11 +23,6 @@ var ( } ) -// RandomGenesisSubspace picks a random genesis subspace from the given slice -func RandomGenesisSubspace(r *rand.Rand, subspaces []types.GenesisSubspace) types.GenesisSubspace { - return subspaces[r.Intn(len(subspaces))] -} - // RandomSubspace picks a random subspace from an array and returns its position as well as value. func RandomSubspace(r *rand.Rand, subspaces []types.Subspace) types.Subspace { return subspaces[r.Intn(len(subspaces))] @@ -75,9 +69,19 @@ func RandomDate(r *rand.Rand) time.Time { return time.Unix(sec, 0).Truncate(time.Millisecond) } -// RandomString returns a random string from the given slice -func RandomString(r *rand.Rand, strings []string) string { - return strings[r.Intn(len(strings))] +// RandomSection returns a randomly selected section from the slice given +func RandomSection(r *rand.Rand, sections []types.Section) types.Section { + return sections[r.Intn(len(sections))] +} + +// RandomSectionName returns a random section name +func RandomSectionName(r *rand.Rand) string { + return simtypes.RandStringOfLength(r, 10) +} + +// RandomSectionDescription returns a random section description +func RandomSectionDescription(r *rand.Rand) string { + return simtypes.RandStringOfLength(r, 20) } // RandomGroup returns a random group selecting it from the list of groups given @@ -91,7 +95,7 @@ func RandomPermission(r *rand.Rand, permissions []types.Permission) types.Permis } // RandomAddress returns a random address from the slice given -func RandomAddress(r *rand.Rand, addresses []sdk.AccAddress) sdk.AccAddress { +func RandomAddress(r *rand.Rand, addresses []string) string { return addresses[r.Intn(len(addresses))] } @@ -101,9 +105,9 @@ func RandomAuthAccount(r *rand.Rand, accounts []authtypes.AccountI) authtypes.Ac } // GetAccount gets the account having the given address from the accs list -func GetAccount(address sdk.Address, accs []simtypes.Account) *simtypes.Account { +func GetAccount(address string, accs []simtypes.Account) *simtypes.Account { for _, acc := range accs { - if acc.Address.Equals(address) { + if acc.Address.String() == address { return &acc } } diff --git a/x/subspaces/types/codec.go b/x/subspaces/types/codec.go index 8dff3bdaac..a0998def3a 100644 --- a/x/subspaces/types/codec.go +++ b/x/subspaces/types/codec.go @@ -12,11 +12,20 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(MsgCreateSubspace{}, "desmos/MsgCreateSubspace", nil) cdc.RegisterConcrete(MsgEditSubspace{}, "desmos/MsgEditSubspace", nil) cdc.RegisterConcrete(MsgCreateUserGroup{}, "desmos/MsgCreateUserGroup", nil) + + cdc.RegisterConcrete(MsgCreateSection{}, "desmos/MsgCreateSection", nil) + cdc.RegisterConcrete(MsgEditSection{}, "desmos/MsgEditSection", nil) + cdc.RegisterConcrete(MsgMoveSection{}, "desmos/MsgMoveSection", nil) + cdc.RegisterConcrete(MsgDeleteSection{}, "desmos/MsgDeleteSection", nil) + cdc.RegisterConcrete(MsgEditUserGroup{}, "desmos/MsgEditUserGroup", nil) + cdc.RegisterConcrete(MsgMoveUserGroup{}, "desmos/MsgMoveUserGroup", nil) cdc.RegisterConcrete(MsgSetUserGroupPermissions{}, "desmos/MsgSetUserGroupPermissions", nil) cdc.RegisterConcrete(MsgDeleteUserGroup{}, "desmos/MsgDeleteUserGroup", nil) + cdc.RegisterConcrete(MsgAddUserToUserGroup{}, "desmos/MsgAddUserToUserGroup", nil) cdc.RegisterConcrete(MsgRemoveUserFromUserGroup{}, "desmos/MsgRemoveUserFromUserGroup", nil) + cdc.RegisterConcrete(MsgSetUserPermissions{}, "desmos/MsgSetUserPermissions", nil) } @@ -25,7 +34,12 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgCreateSubspace{}, &MsgEditSubspace{}, &MsgCreateUserGroup{}, + &MsgCreateSection{}, + &MsgEditSection{}, + &MsgMoveSection{}, + &MsgDeleteSection{}, &MsgEditUserGroup{}, + &MsgMoveUserGroup{}, &MsgSetUserGroupPermissions{}, &MsgDeleteUserGroup{}, &MsgAddUserToUserGroup{}, diff --git a/x/subspaces/types/errors.go b/x/subspaces/types/errors.go index 3b5714886e..23b188915e 100644 --- a/x/subspaces/types/errors.go +++ b/x/subspaces/types/errors.go @@ -8,4 +8,5 @@ var ( // ErrPermissionDenied is returned if a user cannot perform a specific action inside a subspace ErrPermissionDenied = sdkerrors.Register(ModuleName, 1, "permission denied for user") ErrInvalidGenesis = sdkerrors.Register(ModuleName, 2, "invalid genesis state") + ErrInvalidSection = sdkerrors.Register(ModuleName, 3, "invalid section") ) diff --git a/x/subspaces/types/events.go b/x/subspaces/types/events.go index cb0df1d9cd..38eaeda778 100644 --- a/x/subspaces/types/events.go +++ b/x/subspaces/types/events.go @@ -5,8 +5,13 @@ const ( EventTypeCreateSubspace = "create_subspace" EventTypeEditSubspace = "edit_subspace" EventTypeDeleteSubspace = "delete_subspace" + EventTypeCreateSection = "create_section" + EventTypeEditSection = "edit_section" + EventTypeMoveSection = "move_section" + EventTypeDeleteSection = "delete_section" EventTypeCreateUserGroup = "create_user_group" EventTypeEditUserGroup = "edit_user_group" + EvenTypeMoveUserGroup = "move_user_group" EventTypeSetUserGroupPermissions = "set_user_group_permissions" EventTypeDeleteUserGroup = "delete_user_group" EventTypeAddUserToGroup = "add_group_member" @@ -18,6 +23,7 @@ const ( AttributeKeySubspaceName = "subspace_name" AttributeKeySubspaceCreator = "subspace_creator" AttributeKeyCreationTime = "creation_date" + AttributeKeySectionID = "section_id" AttributeKeyUserGroupID = "user_group_id" AttributeKeyUser = "user" ) diff --git a/x/subspaces/types/genesis.go b/x/subspaces/types/genesis.go index d2ba4f20ac..417ffb9f13 100644 --- a/x/subspaces/types/genesis.go +++ b/x/subspaces/types/genesis.go @@ -6,90 +6,22 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewGenesisSubspace returns a new GenesisSubspace instance -func NewGenesisSubspace(subspace Subspace, initialGroupID uint32) GenesisSubspace { - return GenesisSubspace{ - Subspace: subspace, - InitialGroupID: initialGroupID, - } -} - -// Validate returns an error if something is wrong within the subspace data -func (subspace GenesisSubspace) Validate() error { - if subspace.InitialGroupID == 0 { - return fmt.Errorf("invalid initial group id: %d", subspace.InitialGroupID) - } - - return subspace.Subspace.Validate() -} - -// ------------------------------------------------------------------------------------------------------------------- - -// NewACLEntry returns a new ACLEntry instance -func NewACLEntry(subspaceID uint64, user string, permissions Permission) ACLEntry { - return ACLEntry{ - SubspaceID: subspaceID, - User: user, - Permissions: permissions, - } -} - -// Validate returns an error if something is wrong within the entry data -func (entry ACLEntry) Validate() error { - if entry.SubspaceID == 0 { - return fmt.Errorf("invalid subspace id: %d", entry.SubspaceID) - } - - _, err := sdk.AccAddressFromBech32(entry.User) - if err != nil { - return fmt.Errorf("invalid user address: %s", entry.User) - } - - return nil -} - -// ------------------------------------------------------------------------------------------------------------------- - -// NewUserGroupMembersEntry returns a new UserGroupMembersEntry instance -func NewUserGroupMembersEntry(subspaceID uint64, groupID uint32, members []string) UserGroupMembersEntry { - return UserGroupMembersEntry{ - SubspaceID: subspaceID, - GroupID: groupID, - Members: members, - } -} - -// Validate returns an error if something is wrong within the entry data -func (entry UserGroupMembersEntry) Validate() error { - if entry.SubspaceID == 0 { - return fmt.Errorf("invalid subspace id: %d", entry.SubspaceID) - } - - if entry.GroupID == 0 { - return fmt.Errorf("invalid group id: %d", entry.GroupID) - } - - for _, user := range entry.Members { - _, err := sdk.AccAddressFromBech32(user) - if err != nil { - return fmt.Errorf("invalid user address: %s", user) - } - } - - return nil -} - -// ------------------------------------------------------------------------------------------------------------------- - // NewGenesisState creates a new genesis state func NewGenesisState( - initialSubspaceID uint64, subspaces []GenesisSubspace, acl []ACLEntry, - userGroups []UserGroup, userGroupMembers []UserGroupMembersEntry, + initialSubspaceID uint64, + subspacesData []SubspaceData, + subspaces []Subspace, + sections []Section, + userPermissions []UserPermission, + userGroups []UserGroup, + userGroupMembers []UserGroupMemberEntry, ) *GenesisState { return &GenesisState{ InitialSubspaceID: initialSubspaceID, + SubspacesData: subspacesData, Subspaces: subspaces, - ACL: acl, + Sections: sections, + UserPermissions: userPermissions, UserGroups: userGroups, UserGroupsMembers: userGroupMembers, } @@ -97,136 +29,140 @@ func NewGenesisState( // DefaultGenesisState returns a default GenesisState func DefaultGenesisState() *GenesisState { - return NewGenesisState(1, nil, nil, nil, nil) + return NewGenesisState( + 1, + nil, + nil, + nil, + nil, + nil, + nil, + ) } -// ------------------------------------------------------------------------------------------------------------------- - // ValidateGenesis validates the given genesis state and returns an error if something is invalid func ValidateGenesis(data *GenesisState) error { // Make sure the initial subspace id is valid - if data.InitialSubspaceID <= uint64(len(data.Subspaces)) { + if data.InitialSubspaceID == 0 { return fmt.Errorf("invalid initial subspace id: %d", data.InitialSubspaceID) } - // Validate the subspace - for _, subspace := range data.Subspaces { - err := subspace.Validate() + // Validate the subspaces data + for _, entry := range data.SubspacesData { + if containsDuplicatedSubspaceData(data.SubspacesData, entry) { + return fmt.Errorf("duplicated subspace data for id: %d", entry.SubspaceID) + } + + err := entry.Validate() if err != nil { return err } + } + // Validate the subspace + for _, subspace := range data.Subspaces { if containsDuplicatedSubspace(data.Subspaces, subspace) { - return fmt.Errorf("duplicated subspace: %d", subspace.Subspace.ID) + return fmt.Errorf("duplicated subspace: %d", subspace.ID) } - } - // Validate the ACL entries - for _, entry := range data.ACL { - err := entry.Validate() + err := subspace.Validate() if err != nil { return err } + } - if containsDuplicatedACLEntry(data.ACL, entry) { - return fmt.Errorf("duplicated ACL entry for subspace %d and user %s", entry.SubspaceID, entry.User) + for _, section := range data.Sections { + if containsDuplicatedSection(data.Sections, section) { + return fmt.Errorf("duplicated section: subspace id %d, section id %d", section.SubspaceID, section.ID) } - // Make sure the associated subspace exists - subspace, found := findSubspace(data.Subspaces, entry.SubspaceID) - if !found { - return fmt.Errorf("invalid ACL entry: subspace %d not found", subspace.Subspace.ID) + err := section.Validate() + if err != nil { + return err } } - // Validate the user groups - groupsCount := map[uint64]int{} - for _, group := range data.UserGroups { - err := group.Validate() + // Validate the user permissions + for _, entry := range data.UserPermissions { + if containsDuplicatedUserPermission(data.UserPermissions, entry) { + return fmt.Errorf("duplicated user permission: subspace id %d, user %s", entry.SubspaceID, entry.User) + } + + err := entry.Validate() if err != nil { return err } + } + // Validate the user groups + for _, group := range data.UserGroups { if containsDuplicatedGroups(data.UserGroups, group) { return fmt.Errorf("duplicated group for subspace %d and group %d", group.SubspaceID, group.ID) } - // Increment the groups count for this subspace - groupsCount[group.SubspaceID]++ - } - - // Make sure each subspace has a correct initial group id based on the number of groups inside that subspace - for subspaceID, count := range groupsCount { - genSub, found := findSubspace(data.Subspaces, subspaceID) - if !found { - return fmt.Errorf("invalid group id: subspace %d not found", subspaceID) - } - - if genSub.InitialGroupID <= uint32(count) { - return fmt.Errorf("invalid initial group id for subspace %d: %d", genSub.Subspace.ID, genSub.InitialGroupID) + err := group.Validate() + if err != nil { + return err } } // Validate the group members for _, entry := range data.UserGroupsMembers { - err := entry.Validate() - if err != nil { - return err - } - if containsDuplicatedMembersEntries(data.UserGroupsMembers, entry) { return fmt.Errorf("duplicated user group members entry for group %d within subspace %d", entry.GroupID, entry.SubspaceID) } - // Make sure the associated subspace exists - _, found := findGroup(data.UserGroups, entry.SubspaceID, entry.GroupID) - if !found { - return fmt.Errorf("invalid group members entry: group %d for subspace %d not found", - entry.GroupID, entry.SubspaceID) + err := entry.Validate() + if err != nil { + return err } } return nil } -// findSubspace searches the subspace with the given id inside the provided slice -func findSubspace(subspaces []GenesisSubspace, subspaceID uint64) (genSub GenesisSubspace, found bool) { - for _, subspace := range subspaces { - if subspace.Subspace.ID == subspaceID { - return subspace, true +// containsDuplicatedSubspaceData tells whether the given entries slice contains two or more +// data for the subspace with the same id of the given data +func containsDuplicatedSubspaceData(entries []SubspaceData, data SubspaceData) bool { + var count = 0 + for _, s := range entries { + if s.SubspaceID == data.SubspaceID { + count++ } } - return GenesisSubspace{}, false + return count > 1 } -// findGroup searches the group for the group having the given id and subspace id inside the given slice -func findGroup(groups []UserGroup, subspaceID uint64, groupID uint32) (group UserGroup, found bool) { - for _, group := range groups { - if group.SubspaceID == subspaceID && group.ID == groupID { - return group, true +// containsDuplicatedSubspace tells whether the given subspaces slice contains two or more +// subspaces with the same id of the given subspace +func containsDuplicatedSubspace(subspaces []Subspace, subspace Subspace) bool { + var count = 0 + for _, s := range subspaces { + if s.ID == subspace.ID { + count++ } } - return UserGroup{}, false + return count > 1 } -// containsDuplicatedSubspace tells whether the given subspaces slice contains two or more -// subspaces with the same id of the given subspace -func containsDuplicatedSubspace(subspaces []GenesisSubspace, subspace GenesisSubspace) bool { +// containsDuplicatedSection tells whether the given sections slice contains two or more +// sections with the same id for the same subspace +func containsDuplicatedSection(sections []Section, section Section) bool { var count = 0 - for _, s := range subspaces { - if s.Subspace.ID == subspace.Subspace.ID { + for _, s := range sections { + if s.SubspaceID == section.SubspaceID && s.ID == section.ID { count++ } } return count > 1 } -// containsDuplicatedACLEntry tells whether the given entries slice contains two or more -// entries for the same user and subspace -func containsDuplicatedACLEntry(entries []ACLEntry, entry ACLEntry) bool { +// containsDuplicatedUserPermission tells whether the given entries slice contains two or more +// entries for the same user and subspace section +func containsDuplicatedUserPermission(entries []UserPermission, entry UserPermission) bool { var count = 0 for _, e := range entries { - if e.SubspaceID == entry.SubspaceID && e.User == entry.User { + if e.SubspaceID == entry.SubspaceID && e.SectionID == entry.SectionID && e.User == entry.User { count++ } } @@ -247,12 +183,99 @@ func containsDuplicatedGroups(groups []UserGroup, group UserGroup) bool { // containsDuplicatedMembersEntries tells whether the given entries slice contains two or more // entries for the same subspace and group id -func containsDuplicatedMembersEntries(entries []UserGroupMembersEntry, entry UserGroupMembersEntry) bool { +func containsDuplicatedMembersEntries(entries []UserGroupMemberEntry, entry UserGroupMemberEntry) bool { var count = 0 for _, e := range entries { - if e.SubspaceID == entry.SubspaceID && e.GroupID == entry.GroupID { + if e.SubspaceID == entry.SubspaceID && e.GroupID == entry.GroupID && e.User == entry.User { count++ } } return count > 1 } + +// -------------------------------------------------------------------------------------------------------------------- + +// NewSubspaceData returns a new SubspaceData instance +func NewSubspaceData(subspaceID uint64, nextSectionID uint32, nextGroupID uint32) SubspaceData { + return SubspaceData{ + SubspaceID: subspaceID, + NextGroupID: nextGroupID, + NextSectionID: nextSectionID, + } +} + +// Validate implements fmt.Validator +func (data SubspaceData) Validate() error { + if data.SubspaceID == 0 { + return fmt.Errorf("invalid subspace id: %d", data.NextSectionID) + } + + if data.NextSectionID == 0 { + return fmt.Errorf("invalid initial section id: %d", data.NextSectionID) + } + + if data.NextGroupID == 0 { + return fmt.Errorf("invalid initial group id: %d", data.NextSectionID) + } + + return nil +} + +// ------------------------------------------------------------------------------------------------------------------- + +// NewUserPermission returns a new UserPermission instance +func NewUserPermission(subspaceID uint64, sectionID uint32, user string, permissions Permission) UserPermission { + return UserPermission{ + SubspaceID: subspaceID, + SectionID: sectionID, + User: user, + Permissions: permissions, + } +} + +// Validate implements fmt.Validator +func (p UserPermission) Validate() error { + if p.SubspaceID == 0 { + return fmt.Errorf("invalid subspace id: %d", p.SubspaceID) + } + + if !IsPermissionValid(p.Permissions) { + return fmt.Errorf("invalid permission value: %b", p.Permissions) + } + + _, err := sdk.AccAddressFromBech32(p.User) + if err != nil { + return fmt.Errorf("invalid user address: %s", err) + } + + return nil +} + +// ------------------------------------------------------------------------------------------------------------------- + +// NewUserGroupMemberEntry returns a new UserGroupMemberEntry instance +func NewUserGroupMemberEntry(subspaceID uint64, groupID uint32, user string) UserGroupMemberEntry { + return UserGroupMemberEntry{ + SubspaceID: subspaceID, + GroupID: groupID, + User: user, + } +} + +// Validate implements fmt.Validator +func (entry UserGroupMemberEntry) Validate() error { + if entry.SubspaceID == 0 { + return fmt.Errorf("invalid subspace id: %d", entry.SubspaceID) + } + + if entry.GroupID == 0 { + return fmt.Errorf("invalid group id: %d", entry.GroupID) + } + + _, err := sdk.AccAddressFromBech32(entry.User) + if err != nil { + return fmt.Errorf("invalid user address: %s", err) + } + + return nil +} diff --git a/x/subspaces/types/genesis.pb.go b/x/subspaces/types/genesis.pb.go index 8d0ea0c7b9..7744eb024f 100644 --- a/x/subspaces/types/genesis.pb.go +++ b/x/subspaces/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: desmos/subspaces/v1/genesis.proto +// source: desmos/subspaces/v2/genesis.proto package types @@ -25,18 +25,20 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState contains the data of the genesis state for the subspaces module type GenesisState struct { - InitialSubspaceID uint64 `protobuf:"varint,1,opt,name=initial_subspace_id,json=initialSubspaceId,proto3" json:"initial_subspace_id,omitempty"` - Subspaces []GenesisSubspace `protobuf:"bytes,2,rep,name=subspaces,proto3" json:"subspaces"` - ACL []ACLEntry `protobuf:"bytes,3,rep,name=acl,proto3" json:"acl"` - UserGroups []UserGroup `protobuf:"bytes,4,rep,name=user_groups,json=userGroups,proto3" json:"user_groups"` - UserGroupsMembers []UserGroupMembersEntry `protobuf:"bytes,5,rep,name=user_groups_members,json=userGroupsMembers,proto3" json:"user_groups_members"` + InitialSubspaceID uint64 `protobuf:"varint,1,opt,name=initial_subspace_id,json=initialSubspaceId,proto3" json:"initial_subspace_id,omitempty"` + SubspacesData []SubspaceData `protobuf:"bytes,2,rep,name=subspaces_data,json=subspacesData,proto3" json:"subspaces_data"` + Subspaces []Subspace `protobuf:"bytes,3,rep,name=subspaces,proto3" json:"subspaces"` + Sections []Section `protobuf:"bytes,4,rep,name=sections,proto3" json:"sections"` + UserPermissions []UserPermission `protobuf:"bytes,5,rep,name=user_permissions,json=userPermissions,proto3" json:"user_permissions"` + UserGroups []UserGroup `protobuf:"bytes,6,rep,name=user_groups,json=userGroups,proto3" json:"user_groups"` + UserGroupsMembers []UserGroupMemberEntry `protobuf:"bytes,7,rep,name=user_groups_members,json=userGroupsMembers,proto3" json:"user_groups_members"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_bce8af665337782b, []int{0} + return fileDescriptor_e29defb77aaf744c, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -72,16 +74,30 @@ func (m *GenesisState) GetInitialSubspaceID() uint64 { return 0 } -func (m *GenesisState) GetSubspaces() []GenesisSubspace { +func (m *GenesisState) GetSubspacesData() []SubspaceData { + if m != nil { + return m.SubspacesData + } + return nil +} + +func (m *GenesisState) GetSubspaces() []Subspace { if m != nil { return m.Subspaces } return nil } -func (m *GenesisState) GetACL() []ACLEntry { +func (m *GenesisState) GetSections() []Section { if m != nil { - return m.ACL + return m.Sections + } + return nil +} + +func (m *GenesisState) GetUserPermissions() []UserPermission { + if m != nil { + return m.UserPermissions } return nil } @@ -93,31 +109,32 @@ func (m *GenesisState) GetUserGroups() []UserGroup { return nil } -func (m *GenesisState) GetUserGroupsMembers() []UserGroupMembersEntry { +func (m *GenesisState) GetUserGroupsMembers() []UserGroupMemberEntry { if m != nil { return m.UserGroupsMembers } return nil } -// GenesisSubspace contains the genesis data for a single subspace -type GenesisSubspace struct { - Subspace Subspace `protobuf:"bytes,1,opt,name=subspace,proto3" json:"subspace"` - InitialGroupID uint32 `protobuf:"varint,2,opt,name=initial_group_id,json=initialGroupId,proto3" json:"initial_group_id,omitempty"` +// SubspaceData contains the genesis data for a single subspace +type SubspaceData struct { + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + NextGroupID uint32 `protobuf:"varint,2,opt,name=next_group_id,json=nextGroupId,proto3" json:"next_group_id,omitempty"` + NextSectionID uint32 `protobuf:"varint,3,opt,name=next_section_id,json=nextSectionId,proto3" json:"next_section_id,omitempty"` } -func (m *GenesisSubspace) Reset() { *m = GenesisSubspace{} } -func (m *GenesisSubspace) String() string { return proto.CompactTextString(m) } -func (*GenesisSubspace) ProtoMessage() {} -func (*GenesisSubspace) Descriptor() ([]byte, []int) { - return fileDescriptor_bce8af665337782b, []int{1} +func (m *SubspaceData) Reset() { *m = SubspaceData{} } +func (m *SubspaceData) String() string { return proto.CompactTextString(m) } +func (*SubspaceData) ProtoMessage() {} +func (*SubspaceData) Descriptor() ([]byte, []int) { + return fileDescriptor_e29defb77aaf744c, []int{1} } -func (m *GenesisSubspace) XXX_Unmarshal(b []byte) error { +func (m *SubspaceData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *GenesisSubspace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *SubspaceData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_GenesisSubspace.Marshal(b, m, deterministic) + return xxx_messageInfo_SubspaceData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -127,51 +144,59 @@ func (m *GenesisSubspace) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *GenesisSubspace) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisSubspace.Merge(m, src) +func (m *SubspaceData) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubspaceData.Merge(m, src) } -func (m *GenesisSubspace) XXX_Size() int { +func (m *SubspaceData) XXX_Size() int { return m.Size() } -func (m *GenesisSubspace) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisSubspace.DiscardUnknown(m) +func (m *SubspaceData) XXX_DiscardUnknown() { + xxx_messageInfo_SubspaceData.DiscardUnknown(m) } -var xxx_messageInfo_GenesisSubspace proto.InternalMessageInfo +var xxx_messageInfo_SubspaceData proto.InternalMessageInfo -func (m *GenesisSubspace) GetSubspace() Subspace { +func (m *SubspaceData) GetSubspaceID() uint64 { if m != nil { - return m.Subspace + return m.SubspaceID } - return Subspace{} + return 0 } -func (m *GenesisSubspace) GetInitialGroupID() uint32 { +func (m *SubspaceData) GetNextGroupID() uint32 { if m != nil { - return m.InitialGroupID + return m.NextGroupID } return 0 } -// ACLEntry represents a single Access Control List entry -type ACLEntry struct { +func (m *SubspaceData) GetNextSectionID() uint32 { + if m != nil { + return m.NextSectionID + } + return 0 +} + +// UserPermission represents a single Access Control List entry +type UserPermission struct { SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` - User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` - Permissions uint32 `protobuf:"varint,3,opt,name=permissions,proto3" json:"permissions,omitempty"` + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` + User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"` + Permissions uint32 `protobuf:"varint,4,opt,name=permissions,proto3" json:"permissions,omitempty"` } -func (m *ACLEntry) Reset() { *m = ACLEntry{} } -func (m *ACLEntry) String() string { return proto.CompactTextString(m) } -func (*ACLEntry) ProtoMessage() {} -func (*ACLEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_bce8af665337782b, []int{2} +func (m *UserPermission) Reset() { *m = UserPermission{} } +func (m *UserPermission) String() string { return proto.CompactTextString(m) } +func (*UserPermission) ProtoMessage() {} +func (*UserPermission) Descriptor() ([]byte, []int) { + return fileDescriptor_e29defb77aaf744c, []int{2} } -func (m *ACLEntry) XXX_Unmarshal(b []byte) error { +func (m *UserPermission) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *UserPermission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLEntry.Marshal(b, m, deterministic) + return xxx_messageInfo_UserPermission.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -181,58 +206,65 @@ func (m *ACLEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *ACLEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLEntry.Merge(m, src) +func (m *UserPermission) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserPermission.Merge(m, src) } -func (m *ACLEntry) XXX_Size() int { +func (m *UserPermission) XXX_Size() int { return m.Size() } -func (m *ACLEntry) XXX_DiscardUnknown() { - xxx_messageInfo_ACLEntry.DiscardUnknown(m) +func (m *UserPermission) XXX_DiscardUnknown() { + xxx_messageInfo_UserPermission.DiscardUnknown(m) } -var xxx_messageInfo_ACLEntry proto.InternalMessageInfo +var xxx_messageInfo_UserPermission proto.InternalMessageInfo -func (m *ACLEntry) GetSubspaceID() uint64 { +func (m *UserPermission) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *ACLEntry) GetUser() string { +func (m *UserPermission) GetSectionID() uint32 { + if m != nil { + return m.SectionID + } + return 0 +} + +func (m *UserPermission) GetUser() string { if m != nil { return m.User } return "" } -func (m *ACLEntry) GetPermissions() uint32 { +func (m *UserPermission) GetPermissions() uint32 { if m != nil { return m.Permissions } return 0 } -// UserGroupMembersEntry contains all the members of a specific user group -type UserGroupMembersEntry struct { - SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` - GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` - Members []string `protobuf:"bytes,3,rep,name=members,proto3" json:"members,omitempty"` +// UserGroupMemberEntry contains the details of a user group member +type UserGroupMemberEntry struct { + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"` } -func (m *UserGroupMembersEntry) Reset() { *m = UserGroupMembersEntry{} } -func (m *UserGroupMembersEntry) String() string { return proto.CompactTextString(m) } -func (*UserGroupMembersEntry) ProtoMessage() {} -func (*UserGroupMembersEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_bce8af665337782b, []int{3} +func (m *UserGroupMemberEntry) Reset() { *m = UserGroupMemberEntry{} } +func (m *UserGroupMemberEntry) String() string { return proto.CompactTextString(m) } +func (*UserGroupMemberEntry) ProtoMessage() {} +func (*UserGroupMemberEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_e29defb77aaf744c, []int{3} } -func (m *UserGroupMembersEntry) XXX_Unmarshal(b []byte) error { +func (m *UserGroupMemberEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *UserGroupMembersEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *UserGroupMemberEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_UserGroupMembersEntry.Marshal(b, m, deterministic) + return xxx_messageInfo_UserGroupMemberEntry.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -242,83 +274,86 @@ func (m *UserGroupMembersEntry) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *UserGroupMembersEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserGroupMembersEntry.Merge(m, src) +func (m *UserGroupMemberEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserGroupMemberEntry.Merge(m, src) } -func (m *UserGroupMembersEntry) XXX_Size() int { +func (m *UserGroupMemberEntry) XXX_Size() int { return m.Size() } -func (m *UserGroupMembersEntry) XXX_DiscardUnknown() { - xxx_messageInfo_UserGroupMembersEntry.DiscardUnknown(m) +func (m *UserGroupMemberEntry) XXX_DiscardUnknown() { + xxx_messageInfo_UserGroupMemberEntry.DiscardUnknown(m) } -var xxx_messageInfo_UserGroupMembersEntry proto.InternalMessageInfo +var xxx_messageInfo_UserGroupMemberEntry proto.InternalMessageInfo -func (m *UserGroupMembersEntry) GetSubspaceID() uint64 { +func (m *UserGroupMemberEntry) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *UserGroupMembersEntry) GetGroupID() uint32 { +func (m *UserGroupMemberEntry) GetGroupID() uint32 { if m != nil { return m.GroupID } return 0 } -func (m *UserGroupMembersEntry) GetMembers() []string { +func (m *UserGroupMemberEntry) GetUser() string { if m != nil { - return m.Members + return m.User } - return nil + return "" } func init() { - proto.RegisterType((*GenesisState)(nil), "desmos.subspaces.v1.GenesisState") - proto.RegisterType((*GenesisSubspace)(nil), "desmos.subspaces.v1.GenesisSubspace") - proto.RegisterType((*ACLEntry)(nil), "desmos.subspaces.v1.ACLEntry") - proto.RegisterType((*UserGroupMembersEntry)(nil), "desmos.subspaces.v1.UserGroupMembersEntry") + proto.RegisterType((*GenesisState)(nil), "desmos.subspaces.v2.GenesisState") + proto.RegisterType((*SubspaceData)(nil), "desmos.subspaces.v2.SubspaceData") + proto.RegisterType((*UserPermission)(nil), "desmos.subspaces.v2.UserPermission") + proto.RegisterType((*UserGroupMemberEntry)(nil), "desmos.subspaces.v2.UserGroupMemberEntry") } -func init() { proto.RegisterFile("desmos/subspaces/v1/genesis.proto", fileDescriptor_bce8af665337782b) } +func init() { proto.RegisterFile("desmos/subspaces/v2/genesis.proto", fileDescriptor_e29defb77aaf744c) } -var fileDescriptor_bce8af665337782b = []byte{ - // 513 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x3b, 0x9b, 0xea, 0xb6, 0x2f, 0x5a, 0xed, 0xd4, 0x85, 0xb0, 0x60, 0x12, 0x17, 0x91, - 0x22, 0x98, 0xb0, 0xbb, 0x37, 0x59, 0x90, 0xcd, 0x6e, 0x59, 0x0b, 0xf5, 0x92, 0xc5, 0x8b, 0x97, - 0x9a, 0x34, 0x43, 0x1c, 0x68, 0x9a, 0x90, 0x49, 0x8a, 0x8b, 0xff, 0xc4, 0x1e, 0x3c, 0x88, 0xa7, - 0xfd, 0x73, 0xf6, 0xb8, 0x47, 0x4f, 0x41, 0xd2, 0x8b, 0x7f, 0x86, 0x64, 0x92, 0x69, 0x43, 0x8d, - 0x82, 0xb7, 0x99, 0xf7, 0xe3, 0xf3, 0xbe, 0xf3, 0xde, 0x1b, 0x78, 0xe6, 0x11, 0x16, 0x84, 0xcc, - 0x64, 0xa9, 0xcb, 0x22, 0x67, 0x46, 0x98, 0xb9, 0x3c, 0x34, 0x7d, 0xb2, 0x20, 0x8c, 0x32, 0x23, - 0x8a, 0xc3, 0x24, 0xc4, 0x83, 0x32, 0xc4, 0x58, 0x87, 0x18, 0xcb, 0xc3, 0xfd, 0x27, 0x7e, 0xe8, - 0x87, 0xdc, 0x6f, 0x16, 0xa7, 0x32, 0x74, 0x5f, 0x6f, 0xa2, 0x05, 0xa1, 0x47, 0xe6, 0x15, 0xec, - 0xe0, 0x5a, 0x82, 0x07, 0x17, 0x25, 0xfe, 0x32, 0x71, 0x12, 0x82, 0x47, 0x30, 0xa0, 0x0b, 0x9a, - 0x50, 0x67, 0x3e, 0x15, 0x59, 0x53, 0xea, 0x29, 0x48, 0x47, 0xc3, 0xb6, 0xb5, 0x97, 0x67, 0x5a, - 0x7f, 0x5c, 0xba, 0x2f, 0x2b, 0xef, 0xf8, 0xdc, 0xee, 0xd3, 0x2d, 0x93, 0x87, 0xdf, 0x42, 0x77, - 0x5d, 0x54, 0xd9, 0xd1, 0xa5, 0xa1, 0x7c, 0xf4, 0xdc, 0x68, 0x10, 0x6e, 0x88, 0xe2, 0x95, 0xcd, - 0x6a, 0xdf, 0x66, 0x5a, 0xcb, 0xde, 0x24, 0xe3, 0x13, 0x90, 0x9c, 0xd9, 0x5c, 0x91, 0x38, 0xe3, - 0x69, 0x23, 0xe3, 0xf4, 0x6c, 0x32, 0x5a, 0x24, 0xf1, 0x95, 0x25, 0x17, 0xc9, 0x79, 0xa6, 0x49, - 0xa7, 0x67, 0x13, 0xbb, 0x48, 0xc3, 0x23, 0x90, 0x53, 0x46, 0xe2, 0xa9, 0x1f, 0x87, 0x69, 0xc4, - 0x94, 0x36, 0xa7, 0xa8, 0x8d, 0x94, 0xf7, 0x8c, 0xc4, 0x17, 0x45, 0x58, 0xa5, 0x01, 0x52, 0x61, - 0x60, 0xf8, 0x23, 0x0c, 0x6a, 0x98, 0x69, 0x40, 0x02, 0x97, 0xc4, 0x4c, 0xb9, 0xc7, 0x71, 0x2f, - 0xff, 0x8d, 0x7b, 0x57, 0x06, 0x97, 0x0a, 0x4b, 0x74, 0x7f, 0x83, 0xae, 0xbc, 0xaf, 0x3b, 0xdf, - 0x6e, 0x34, 0xf4, 0xeb, 0x46, 0x43, 0x07, 0xdf, 0x11, 0x3c, 0xda, 0xea, 0x0a, 0x7e, 0x03, 0x1d, - 0x01, 0xe7, 0xa3, 0xf8, 0x5b, 0x27, 0xb6, 0xda, 0xb8, 0x4e, 0xc2, 0x27, 0xf0, 0x58, 0x8c, 0x95, - 0xbf, 0xa1, 0x98, 0xe9, 0x8e, 0x8e, 0x86, 0x0f, 0x2d, 0x9c, 0x67, 0x5a, 0xaf, 0x9a, 0x29, 0x97, - 0x34, 0x3e, 0xb7, 0x7b, 0xb4, 0x7e, 0xf7, 0x6a, 0xe2, 0xbe, 0x40, 0x47, 0x74, 0x1b, 0x9b, 0x20, - 0xff, 0xb9, 0x22, 0xbd, 0x3c, 0xd3, 0xa0, 0xb6, 0x1b, 0xc0, 0x36, 0x4b, 0x81, 0xa1, 0x5d, 0x3c, - 0x9c, 0x17, 0xee, 0xda, 0xfc, 0x8c, 0x75, 0x90, 0x23, 0x12, 0x07, 0x94, 0x31, 0x1a, 0x2e, 0x98, - 0x22, 0x15, 0x9a, 0xec, 0xba, 0xa9, 0x56, 0xfc, 0x2b, 0x82, 0xbd, 0xc6, 0xb6, 0xfe, 0xbf, 0x94, - 0x17, 0xd0, 0xd9, 0xea, 0x83, 0x9c, 0x67, 0xda, 0xae, 0x68, 0xc0, 0xae, 0x5f, 0xbe, 0x1c, 0x2b, - 0xb0, 0x2b, 0x86, 0x5d, 0x6c, 0x60, 0xd7, 0x16, 0xd7, 0x8d, 0x2c, 0x6b, 0x72, 0x9b, 0xab, 0xe8, - 0x2e, 0x57, 0xd1, 0xcf, 0x5c, 0x45, 0xd7, 0x2b, 0xb5, 0x75, 0xb7, 0x52, 0x5b, 0x3f, 0x56, 0x6a, - 0xeb, 0xc3, 0x91, 0x4f, 0x93, 0x4f, 0xa9, 0x6b, 0xcc, 0xc2, 0xc0, 0x2c, 0xc7, 0xf5, 0x6a, 0xee, - 0xb8, 0xac, 0x3a, 0x9b, 0xcb, 0x63, 0xf3, 0x73, 0xed, 0x6f, 0x26, 0x57, 0x11, 0x61, 0xee, 0x7d, - 0xfe, 0x31, 0x8f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x60, 0xe6, 0xd1, 0x54, 0x0a, 0x04, 0x00, - 0x00, +var fileDescriptor_e29defb77aaf744c = []byte{ + // 575 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x6a, 0xdb, 0x4c, + 0x14, 0x85, 0xad, 0x44, 0x7f, 0x62, 0x5f, 0xc5, 0xf6, 0xef, 0x71, 0x0a, 0x22, 0xb4, 0x92, 0x93, + 0x42, 0x71, 0xa1, 0x95, 0xc0, 0x5e, 0xb5, 0x8b, 0x42, 0x8d, 0x4d, 0x30, 0xb4, 0xa1, 0x28, 0xed, + 0xa6, 0x1b, 0x21, 0x5b, 0x83, 0x2a, 0xb0, 0x24, 0xa3, 0x19, 0x19, 0xe7, 0x21, 0x0a, 0x5d, 0x76, + 0x99, 0x37, 0x68, 0xb7, 0x7d, 0x83, 0x2c, 0xb3, 0xec, 0x4a, 0x14, 0x79, 0xd3, 0xc7, 0x28, 0x1a, + 0x8d, 0x64, 0x25, 0x55, 0x03, 0xd9, 0x8d, 0xee, 0x9c, 0xf3, 0xcd, 0xe1, 0xde, 0x8b, 0xe0, 0xd8, + 0xc6, 0xc4, 0x0b, 0x88, 0x4e, 0xa2, 0x19, 0x59, 0x5a, 0x73, 0x4c, 0xf4, 0xd5, 0x40, 0x77, 0xb0, + 0x8f, 0x89, 0x4b, 0xb4, 0x65, 0x18, 0xd0, 0x00, 0x75, 0x33, 0x89, 0x56, 0x48, 0xb4, 0xd5, 0xe0, + 0xe8, 0xd0, 0x09, 0x9c, 0x80, 0xdd, 0xeb, 0xe9, 0x29, 0x93, 0x1e, 0xf5, 0xaa, 0x68, 0x5e, 0x60, + 0xe3, 0x05, 0x87, 0x9d, 0x7c, 0x17, 0xe1, 0xe0, 0x34, 0xc3, 0x9f, 0x53, 0x8b, 0x62, 0x34, 0x81, + 0xae, 0xeb, 0xbb, 0xd4, 0xb5, 0x16, 0x66, 0xee, 0x32, 0x5d, 0x5b, 0x16, 0x7a, 0x42, 0x5f, 0x1c, + 0x3d, 0x48, 0x62, 0xb5, 0x33, 0xcd, 0xae, 0xcf, 0xf9, 0xed, 0x74, 0x6c, 0x74, 0xdc, 0x5b, 0x25, + 0x1b, 0x9d, 0x41, 0xab, 0x78, 0xd4, 0xb4, 0x2d, 0x6a, 0xc9, 0x3b, 0xbd, 0xdd, 0xbe, 0x34, 0x38, + 0xd6, 0x2a, 0xd2, 0x6b, 0xb9, 0x71, 0x6c, 0x51, 0x6b, 0x24, 0x5e, 0xc5, 0x6a, 0xcd, 0x68, 0x16, + 0x82, 0xb4, 0x88, 0x5e, 0x43, 0xa3, 0x28, 0xc8, 0xbb, 0x0c, 0xf5, 0xe8, 0x4e, 0x14, 0xc7, 0x6c, + 0x5d, 0xe8, 0x15, 0xd4, 0x09, 0x9e, 0x53, 0x37, 0xf0, 0x89, 0x2c, 0x32, 0xc2, 0xc3, 0x6a, 0x42, + 0x26, 0xe2, 0x80, 0xc2, 0x83, 0xde, 0xc3, 0xff, 0x11, 0xc1, 0xa1, 0xb9, 0xc4, 0xa1, 0xe7, 0x12, + 0xc2, 0x38, 0xff, 0x31, 0xce, 0xe3, 0x4a, 0xce, 0x07, 0x82, 0xc3, 0x77, 0x85, 0x96, 0xe3, 0xda, + 0xd1, 0x8d, 0x2a, 0x41, 0x13, 0x90, 0x18, 0xd5, 0x09, 0x83, 0x68, 0x49, 0xe4, 0x3d, 0x06, 0x54, + 0xfe, 0x09, 0x3c, 0x4d, 0x65, 0x9c, 0x05, 0x51, 0x5e, 0x20, 0xc8, 0x84, 0x6e, 0x09, 0x63, 0x7a, + 0xd8, 0x9b, 0xe1, 0x90, 0xc8, 0xfb, 0x0c, 0xf7, 0xf4, 0x6e, 0xdc, 0x5b, 0x26, 0x9e, 0xf8, 0x34, + 0xbc, 0xe0, 0xe4, 0xce, 0x96, 0x9c, 0x5d, 0x92, 0x97, 0xf5, 0xaf, 0x97, 0xaa, 0xf0, 0xfb, 0x52, + 0x15, 0x4e, 0x7e, 0x08, 0x70, 0x50, 0x1e, 0x18, 0xd2, 0x41, 0xfa, 0x7b, 0x55, 0x5a, 0x49, 0xac, + 0x42, 0x69, 0x47, 0x80, 0x6c, 0x97, 0x63, 0x08, 0x4d, 0x1f, 0xaf, 0x69, 0x16, 0x36, 0xb5, 0xec, + 0xf4, 0x84, 0x7e, 0x73, 0xd4, 0x4e, 0x62, 0x55, 0x3a, 0xc3, 0x6b, 0xca, 0x5e, 0x9e, 0x8e, 0x0d, + 0xc9, 0x2f, 0x3e, 0x6c, 0xf4, 0x02, 0xda, 0xcc, 0xc4, 0xe7, 0x91, 0xda, 0x76, 0x99, 0xad, 0x93, + 0xc4, 0x6a, 0x33, 0xb5, 0xf1, 0xc1, 0x4d, 0xc7, 0x06, 0xc3, 0xe7, 0x9f, 0x76, 0x29, 0xfb, 0x37, + 0x01, 0x5a, 0x37, 0xe7, 0x72, 0xff, 0xf4, 0xcf, 0x00, 0x4a, 0x19, 0xb2, 0xe8, 0xcd, 0x24, 0x56, + 0x1b, 0xdb, 0xf7, 0x1b, 0x24, 0x7f, 0x1b, 0x21, 0x10, 0xd3, 0x66, 0xb2, 0xac, 0x0d, 0x83, 0x9d, + 0x51, 0x0f, 0xa4, 0xf2, 0x12, 0x89, 0x29, 0xc2, 0x28, 0x97, 0x4a, 0x89, 0x3f, 0x0b, 0x70, 0x58, + 0x35, 0xa9, 0xfb, 0xe7, 0x7e, 0x02, 0xf5, 0x5b, 0x0d, 0x97, 0x92, 0x58, 0xdd, 0xcf, 0x9b, 0xbd, + 0xef, 0xf0, 0x46, 0x57, 0x24, 0xde, 0xe6, 0x19, 0xbd, 0xb9, 0x4a, 0x14, 0xe1, 0x3a, 0x51, 0x84, + 0x5f, 0x89, 0x22, 0x7c, 0xd9, 0x28, 0xb5, 0xeb, 0x8d, 0x52, 0xfb, 0xb9, 0x51, 0x6a, 0x1f, 0x07, + 0x8e, 0x4b, 0x3f, 0x45, 0x33, 0x6d, 0x1e, 0x78, 0x7a, 0xb6, 0x6f, 0xcf, 0x17, 0xd6, 0x8c, 0xf0, + 0xb3, 0xbe, 0x1a, 0xea, 0xeb, 0xd2, 0x8f, 0x88, 0x5e, 0x2c, 0x31, 0x99, 0xed, 0xb1, 0xbf, 0xd0, + 0xf0, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6b, 0xd0, 0xfa, 0xeb, 0xf7, 0x04, 0x00, 0x00, } func (this *GenesisState) Equal(that interface{}) bool { @@ -343,6 +378,14 @@ func (this *GenesisState) Equal(that interface{}) bool { if this.InitialSubspaceID != that1.InitialSubspaceID { return false } + if len(this.SubspacesData) != len(that1.SubspacesData) { + return false + } + for i := range this.SubspacesData { + if !this.SubspacesData[i].Equal(&that1.SubspacesData[i]) { + return false + } + } if len(this.Subspaces) != len(that1.Subspaces) { return false } @@ -351,11 +394,19 @@ func (this *GenesisState) Equal(that interface{}) bool { return false } } - if len(this.ACL) != len(that1.ACL) { + if len(this.Sections) != len(that1.Sections) { + return false + } + for i := range this.Sections { + if !this.Sections[i].Equal(&that1.Sections[i]) { + return false + } + } + if len(this.UserPermissions) != len(that1.UserPermissions) { return false } - for i := range this.ACL { - if !this.ACL[i].Equal(&that1.ACL[i]) { + for i := range this.UserPermissions { + if !this.UserPermissions[i].Equal(&that1.UserPermissions[i]) { return false } } @@ -377,14 +428,14 @@ func (this *GenesisState) Equal(that interface{}) bool { } return true } -func (this *GenesisSubspace) Equal(that interface{}) bool { +func (this *SubspaceData) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*GenesisSubspace) + that1, ok := that.(*SubspaceData) if !ok { - that2, ok := that.(GenesisSubspace) + that2, ok := that.(SubspaceData) if ok { that1 = &that2 } else { @@ -396,22 +447,25 @@ func (this *GenesisSubspace) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Subspace.Equal(&that1.Subspace) { + if this.SubspaceID != that1.SubspaceID { return false } - if this.InitialGroupID != that1.InitialGroupID { + if this.NextGroupID != that1.NextGroupID { + return false + } + if this.NextSectionID != that1.NextSectionID { return false } return true } -func (this *ACLEntry) Equal(that interface{}) bool { +func (this *UserPermission) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*ACLEntry) + that1, ok := that.(*UserPermission) if !ok { - that2, ok := that.(ACLEntry) + that2, ok := that.(UserPermission) if ok { that1 = &that2 } else { @@ -426,6 +480,9 @@ func (this *ACLEntry) Equal(that interface{}) bool { if this.SubspaceID != that1.SubspaceID { return false } + if this.SectionID != that1.SectionID { + return false + } if this.User != that1.User { return false } @@ -434,14 +491,14 @@ func (this *ACLEntry) Equal(that interface{}) bool { } return true } -func (this *UserGroupMembersEntry) Equal(that interface{}) bool { +func (this *UserGroupMemberEntry) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*UserGroupMembersEntry) + that1, ok := that.(*UserGroupMemberEntry) if !ok { - that2, ok := that.(UserGroupMembersEntry) + that2, ok := that.(UserGroupMemberEntry) if ok { that1 = &that2 } else { @@ -459,14 +516,9 @@ func (this *UserGroupMembersEntry) Equal(that interface{}) bool { if this.GroupID != that1.GroupID { return false } - if len(this.Members) != len(that1.Members) { + if this.User != that1.User { return false } - for i := range this.Members { - if this.Members[i] != that1.Members[i] { - return false - } - } return true } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -500,7 +552,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a } } if len(m.UserGroups) > 0 { @@ -514,13 +566,13 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 } } - if len(m.ACL) > 0 { - for iNdEx := len(m.ACL) - 1; iNdEx >= 0; iNdEx-- { + if len(m.UserPermissions) > 0 { + for iNdEx := len(m.UserPermissions) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.ACL[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.UserPermissions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -528,7 +580,21 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a + } + } + if len(m.Sections) > 0 { + for iNdEx := len(m.Sections) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Sections[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 } } if len(m.Subspaces) > 0 { @@ -542,6 +608,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x1a + } + } + if len(m.SubspacesData) > 0 { + for iNdEx := len(m.SubspacesData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SubspacesData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x12 } } @@ -553,7 +633,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *GenesisSubspace) Marshal() (dAtA []byte, err error) { +func (m *SubspaceData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -563,35 +643,35 @@ func (m *GenesisSubspace) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GenesisSubspace) MarshalTo(dAtA []byte) (int, error) { +func (m *SubspaceData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GenesisSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *SubspaceData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.InitialGroupID != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.InitialGroupID)) + if m.NextSectionID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextSectionID)) + i-- + dAtA[i] = 0x18 + } + if m.NextGroupID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextGroupID)) i-- dAtA[i] = 0x10 } - { - size, err := m.Subspace.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + if m.SubspaceID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *ACLEntry) Marshal() (dAtA []byte, err error) { +func (m *UserPermission) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -601,12 +681,12 @@ func (m *ACLEntry) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLEntry) MarshalTo(dAtA []byte) (int, error) { +func (m *UserPermission) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *UserPermission) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -614,14 +694,19 @@ func (m *ACLEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Permissions != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.Permissions)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.User) > 0 { i -= len(m.User) copy(dAtA[i:], m.User) i = encodeVarintGenesis(dAtA, i, uint64(len(m.User))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.SectionID != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 } if m.SubspaceID != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.SubspaceID)) @@ -631,7 +716,7 @@ func (m *ACLEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *UserGroupMembersEntry) Marshal() (dAtA []byte, err error) { +func (m *UserGroupMemberEntry) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -641,24 +726,22 @@ func (m *UserGroupMembersEntry) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *UserGroupMembersEntry) MarshalTo(dAtA []byte) (int, error) { +func (m *UserGroupMemberEntry) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *UserGroupMembersEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *UserGroupMemberEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Members) > 0 { - for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Members[iNdEx]) - copy(dAtA[i:], m.Members[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Members[iNdEx]))) - i-- - dAtA[i] = 0x1a - } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0x1a } if m.GroupID != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.GroupID)) @@ -693,14 +776,26 @@ func (m *GenesisState) Size() (n int) { if m.InitialSubspaceID != 0 { n += 1 + sovGenesis(uint64(m.InitialSubspaceID)) } + if len(m.SubspacesData) > 0 { + for _, e := range m.SubspacesData { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } if len(m.Subspaces) > 0 { for _, e := range m.Subspaces { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.ACL) > 0 { - for _, e := range m.ACL { + if len(m.Sections) > 0 { + for _, e := range m.Sections { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.UserPermissions) > 0 { + for _, e := range m.UserPermissions { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -720,21 +815,25 @@ func (m *GenesisState) Size() (n int) { return n } -func (m *GenesisSubspace) Size() (n int) { +func (m *SubspaceData) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Subspace.Size() - n += 1 + l + sovGenesis(uint64(l)) - if m.InitialGroupID != 0 { - n += 1 + sovGenesis(uint64(m.InitialGroupID)) + if m.SubspaceID != 0 { + n += 1 + sovGenesis(uint64(m.SubspaceID)) + } + if m.NextGroupID != 0 { + n += 1 + sovGenesis(uint64(m.NextGroupID)) + } + if m.NextSectionID != 0 { + n += 1 + sovGenesis(uint64(m.NextSectionID)) } return n } -func (m *ACLEntry) Size() (n int) { +func (m *UserPermission) Size() (n int) { if m == nil { return 0 } @@ -743,6 +842,9 @@ func (m *ACLEntry) Size() (n int) { if m.SubspaceID != 0 { n += 1 + sovGenesis(uint64(m.SubspaceID)) } + if m.SectionID != 0 { + n += 1 + sovGenesis(uint64(m.SectionID)) + } l = len(m.User) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) @@ -753,7 +855,7 @@ func (m *ACLEntry) Size() (n int) { return n } -func (m *UserGroupMembersEntry) Size() (n int) { +func (m *UserGroupMemberEntry) Size() (n int) { if m == nil { return 0 } @@ -765,11 +867,9 @@ func (m *UserGroupMembersEntry) Size() (n int) { if m.GroupID != 0 { n += 1 + sovGenesis(uint64(m.GroupID)) } - if len(m.Members) > 0 { - for _, s := range m.Members { - l = len(s) - n += 1 + l + sovGenesis(uint64(l)) - } + l = len(m.User) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) } return n } @@ -830,7 +930,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subspaces", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SubspacesData", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -857,14 +957,14 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Subspaces = append(m.Subspaces, GenesisSubspace{}) - if err := m.Subspaces[len(m.Subspaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.SubspacesData = append(m.SubspacesData, SubspaceData{}) + if err := m.SubspacesData[len(m.SubspacesData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ACL", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Subspaces", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -891,12 +991,80 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ACL = append(m.ACL, ACLEntry{}) - if err := m.ACL[len(m.ACL)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Subspaces = append(m.Subspaces, Subspace{}) + if err := m.Subspaces[len(m.Subspaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sections", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sections = append(m.Sections, Section{}) + if err := m.Sections[len(m.Sections)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserPermissions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UserPermissions = append(m.UserPermissions, UserPermission{}) + if err := m.UserPermissions[len(m.UserPermissions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UserGroups", wireType) } @@ -930,7 +1098,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UserGroupsMembers", wireType) } @@ -959,7 +1127,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UserGroupsMembers = append(m.UserGroupsMembers, UserGroupMembersEntry{}) + m.UserGroupsMembers = append(m.UserGroupsMembers, UserGroupMemberEntry{}) if err := m.UserGroupsMembers[len(m.UserGroupsMembers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -985,7 +1153,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } -func (m *GenesisSubspace) Unmarshal(dAtA []byte) error { +func (m *SubspaceData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1008,17 +1176,17 @@ func (m *GenesisSubspace) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisSubspace: wiretype end group for non-group") + return fmt.Errorf("proto: SubspaceData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SubspaceData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subspace", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) } - var msglen int + m.SubspaceID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -1028,30 +1196,35 @@ func (m *GenesisSubspace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.SubspaceID |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextGroupID", wireType) } - if err := m.Subspace.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.NextGroupID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextGroupID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - iNdEx = postIndex - case 2: + case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field InitialGroupID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NextSectionID", wireType) } - m.InitialGroupID = 0 + m.NextSectionID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -1061,7 +1234,7 @@ func (m *GenesisSubspace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.InitialGroupID |= uint32(b&0x7F) << shift + m.NextSectionID |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -1087,7 +1260,7 @@ func (m *GenesisSubspace) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLEntry) Unmarshal(dAtA []byte) error { +func (m *UserPermission) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1110,10 +1283,10 @@ func (m *ACLEntry) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ACLEntry: wiretype end group for non-group") + return fmt.Errorf("proto: UserPermission: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ACLEntry: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UserPermission: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1136,6 +1309,25 @@ func (m *ACLEntry) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) } @@ -1167,7 +1359,7 @@ func (m *ACLEntry) Unmarshal(dAtA []byte) error { } m.User = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) } @@ -1207,7 +1399,7 @@ func (m *ACLEntry) Unmarshal(dAtA []byte) error { } return nil } -func (m *UserGroupMembersEntry) Unmarshal(dAtA []byte) error { +func (m *UserGroupMemberEntry) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1230,10 +1422,10 @@ func (m *UserGroupMembersEntry) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserGroupMembersEntry: wiretype end group for non-group") + return fmt.Errorf("proto: UserGroupMemberEntry: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserGroupMembersEntry: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UserGroupMemberEntry: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1276,7 +1468,7 @@ func (m *UserGroupMembersEntry) Unmarshal(dAtA []byte) error { } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1304,7 +1496,7 @@ func (m *UserGroupMembersEntry) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, string(dAtA[iNdEx:postIndex])) + m.User = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/subspaces/types/genesis_test.go b/x/subspaces/types/genesis_test.go index b89e757711..db929db330 100644 --- a/x/subspaces/types/genesis_test.go +++ b/x/subspaces/types/genesis_test.go @@ -9,36 +9,216 @@ import ( "github.com/stretchr/testify/require" ) -func TestACLEntry_Validate(t *testing.T) { +func TestValidateGenesis(t *testing.T) { testCases := []struct { name string - entry types.ACLEntry + genesis *types.GenesisState shouldErr bool }{ { - name: "invalid subspace id returns error", - entry: types.NewACLEntry( - 0, - "cosmos19gz9jn5pl6ke6qg5s4gt9ga9my7w8a0x3ar0qy", - types.PermissionWrite, - ), + name: "invalid initial subspace id returns error", + genesis: types.NewGenesisState(0, nil, nil, nil, nil, nil, nil), + shouldErr: true, + }, + { + name: "duplicated subspace data returns error", + genesis: types.NewGenesisState(1, []types.SubspaceData{ + types.NewSubspaceData(1, 1, 1), + types.NewSubspaceData(1, 1, 1), + }, nil, nil, nil, nil, nil), shouldErr: true, }, { - name: "invalid user returns no error", - entry: types.NewACLEntry( - 1, - "cosmos19gz9jn5pl6ke6", - types.PermissionWrite, + name: "invalid subspace data returns error", + genesis: types.NewGenesisState(1, []types.SubspaceData{ + types.NewSubspaceData(1, 1, 0), + }, nil, nil, nil, nil, nil), + shouldErr: true, + }, + { + name: "duplicated subspace returns error", + genesis: types.NewGenesisState(1, nil, []types.Subspace{ + types.NewSubspace( + 1, + "This is a test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + ), + types.NewSubspace( + 1, + "Another test subspace", + "This is another test subspace", + "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", + "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", + "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + ), + }, nil, nil, nil, nil), + shouldErr: true, + }, + { + name: "invalid subspace returns error", + genesis: types.NewGenesisState(2, nil, []types.Subspace{ + types.NewSubspace( + 0, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + ), + }, nil, nil, nil, nil), + shouldErr: true, + }, + { + name: "duplication section returns error", + genesis: types.NewGenesisState(1, nil, nil, []types.Section{ + types.NewSection(1, 1, 0, "Test section", "Test section"), + types.NewSection(1, 1, 0, "Test section", "Test section"), + }, nil, nil, nil), + shouldErr: true, + }, + { + name: "invalid section returns error", + genesis: types.NewGenesisState(1, nil, nil, []types.Section{ + types.NewSection(0, 1, 0, "Test section", "Test section"), + }, nil, nil, nil), + shouldErr: true, + }, + { + name: "duplicated user permission returns error", + genesis: types.NewGenesisState(1, nil, nil, nil, []types.UserPermission{ + types.NewUserPermission(1, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite), + types.NewUserPermission(1, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionSetPermissions), + }, nil, nil), + shouldErr: true, + }, + { + name: "invalid user permission returns error", + genesis: types.NewGenesisState(1, nil, nil, nil, []types.UserPermission{ + types.NewUserPermission(0, 0, "", types.PermissionWrite), + }, nil, nil), + shouldErr: true, + }, + { + name: "duplicated group returns error", + genesis: types.NewGenesisState(1, nil, nil, nil, nil, []types.UserGroup{ + types.NewUserGroup( + 1, + 1, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + ), + types.NewUserGroup( + 1, + 1, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + ), + }, nil), + shouldErr: true, + }, + { + name: "invalid group returns error", + genesis: types.NewGenesisState(1, nil, nil, nil, nil, []types.UserGroup{ + types.NewUserGroup( + 1, + 1, + 0, + "", + "This is a test group", + types.PermissionWrite, + ), + }, nil), + shouldErr: true, + }, + { + name: "duplicated group members entry returns error", + genesis: types.NewGenesisState(1, nil, nil, nil, nil, nil, []types.UserGroupMemberEntry{ + types.NewUserGroupMemberEntry(1, 1, ""), + types.NewUserGroupMemberEntry(1, 1, ""), + }), + shouldErr: true, + }, + { + name: "invalid group members entry returns error", + genesis: types.NewGenesisState(1, nil, nil, nil, nil, nil, []types.UserGroupMemberEntry{ + types.NewUserGroupMemberEntry(1, 0, ""), + }, ), shouldErr: true, }, { - name: "valid user entry returns no error", - entry: types.NewACLEntry( - 1, - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - types.PermissionEverything, + name: "default genesis returns no error", + genesis: types.DefaultGenesisState(), + shouldErr: false, + }, + { + name: "valid genesis state returns no error", + genesis: types.NewGenesisState( + 3, + []types.SubspaceData{ + types.NewSubspaceData(1, 1, 3), + types.NewSubspaceData(2, 1, 1), + }, + []types.Subspace{ + types.NewSubspace( + 1, + "Test subspace", + "This is a test subspace", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", + time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), + ), + types.NewSubspace( + 2, + "Another test subspace", + "This is another test subspace", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", + time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), + ), + }, + []types.Section{ + types.NewSection(1, 1, 0, "Test section", "Test section"), + }, + []types.UserPermission{ + types.NewUserPermission(1, 0, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite), + types.NewUserPermission(2, 0, "cosmos19gz9jn5pl6ke6qg5s4gt9ga9my7w8a0x3ar0qy", types.PermissionManageGroups), + }, + []types.UserGroup{ + types.NewUserGroup( + 1, + 1, + 1, + "Test group", + "This is a test group", + types.PermissionWrite, + ), + types.NewUserGroup( + 2, + 1, + 1, + "Another test group", + "This is another test group", + types.PermissionWrite, + ), + }, + []types.UserGroupMemberEntry{ + types.NewUserGroupMemberEntry(1, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd"), + types.NewUserGroupMemberEntry(2, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd"), + types.NewUserGroupMemberEntry(2, 1, "cosmos19gz9jn5pl6ke6qg5s4gt9ga9my7w8a0x3ar0qy"), + }, ), shouldErr: false, }, @@ -47,7 +227,7 @@ func TestACLEntry_Validate(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := tc.entry.Validate() + err := types.ValidateGenesis(tc.genesis) if tc.shouldErr { require.Error(t, err) } else { @@ -59,35 +239,30 @@ func TestACLEntry_Validate(t *testing.T) { // ------------------------------------------------------------------------------------------------------------------- -func TestUserGroupMembersEntry_Validate(t *testing.T) { +func TestSubspaceData_Validate(t *testing.T) { testCases := []struct { name string - entry types.UserGroupMembersEntry + data types.SubspaceData shouldErr bool }{ { name: "invalid subspace id returns error", - entry: types.NewUserGroupMembersEntry(0, 1, nil), + data: types.NewSubspaceData(0, 1, 1), shouldErr: true, }, { - name: "invalid group id returns error", - entry: types.NewUserGroupMembersEntry(1, 0, nil), + name: "invalid next section id returns error", + data: types.NewSubspaceData(1, 0, 1), shouldErr: true, }, { - name: "invalid member returns error", - entry: types.NewUserGroupMembersEntry(1, 1, []string{ - "invalid-user", - }), + name: "invalid next group id returns error", + data: types.NewSubspaceData(1, 1, 0), shouldErr: true, }, { - name: "valid entry returns no error", - entry: types.NewUserGroupMembersEntry(1, 1, []string{ - "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", - "cosmos19gz9jn5pl6ke6qg5s4gt9ga9my7w8a0x3ar0qy", - }), + name: "valid data returns no error", + data: types.NewSubspaceData(1, 1, 1), shouldErr: false, }, } @@ -95,7 +270,7 @@ func TestUserGroupMembersEntry_Validate(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := tc.entry.Validate() + err := tc.data.Validate() if tc.shouldErr { require.Error(t, err) } else { @@ -107,486 +282,73 @@ func TestUserGroupMembersEntry_Validate(t *testing.T) { // ------------------------------------------------------------------------------------------------------------------- -func TestValidateGenesis(t *testing.T) { +func TestUserPermission_Validate(t *testing.T) { testCases := []struct { name string - genesis *types.GenesisState + entry types.UserPermission shouldErr bool }{ { - name: "invalid initial subspace id returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - nil, - nil, - ), - shouldErr: true, - }, - { - name: "invalid subspace returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 0, - "Test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - nil, - nil, - ), - shouldErr: true, - }, - { - name: "duplicated subspace returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Another test subspace", - "This is another test subspace", - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - "cosmos1vkuuth0rak58x36m7wuzj7ztttxh26fhqcfxm0", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - nil, - nil, - ), - shouldErr: true, - }, - { - name: "invalid ACL entry returns error", - genesis: types.NewGenesisState( - 1, - nil, - []types.ACLEntry{ - types.NewACLEntry(0, "group", types.PermissionWrite), - }, - nil, - nil, - ), - shouldErr: true, - }, - { - name: "duplicated ACL entry returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - []types.ACLEntry{ - types.NewACLEntry(1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite), - types.NewACLEntry(1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionSetPermissions), - }, - nil, - nil, - ), + name: "invalid subspace id returns error", + entry: types.NewUserPermission(0, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite), shouldErr: true, }, { - name: "ACL entry without subspace returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - []types.ACLEntry{ - types.NewACLEntry(1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionWrite), - types.NewACLEntry(2, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionSetPermissions), - }, - nil, - nil, - ), + name: "invalid user returns error", + entry: types.NewUserPermission(1, 0, "", types.PermissionWrite), shouldErr: true, }, { - name: "invalid group returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 0, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - nil, - ), + name: "invalid permission returns error", + entry: types.NewUserPermission(1, 0, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", 512), shouldErr: true, }, { - name: "duplicated group returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - nil, - ), - shouldErr: true, - }, - { - name: "group without subspace returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - types.NewUserGroup( - 1, - 2, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - nil, - ), - shouldErr: true, - }, - { - name: "invalid initial group id returns error", - genesis: types.NewGenesisState( - 1, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - nil, - ), - shouldErr: true, + name: "valid user entry returns no error", + entry: types.NewUserPermission(1, 0, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd", types.PermissionEverything), + shouldErr: false, }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.entry.Validate() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +// ------------------------------------------------------------------------------------------------------------------- + +func TestUserGroupMembersEntry_Validate(t *testing.T) { + testCases := []struct { + name string + entry types.UserGroupMemberEntry + shouldErr bool + }{ { - name: "invalid group members entry returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 0, nil), - }, - ), + name: "invalid subspace id returns error", + entry: types.NewUserGroupMemberEntry(0, 1, ""), shouldErr: true, }, { - name: "duplicated group members entry returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 1, nil), - types.NewUserGroupMembersEntry(1, 1, nil), - }, - ), + name: "invalid group id returns error", + entry: types.NewUserGroupMemberEntry(1, 0, ""), shouldErr: true, }, { - name: "group members entry without group returns error", - genesis: types.NewGenesisState( - 2, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "This is a test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 1, - ), - }, - nil, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - }, - []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 1, nil), - types.NewUserGroupMembersEntry(1, 2, nil), - }, - ), + name: "invalid member returns error", + entry: types.NewUserGroupMemberEntry(1, 1, ""), shouldErr: true, }, { - name: "default genesis returns no error", - genesis: types.DefaultGenesisState(), - shouldErr: false, - }, - { - name: "valid genesis state returns no error", - genesis: types.NewGenesisState( - 3, - []types.GenesisSubspace{ - types.NewGenesisSubspace( - types.NewSubspace( - 1, - "Test subspace", - "This is a test subspace", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - "cosmos1s0he0z3g92zwsxdj83h0ky9w463sx7gq9mqtgn", - time.Date(2020, 1, 1, 12, 00, 00, 000, time.UTC), - ), - 2, - ), - types.NewGenesisSubspace( - types.NewSubspace( - 2, - "Another test subspace", - "This is another test subspace", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - time.Date(2020, 1, 2, 12, 00, 00, 000, time.UTC), - ), - 2, - ), - }, - []types.ACLEntry{ - types.NewACLEntry(1, "cosmos19gz9jn5pl6ke6qg5s4gt9ga9my7w8a0x3ar0qy", types.PermissionWrite), - types.NewACLEntry(2, "cosmos1nv9kkuads7f627q2zf4k9kwdudx709rjck3s7e", types.PermissionManageGroups), - }, - []types.UserGroup{ - types.NewUserGroup( - 1, - 1, - "Test group", - "This is a test group", - types.PermissionWrite, - ), - types.NewUserGroup( - 2, - 1, - "Another test group", - "This is another test group", - types.PermissionWrite, - ), - }, - []types.UserGroupMembersEntry{ - types.NewUserGroupMembersEntry(1, 1, []string{ - "cosmos1a0cj0j6ujn2xap8p40y6648d0w2npytw3xvenm", - }), - types.NewUserGroupMembersEntry(2, 1, []string{ - "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", - "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", - }), - }, - ), + name: "valid entry returns no error", + entry: types.NewUserGroupMemberEntry(1, 1, "cosmos15p3m7a93luselt80ffzpf4jwtn9ama34ray0nd"), shouldErr: false, }, } @@ -594,7 +356,7 @@ func TestValidateGenesis(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := types.ValidateGenesis(tc.genesis) + err := tc.entry.Validate() if tc.shouldErr { require.Error(t, err) } else { diff --git a/x/subspaces/types/hooks.go b/x/subspaces/types/hooks.go index ebc7d19693..d8a54fe1ae 100644 --- a/x/subspaces/types/hooks.go +++ b/x/subspaces/types/hooks.go @@ -17,13 +17,16 @@ type SubspacesHooks interface { AfterSubspaceSaved(ctx sdk.Context, subspaceID uint64) // Must be called when a subspace is saved AfterSubspaceDeleted(ctx sdk.Context, subspaceID uint64) // Must be called when a subspace is deleted - AfterSubspaceGroupSaved(ctx sdk.Context, subspaceID uint64, groupID uint32) // Must be called when a subspace group is created - AfterSubspaceGroupMemberAdded(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) // Must be called when a user is added to a group - AfterSubspaceGroupMemberRemoved(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) // Must be called when a user is removed from a group - AfterSubspaceGroupDeleted(ctx sdk.Context, subspaceID uint64, groupID uint32) // Must be called when a subspace group is deleted + AfterSubspaceSectionSaved(ctx sdk.Context, subspaceID uint64, sectionID uint32) // Must be called when a subspace section is saved + AfterSubspaceSectionDeleted(ctx sdk.Context, subspaceID uint64, sectionID uint32) // Must be called when a subspace section is deleted - AfterUserPermissionSet(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permissions Permission) // Must be called when a permission is set for a user - AfterUserPermissionRemoved(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress) // Must be called when a permission is removed for a user + AfterSubspaceGroupSaved(ctx sdk.Context, subspaceID uint64, groupID uint32) // Must be called when a subspace group is created + AfterSubspaceGroupMemberAdded(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) // Must be called when a user is added to a group + AfterSubspaceGroupMemberRemoved(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) // Must be called when a user is removed from a group + AfterSubspaceGroupDeleted(ctx sdk.Context, subspaceID uint64, groupID uint32) // Must be called when a subspace group is deleted + + AfterUserPermissionSet(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permissions Permission) // Must be called when a permission is set for a user + AfterUserPermissionRemoved(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) // Must be called when a permission is removed for a user } // -------------------------------------------------------------------------------------------------------------------- @@ -49,6 +52,20 @@ func (h MultiSubspacesHooks) AfterSubspaceDeleted(ctx sdk.Context, subspaceID ui } } +// AfterSubspaceSectionSaved implements SubspacesHooks +func (h MultiSubspacesHooks) AfterSubspaceSectionSaved(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + for _, hook := range h { + hook.AfterSubspaceSectionSaved(ctx, subspaceID, sectionID) + } +} + +// AfterSubspaceSectionDeleted implements SubspacesHooks +func (h MultiSubspacesHooks) AfterSubspaceSectionDeleted(ctx sdk.Context, subspaceID uint64, sectionID uint32) { + for _, hook := range h { + hook.AfterSubspaceSectionDeleted(ctx, subspaceID, sectionID) + } +} + // AfterSubspaceGroupSaved implements SubspacesHook func (h MultiSubspacesHooks) AfterSubspaceGroupSaved(ctx sdk.Context, subspaceID uint64, groupID uint32) { for _, hook := range h { @@ -57,14 +74,14 @@ func (h MultiSubspacesHooks) AfterSubspaceGroupSaved(ctx sdk.Context, subspaceID } // AfterSubspaceGroupMemberAdded implements SubspacesHook -func (h MultiSubspacesHooks) AfterSubspaceGroupMemberAdded(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) { +func (h MultiSubspacesHooks) AfterSubspaceGroupMemberAdded(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) { for _, hook := range h { hook.AfterSubspaceGroupMemberAdded(ctx, subspaceID, groupID, user) } } // AfterSubspaceGroupMemberRemoved implements SubspacesHook -func (h MultiSubspacesHooks) AfterSubspaceGroupMemberRemoved(ctx sdk.Context, subspaceID uint64, groupID uint32, user sdk.AccAddress) { +func (h MultiSubspacesHooks) AfterSubspaceGroupMemberRemoved(ctx sdk.Context, subspaceID uint64, groupID uint32, user string) { for _, hook := range h { hook.AfterSubspaceGroupMemberRemoved(ctx, subspaceID, groupID, user) } @@ -78,15 +95,15 @@ func (h MultiSubspacesHooks) AfterSubspaceGroupDeleted(ctx sdk.Context, subspace } // AfterUserPermissionSet implements SubspacesHook -func (h MultiSubspacesHooks) AfterUserPermissionSet(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress, permissions Permission) { +func (h MultiSubspacesHooks) AfterUserPermissionSet(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string, permissions Permission) { for _, hook := range h { - hook.AfterUserPermissionSet(ctx, subspaceID, user, permissions) + hook.AfterUserPermissionSet(ctx, subspaceID, sectionID, user, permissions) } } // AfterUserPermissionRemoved implements SubspacesHook -func (h MultiSubspacesHooks) AfterUserPermissionRemoved(ctx sdk.Context, subspaceID uint64, user sdk.AccAddress) { +func (h MultiSubspacesHooks) AfterUserPermissionRemoved(ctx sdk.Context, subspaceID uint64, sectionID uint32, user string) { for _, hook := range h { - hook.AfterUserPermissionRemoved(ctx, subspaceID, user) + hook.AfterUserPermissionRemoved(ctx, subspaceID, sectionID, user) } } diff --git a/x/subspaces/types/keys.go b/x/subspaces/types/keys.go index 971bf79223..9d0ae88345 100644 --- a/x/subspaces/types/keys.go +++ b/x/subspaces/types/keys.go @@ -2,30 +2,33 @@ package types import ( "encoding/binary" - - sdk "github.com/cosmos/cosmos-sdk/types" + "fmt" ) // DONTCOVER const ( - ModuleName = "subspaces" - RouterKey = ModuleName - StoreKey = ModuleName + ModuleName = "subspaces" + RouterKey = ModuleName + StoreKey = ModuleName + QuerierRoute = ModuleName ActionCreateSubspace = "create_subspace" ActionEditSubspace = "edit_subspace" ActionDeleteSubspace = "delete_subspace" + ActionCreateSection = "create_section" + ActionEditSection = "edit_section" + ActionMoveSection = "move_section" + ActionDeleteSection = "delete_section" ActionCreateUserGroup = "create_user_group" ActionEditUserGroup = "edit_user_group" + ActionMoveUserGroup = "move_user_group" ActionSetUserGroupPermissions = "set_user_group_permissions" ActionDeleteUserGroup = "delete_user_group" ActionAddUserToUserGroup = "add_user_to_user_group" ActionRemoveUserFromUserGroup = "remove_user_from_user_group" ActionSetUserPermissions = "set_user_permissions" - QuerierRoute = ModuleName - DoNotModify = "[do-not-modify]" ) @@ -34,8 +37,10 @@ var ( SubspacePrefix = []byte{0x01} GroupIDPrefix = []byte{0x02} GroupsPrefix = []byte{0x03} - GroupMembersStorePrefix = []byte{0x04} + GroupsMembersPrefix = []byte{0x04} UserPermissionsStorePrefix = []byte{0x05} + SectionIDPrefix = []byte{0x06} + SectionsPrefix = []byte{0x07} ) // GetSubspaceIDBytes returns the byte representation of the subspaceID @@ -50,28 +55,50 @@ func GetSubspaceIDFromBytes(bz []byte) (subspaceID uint64) { return binary.BigEndian.Uint64(bz) } -// SubspaceKey returns the key for a specific subspace -func SubspaceKey(subspaceID uint64) []byte { +// SubspaceStoreKey returns the key for a specific subspace +func SubspaceStoreKey(subspaceID uint64) []byte { return append(SubspacePrefix, GetSubspaceIDBytes(subspaceID)...) } -// PermissionsStoreKey returns the key used to store the entire ACL for a given subspace -func PermissionsStoreKey(subspaceID uint64) []byte { - return append(UserPermissionsStorePrefix, GetSubspaceIDBytes(subspaceID)...) +// -------------------------------------------------------------------------------------------------------------------- + +// GetSectionIDBytes returns the byte representation of the sectionID +func GetSectionIDBytes(sectionID uint32) (sectionIDBz []byte) { + sectionIDBz = make([]byte, 4) + binary.BigEndian.PutUint32(sectionIDBz, sectionID) + return +} + +// GetSectionIDFromBytes returns sectionID in uint32 format from a byte array +func GetSectionIDFromBytes(bz []byte) (sectionID uint32) { + return binary.BigEndian.Uint32(bz) } -func GetAddressBytes(user sdk.AccAddress) []byte { - return user +// NextSectionIDStoreKey returns the key used to store the next section id for the given subspace +func NextSectionIDStoreKey(subspaceID uint64) []byte { + return append(SectionIDPrefix, GetSubspaceIDBytes(subspaceID)...) } -func GetAddressFromBytes(bz []byte) sdk.AccAddress { - return bz +// SubspaceSectionsPrefix returns the prefix used to store all the sections for the given subspace +func SubspaceSectionsPrefix(subspaceID uint64) []byte { + return append(SectionsPrefix, GetSubspaceIDBytes(subspaceID)...) +} + +// SectionStoreKey returns the key used to store the given section +func SectionStoreKey(subspaceID uint64, sectionID uint32) []byte { + return append(SubspaceSectionsPrefix(subspaceID), GetSectionIDBytes(sectionID)...) } // -------------------------------------------------------------------------------------------------------------------- -// GroupIDStoreKey returns the store key that is used to store the group id to be used next for the given subspace -func GroupIDStoreKey(subspaceID uint64) []byte { +var ( + lenGroupMemberPrefix = len(GroupsMembersPrefix) + lenSubspaceID = len(GetSubspaceIDBytes(1)) + lenGroupID = len(GetGroupIDBytes(1)) +) + +// NextGroupIDStoreKey returns the store key that is used to store the group id to be used next for the given subspace +func NextGroupIDStoreKey(subspaceID uint64) []byte { return append(GroupIDPrefix, GetSubspaceIDBytes(subspaceID)...) } @@ -87,30 +114,94 @@ func GetGroupIDFromBytes(bz []byte) (subspaceID uint32) { return binary.BigEndian.Uint32(bz) } -// GroupsStoreKey returns the key used to store all the groups of a given subspace -func GroupsStoreKey(subspaceID uint64) []byte { +// SubspaceGroupsPrefix returns the store prefix used to store all the groups of a given subspace +func SubspaceGroupsPrefix(subspaceID uint64) []byte { return append(GroupsPrefix, GetSubspaceIDBytes(subspaceID)...) } -// GroupStoreKey returns the key used to store a group for a subspace -func GroupStoreKey(subspaceID uint64, groupID uint32) []byte { - return append(GroupsStoreKey(subspaceID), GetGroupIDBytes(groupID)...) +// SectionGroupsPrefix returns the prefix used to store all the groups for the given section +func SectionGroupsPrefix(subspaceID uint64, sectionID uint32) []byte { + return append(SubspaceGroupsPrefix(subspaceID), GetSectionIDBytes(sectionID)...) +} + +// GroupStoreKey returns the key used to store the group having the given id inside the specified section +func GroupStoreKey(subspaceID uint64, sectionID uint32, groupID uint32) []byte { + return append(SectionGroupsPrefix(subspaceID, sectionID), GetGroupIDBytes(groupID)...) } -// GroupMembersStoreKey returns the key used to store all the members of the given group inside the given subspace -func GroupMembersStoreKey(subspaceID uint64, groupID uint32) []byte { - return append(append(GroupMembersStorePrefix, GetSubspaceIDBytes(subspaceID)...), GetGroupIDBytes(groupID)...) +// SubspaceGroupsMembersPrefix returns the prefix used to store groups members for the subspace having the given id +func SubspaceGroupsMembersPrefix(subspaceID uint64) []byte { + return append(GroupsMembersPrefix, GetSubspaceIDBytes(subspaceID)...) +} + +// GroupMembersPrefix returns the key used to store all the members of the given group inside the given subspace +func GroupMembersPrefix(subspaceID uint64, groupID uint32) []byte { + return append(SubspaceGroupsMembersPrefix(subspaceID), GetGroupIDBytes(groupID)...) } // GroupMemberStoreKey returns the key used to store the membership of the given user to the // specified group inside the provided subspace -func GroupMemberStoreKey(subspaceID uint64, groupID uint32, user sdk.AccAddress) []byte { - return append(GroupMembersStoreKey(subspaceID, groupID), GetAddressBytes(user)...) +func GroupMemberStoreKey(subspaceID uint64, groupID uint32, user string) []byte { + return append(GroupMembersPrefix(subspaceID, groupID), GetAddressBytes(user)...) +} + +// SplitGroupMemberStoreKey splits the given group member store key into the +// associated subspace id, group id and user address +func SplitGroupMemberStoreKey(key []byte) (subspaceID uint64, groupID uint32, user string) { + expectedMinLength := lenGroupMemberPrefix + lenSubspaceID + lenGroupID + if len(key) < expectedMinLength { + panic(fmt.Errorf("invalid key length; expected min %d got %d", expectedMinLength, len(key))) + } + + key = key[lenGroupMemberPrefix:] // Trim the prefix + subspaceID = GetSubspaceIDFromBytes(key[:lenSubspaceID]) + groupID = GetGroupIDFromBytes(key[+lenSubspaceID : lenSubspaceID+lenGroupID]) + user = GetAddressFromBytes(key[lenSubspaceID+lenGroupID:]) + return subspaceID, groupID, user } // -------------------------------------------------------------------------------------------------------------------- +var ( + lenUserPermissionPrefix = len(UserPermissionsStorePrefix) + lenSectionID = len(GetSectionIDBytes(1)) +) + +// GetAddressBytes returns the given user address as a byte array +func GetAddressBytes(user string) []byte { + return []byte(user) +} + +// GetAddressFromBytes returns the sdk.AccAddress representation of the given user address +func GetAddressFromBytes(bz []byte) string { + return string(bz) +} + +// SubspacePermissionsPrefix returns the prefix used to store user permissions for the given subspace +func SubspacePermissionsPrefix(subspaceID uint64) []byte { + return append(UserPermissionsStorePrefix, GetSubspaceIDBytes(subspaceID)...) +} + +// SectionPermissionsPrefix returns the prefix used to store the permissions for the given section +func SectionPermissionsPrefix(subspaceID uint64, sectionID uint32) []byte { + return append(SubspacePermissionsPrefix(subspaceID), GetSectionIDBytes(sectionID)...) +} + // UserPermissionStoreKey returns the key used to store the permission for the given user inside the given subspace -func UserPermissionStoreKey(subspaceID uint64, user sdk.AccAddress) []byte { - return append(PermissionsStoreKey(subspaceID), GetAddressBytes(user)...) +func UserPermissionStoreKey(subspaceID uint64, sectionID uint32, user string) []byte { + return append(SectionPermissionsPrefix(subspaceID, sectionID), GetAddressBytes(user)...) +} + +// SplitUserAddressPermissionKey splits a UserPermissionStoreKey into the subspace id, section id and user address +func SplitUserAddressPermissionKey(key []byte) (subspaceID uint64, sectionID uint32, user string) { + expectedMinLength := lenUserPermissionPrefix + lenSubspaceID + lenSectionID + if len(key) < expectedMinLength { + panic(fmt.Errorf("invalid key length; expected min %d but got %d", expectedMinLength, len(key))) + } + + key = key[lenUserPermissionPrefix:] // Remove the prefix + subspaceID = GetSubspaceIDFromBytes(key[:lenSubspaceID]) + sectionID = GetSectionIDFromBytes(key[lenSubspaceID : lenSubspaceID+lenSectionID]) + user = GetAddressFromBytes(key[lenSubspaceID+lenSectionID:]) + return subspaceID, sectionID, user } diff --git a/x/subspaces/types/keys_test.go b/x/subspaces/types/keys_test.go new file mode 100644 index 0000000000..347d19e95e --- /dev/null +++ b/x/subspaces/types/keys_test.go @@ -0,0 +1,87 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/desmos-labs/desmos/v3/x/subspaces/types" +) + +func TestSplitGroupMemberStoreKey(t *testing.T) { + testCases := []struct { + name string + key []byte + shouldErr bool + expSubspaceID uint64 + expGroupID uint32 + expUserAddr string + }{ + { + name: "invalid key returns error", + key: []byte{0x01}, + shouldErr: true, + }, + { + name: "valid key is split accordingly", + key: types.GroupMemberStoreKey(1, 2, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5"), + shouldErr: false, + expSubspaceID: 1, + expGroupID: 2, + expUserAddr: "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + if tc.shouldErr { + require.Panics(t, func() { types.SplitGroupMemberStoreKey(tc.key) }) + } else { + subspaceID, groupID, user := types.SplitGroupMemberStoreKey(tc.key) + require.Equal(t, tc.expSubspaceID, subspaceID) + require.Equal(t, tc.expGroupID, groupID) + require.Equal(t, tc.expUserAddr, user) + } + }) + } + +} + +func TestSplitUserAddressPermissionKey(t *testing.T) { + testCases := []struct { + name string + key []byte + shouldErr bool + expSubspaceID uint64 + expSectionID uint32 + expUser string + }{ + { + name: "invalid key returns error", + key: []byte{0x01}, + shouldErr: true, + }, + { + name: "valid key returns proper data", + key: types.UserPermissionStoreKey(1, 2, "cosmos1vlknheepy5454pw4j6x53yeg57l7ec39rf8ffp"), + expSubspaceID: 1, + expSectionID: 2, + expUser: "cosmos1vlknheepy5454pw4j6x53yeg57l7ec39rf8ffp", + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + if tc.shouldErr { + require.Panics(t, func() { types.SplitUserAddressPermissionKey(tc.key) }) + } else { + subspaceID, sectionID, user := types.SplitUserAddressPermissionKey(tc.key) + require.Equal(t, tc.expSubspaceID, subspaceID) + require.Equal(t, tc.expSectionID, sectionID) + require.Equal(t, tc.expUser, user) + } + }) + } +} diff --git a/x/subspaces/types/models.go b/x/subspaces/types/models.go index 36812f678a..4def7501e1 100644 --- a/x/subspaces/types/models.go +++ b/x/subspaces/types/models.go @@ -35,7 +35,7 @@ func NewSubspace(subspaceID uint64, name, description, treasury, owner, creator } } -// Validate will perform some checks to ensure the subspace validity +// Validate implements fmt.Validator func (sub Subspace) Validate() error { if sub.ID == 0 { return fmt.Errorf("invalid subspace id: %d", sub.ID) @@ -69,7 +69,36 @@ func (sub Subspace) Validate() error { return nil } -// -------------------------------------------------------------------------------------------------------------------- +// Update updates the fields of a given subspace without validating it. +// Before storing the updated subspace, a validation with Validate() should +// be performed. +func (sub Subspace) Update(update SubspaceUpdate) Subspace { + if update.Name == DoNotModify { + update.Name = sub.Name + } + + if update.Description == DoNotModify { + update.Description = sub.Description + } + + if update.Treasury == DoNotModify { + update.Treasury = sub.Treasury + } + + if update.Owner == DoNotModify { + update.Owner = sub.Owner + } + + return NewSubspace( + sub.ID, + update.Name, + update.Description, + update.Treasury, + update.Owner, + sub.Creator, + sub.CreationTime, + ) +} // SubspaceUpdate contains all the data that can be updated about a subspace. // When performing an update, if a field should not be edited then it must be set to types.DoNotModify @@ -81,8 +110,8 @@ type SubspaceUpdate struct { } // NewSubspaceUpdate builds a new SubspaceUpdate instance containing the given data -func NewSubspaceUpdate(name, description, treasury, owner string) *SubspaceUpdate { - return &SubspaceUpdate{ +func NewSubspaceUpdate(name, description, treasury, owner string) SubspaceUpdate { + return SubspaceUpdate{ Name: name, Description: description, Treasury: treasury, @@ -90,37 +119,101 @@ func NewSubspaceUpdate(name, description, treasury, owner string) *SubspaceUpdat } } -// Update updates the fields of a given subspace without validating it. -// Before storing the updated subspace, a validation with Validate() should -// be performed. -func (sub Subspace) Update(update *SubspaceUpdate) Subspace { - if update.Name == DoNotModify { - update.Name = sub.Name +// -------------------------------------------------------------------------------------------------------------------- + +const ( + // RootSectionID represents the id of the root section of each subspace + RootSectionID = 0 +) + +// ParseSectionID parses the given value as a section id, returning an error if it's invalid +func ParseSectionID(value string) (uint32, error) { + if value == "" { + return 0, nil } - if update.Description == DoNotModify { - update.Description = sub.Description + sectionID, err := strconv.ParseUint(value, 10, 32) + if err != nil { + return 0, fmt.Errorf("invalid group id: %s", err) } + return uint32(sectionID), nil +} - if update.Treasury == DoNotModify { - update.Treasury = sub.Treasury +// NewSection returns a new Section instance +func NewSection(subspaceID uint64, id uint32, parentID uint32, name string, description string) Section { + return Section{ + SubspaceID: subspaceID, + ID: id, + ParentID: parentID, + Name: name, + Description: description, } +} - if update.Owner == DoNotModify { - update.Owner = sub.Owner +// DefaultSection returns the default section for the given subspace +func DefaultSection(subspaceID uint64) Section { + return NewSection( + subspaceID, + RootSectionID, + RootSectionID, + "Default section", + "This is the default subspace section", + ) +} + +// Validate implements fmt.Validator +func (s Section) Validate() error { + if s.SubspaceID == 0 { + return fmt.Errorf("invalid subspace id: %d", s.SubspaceID) } - return NewSubspace( - sub.ID, + if s.ID != RootSectionID && s.ParentID == s.ID { + return fmt.Errorf("invalid parent id: %d", s.ParentID) + } + + if strings.TrimSpace(s.Name) == "" { + return fmt.Errorf("invalid section name: %s", s.Name) + } + + return nil +} + +// Update updates the fields of a given section without validating it. +// Before storing the updated section, a validation with Validate() should +// be performed. +func (s Section) Update(update SectionUpdate) Section { + if update.Name == DoNotModify { + update.Name = s.Name + } + + if update.Description == DoNotModify { + update.Description = s.Description + } + + return NewSection( + s.SubspaceID, + s.ID, + s.ParentID, update.Name, update.Description, - update.Treasury, - update.Owner, - sub.Creator, - sub.CreationTime, ) } +// SectionUpdate contains all the data that can be updated about a section. +// When performing an update, if a field should not be edited then it must be set to types.DoNotModify +type SectionUpdate struct { + Name string + Description string +} + +// NewSectionUpdate returns a new SectionUpdate instance +func NewSectionUpdate(name string, description string) SectionUpdate { + return SectionUpdate{ + Name: name, + Description: description, + } +} + // -------------------------------------------------------------------------------------------------------------------- // ParseGroupID parses the given value as a group id, returning an error if it's invalid @@ -137,9 +230,10 @@ func ParseGroupID(value string) (uint32, error) { } // NewUserGroup returns a new UserGroup instance -func NewUserGroup(subspaceID uint64, id uint32, name, description string, permissions Permission) UserGroup { +func NewUserGroup(subspaceID uint64, sectionID uint32, id uint32, name, description string, permissions Permission) UserGroup { return UserGroup{ SubspaceID: subspaceID, + SectionID: sectionID, ID: id, Name: name, Description: description, @@ -152,13 +246,14 @@ func DefaultUserGroup(subspaceID uint64) UserGroup { return NewUserGroup( subspaceID, 0, + 0, "Default", "This is a default user group which all users are automatically part of", PermissionNothing, ) } -// Validate returns an error if something is wrong within the group data +// Validate implements fmt.Validator func (group UserGroup) Validate() error { if group.SubspaceID == 0 { return fmt.Errorf("invalid subspace id: %d", group.SubspaceID) @@ -171,27 +266,10 @@ func (group UserGroup) Validate() error { return nil } -// -------------------------------------------------------------------------------------------------------------------- - -// GroupUpdate contains all the data that can be updated about a group. -// When performing an update, if a field should not be edited then it must be set to types.DoNotModify -type GroupUpdate struct { - Name string - Description string -} - -// NewGroupUpdate builds a new SubspaceUpdate instance containing the given data -func NewGroupUpdate(name, description string) *GroupUpdate { - return &GroupUpdate{ - Name: name, - Description: description, - } -} - // Update updates the fields of a given group without validating it. // Before storing the updated group, a validation with Validate() should // be performed. -func (group UserGroup) Update(update *GroupUpdate) UserGroup { +func (group UserGroup) Update(update GroupUpdate) UserGroup { if update.Name == DoNotModify { update.Name = group.Name } @@ -202,6 +280,7 @@ func (group UserGroup) Update(update *GroupUpdate) UserGroup { return NewUserGroup( group.SubspaceID, + group.SectionID, group.ID, update.Name, update.Description, @@ -209,28 +288,17 @@ func (group UserGroup) Update(update *GroupUpdate) UserGroup { ) } -// -------------------------------------------------------------------------------------------------------------------- +// GroupUpdate contains all the data that can be updated about a group. +// When performing an update, if a field should not be edited then it must be set to types.DoNotModify +type GroupUpdate struct { + Name string + Description string +} -// NewPermissionDetailUser returns a new PermissionDetail for the user with the given address and permission value -func NewPermissionDetailUser(user string, permission Permission) PermissionDetail { - return PermissionDetail{ - Sum: &PermissionDetail_User_{ - User: &PermissionDetail_User{ - User: user, - Permission: permission, - }, - }, - } -} - -// NewPermissionDetailGroup returns a new PermissionDetail for the user with the given id and permission value -func NewPermissionDetailGroup(groupID uint32, permission Permission) PermissionDetail { - return PermissionDetail{ - Sum: &PermissionDetail_Group_{ - Group: &PermissionDetail_Group{ - GroupID: groupID, - Permission: permission, - }, - }, +// NewGroupUpdate builds a new SubspaceUpdate instance containing the given data +func NewGroupUpdate(name, description string) GroupUpdate { + return GroupUpdate{ + Name: name, + Description: description, } } diff --git a/x/subspaces/types/models.pb.go b/x/subspaces/types/models.pb.go index 187eff80d1..257ca17874 100644 --- a/x/subspaces/types/models.pb.go +++ b/x/subspaces/types/models.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: desmos/subspaces/v1/models.proto +// source: desmos/subspaces/v2/models.proto package types @@ -50,7 +50,7 @@ func (m *Subspace) Reset() { *m = Subspace{} } func (m *Subspace) String() string { return proto.CompactTextString(m) } func (*Subspace) ProtoMessage() {} func (*Subspace) Descriptor() ([]byte, []int) { - return fileDescriptor_58f218b6c9069791, []int{0} + return fileDescriptor_a588429ec794f86a, []int{0} } func (m *Subspace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -128,32 +128,32 @@ func (m *Subspace) GetCreationTime() time.Time { return time.Time{} } -// UserGroup represents a group of users -type UserGroup struct { - // ID of the subspace inside which this group exists +// Section contains the data of a single subspace section +type Section struct { + // Id of the subspace inside which the section exists SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - // Unique id that identifies the group + // Unique id of the section within the subspace ID uint32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` - // Human-readable name of the user group - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` - // Optional description of this group - Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - // Permissions that will be granted to all the users part of this group - Permissions uint32 `protobuf:"varint,5,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` + // (optional) Id of the parent section + ParentID uint32 `protobuf:"varint,3,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty" yaml:"parent_id"` + // Name of the section within the subspace + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // (optional) Description of the section + Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` } -func (m *UserGroup) Reset() { *m = UserGroup{} } -func (m *UserGroup) String() string { return proto.CompactTextString(m) } -func (*UserGroup) ProtoMessage() {} -func (*UserGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_58f218b6c9069791, []int{1} +func (m *Section) Reset() { *m = Section{} } +func (m *Section) String() string { return proto.CompactTextString(m) } +func (*Section) ProtoMessage() {} +func (*Section) Descriptor() ([]byte, []int) { + return fileDescriptor_a588429ec794f86a, []int{1} } -func (m *UserGroup) XXX_Unmarshal(b []byte) error { +func (m *Section) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *UserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Section) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_UserGroup.Marshal(b, m, deterministic) + return xxx_messageInfo_Section.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -163,76 +163,81 @@ func (m *UserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *UserGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserGroup.Merge(m, src) +func (m *Section) XXX_Merge(src proto.Message) { + xxx_messageInfo_Section.Merge(m, src) } -func (m *UserGroup) XXX_Size() int { +func (m *Section) XXX_Size() int { return m.Size() } -func (m *UserGroup) XXX_DiscardUnknown() { - xxx_messageInfo_UserGroup.DiscardUnknown(m) +func (m *Section) XXX_DiscardUnknown() { + xxx_messageInfo_Section.DiscardUnknown(m) } -var xxx_messageInfo_UserGroup proto.InternalMessageInfo +var xxx_messageInfo_Section proto.InternalMessageInfo -func (m *UserGroup) GetSubspaceID() uint64 { +func (m *Section) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *UserGroup) GetID() uint32 { +func (m *Section) GetID() uint32 { if m != nil { return m.ID } return 0 } -func (m *UserGroup) GetName() string { +func (m *Section) GetParentID() uint32 { if m != nil { - return m.Name + return m.ParentID } - return "" + return 0 } -func (m *UserGroup) GetDescription() string { +func (m *Section) GetName() string { if m != nil { - return m.Description + return m.Name } return "" } -func (m *UserGroup) GetPermissions() uint32 { +func (m *Section) GetDescription() string { if m != nil { - return m.Permissions + return m.Description } - return 0 + return "" } -// PermissionDetail contains the details data of a permission -type PermissionDetail struct { - // sum is the oneof that specifies whether this represents a user or - // group permission detail - // - // Types that are valid to be assigned to Sum: - // *PermissionDetail_User_ - // *PermissionDetail_Group_ - Sum isPermissionDetail_Sum `protobuf_oneof:"sum"` +// UserGroup represents a group of users +type UserGroup struct { + // ID of the subspace inside which this group exists + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // (optional) Id of the section inside which this group is valid + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + // Unique id that identifies the group + ID uint32 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + // Human-readable name of the user group + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // Optional description of this group + Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // Permissions that will be granted to all the users part of this group + Permissions uint32 `protobuf:"varint,6,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` } -func (m *PermissionDetail) Reset() { *m = PermissionDetail{} } -func (m *PermissionDetail) String() string { return proto.CompactTextString(m) } -func (*PermissionDetail) ProtoMessage() {} -func (*PermissionDetail) Descriptor() ([]byte, []int) { - return fileDescriptor_58f218b6c9069791, []int{2} +func (m *UserGroup) Reset() { *m = UserGroup{} } +func (m *UserGroup) String() string { return proto.CompactTextString(m) } +func (*UserGroup) ProtoMessage() {} +func (*UserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_a588429ec794f86a, []int{2} } -func (m *PermissionDetail) XXX_Unmarshal(b []byte) error { +func (m *UserGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PermissionDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *UserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PermissionDetail.Marshal(b, m, deterministic) + return xxx_messageInfo_UserGroup.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -242,198 +247,106 @@ func (m *PermissionDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *PermissionDetail) XXX_Merge(src proto.Message) { - xxx_messageInfo_PermissionDetail.Merge(m, src) +func (m *UserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserGroup.Merge(m, src) } -func (m *PermissionDetail) XXX_Size() int { +func (m *UserGroup) XXX_Size() int { return m.Size() } -func (m *PermissionDetail) XXX_DiscardUnknown() { - xxx_messageInfo_PermissionDetail.DiscardUnknown(m) -} - -var xxx_messageInfo_PermissionDetail proto.InternalMessageInfo - -type isPermissionDetail_Sum interface { - isPermissionDetail_Sum() - Equal(interface{}) bool - MarshalTo([]byte) (int, error) - Size() int -} - -type PermissionDetail_User_ struct { - User *PermissionDetail_User `protobuf:"bytes,1,opt,name=user,proto3,oneof" json:"user,omitempty"` -} -type PermissionDetail_Group_ struct { - Group *PermissionDetail_Group `protobuf:"bytes,2,opt,name=group,proto3,oneof" json:"group,omitempty"` +func (m *UserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_UserGroup.DiscardUnknown(m) } -func (*PermissionDetail_User_) isPermissionDetail_Sum() {} -func (*PermissionDetail_Group_) isPermissionDetail_Sum() {} +var xxx_messageInfo_UserGroup proto.InternalMessageInfo -func (m *PermissionDetail) GetSum() isPermissionDetail_Sum { +func (m *UserGroup) GetSubspaceID() uint64 { if m != nil { - return m.Sum + return m.SubspaceID } - return nil + return 0 } -func (m *PermissionDetail) GetUser() *PermissionDetail_User { - if x, ok := m.GetSum().(*PermissionDetail_User_); ok { - return x.User +func (m *UserGroup) GetSectionID() uint32 { + if m != nil { + return m.SectionID } - return nil + return 0 } -func (m *PermissionDetail) GetGroup() *PermissionDetail_Group { - if x, ok := m.GetSum().(*PermissionDetail_Group_); ok { - return x.Group +func (m *UserGroup) GetID() uint32 { + if m != nil { + return m.ID } - return nil + return 0 } -// XXX_OneofWrappers is for the internal use of the proto package. -func (*PermissionDetail) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*PermissionDetail_User_)(nil), - (*PermissionDetail_Group_)(nil), +func (m *UserGroup) GetName() string { + if m != nil { + return m.Name } + return "" } -// User is a permission that has been set to a specific user -type PermissionDetail_User struct { - // User for which the permission was set - User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` - // Permission set to the user - Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty" yaml:"permission"` -} - -func (m *PermissionDetail_User) Reset() { *m = PermissionDetail_User{} } -func (m *PermissionDetail_User) String() string { return proto.CompactTextString(m) } -func (*PermissionDetail_User) ProtoMessage() {} -func (*PermissionDetail_User) Descriptor() ([]byte, []int) { - return fileDescriptor_58f218b6c9069791, []int{2, 0} -} -func (m *PermissionDetail_User) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PermissionDetail_User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PermissionDetail_User.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *UserGroup) GetDescription() string { + if m != nil { + return m.Description } -} -func (m *PermissionDetail_User) XXX_Merge(src proto.Message) { - xxx_messageInfo_PermissionDetail_User.Merge(m, src) -} -func (m *PermissionDetail_User) XXX_Size() int { - return m.Size() -} -func (m *PermissionDetail_User) XXX_DiscardUnknown() { - xxx_messageInfo_PermissionDetail_User.DiscardUnknown(m) -} - -var xxx_messageInfo_PermissionDetail_User proto.InternalMessageInfo - -// Group is a permission that has been set to a user group -type PermissionDetail_Group struct { - // Unique id of the group - GroupID uint32 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` - // Permission set to the group - Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty"` + return "" } -func (m *PermissionDetail_Group) Reset() { *m = PermissionDetail_Group{} } -func (m *PermissionDetail_Group) String() string { return proto.CompactTextString(m) } -func (*PermissionDetail_Group) ProtoMessage() {} -func (*PermissionDetail_Group) Descriptor() ([]byte, []int) { - return fileDescriptor_58f218b6c9069791, []int{2, 1} -} -func (m *PermissionDetail_Group) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PermissionDetail_Group) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PermissionDetail_Group.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *UserGroup) GetPermissions() uint32 { + if m != nil { + return m.Permissions } -} -func (m *PermissionDetail_Group) XXX_Merge(src proto.Message) { - xxx_messageInfo_PermissionDetail_Group.Merge(m, src) -} -func (m *PermissionDetail_Group) XXX_Size() int { - return m.Size() -} -func (m *PermissionDetail_Group) XXX_DiscardUnknown() { - xxx_messageInfo_PermissionDetail_Group.DiscardUnknown(m) + return 0 } -var xxx_messageInfo_PermissionDetail_Group proto.InternalMessageInfo - func init() { - proto.RegisterType((*Subspace)(nil), "desmos.subspaces.v1.Subspace") - proto.RegisterType((*UserGroup)(nil), "desmos.subspaces.v1.UserGroup") - proto.RegisterType((*PermissionDetail)(nil), "desmos.subspaces.v1.PermissionDetail") - proto.RegisterType((*PermissionDetail_User)(nil), "desmos.subspaces.v1.PermissionDetail.User") - proto.RegisterType((*PermissionDetail_Group)(nil), "desmos.subspaces.v1.PermissionDetail.Group") -} - -func init() { proto.RegisterFile("desmos/subspaces/v1/models.proto", fileDescriptor_58f218b6c9069791) } - -var fileDescriptor_58f218b6c9069791 = []byte{ - // 635 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xbf, 0x6f, 0xd3, 0x40, - 0x1c, 0xc5, 0xed, 0xfc, 0x68, 0xd2, 0x73, 0x43, 0xcb, 0xb5, 0x20, 0x2b, 0x83, 0x2f, 0xba, 0x22, - 0x54, 0xf1, 0xc3, 0x56, 0x53, 0x21, 0x95, 0x4e, 0x28, 0x14, 0xd1, 0x4a, 0x0c, 0xe8, 0x80, 0x85, - 0xa5, 0x72, 0xe2, 0x23, 0x58, 0xb2, 0x73, 0x96, 0xcf, 0x2e, 0x74, 0x65, 0x40, 0x8c, 0x1d, 0x11, - 0x53, 0xff, 0x9c, 0x8e, 0x1d, 0x99, 0x0e, 0xe4, 0x2e, 0xcc, 0xfe, 0x0b, 0x90, 0xef, 0xec, 0xd4, - 0x94, 0x4a, 0x94, 0xed, 0xeb, 0x7b, 0x9f, 0x77, 0xe7, 0xbc, 0xe7, 0x0b, 0x18, 0x78, 0x94, 0x87, - 0x8c, 0x3b, 0x3c, 0x1d, 0xf3, 0xc8, 0x9d, 0x50, 0xee, 0x1c, 0x6e, 0x3a, 0x21, 0xf3, 0x68, 0xc0, - 0xed, 0x28, 0x66, 0x09, 0x83, 0xab, 0x8a, 0xb0, 0xe7, 0x84, 0x7d, 0xb8, 0xd9, 0x5f, 0x9b, 0xb2, - 0x29, 0x93, 0xba, 0x53, 0x4c, 0x0a, 0xed, 0xa3, 0x29, 0x63, 0xd3, 0x80, 0x3a, 0xf2, 0x69, 0x9c, - 0xbe, 0x73, 0x12, 0x3f, 0xa4, 0x3c, 0x71, 0xc3, 0x48, 0x01, 0xf8, 0x53, 0x13, 0x74, 0x5f, 0x95, - 0xfb, 0xc0, 0x75, 0xd0, 0xf0, 0x3d, 0x53, 0x1f, 0xe8, 0x1b, 0xad, 0xd1, 0x6a, 0x26, 0x50, 0x63, - 0x7f, 0x37, 0x17, 0x68, 0xf1, 0xc8, 0x0d, 0x83, 0x1d, 0xec, 0x7b, 0x98, 0x34, 0x7c, 0x0f, 0xae, - 0x83, 0xd6, 0xcc, 0x0d, 0xa9, 0xd9, 0x18, 0xe8, 0x1b, 0x8b, 0xa3, 0xe5, 0x5c, 0x20, 0x43, 0x01, - 0xc5, 0x2a, 0x26, 0x52, 0x84, 0xdb, 0xc0, 0xf0, 0x28, 0x9f, 0xc4, 0x7e, 0x94, 0xf8, 0x6c, 0x66, - 0x36, 0x25, 0x7b, 0x3b, 0x17, 0x08, 0x2a, 0xb6, 0x26, 0x62, 0x52, 0x47, 0xa1, 0x03, 0xba, 0x49, - 0x4c, 0x5d, 0x9e, 0xc6, 0x47, 0x66, 0x4b, 0xda, 0x56, 0x73, 0x81, 0x96, 0x95, 0xad, 0x52, 0x30, - 0x99, 0x43, 0xf0, 0x2e, 0x68, 0xb3, 0x0f, 0x33, 0x1a, 0x9b, 0x6d, 0x49, 0xaf, 0xe4, 0x02, 0x2d, - 0x29, 0x5a, 0x2e, 0x63, 0xa2, 0x64, 0xf8, 0x00, 0x74, 0x26, 0x31, 0x75, 0x13, 0x16, 0x9b, 0x0b, - 0x92, 0x84, 0xb9, 0x40, 0x37, 0x14, 0x59, 0x0a, 0x98, 0x54, 0x08, 0x74, 0x41, 0x4f, 0x8e, 0x3e, - 0x9b, 0x1d, 0x14, 0x99, 0x99, 0x9d, 0x81, 0xbe, 0x61, 0x0c, 0xfb, 0xb6, 0x0a, 0xd4, 0xae, 0x02, - 0xb5, 0x5f, 0x57, 0x81, 0x8e, 0x06, 0xa7, 0x02, 0x69, 0xb9, 0x40, 0x6b, 0xb5, 0x3d, 0x2b, 0x3b, - 0x3e, 0xfe, 0x81, 0x74, 0xb2, 0x54, 0xad, 0x15, 0xa6, 0x9d, 0xee, 0xd7, 0x13, 0xa4, 0xff, 0x3a, - 0x41, 0x3a, 0xfe, 0xd6, 0x00, 0x8b, 0x6f, 0x38, 0x8d, 0x9f, 0xc7, 0x2c, 0x8d, 0xe0, 0x33, 0x60, - 0x54, 0xcd, 0x1e, 0xcc, 0xeb, 0xb8, 0x93, 0x09, 0x04, 0xaa, 0xa2, 0x64, 0x2d, 0x65, 0x92, 0x35, - 0x14, 0x13, 0x50, 0x3d, 0xed, 0x7b, 0x65, 0x99, 0x45, 0x4b, 0xbd, 0x7f, 0x97, 0xd9, 0xfc, 0x8f, - 0x32, 0x5b, 0xd7, 0x2f, 0x73, 0x1b, 0x18, 0x11, 0x8d, 0x43, 0x9f, 0x73, 0x9f, 0xcd, 0xb8, 0x6c, - 0xa8, 0x57, 0x77, 0xd6, 0x44, 0x4c, 0xea, 0x68, 0x2d, 0x9c, 0xcf, 0x4d, 0xb0, 0xf2, 0x72, 0xae, - 0xec, 0xd2, 0xc4, 0xf5, 0x03, 0xf8, 0x04, 0xb4, 0x52, 0x4e, 0x63, 0x19, 0x8e, 0x31, 0xbc, 0x67, - 0x5f, 0x71, 0x23, 0xec, 0xcb, 0x26, 0xbb, 0x88, 0x78, 0x4f, 0x23, 0xd2, 0x09, 0x9f, 0x82, 0xf6, - 0xb4, 0x88, 0x5b, 0x26, 0x64, 0x0c, 0xef, 0x5f, 0x6f, 0x0b, 0xd9, 0xd0, 0x9e, 0x46, 0x94, 0xb7, - 0x1f, 0x80, 0x56, 0xb1, 0x69, 0x11, 0xe3, 0xfc, 0x75, 0xfe, 0x88, 0xb1, 0x58, 0xc5, 0xe5, 0x89, - 0x8f, 0x00, 0xb8, 0xf8, 0x85, 0x65, 0x31, 0xb7, 0x72, 0x81, 0x6e, 0x5e, 0xce, 0x02, 0x93, 0x1a, - 0xb8, 0xd3, 0xfd, 0x72, 0x82, 0xb4, 0x22, 0x89, 0x7e, 0x00, 0xda, 0xea, 0x0b, 0x79, 0x0c, 0xba, - 0xf2, 0xfc, 0xea, 0xf3, 0xe8, 0x8d, 0xac, 0x4c, 0xa0, 0x8e, 0x14, 0x65, 0xcb, 0xe5, 0x75, 0xa9, - 0x20, 0x4c, 0x3a, 0x72, 0xdc, 0xf7, 0xa0, 0xf5, 0xf7, 0x4b, 0x5c, 0x7d, 0xda, 0xc5, 0x34, 0x6a, - 0x83, 0x26, 0x4f, 0xc3, 0xd1, 0x8b, 0xd3, 0xcc, 0xd2, 0xcf, 0x32, 0x4b, 0xff, 0x99, 0x59, 0xfa, - 0xf1, 0xb9, 0xa5, 0x9d, 0x9d, 0x5b, 0xda, 0xf7, 0x73, 0x4b, 0x7b, 0x3b, 0x9c, 0xfa, 0xc9, 0xfb, - 0x74, 0x6c, 0x4f, 0x58, 0xe8, 0xa8, 0x18, 0x1f, 0x06, 0xee, 0x98, 0x97, 0xb3, 0x73, 0xb8, 0xe5, - 0x7c, 0xac, 0xfd, 0x9d, 0x25, 0x47, 0x11, 0xe5, 0xe3, 0x05, 0x79, 0x83, 0xb6, 0x7e, 0x07, 0x00, - 0x00, 0xff, 0xff, 0xe7, 0x28, 0x53, 0x0e, 0xef, 0x04, 0x00, 0x00, + proto.RegisterType((*Subspace)(nil), "desmos.subspaces.v2.Subspace") + proto.RegisterType((*Section)(nil), "desmos.subspaces.v2.Section") + proto.RegisterType((*UserGroup)(nil), "desmos.subspaces.v2.UserGroup") +} + +func init() { proto.RegisterFile("desmos/subspaces/v2/models.proto", fileDescriptor_a588429ec794f86a) } + +var fileDescriptor_a588429ec794f86a = []byte{ + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x31, 0x6f, 0xd3, 0x4e, + 0x18, 0xc6, 0x63, 0x27, 0x6d, 0xe3, 0x4b, 0xf3, 0x6f, 0xff, 0x4e, 0x85, 0xac, 0x0c, 0x3e, 0xeb, + 0x8a, 0x50, 0x06, 0xb0, 0xa5, 0x74, 0x41, 0x95, 0x18, 0x88, 0x40, 0x28, 0x12, 0x03, 0xba, 0xc2, + 0xc2, 0x12, 0x39, 0xf1, 0x11, 0x2c, 0xc5, 0x3e, 0xeb, 0xce, 0x09, 0x64, 0xe5, 0x13, 0x74, 0x64, + 0x41, 0xea, 0xc7, 0xe9, 0xd8, 0x91, 0x85, 0x03, 0x39, 0x0b, 0xb3, 0x3f, 0x01, 0xf2, 0x9d, 0xed, + 0x7a, 0x01, 0x81, 0x04, 0xdb, 0xdd, 0xfb, 0xfe, 0x9e, 0x37, 0xca, 0xf3, 0xbc, 0x3e, 0xe0, 0x04, + 0x84, 0x47, 0x94, 0x7b, 0x7c, 0x3d, 0xe7, 0x89, 0xbf, 0x20, 0xdc, 0xdb, 0x8c, 0xbd, 0x88, 0x06, + 0x64, 0xc5, 0xdd, 0x84, 0xd1, 0x94, 0x9a, 0x03, 0x45, 0xb8, 0x35, 0xe1, 0x6e, 0xc6, 0xc3, 0x93, + 0x25, 0x5d, 0x52, 0xd9, 0xf7, 0x8a, 0x93, 0x42, 0x87, 0x70, 0x49, 0xe9, 0x72, 0x45, 0x3c, 0x79, + 0x9b, 0xaf, 0xdf, 0x78, 0x69, 0x18, 0x11, 0x9e, 0xfa, 0x51, 0xa2, 0x00, 0xf4, 0xa1, 0x0d, 0xba, + 0x17, 0xe5, 0x1c, 0xf3, 0x14, 0xe8, 0x61, 0x60, 0x69, 0x8e, 0x36, 0xea, 0x4c, 0x06, 0x99, 0x80, + 0xfa, 0xf4, 0x49, 0x2e, 0xa0, 0xb1, 0xf5, 0xa3, 0xd5, 0x39, 0x0a, 0x03, 0x84, 0xf5, 0x30, 0x30, + 0x4f, 0x41, 0x27, 0xf6, 0x23, 0x62, 0xe9, 0x8e, 0x36, 0x32, 0x26, 0x47, 0xb9, 0x80, 0x3d, 0x05, + 0x14, 0x55, 0x84, 0x65, 0xd3, 0x7c, 0x08, 0x7a, 0x01, 0xe1, 0x0b, 0x16, 0x26, 0x69, 0x48, 0x63, + 0xab, 0x2d, 0xd9, 0x3b, 0xb9, 0x80, 0xa6, 0x62, 0x1b, 0x4d, 0x84, 0x9b, 0xa8, 0xe9, 0x81, 0x6e, + 0xca, 0x88, 0xcf, 0xd7, 0x6c, 0x6b, 0x75, 0xa4, 0x6c, 0x90, 0x0b, 0x78, 0xa4, 0x64, 0x55, 0x07, + 0xe1, 0x1a, 0x32, 0xef, 0x81, 0x3d, 0xfa, 0x2e, 0x26, 0xcc, 0xda, 0x93, 0xf4, 0x71, 0x2e, 0xe0, + 0xa1, 0xa2, 0x65, 0x19, 0x61, 0xd5, 0x36, 0xef, 0x83, 0x83, 0x05, 0x23, 0x7e, 0x4a, 0x99, 0xb5, + 0x2f, 0x49, 0x33, 0x17, 0xf0, 0x3f, 0x45, 0x96, 0x0d, 0x84, 0x2b, 0xc4, 0xf4, 0x41, 0x5f, 0x1e, + 0x43, 0x1a, 0xcf, 0x0a, 0xcf, 0xac, 0x03, 0x47, 0x1b, 0xf5, 0xc6, 0x43, 0x57, 0x19, 0xea, 0x56, + 0x86, 0xba, 0x2f, 0x2b, 0x43, 0x27, 0xce, 0xb5, 0x80, 0xad, 0x5c, 0xc0, 0x93, 0xc6, 0xcc, 0x4a, + 0x8e, 0x2e, 0xbf, 0x42, 0x0d, 0x1f, 0x56, 0xb5, 0x42, 0x74, 0xde, 0xfd, 0x78, 0x05, 0xb5, 0xef, + 0x57, 0x50, 0x43, 0x9f, 0x74, 0x70, 0x70, 0x41, 0x16, 0xf2, 0xff, 0x3f, 0x05, 0xbd, 0x2a, 0xd7, + 0x59, 0x1d, 0xc6, 0xdd, 0x4c, 0x40, 0x50, 0xc5, 0x24, 0x43, 0x29, 0x7d, 0x6c, 0xa0, 0x08, 0x83, + 0xea, 0x36, 0x0d, 0xca, 0x28, 0x8b, 0x8c, 0xfa, 0x3f, 0x8f, 0xf2, 0x11, 0x30, 0x12, 0x9f, 0x91, + 0x38, 0x2d, 0x7e, 0xa9, 0x2d, 0x59, 0x27, 0x13, 0xb0, 0xfb, 0x42, 0x16, 0xa5, 0xe2, 0x58, 0x29, + 0x6a, 0x0c, 0xe1, 0xae, 0x3a, 0x4f, 0x6f, 0x37, 0xa1, 0xf3, 0x07, 0x9b, 0xb0, 0xf7, 0xdb, 0x9b, + 0xd0, 0xf0, 0xe7, 0x8b, 0x0e, 0x8c, 0x57, 0x9c, 0xb0, 0x67, 0x8c, 0xae, 0x93, 0xbf, 0xe5, 0xd0, + 0x63, 0x00, 0xb8, 0xf2, 0x7c, 0x56, 0x3b, 0x85, 0x32, 0x01, 0x8d, 0x32, 0x09, 0x39, 0xe4, 0xff, + 0x72, 0x48, 0x0d, 0x22, 0x6c, 0x94, 0x97, 0xda, 0xe4, 0xf6, 0xaf, 0x4d, 0xfe, 0xb7, 0x2e, 0x15, + 0xca, 0x84, 0xb0, 0x28, 0xe4, 0x3c, 0xa4, 0x31, 0x97, 0xab, 0xdd, 0x6f, 0x2a, 0x1b, 0x4d, 0x84, + 0x9b, 0xe8, 0xad, 0xbf, 0x93, 0xe7, 0xd7, 0x99, 0xad, 0xdd, 0x64, 0xb6, 0xf6, 0x2d, 0xb3, 0xb5, + 0xcb, 0x9d, 0xdd, 0xba, 0xd9, 0xd9, 0xad, 0xcf, 0x3b, 0xbb, 0xf5, 0x7a, 0xbc, 0x0c, 0xd3, 0xb7, + 0xeb, 0xb9, 0xbb, 0xa0, 0x91, 0xa7, 0x5e, 0x9d, 0x07, 0x2b, 0x7f, 0xce, 0xcb, 0xb3, 0xb7, 0x39, + 0xf3, 0xde, 0x37, 0x1e, 0xaa, 0x74, 0x9b, 0x10, 0x3e, 0xdf, 0x97, 0xdf, 0xc6, 0xd9, 0x8f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x46, 0x67, 0x05, 0x9e, 0xc9, 0x04, 0x00, 0x00, } func (this *Subspace) Equal(that interface{}) bool { @@ -478,14 +391,14 @@ func (this *Subspace) Equal(that interface{}) bool { } return true } -func (this *UserGroup) Equal(that interface{}) bool { +func (this *Section) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*UserGroup) + that1, ok := that.(*Section) if !ok { - that2, ok := that.(UserGroup) + that2, ok := that.(Section) if ok { that1 = &that2 } else { @@ -503,79 +416,25 @@ func (this *UserGroup) Equal(that interface{}) bool { if this.ID != that1.ID { return false } - if this.Name != that1.Name { + if this.ParentID != that1.ParentID { return false } - if this.Description != that1.Description { - return false - } - if this.Permissions != that1.Permissions { - return false - } - return true -} -func (this *PermissionDetail) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PermissionDetail) - if !ok { - that2, ok := that.(PermissionDetail) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if that1.Sum == nil { - if this.Sum != nil { - return false - } - } else if this.Sum == nil { - return false - } else if !this.Sum.Equal(that1.Sum) { - return false - } - return true -} -func (this *PermissionDetail_User_) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PermissionDetail_User_) - if !ok { - that2, ok := that.(PermissionDetail_User_) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { + if this.Name != that1.Name { return false } - if !this.User.Equal(that1.User) { + if this.Description != that1.Description { return false } return true } -func (this *PermissionDetail_Group_) Equal(that interface{}) bool { +func (this *UserGroup) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*PermissionDetail_Group_) + that1, ok := that.(*UserGroup) if !ok { - that2, ok := that.(PermissionDetail_Group_) + that2, ok := that.(UserGroup) if ok { that1 = &that2 } else { @@ -587,61 +446,22 @@ func (this *PermissionDetail_Group_) Equal(that interface{}) bool { } else if this == nil { return false } - if !this.Group.Equal(that1.Group) { - return false - } - return true -} -func (this *PermissionDetail_User) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PermissionDetail_User) - if !ok { - that2, ok := that.(PermissionDetail_User) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { + if this.SubspaceID != that1.SubspaceID { return false } - if this.User != that1.User { + if this.SectionID != that1.SectionID { return false } - if this.Permission != that1.Permission { + if this.ID != that1.ID { return false } - return true -} -func (this *PermissionDetail_Group) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PermissionDetail_Group) - if !ok { - that2, ok := that.(PermissionDetail_Group) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { + if this.Name != that1.Name { return false } - if this.GroupID != that1.GroupID { + if this.Description != that1.Description { return false } - if this.Permission != that1.Permission { + if this.Permissions != that1.Permissions { return false } return true @@ -717,7 +537,7 @@ func (m *Subspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *UserGroup) Marshal() (dAtA []byte, err error) { +func (m *Section) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -727,34 +547,34 @@ func (m *UserGroup) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *UserGroup) MarshalTo(dAtA []byte) (int, error) { +func (m *Section) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *UserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Section) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Permissions != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.Permissions)) - i-- - dAtA[i] = 0x28 - } if len(m.Description) > 0 { i -= len(m.Description) copy(dAtA[i:], m.Description) i = encodeVarintModels(dAtA, i, uint64(len(m.Description))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 + } + if m.ParentID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.ParentID)) + i-- + dAtA[i] = 0x18 } if m.ID != 0 { i = encodeVarintModels(dAtA, i, uint64(m.ID)) @@ -769,7 +589,7 @@ func (m *UserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *PermissionDetail) Marshal() (dAtA []byte, err error) { +func (m *UserGroup) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -779,132 +599,47 @@ func (m *PermissionDetail) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PermissionDetail) MarshalTo(dAtA []byte) (int, error) { +func (m *UserGroup) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PermissionDetail) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *UserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Sum != nil { - { - size := m.Sum.Size() - i -= size - if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *PermissionDetail_User_) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PermissionDetail_User_) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.User != nil { - { - size, err := m.User.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } + if m.Permissions != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Permissions)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x30 } - return len(dAtA) - i, nil -} -func (m *PermissionDetail_Group_) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PermissionDetail_Group_) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Group != nil { - { - size, err := m.Group.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintModels(dAtA, i, uint64(size)) - } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintModels(dAtA, i, uint64(len(m.Description))) i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *PermissionDetail_User) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + dAtA[i] = 0x2a } - return dAtA[:n], nil -} - -func (m *PermissionDetail_User) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PermissionDetail_User) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Permission != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.Permission)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintModels(dAtA, i, uint64(len(m.Name))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x22 } - if len(m.User) > 0 { - i -= len(m.User) - copy(dAtA[i:], m.User) - i = encodeVarintModels(dAtA, i, uint64(len(m.User))) + if m.ID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.ID)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x18 } - return len(dAtA) - i, nil -} - -func (m *PermissionDetail_Group) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PermissionDetail_Group) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PermissionDetail_Group) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Permission != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.Permission)) + if m.SectionID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.SectionID)) i-- dAtA[i] = 0x10 } - if m.GroupID != 0 { - i = encodeVarintModels(dAtA, i, uint64(m.GroupID)) + if m.SubspaceID != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.SubspaceID)) i-- dAtA[i] = 0x8 } @@ -948,103 +683,65 @@ func (m *Subspace) Size() (n int) { n += 1 + l + sovModels(uint64(l)) } l = len(m.Creator) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CreationTime) - n += 1 + l + sovModels(uint64(l)) - return n -} - -func (m *UserGroup) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SubspaceID != 0 { - n += 1 + sovModels(uint64(m.SubspaceID)) - } - if m.ID != 0 { - n += 1 + sovModels(uint64(m.ID)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovModels(uint64(l)) - } - if m.Permissions != 0 { - n += 1 + sovModels(uint64(m.Permissions)) - } - return n -} - -func (m *PermissionDetail) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - n += m.Sum.Size() - } - return n -} - -func (m *PermissionDetail_User_) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.User != nil { - l = m.User.Size() - n += 1 + l + sovModels(uint64(l)) - } - return n -} -func (m *PermissionDetail_Group_) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Group != nil { - l = m.Group.Size() + if l > 0 { n += 1 + l + sovModels(uint64(l)) } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CreationTime) + n += 1 + l + sovModels(uint64(l)) return n } -func (m *PermissionDetail_User) Size() (n int) { + +func (m *Section) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.User) + if m.SubspaceID != 0 { + n += 1 + sovModels(uint64(m.SubspaceID)) + } + if m.ID != 0 { + n += 1 + sovModels(uint64(m.ID)) + } + if m.ParentID != 0 { + n += 1 + sovModels(uint64(m.ParentID)) + } + l = len(m.Name) if l > 0 { n += 1 + l + sovModels(uint64(l)) } - if m.Permission != 0 { - n += 1 + sovModels(uint64(m.Permission)) + l = len(m.Description) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) } return n } -func (m *PermissionDetail_Group) Size() (n int) { +func (m *UserGroup) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.GroupID != 0 { - n += 1 + sovModels(uint64(m.GroupID)) + if m.SubspaceID != 0 { + n += 1 + sovModels(uint64(m.SubspaceID)) + } + if m.SectionID != 0 { + n += 1 + sovModels(uint64(m.SectionID)) + } + if m.ID != 0 { + n += 1 + sovModels(uint64(m.ID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) } - if m.Permission != 0 { - n += 1 + sovModels(uint64(m.Permission)) + if m.Permissions != 0 { + n += 1 + sovModels(uint64(m.Permissions)) } return n } @@ -1317,7 +1014,7 @@ func (m *Subspace) Unmarshal(dAtA []byte) error { } return nil } -func (m *UserGroup) Unmarshal(dAtA []byte) error { +func (m *Section) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1340,10 +1037,10 @@ func (m *UserGroup) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserGroup: wiretype end group for non-group") + return fmt.Errorf("proto: Section: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserGroup: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Section: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1385,6 +1082,25 @@ func (m *UserGroup) Unmarshal(dAtA []byte) error { } } case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ParentID", wireType) + } + m.ParentID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ParentID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -1416,7 +1132,7 @@ func (m *UserGroup) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } @@ -1448,25 +1164,6 @@ func (m *UserGroup) Unmarshal(dAtA []byte) error { } m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipModels(dAtA[iNdEx:]) @@ -1488,7 +1185,7 @@ func (m *UserGroup) Unmarshal(dAtA []byte) error { } return nil } -func (m *PermissionDetail) Unmarshal(dAtA []byte) error { +func (m *UserGroup) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1511,17 +1208,17 @@ func (m *PermissionDetail) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PermissionDetail: wiretype end group for non-group") + return fmt.Errorf("proto: UserGroup: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PermissionDetail: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UserGroup: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) } - var msglen int + m.SubspaceID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowModels @@ -1531,32 +1228,16 @@ func (m *PermissionDetail) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.SubspaceID |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PermissionDetail_User{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &PermissionDetail_User_{v} - iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) } - var msglen int + m.SectionID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowModels @@ -1566,80 +1247,33 @@ func (m *PermissionDetail) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.SectionID |= uint32(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthModels - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthModels - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &PermissionDetail_Group{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Sum = &PermissionDetail_Group_{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthModels - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PermissionDetail_User) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: User: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: User: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1667,13 +1301,13 @@ func (m *PermissionDetail_User) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.User = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } - m.Permission = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowModels @@ -1683,85 +1317,29 @@ func (m *PermissionDetail_User) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permission |= uint32(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - default: - iNdEx = preIndex - skippy, err := skipModels(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthModels } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PermissionDetail_Group) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Group: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Group: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupID", wireType) - } - m.GroupID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowModels - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GroupID |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) } - m.Permission = 0 + m.Permissions = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowModels @@ -1771,7 +1349,7 @@ func (m *PermissionDetail_Group) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permission |= uint32(b&0x7F) << shift + m.Permissions |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/subspaces/types/models_test.go b/x/subspaces/types/models_test.go index d4faf8b9e8..617991c11a 100644 --- a/x/subspaces/types/models_test.go +++ b/x/subspaces/types/models_test.go @@ -161,13 +161,11 @@ func TestSubspace_Validate(t *testing.T) { } } -// -------------------------------------------------------------------------------------------------------------------- - func TestSubspace_Update(t *testing.T) { testCases := []struct { name string subspace types.Subspace - update *types.SubspaceUpdate + update types.SubspaceUpdate expResult types.Subspace }{ { @@ -237,6 +235,194 @@ func TestSubspace_Update(t *testing.T) { // -------------------------------------------------------------------------------------------------------------------- +func TestParseSectionID(t *testing.T) { + testCases := []struct { + name string + value string + shouldErr bool + expID uint32 + }{ + { + name: "invalid id returns error", + value: "id", + shouldErr: true, + }, + { + name: "empty value returns zero", + value: "", + shouldErr: false, + expID: 0, + }, + { + name: "valid id returns correct value", + value: "2", + shouldErr: false, + expID: 2, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + id, err := types.ParseSectionID(tc.value) + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, tc.expID, id) + } + }) + } +} + +func TestSection_Validate(t *testing.T) { + testCases := []struct { + name string + section types.Section + shouldErr bool + }{ + { + name: "invalid subspace id returns error", + section: types.NewSection( + 0, + 0, + 1, + "Test section", + "This is a test section", + ), + shouldErr: true, + }, + { + name: "invalid parent id returns error", + section: types.NewSection( + 1, + 1, + 1, + "Test section", + "This is a test section", + ), + shouldErr: true, + }, + { + name: "invalid section name returns error - empty", + section: types.NewSection( + 1, + 1, + 0, + "", + "This is a test section", + ), + shouldErr: true, + }, + { + name: "invalid section name returns error - blank", + section: types.NewSection( + 1, + 1, + 0, + " ", + "This is a test section", + ), + shouldErr: true, + }, + { + name: "default section does not return error", + section: types.DefaultSection(1), + shouldErr: false, + }, + { + name: "default section returns no error", + section: types.DefaultSection(1), + shouldErr: false, + }, + { + name: "valid data returns no error", + section: types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), + shouldErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.section.Validate() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestSection_Update(t *testing.T) { + testCases := []struct { + name string + section types.Section + update types.SectionUpdate + expResult types.Section + }{ + { + name: "nothing is updated when using DoNotModify", + section: types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), + update: types.NewSectionUpdate( + types.DoNotModify, + types.DoNotModify, + ), + expResult: types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), + }, + { + name: "each field is updated when edited", + section: types.NewSection( + 1, + 1, + 0, + "Test section", + "This is a test section", + ), + update: types.NewSectionUpdate( + "New section name", + "New section description", + ), + expResult: types.NewSection( + 1, + 1, + 0, + "New section name", + "New section description", + ), + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + result := tc.section.Update(tc.update) + require.Equal(t, tc.expResult, result) + }) + } +} + +// -------------------------------------------------------------------------------------------------------------------- + func TestParseUserGroupID(t *testing.T) { testCases := []struct { name string @@ -286,6 +472,7 @@ func TestUserGroup_Validate(t *testing.T) { { name: "invalid subspace id returns error", group: types.NewUserGroup( + 0, 0, 1, "Test group", @@ -298,6 +485,7 @@ func TestUserGroup_Validate(t *testing.T) { name: "invalid group name returns error - empty", group: types.NewUserGroup( 1, + 0, 1, "", "This is a test group", @@ -309,6 +497,7 @@ func TestUserGroup_Validate(t *testing.T) { name: "invalid group name returns error - blank", group: types.NewUserGroup( 1, + 0, 1, " ", "This is a test group", @@ -331,19 +520,18 @@ func TestUserGroup_Validate(t *testing.T) { } } -// -------------------------------------------------------------------------------------------------------------------- - func TestUserGroup_Update(t *testing.T) { testCases := []struct { name string subspace types.UserGroup - update *types.GroupUpdate + update types.GroupUpdate expResult types.UserGroup }{ { name: "nothing is updated when using DoNotModify", subspace: types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -355,6 +543,7 @@ func TestUserGroup_Update(t *testing.T) { ), expResult: types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -365,6 +554,7 @@ func TestUserGroup_Update(t *testing.T) { name: "each field is updated when edited", subspace: types.NewUserGroup( 1, + 0, 1, "Test group", "This is a test group", @@ -376,6 +566,7 @@ func TestUserGroup_Update(t *testing.T) { ), expResult: types.NewUserGroup( 1, + 0, 1, "New group name", "New group description", diff --git a/x/subspaces/types/msgs.go b/x/subspaces/types/msgs.go index ea55913894..64f05ee9dd 100644 --- a/x/subspaces/types/msgs.go +++ b/x/subspaces/types/msgs.go @@ -7,8 +7,32 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +var ( + _ sdk.Msg = &MsgCreateSubspace{} + _ sdk.Msg = &MsgEditSubspace{} + _ sdk.Msg = &MsgDeleteSubspace{} + _ sdk.Msg = &MsgCreateSection{} + _ sdk.Msg = &MsgEditSection{} + _ sdk.Msg = &MsgMoveSection{} + _ sdk.Msg = &MsgDeleteSection{} + _ sdk.Msg = &MsgCreateUserGroup{} + _ sdk.Msg = &MsgEditUserGroup{} + _ sdk.Msg = &MsgMoveUserGroup{} + _ sdk.Msg = &MsgSetUserGroupPermissions{} + _ sdk.Msg = &MsgDeleteUserGroup{} + _ sdk.Msg = &MsgAddUserToUserGroup{} + _ sdk.Msg = &MsgRemoveUserFromUserGroup{} + _ sdk.Msg = &MsgSetUserPermissions{} +) + // NewMsgCreateSubspace creates a new MsgCreateSubspace instance -func NewMsgCreateSubspace(name, description, treasury, owner, creator string) *MsgCreateSubspace { +func NewMsgCreateSubspace( + name string, + description string, + treasury string, + owner string, + creator string, +) *MsgCreateSubspace { if owner == "" { // If the owner is empty, set the creator as the owner owner = creator @@ -69,7 +93,14 @@ func (msg MsgCreateSubspace) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // NewMsgEditSubspace creates a new MsgEditSubspace instance -func NewMsgEditSubspace(subspaceID uint64, name, description, treasury, owner, signer string) *MsgEditSubspace { +func NewMsgEditSubspace( + subspaceID uint64, + name string, + description, + treasury string, + owner string, + signer string, +) *MsgEditSubspace { return &MsgEditSubspace{ SubspaceID: subspaceID, Name: name, @@ -154,10 +185,224 @@ func (msg MsgDeleteSubspace) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- +// NewMsgCreateSection returns a new MsgCreateSection instance +func NewMsgCreateSection( + subspaceID uint64, + name string, + description string, + parentID uint32, + creator string, +) *MsgCreateSection { + return &MsgCreateSection{ + SubspaceID: subspaceID, + Name: name, + Description: description, + ParentID: parentID, + Creator: creator, + } +} + +// Route implements sdk.Msg +func (msg MsgCreateSection) Route() string { return RouterKey } + +// Type implements sdk.Msg +func (msg MsgCreateSection) Type() string { return ActionCreateSection } + +// ValidateBasic implements sdk.Msg +func (msg MsgCreateSection) ValidateBasic() error { + if msg.SubspaceID == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id: %d", msg.SubspaceID) + } + + if strings.TrimSpace(msg.Name) == "" { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid section name: %s", msg.Name) + } + + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg MsgCreateSection) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCodec.MustMarshalJSON(&msg)) +} + +// GetSigners implements sdk.Msg +func (msg MsgCreateSection) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Creator) + return []sdk.AccAddress{addr} +} + +// -------------------------------------------------------------------------------------------------------------------- + +// NewMsgEditSection returns a new MsgEditSection instance +func NewMsgEditSection( + subspaceID uint64, + sectionID uint32, + name string, + description string, + editor string, +) *MsgEditSection { + return &MsgEditSection{ + SubspaceID: subspaceID, + SectionID: sectionID, + Name: name, + Description: description, + Editor: editor, + } +} + +// Route implements sdk.Msg +func (msg MsgEditSection) Route() string { return RouterKey } + +// Type implements sdk.Msg +func (msg MsgEditSection) Type() string { return ActionEditSection } + +// ValidateBasic implements sdk.Msg +func (msg MsgEditSection) ValidateBasic() error { + if msg.SubspaceID == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id: %d", msg.SubspaceID) + } + + if strings.TrimSpace(msg.Name) == "" { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid section name: %s", msg.Name) + } + + _, err := sdk.AccAddressFromBech32(msg.Editor) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid editor address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg MsgEditSection) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCodec.MustMarshalJSON(&msg)) +} + +// GetSigners implements sdk.Msg +func (msg MsgEditSection) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Editor) + return []sdk.AccAddress{addr} +} + +// -------------------------------------------------------------------------------------------------------------------- + +// NewMsgMoveSection returns a new MsgMoveSection instance +func NewMsgMoveSection( + subspaceID uint64, + sectionID uint32, + newParentID uint32, + signer string, +) *MsgMoveSection { + return &MsgMoveSection{ + SubspaceID: subspaceID, + SectionID: sectionID, + NewParentID: newParentID, + Signer: signer, + } +} + +// Route implements sdk.Msg +func (msg MsgMoveSection) Route() string { return RouterKey } + +// Type implements sdk.Msg +func (msg MsgMoveSection) Type() string { return ActionMoveSection } + +// ValidateBasic implements sdk.Msg +func (msg MsgMoveSection) ValidateBasic() error { + if msg.SubspaceID == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id: %d", msg.SubspaceID) + } + + if msg.SectionID == RootSectionID { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid section id: %d", msg.SectionID) + } + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg MsgMoveSection) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCodec.MustMarshalJSON(&msg)) +} + +// GetSigners implements sdk.Msg +func (msg MsgMoveSection) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{addr} +} + +// -------------------------------------------------------------------------------------------------------------------- + +// NewMsgDeleteSection returns a new MsgDeleteSection instance +func NewMsgDeleteSection(subspaceID uint64, sectionID uint32, signer string) *MsgDeleteSection { + return &MsgDeleteSection{ + SubspaceID: subspaceID, + SectionID: sectionID, + Signer: signer, + } +} + +// Route implements sdk.Msg +func (msg MsgDeleteSection) Route() string { return RouterKey } + +// Type implements sdk.Msg +func (msg MsgDeleteSection) Type() string { return ActionDeleteSection } + +// ValidateBasic implements sdk.Msg +func (msg MsgDeleteSection) ValidateBasic() error { + if msg.SubspaceID == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id: %d", msg.SubspaceID) + } + + if msg.SectionID == RootSectionID { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid section id: %d", msg.SectionID) + } + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg MsgDeleteSection) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCodec.MustMarshalJSON(&msg)) +} + +// GetSigners implements sdk.Msg +func (msg MsgDeleteSection) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{addr} +} + +// -------------------------------------------------------------------------------------------------------------------- + // NewMsgCreateUserGroup creates a new MsgCreateUserGroup instance -func NewMsgCreateUserGroup(subspaceID uint64, name, description string, permissions uint32, creator string) *MsgCreateUserGroup { +func NewMsgCreateUserGroup( + subspaceID uint64, + sectionID uint32, + name string, + description string, + permissions uint32, + creator string, +) *MsgCreateUserGroup { return &MsgCreateUserGroup{ SubspaceID: subspaceID, + SectionID: sectionID, Name: name, Description: description, DefaultPermissions: permissions, @@ -203,7 +448,13 @@ func (msg MsgCreateUserGroup) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // NewMsgEditUserGroup returns a new NewMsgEditUserGroup instance -func NewMsgEditUserGroup(subspaceID uint64, groupID uint32, name, description string, signer string) *MsgEditUserGroup { +func NewMsgEditUserGroup( + subspaceID uint64, + groupID uint32, + name string, + description string, + signer string, +) *MsgEditUserGroup { return &MsgEditUserGroup{ SubspaceID: subspaceID, GroupID: groupID, @@ -246,8 +497,61 @@ func (msg MsgEditUserGroup) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- +// NewMsgMoveUserGroup returns a new NewMsgMoveUserGroup instance +func NewMsgMoveUserGroup( + subspaceID uint64, + groupID uint32, + newSectionID uint32, + signer string, +) *MsgMoveUserGroup { + return &MsgMoveUserGroup{ + SubspaceID: subspaceID, + GroupID: groupID, + NewSectionID: newSectionID, + Signer: signer, + } +} + +// Route implements sdk.Msg +func (msg MsgMoveUserGroup) Route() string { return RouterKey } + +// Type implements sdk.Msg +func (msg MsgMoveUserGroup) Type() string { return ActionMoveUserGroup } + +// ValidateBasic implements sdk.Msg +func (msg MsgMoveUserGroup) ValidateBasic() error { + if msg.SubspaceID == 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid subspace id: %d", msg.SubspaceID) + } + + _, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid signer address") + } + + return nil +} + +// GetSignBytes implements sdk.Msg +func (msg MsgMoveUserGroup) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCodec.MustMarshalJSON(&msg)) +} + +// GetSigners implements sdk.Msg +func (msg MsgMoveUserGroup) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Signer) + return []sdk.AccAddress{addr} +} + +// -------------------------------------------------------------------------------------------------------------------- + // NewMsgSetUserGroupPermissions returns a new MsgSetUserGroupPermissions instance -func NewMsgSetUserGroupPermissions(subspaceID uint64, groupID uint32, permissions Permission, signer string) *MsgSetUserGroupPermissions { +func NewMsgSetUserGroupPermissions( + subspaceID uint64, + groupID uint32, + permissions Permission, + signer string, +) *MsgSetUserGroupPermissions { return &MsgSetUserGroupPermissions{ SubspaceID: subspaceID, GroupID: groupID, @@ -336,7 +640,12 @@ func (msg MsgDeleteUserGroup) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // NewMsgAddUserToUserGroup creates a new MsgAddUserToUserGroup instance -func NewMsgAddUserToUserGroup(subspaceID uint64, groupID uint32, user string, signer string) *MsgAddUserToUserGroup { +func NewMsgAddUserToUserGroup( + subspaceID uint64, + groupID uint32, + user string, + signer string, +) *MsgAddUserToUserGroup { return &MsgAddUserToUserGroup{ SubspaceID: subspaceID, GroupID: groupID, @@ -388,7 +697,12 @@ func (msg MsgAddUserToUserGroup) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // NewMsgRemoveUserFromUserGroup creates a new MsgRemoveUserFromUserGroup instance -func NewMsgRemoveUserFromUserGroup(subspaceID uint64, groupID uint32, user string, signer string) *MsgRemoveUserFromUserGroup { +func NewMsgRemoveUserFromUserGroup( + subspaceID uint64, + groupID uint32, + user string, + signer string, +) *MsgRemoveUserFromUserGroup { return &MsgRemoveUserFromUserGroup{ SubspaceID: subspaceID, GroupID: groupID, @@ -440,9 +754,16 @@ func (msg MsgRemoveUserFromUserGroup) GetSigners() []sdk.AccAddress { // -------------------------------------------------------------------------------------------------------------------- // NewMsgSetUserPermissions creates a new MsgSetUserPermissions instance -func NewMsgSetUserPermissions(subspaceID uint64, user string, permissions uint32, signer string) *MsgSetUserPermissions { +func NewMsgSetUserPermissions( + subspaceID uint64, + sectionID uint32, + user string, + permissions uint32, + signer string, +) *MsgSetUserPermissions { return &MsgSetUserPermissions{ SubspaceID: subspaceID, + SectionID: sectionID, User: user, Permissions: permissions, Signer: signer, diff --git a/x/subspaces/types/msgs.pb.go b/x/subspaces/types/msgs.pb.go index 2bbd9be6bc..4f8145b0d7 100644 --- a/x/subspaces/types/msgs.pb.go +++ b/x/subspaces/types/msgs.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: desmos/subspaces/v1/msgs.proto +// source: desmos/subspaces/v2/msgs.proto package types @@ -41,7 +41,7 @@ func (m *MsgCreateSubspace) Reset() { *m = MsgCreateSubspace{} } func (m *MsgCreateSubspace) String() string { return proto.CompactTextString(m) } func (*MsgCreateSubspace) ProtoMessage() {} func (*MsgCreateSubspace) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{0} + return fileDescriptor_d549e2340fbe3f45, []int{0} } func (m *MsgCreateSubspace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,7 +79,7 @@ func (m *MsgCreateSubspaceResponse) Reset() { *m = MsgCreateSubspaceResp func (m *MsgCreateSubspaceResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateSubspaceResponse) ProtoMessage() {} func (*MsgCreateSubspaceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{1} + return fileDescriptor_d549e2340fbe3f45, []int{1} } func (m *MsgCreateSubspaceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -129,7 +129,7 @@ func (m *MsgEditSubspace) Reset() { *m = MsgEditSubspace{} } func (m *MsgEditSubspace) String() string { return proto.CompactTextString(m) } func (*MsgEditSubspace) ProtoMessage() {} func (*MsgEditSubspace) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{2} + return fileDescriptor_d549e2340fbe3f45, []int{2} } func (m *MsgEditSubspace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -166,7 +166,7 @@ func (m *MsgEditSubspaceResponse) Reset() { *m = MsgEditSubspaceResponse func (m *MsgEditSubspaceResponse) String() string { return proto.CompactTextString(m) } func (*MsgEditSubspaceResponse) ProtoMessage() {} func (*MsgEditSubspaceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{3} + return fileDescriptor_d549e2340fbe3f45, []int{3} } func (m *MsgEditSubspaceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -205,7 +205,7 @@ func (m *MsgDeleteSubspace) Reset() { *m = MsgDeleteSubspace{} } func (m *MsgDeleteSubspace) String() string { return proto.CompactTextString(m) } func (*MsgDeleteSubspace) ProtoMessage() {} func (*MsgDeleteSubspace) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{4} + return fileDescriptor_d549e2340fbe3f45, []int{4} } func (m *MsgDeleteSubspace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -242,7 +242,7 @@ func (m *MsgDeleteSubspaceResponse) Reset() { *m = MsgDeleteSubspaceResp func (m *MsgDeleteSubspaceResponse) String() string { return proto.CompactTextString(m) } func (*MsgDeleteSubspaceResponse) ProtoMessage() {} func (*MsgDeleteSubspaceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{5} + return fileDescriptor_d549e2340fbe3f45, []int{5} } func (m *MsgDeleteSubspaceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -271,31 +271,33 @@ func (m *MsgDeleteSubspaceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDeleteSubspaceResponse proto.InternalMessageInfo -// MsgCreateUserGroup represents the message used to create a user group -type MsgCreateUserGroup struct { +// MsgCreateSection represents the message to be used when creating a subspace +// section +type MsgCreateSection struct { + // Id of the subspace inside which the section will be placed SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - // Name of the group + // Name of the section to be created Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` - // Optional description of the group + // (optional) Description of the section Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - // Default permissions to be applied to the group - DefaultPermissions uint32 `protobuf:"varint,4,opt,name=default_permissions,json=defaultPermissions,proto3" json:"default_permissions,omitempty" yaml:"default_permissions"` - // Creator of the group + // (optional) Id of the parent section + ParentID uint32 `protobuf:"varint,4,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty" yaml:"parent_id"` + // User creating the section Creator string `protobuf:"bytes,5,opt,name=creator,proto3" json:"creator,omitempty" yaml:"creator"` } -func (m *MsgCreateUserGroup) Reset() { *m = MsgCreateUserGroup{} } -func (m *MsgCreateUserGroup) String() string { return proto.CompactTextString(m) } -func (*MsgCreateUserGroup) ProtoMessage() {} -func (*MsgCreateUserGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{6} +func (m *MsgCreateSection) Reset() { *m = MsgCreateSection{} } +func (m *MsgCreateSection) String() string { return proto.CompactTextString(m) } +func (*MsgCreateSection) ProtoMessage() {} +func (*MsgCreateSection) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{6} } -func (m *MsgCreateUserGroup) XXX_Unmarshal(b []byte) error { +func (m *MsgCreateSection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreateUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCreateSection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreateUserGroup.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCreateSection.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -305,70 +307,71 @@ func (m *MsgCreateUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgCreateUserGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateUserGroup.Merge(m, src) +func (m *MsgCreateSection) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateSection.Merge(m, src) } -func (m *MsgCreateUserGroup) XXX_Size() int { +func (m *MsgCreateSection) XXX_Size() int { return m.Size() } -func (m *MsgCreateUserGroup) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateUserGroup.DiscardUnknown(m) +func (m *MsgCreateSection) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateSection.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateUserGroup proto.InternalMessageInfo +var xxx_messageInfo_MsgCreateSection proto.InternalMessageInfo -func (m *MsgCreateUserGroup) GetSubspaceID() uint64 { +func (m *MsgCreateSection) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgCreateUserGroup) GetName() string { +func (m *MsgCreateSection) GetName() string { if m != nil { return m.Name } return "" } -func (m *MsgCreateUserGroup) GetDescription() string { +func (m *MsgCreateSection) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *MsgCreateUserGroup) GetDefaultPermissions() uint32 { +func (m *MsgCreateSection) GetParentID() uint32 { if m != nil { - return m.DefaultPermissions + return m.ParentID } return 0 } -func (m *MsgCreateUserGroup) GetCreator() string { +func (m *MsgCreateSection) GetCreator() string { if m != nil { return m.Creator } return "" } -// MsgCreateUserGroupResponse defines the Msg/CreateUserGroup response type -type MsgCreateUserGroupResponse struct { - GroupID uint32 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` +// MsgCreateSectionResponse represents the Msg/CreateSection response type +type MsgCreateSectionResponse struct { + // Id of the newly created section + SectionID uint32 `protobuf:"varint,1,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` } -func (m *MsgCreateUserGroupResponse) Reset() { *m = MsgCreateUserGroupResponse{} } -func (m *MsgCreateUserGroupResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateUserGroupResponse) ProtoMessage() {} -func (*MsgCreateUserGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{7} +func (m *MsgCreateSectionResponse) Reset() { *m = MsgCreateSectionResponse{} } +func (m *MsgCreateSectionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateSectionResponse) ProtoMessage() {} +func (*MsgCreateSectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{7} } -func (m *MsgCreateUserGroupResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgCreateSectionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreateUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCreateSectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreateUserGroupResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCreateSectionResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -378,46 +381,52 @@ func (m *MsgCreateUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgCreateUserGroupResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateUserGroupResponse.Merge(m, src) +func (m *MsgCreateSectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateSectionResponse.Merge(m, src) } -func (m *MsgCreateUserGroupResponse) XXX_Size() int { +func (m *MsgCreateSectionResponse) XXX_Size() int { return m.Size() } -func (m *MsgCreateUserGroupResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateUserGroupResponse.DiscardUnknown(m) +func (m *MsgCreateSectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateSectionResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateUserGroupResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgCreateSectionResponse proto.InternalMessageInfo -func (m *MsgCreateUserGroupResponse) GetGroupID() uint32 { +func (m *MsgCreateSectionResponse) GetSectionID() uint32 { if m != nil { - return m.GroupID + return m.SectionID } return 0 } -// MsgEditUserGroup represents the message used to edit a user group -type MsgEditUserGroup struct { - SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` +// MsgEditSection represents the message to be used when editing a subspace +// section +type MsgEditSection struct { + // Id of the subspace inside which the section to be edited is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the section to be edited + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + // (optional) New name of the section + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // (optional) New description of the section Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` + // User editing the section + Editor string `protobuf:"bytes,5,opt,name=editor,proto3" json:"editor,omitempty" yaml:"editor"` } -func (m *MsgEditUserGroup) Reset() { *m = MsgEditUserGroup{} } -func (m *MsgEditUserGroup) String() string { return proto.CompactTextString(m) } -func (*MsgEditUserGroup) ProtoMessage() {} -func (*MsgEditUserGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{8} +func (m *MsgEditSection) Reset() { *m = MsgEditSection{} } +func (m *MsgEditSection) String() string { return proto.CompactTextString(m) } +func (*MsgEditSection) ProtoMessage() {} +func (*MsgEditSection) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{8} } -func (m *MsgEditUserGroup) XXX_Unmarshal(b []byte) error { +func (m *MsgEditSection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgEditUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEditSection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEditUserGroup.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEditSection.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -427,69 +436,69 @@ func (m *MsgEditUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgEditUserGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEditUserGroup.Merge(m, src) +func (m *MsgEditSection) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditSection.Merge(m, src) } -func (m *MsgEditUserGroup) XXX_Size() int { +func (m *MsgEditSection) XXX_Size() int { return m.Size() } -func (m *MsgEditUserGroup) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEditUserGroup.DiscardUnknown(m) +func (m *MsgEditSection) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditSection.DiscardUnknown(m) } -var xxx_messageInfo_MsgEditUserGroup proto.InternalMessageInfo +var xxx_messageInfo_MsgEditSection proto.InternalMessageInfo -func (m *MsgEditUserGroup) GetSubspaceID() uint64 { +func (m *MsgEditSection) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgEditUserGroup) GetGroupID() uint32 { +func (m *MsgEditSection) GetSectionID() uint32 { if m != nil { - return m.GroupID + return m.SectionID } return 0 } -func (m *MsgEditUserGroup) GetName() string { +func (m *MsgEditSection) GetName() string { if m != nil { return m.Name } return "" } -func (m *MsgEditUserGroup) GetDescription() string { +func (m *MsgEditSection) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *MsgEditUserGroup) GetSigner() string { +func (m *MsgEditSection) GetEditor() string { if m != nil { - return m.Signer + return m.Editor } return "" } -// MsgEditUserGroupResponse defines the Msg/EditUserGroup response type -type MsgEditUserGroupResponse struct { +// MsgEditSectionResponse represents the Msg/EditSection response type +type MsgEditSectionResponse struct { } -func (m *MsgEditUserGroupResponse) Reset() { *m = MsgEditUserGroupResponse{} } -func (m *MsgEditUserGroupResponse) String() string { return proto.CompactTextString(m) } -func (*MsgEditUserGroupResponse) ProtoMessage() {} -func (*MsgEditUserGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{9} +func (m *MsgEditSectionResponse) Reset() { *m = MsgEditSectionResponse{} } +func (m *MsgEditSectionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEditSectionResponse) ProtoMessage() {} +func (*MsgEditSectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{9} } -func (m *MsgEditUserGroupResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgEditSectionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgEditUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEditSectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEditUserGroupResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEditSectionResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -499,39 +508,43 @@ func (m *MsgEditUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgEditUserGroupResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEditUserGroupResponse.Merge(m, src) +func (m *MsgEditSectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditSectionResponse.Merge(m, src) } -func (m *MsgEditUserGroupResponse) XXX_Size() int { +func (m *MsgEditSectionResponse) XXX_Size() int { return m.Size() } -func (m *MsgEditUserGroupResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEditUserGroupResponse.DiscardUnknown(m) +func (m *MsgEditSectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditSectionResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgEditUserGroupResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgEditSectionResponse proto.InternalMessageInfo -// MsgSetUserGroupPermissions represents the message used to set the permissions -// of a user group -type MsgSetUserGroupPermissions struct { - SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` - Permissions uint32 `protobuf:"varint,3,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` +// MsgMoveSection represents the message to be used when moving a section to +// another parent +type MsgMoveSection struct { + // Id of the subspace inside which the section lies + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the section to be moved + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + // Id of the new parent + NewParentID uint32 `protobuf:"varint,3,opt,name=new_parent_id,json=newParentId,proto3" json:"new_parent_id,omitempty" yaml:"new_parent_id"` + // Signer of the message + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -func (m *MsgSetUserGroupPermissions) Reset() { *m = MsgSetUserGroupPermissions{} } -func (m *MsgSetUserGroupPermissions) String() string { return proto.CompactTextString(m) } -func (*MsgSetUserGroupPermissions) ProtoMessage() {} -func (*MsgSetUserGroupPermissions) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{10} +func (m *MsgMoveSection) Reset() { *m = MsgMoveSection{} } +func (m *MsgMoveSection) String() string { return proto.CompactTextString(m) } +func (*MsgMoveSection) ProtoMessage() {} +func (*MsgMoveSection) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{10} } -func (m *MsgSetUserGroupPermissions) XXX_Unmarshal(b []byte) error { +func (m *MsgMoveSection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetUserGroupPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgMoveSection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetUserGroupPermissions.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgMoveSection.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -541,63 +554,62 @@ func (m *MsgSetUserGroupPermissions) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgSetUserGroupPermissions) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetUserGroupPermissions.Merge(m, src) +func (m *MsgMoveSection) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMoveSection.Merge(m, src) } -func (m *MsgSetUserGroupPermissions) XXX_Size() int { +func (m *MsgMoveSection) XXX_Size() int { return m.Size() } -func (m *MsgSetUserGroupPermissions) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetUserGroupPermissions.DiscardUnknown(m) +func (m *MsgMoveSection) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMoveSection.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetUserGroupPermissions proto.InternalMessageInfo +var xxx_messageInfo_MsgMoveSection proto.InternalMessageInfo -func (m *MsgSetUserGroupPermissions) GetSubspaceID() uint64 { +func (m *MsgMoveSection) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgSetUserGroupPermissions) GetGroupID() uint32 { +func (m *MsgMoveSection) GetSectionID() uint32 { if m != nil { - return m.GroupID + return m.SectionID } return 0 } -func (m *MsgSetUserGroupPermissions) GetPermissions() uint32 { +func (m *MsgMoveSection) GetNewParentID() uint32 { if m != nil { - return m.Permissions + return m.NewParentID } return 0 } -func (m *MsgSetUserGroupPermissions) GetSigner() string { +func (m *MsgMoveSection) GetSigner() string { if m != nil { return m.Signer } return "" } -// MsgSetUserGroupPermissionsResponse defines the -// Msg/SetUserGroupPermissionsResponse response type -type MsgSetUserGroupPermissionsResponse struct { +// MsgMoveSectionResponse +type MsgMoveSectionResponse struct { } -func (m *MsgSetUserGroupPermissionsResponse) Reset() { *m = MsgSetUserGroupPermissionsResponse{} } -func (m *MsgSetUserGroupPermissionsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetUserGroupPermissionsResponse) ProtoMessage() {} -func (*MsgSetUserGroupPermissionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{11} +func (m *MsgMoveSectionResponse) Reset() { *m = MsgMoveSectionResponse{} } +func (m *MsgMoveSectionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMoveSectionResponse) ProtoMessage() {} +func (*MsgMoveSectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{11} } -func (m *MsgSetUserGroupPermissionsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgMoveSectionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetUserGroupPermissionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgMoveSectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetUserGroupPermissionsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgMoveSectionResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -607,37 +619,40 @@ func (m *MsgSetUserGroupPermissionsResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgSetUserGroupPermissionsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetUserGroupPermissionsResponse.Merge(m, src) +func (m *MsgMoveSectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMoveSectionResponse.Merge(m, src) } -func (m *MsgSetUserGroupPermissionsResponse) XXX_Size() int { +func (m *MsgMoveSectionResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetUserGroupPermissionsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetUserGroupPermissionsResponse.DiscardUnknown(m) +func (m *MsgMoveSectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMoveSectionResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetUserGroupPermissionsResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgMoveSectionResponse proto.InternalMessageInfo -// MsgDeleteUserGroup represents the message used to delete a user group -type MsgDeleteUserGroup struct { +// MsgDeleteSection represents the message to be used when deleting a section +type MsgDeleteSection struct { + // Id of the subspace inside which the section to be deleted is SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` + // Id of the section to delete + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + // User deleting the section + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -func (m *MsgDeleteUserGroup) Reset() { *m = MsgDeleteUserGroup{} } -func (m *MsgDeleteUserGroup) String() string { return proto.CompactTextString(m) } -func (*MsgDeleteUserGroup) ProtoMessage() {} -func (*MsgDeleteUserGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{12} +func (m *MsgDeleteSection) Reset() { *m = MsgDeleteSection{} } +func (m *MsgDeleteSection) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteSection) ProtoMessage() {} +func (*MsgDeleteSection) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{12} } -func (m *MsgDeleteUserGroup) XXX_Unmarshal(b []byte) error { +func (m *MsgDeleteSection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDeleteUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDeleteSection) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDeleteUserGroup.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDeleteSection.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -647,55 +662,55 @@ func (m *MsgDeleteUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgDeleteUserGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDeleteUserGroup.Merge(m, src) +func (m *MsgDeleteSection) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteSection.Merge(m, src) } -func (m *MsgDeleteUserGroup) XXX_Size() int { +func (m *MsgDeleteSection) XXX_Size() int { return m.Size() } -func (m *MsgDeleteUserGroup) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDeleteUserGroup.DiscardUnknown(m) +func (m *MsgDeleteSection) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteSection.DiscardUnknown(m) } -var xxx_messageInfo_MsgDeleteUserGroup proto.InternalMessageInfo +var xxx_messageInfo_MsgDeleteSection proto.InternalMessageInfo -func (m *MsgDeleteUserGroup) GetSubspaceID() uint64 { +func (m *MsgDeleteSection) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgDeleteUserGroup) GetGroupID() uint32 { +func (m *MsgDeleteSection) GetSectionID() uint32 { if m != nil { - return m.GroupID + return m.SectionID } return 0 } -func (m *MsgDeleteUserGroup) GetSigner() string { +func (m *MsgDeleteSection) GetSigner() string { if m != nil { return m.Signer } return "" } -// MsgDeleteUserGroupResponse defines the Msg/DeleteUserGroup response type -type MsgDeleteUserGroupResponse struct { +// MsgDeleteSectionResponse represents the Msg/DeleteSection response type +type MsgDeleteSectionResponse struct { } -func (m *MsgDeleteUserGroupResponse) Reset() { *m = MsgDeleteUserGroupResponse{} } -func (m *MsgDeleteUserGroupResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDeleteUserGroupResponse) ProtoMessage() {} -func (*MsgDeleteUserGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{13} +func (m *MsgDeleteSectionResponse) Reset() { *m = MsgDeleteSectionResponse{} } +func (m *MsgDeleteSectionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteSectionResponse) ProtoMessage() {} +func (*MsgDeleteSectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{13} } -func (m *MsgDeleteUserGroupResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgDeleteSectionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDeleteUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgDeleteSectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDeleteUserGroupResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgDeleteSectionResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -705,39 +720,46 @@ func (m *MsgDeleteUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgDeleteUserGroupResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDeleteUserGroupResponse.Merge(m, src) +func (m *MsgDeleteSectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteSectionResponse.Merge(m, src) } -func (m *MsgDeleteUserGroupResponse) XXX_Size() int { +func (m *MsgDeleteSectionResponse) XXX_Size() int { return m.Size() } -func (m *MsgDeleteUserGroupResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDeleteUserGroupResponse.DiscardUnknown(m) +func (m *MsgDeleteSectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteSectionResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgDeleteUserGroupResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgDeleteSectionResponse proto.InternalMessageInfo -// MsgAddUserToUserGroup represents the message used to add a user to a user -// group -type MsgAddUserToUserGroup struct { +// MsgCreateUserGroup represents the message used to create a user group +type MsgCreateUserGroup struct { + // Id of the subspace inside which the group will be created SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` - User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` + // (optional) Id of the section inside which the group will be created + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + // Name of the group + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // (optional) Description of the group + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // Default permissions to be applied to the group + DefaultPermissions uint32 `protobuf:"varint,5,opt,name=default_permissions,json=defaultPermissions,proto3" json:"default_permissions,omitempty" yaml:"default_permissions"` + // Creator of the group + Creator string `protobuf:"bytes,6,opt,name=creator,proto3" json:"creator,omitempty" yaml:"creator"` } -func (m *MsgAddUserToUserGroup) Reset() { *m = MsgAddUserToUserGroup{} } -func (m *MsgAddUserToUserGroup) String() string { return proto.CompactTextString(m) } -func (*MsgAddUserToUserGroup) ProtoMessage() {} -func (*MsgAddUserToUserGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{14} +func (m *MsgCreateUserGroup) Reset() { *m = MsgCreateUserGroup{} } +func (m *MsgCreateUserGroup) String() string { return proto.CompactTextString(m) } +func (*MsgCreateUserGroup) ProtoMessage() {} +func (*MsgCreateUserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{14} } -func (m *MsgAddUserToUserGroup) XXX_Unmarshal(b []byte) error { +func (m *MsgCreateUserGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddUserToUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCreateUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddUserToUserGroup.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCreateUserGroup.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -747,63 +769,77 @@ func (m *MsgAddUserToUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgAddUserToUserGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddUserToUserGroup.Merge(m, src) +func (m *MsgCreateUserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateUserGroup.Merge(m, src) } -func (m *MsgAddUserToUserGroup) XXX_Size() int { +func (m *MsgCreateUserGroup) XXX_Size() int { return m.Size() } -func (m *MsgAddUserToUserGroup) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddUserToUserGroup.DiscardUnknown(m) +func (m *MsgCreateUserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateUserGroup.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddUserToUserGroup proto.InternalMessageInfo +var xxx_messageInfo_MsgCreateUserGroup proto.InternalMessageInfo -func (m *MsgAddUserToUserGroup) GetSubspaceID() uint64 { +func (m *MsgCreateUserGroup) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgAddUserToUserGroup) GetGroupID() uint32 { +func (m *MsgCreateUserGroup) GetSectionID() uint32 { if m != nil { - return m.GroupID + return m.SectionID } return 0 } -func (m *MsgAddUserToUserGroup) GetUser() string { +func (m *MsgCreateUserGroup) GetName() string { if m != nil { - return m.User + return m.Name } return "" } -func (m *MsgAddUserToUserGroup) GetSigner() string { +func (m *MsgCreateUserGroup) GetDescription() string { if m != nil { - return m.Signer + return m.Description } return "" } -// MsgAddUserToUserGroupResponse defines the Msg/AddUserToUserGroupResponse -// response type -type MsgAddUserToUserGroupResponse struct { +func (m *MsgCreateUserGroup) GetDefaultPermissions() uint32 { + if m != nil { + return m.DefaultPermissions + } + return 0 } -func (m *MsgAddUserToUserGroupResponse) Reset() { *m = MsgAddUserToUserGroupResponse{} } -func (m *MsgAddUserToUserGroupResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddUserToUserGroupResponse) ProtoMessage() {} -func (*MsgAddUserToUserGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{15} +func (m *MsgCreateUserGroup) GetCreator() string { + if m != nil { + return m.Creator + } + return "" } -func (m *MsgAddUserToUserGroupResponse) XXX_Unmarshal(b []byte) error { + +// MsgCreateUserGroupResponse defines the Msg/CreateUserGroup response type +type MsgCreateUserGroupResponse struct { + GroupID uint32 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` +} + +func (m *MsgCreateUserGroupResponse) Reset() { *m = MsgCreateUserGroupResponse{} } +func (m *MsgCreateUserGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateUserGroupResponse) ProtoMessage() {} +func (*MsgCreateUserGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{15} +} +func (m *MsgCreateUserGroupResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddUserToUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCreateUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddUserToUserGroupResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCreateUserGroupResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -813,39 +849,51 @@ func (m *MsgAddUserToUserGroupResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *MsgAddUserToUserGroupResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddUserToUserGroupResponse.Merge(m, src) +func (m *MsgCreateUserGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateUserGroupResponse.Merge(m, src) } -func (m *MsgAddUserToUserGroupResponse) XXX_Size() int { +func (m *MsgCreateUserGroupResponse) XXX_Size() int { return m.Size() } -func (m *MsgAddUserToUserGroupResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddUserToUserGroupResponse.DiscardUnknown(m) +func (m *MsgCreateUserGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateUserGroupResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddUserToUserGroupResponse proto.InternalMessageInfo - -// MsgRemoveUserFromUserGroup represents the message used to remove a user from -// a user group -type MsgRemoveUserFromUserGroup struct { - SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` - User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` -} +var xxx_messageInfo_MsgCreateUserGroupResponse proto.InternalMessageInfo -func (m *MsgRemoveUserFromUserGroup) Reset() { *m = MsgRemoveUserFromUserGroup{} } -func (m *MsgRemoveUserFromUserGroup) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveUserFromUserGroup) ProtoMessage() {} -func (*MsgRemoveUserFromUserGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{16} +func (m *MsgCreateUserGroupResponse) GetGroupID() uint32 { + if m != nil { + return m.GroupID + } + return 0 } -func (m *MsgRemoveUserFromUserGroup) XXX_Unmarshal(b []byte) error { + +// MsgEditUserGroup represents the message used to edit a user group +type MsgEditUserGroup struct { + // Id of the subspace inside which the group to be edited is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the group to be edited + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // (optional) New name of the group + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + // (optional) New description of the group + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + // User editing the group + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` +} + +func (m *MsgEditUserGroup) Reset() { *m = MsgEditUserGroup{} } +func (m *MsgEditUserGroup) String() string { return proto.CompactTextString(m) } +func (*MsgEditUserGroup) ProtoMessage() {} +func (*MsgEditUserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{16} +} +func (m *MsgEditUserGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRemoveUserFromUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEditUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRemoveUserFromUserGroup.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEditUserGroup.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -855,63 +903,69 @@ func (m *MsgRemoveUserFromUserGroup) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgRemoveUserFromUserGroup) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveUserFromUserGroup.Merge(m, src) +func (m *MsgEditUserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditUserGroup.Merge(m, src) } -func (m *MsgRemoveUserFromUserGroup) XXX_Size() int { +func (m *MsgEditUserGroup) XXX_Size() int { return m.Size() } -func (m *MsgRemoveUserFromUserGroup) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveUserFromUserGroup.DiscardUnknown(m) +func (m *MsgEditUserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditUserGroup.DiscardUnknown(m) } -var xxx_messageInfo_MsgRemoveUserFromUserGroup proto.InternalMessageInfo +var xxx_messageInfo_MsgEditUserGroup proto.InternalMessageInfo -func (m *MsgRemoveUserFromUserGroup) GetSubspaceID() uint64 { +func (m *MsgEditUserGroup) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgRemoveUserFromUserGroup) GetGroupID() uint32 { +func (m *MsgEditUserGroup) GetGroupID() uint32 { if m != nil { return m.GroupID } return 0 } -func (m *MsgRemoveUserFromUserGroup) GetUser() string { +func (m *MsgEditUserGroup) GetName() string { if m != nil { - return m.User + return m.Name } return "" } -func (m *MsgRemoveUserFromUserGroup) GetSigner() string { +func (m *MsgEditUserGroup) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgEditUserGroup) GetSigner() string { if m != nil { return m.Signer } return "" } -// MsgRemoveUserFromUserGroupResponse defines the -// Msg/RemoveUserFromUserGroupResponse response type -type MsgRemoveUserFromUserGroupResponse struct { +// MsgEditUserGroupResponse defines the Msg/EditUserGroup response type +type MsgEditUserGroupResponse struct { } -func (m *MsgRemoveUserFromUserGroupResponse) Reset() { *m = MsgRemoveUserFromUserGroupResponse{} } -func (m *MsgRemoveUserFromUserGroupResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveUserFromUserGroupResponse) ProtoMessage() {} -func (*MsgRemoveUserFromUserGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{17} +func (m *MsgEditUserGroupResponse) Reset() { *m = MsgEditUserGroupResponse{} } +func (m *MsgEditUserGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEditUserGroupResponse) ProtoMessage() {} +func (*MsgEditUserGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{17} } -func (m *MsgRemoveUserFromUserGroupResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgEditUserGroupResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRemoveUserFromUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgEditUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRemoveUserFromUserGroupResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgEditUserGroupResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -921,39 +975,43 @@ func (m *MsgRemoveUserFromUserGroupResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgRemoveUserFromUserGroupResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveUserFromUserGroupResponse.Merge(m, src) +func (m *MsgEditUserGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditUserGroupResponse.Merge(m, src) } -func (m *MsgRemoveUserFromUserGroupResponse) XXX_Size() int { +func (m *MsgEditUserGroupResponse) XXX_Size() int { return m.Size() } -func (m *MsgRemoveUserFromUserGroupResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveUserFromUserGroupResponse.DiscardUnknown(m) +func (m *MsgEditUserGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditUserGroupResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgRemoveUserFromUserGroupResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgEditUserGroupResponse proto.InternalMessageInfo -// MsgSetUserPermissions represents the message used to set the permissions of a -// specific user -type MsgSetUserPermissions struct { - SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` - Permissions uint32 `protobuf:"varint,3,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` +// MsgMoveUserGroup represents the message used to move one user group from a +// section to anoter +type MsgMoveUserGroup struct { + // Id of the subspace inside which the group to move is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the group to be moved + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // Id of the new section where to move the group + NewSectionID uint32 `protobuf:"varint,3,opt,name=new_section_id,json=newSectionId,proto3" json:"new_section_id,omitempty" yaml:"new_section_id"` + // User signing the message + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -func (m *MsgSetUserPermissions) Reset() { *m = MsgSetUserPermissions{} } -func (m *MsgSetUserPermissions) String() string { return proto.CompactTextString(m) } -func (*MsgSetUserPermissions) ProtoMessage() {} -func (*MsgSetUserPermissions) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{18} +func (m *MsgMoveUserGroup) Reset() { *m = MsgMoveUserGroup{} } +func (m *MsgMoveUserGroup) String() string { return proto.CompactTextString(m) } +func (*MsgMoveUserGroup) ProtoMessage() {} +func (*MsgMoveUserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{18} } -func (m *MsgSetUserPermissions) XXX_Unmarshal(b []byte) error { +func (m *MsgMoveUserGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetUserPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgMoveUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetUserPermissions.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgMoveUserGroup.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -963,63 +1021,62 @@ func (m *MsgSetUserPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgSetUserPermissions) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetUserPermissions.Merge(m, src) +func (m *MsgMoveUserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMoveUserGroup.Merge(m, src) } -func (m *MsgSetUserPermissions) XXX_Size() int { +func (m *MsgMoveUserGroup) XXX_Size() int { return m.Size() } -func (m *MsgSetUserPermissions) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetUserPermissions.DiscardUnknown(m) +func (m *MsgMoveUserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMoveUserGroup.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetUserPermissions proto.InternalMessageInfo +var xxx_messageInfo_MsgMoveUserGroup proto.InternalMessageInfo -func (m *MsgSetUserPermissions) GetSubspaceID() uint64 { +func (m *MsgMoveUserGroup) GetSubspaceID() uint64 { if m != nil { return m.SubspaceID } return 0 } -func (m *MsgSetUserPermissions) GetUser() string { +func (m *MsgMoveUserGroup) GetGroupID() uint32 { if m != nil { - return m.User + return m.GroupID } - return "" + return 0 } -func (m *MsgSetUserPermissions) GetPermissions() uint32 { +func (m *MsgMoveUserGroup) GetNewSectionID() uint32 { if m != nil { - return m.Permissions + return m.NewSectionID } return 0 } -func (m *MsgSetUserPermissions) GetSigner() string { +func (m *MsgMoveUserGroup) GetSigner() string { if m != nil { return m.Signer } return "" } -// MsgSetUserPermissionsResponse defines the Msg/SetPermissionsResponse -// response type -type MsgSetUserPermissionsResponse struct { +// MsgMoveUserGroupResponse defines the Msg/MoveUserGroup response type +type MsgMoveUserGroupResponse struct { } -func (m *MsgSetUserPermissionsResponse) Reset() { *m = MsgSetUserPermissionsResponse{} } -func (m *MsgSetUserPermissionsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetUserPermissionsResponse) ProtoMessage() {} -func (*MsgSetUserPermissionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c16a431ff9a3b35b, []int{19} +func (m *MsgMoveUserGroupResponse) Reset() { *m = MsgMoveUserGroupResponse{} } +func (m *MsgMoveUserGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMoveUserGroupResponse) ProtoMessage() {} +func (*MsgMoveUserGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{19} } -func (m *MsgSetUserPermissionsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgMoveUserGroupResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetUserPermissionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgMoveUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetUserPermissionsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgMoveUserGroupResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1029,1192 +1086,1310 @@ func (m *MsgSetUserPermissionsResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *MsgSetUserPermissionsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetUserPermissionsResponse.Merge(m, src) +func (m *MsgMoveUserGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMoveUserGroupResponse.Merge(m, src) } -func (m *MsgSetUserPermissionsResponse) XXX_Size() int { +func (m *MsgMoveUserGroupResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetUserPermissionsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetUserPermissionsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSetUserPermissionsResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgCreateSubspace)(nil), "desmos.subspaces.v1.MsgCreateSubspace") - proto.RegisterType((*MsgCreateSubspaceResponse)(nil), "desmos.subspaces.v1.MsgCreateSubspaceResponse") - proto.RegisterType((*MsgEditSubspace)(nil), "desmos.subspaces.v1.MsgEditSubspace") - proto.RegisterType((*MsgEditSubspaceResponse)(nil), "desmos.subspaces.v1.MsgEditSubspaceResponse") - proto.RegisterType((*MsgDeleteSubspace)(nil), "desmos.subspaces.v1.MsgDeleteSubspace") - proto.RegisterType((*MsgDeleteSubspaceResponse)(nil), "desmos.subspaces.v1.MsgDeleteSubspaceResponse") - proto.RegisterType((*MsgCreateUserGroup)(nil), "desmos.subspaces.v1.MsgCreateUserGroup") - proto.RegisterType((*MsgCreateUserGroupResponse)(nil), "desmos.subspaces.v1.MsgCreateUserGroupResponse") - proto.RegisterType((*MsgEditUserGroup)(nil), "desmos.subspaces.v1.MsgEditUserGroup") - proto.RegisterType((*MsgEditUserGroupResponse)(nil), "desmos.subspaces.v1.MsgEditUserGroupResponse") - proto.RegisterType((*MsgSetUserGroupPermissions)(nil), "desmos.subspaces.v1.MsgSetUserGroupPermissions") - proto.RegisterType((*MsgSetUserGroupPermissionsResponse)(nil), "desmos.subspaces.v1.MsgSetUserGroupPermissionsResponse") - proto.RegisterType((*MsgDeleteUserGroup)(nil), "desmos.subspaces.v1.MsgDeleteUserGroup") - proto.RegisterType((*MsgDeleteUserGroupResponse)(nil), "desmos.subspaces.v1.MsgDeleteUserGroupResponse") - proto.RegisterType((*MsgAddUserToUserGroup)(nil), "desmos.subspaces.v1.MsgAddUserToUserGroup") - proto.RegisterType((*MsgAddUserToUserGroupResponse)(nil), "desmos.subspaces.v1.MsgAddUserToUserGroupResponse") - proto.RegisterType((*MsgRemoveUserFromUserGroup)(nil), "desmos.subspaces.v1.MsgRemoveUserFromUserGroup") - proto.RegisterType((*MsgRemoveUserFromUserGroupResponse)(nil), "desmos.subspaces.v1.MsgRemoveUserFromUserGroupResponse") - proto.RegisterType((*MsgSetUserPermissions)(nil), "desmos.subspaces.v1.MsgSetUserPermissions") - proto.RegisterType((*MsgSetUserPermissionsResponse)(nil), "desmos.subspaces.v1.MsgSetUserPermissionsResponse") -} - -func init() { proto.RegisterFile("desmos/subspaces/v1/msgs.proto", fileDescriptor_c16a431ff9a3b35b) } - -var fileDescriptor_c16a431ff9a3b35b = []byte{ - // 920 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0x4b, 0x6f, 0xe3, 0x44, - 0x1c, 0x8f, 0x9d, 0xa4, 0x0d, 0xff, 0x6c, 0x9a, 0x5d, 0x17, 0xd8, 0xac, 0x01, 0x7b, 0x35, 0x94, - 0x5d, 0x58, 0xed, 0xc6, 0xda, 0xec, 0x81, 0x65, 0x6f, 0x84, 0x2d, 0xa8, 0x12, 0x11, 0xc8, 0x05, - 0x21, 0x71, 0xa9, 0x92, 0x78, 0x70, 0x2d, 0xe2, 0x4c, 0xe4, 0x71, 0x02, 0x3d, 0xf7, 0xc2, 0x0d, - 0x3e, 0x01, 0xea, 0xd7, 0xe0, 0xc8, 0x01, 0x89, 0x63, 0x8f, 0x9c, 0x2c, 0x94, 0x5e, 0xca, 0x85, - 0x43, 0x0e, 0x9c, 0x91, 0xc7, 0xf6, 0x64, 0xf2, 0x70, 0xe2, 0xa0, 0x02, 0x85, 0x9b, 0x33, 0xff, - 0xdf, 0x3c, 0x7e, 0x8f, 0x79, 0x28, 0xa0, 0x59, 0x98, 0xba, 0x84, 0x1a, 0x74, 0xd8, 0xa1, 0x83, - 0x76, 0x17, 0x53, 0x63, 0xf4, 0xd8, 0x70, 0xa9, 0x4d, 0xeb, 0x03, 0x8f, 0xf8, 0x44, 0xd9, 0x8d, - 0xea, 0x75, 0x5e, 0xaf, 0x8f, 0x1e, 0xab, 0x2f, 0xda, 0xc4, 0x26, 0xac, 0x6e, 0x84, 0x5f, 0x11, - 0x54, 0xbd, 0xbb, 0x74, 0x28, 0x62, 0xe1, 0x5e, 0x3c, 0x18, 0x3a, 0x95, 0xe1, 0x56, 0x8b, 0xda, - 0xef, 0x79, 0xb8, 0xed, 0xe3, 0xc3, 0x18, 0xa6, 0xbc, 0x0e, 0x85, 0x7e, 0xdb, 0xc5, 0x35, 0xe9, - 0xae, 0xf4, 0xe6, 0x0b, 0xcd, 0xea, 0x24, 0xd0, 0xcb, 0x27, 0x6d, 0xb7, 0xf7, 0x0c, 0x85, 0xad, - 0xc8, 0x64, 0x45, 0xe5, 0x29, 0x94, 0x2d, 0x4c, 0xbb, 0x9e, 0x33, 0xf0, 0x1d, 0xd2, 0xaf, 0xc9, - 0x0c, 0xfb, 0xf2, 0x24, 0xd0, 0x95, 0x08, 0x2b, 0x14, 0x91, 0x29, 0x42, 0x15, 0x03, 0x4a, 0xbe, - 0x87, 0xdb, 0x74, 0xe8, 0x9d, 0xd4, 0xf2, 0xac, 0xdb, 0xee, 0x24, 0xd0, 0xab, 0x51, 0xb7, 0xa4, - 0x82, 0x4c, 0x0e, 0x52, 0xee, 0x41, 0x91, 0x7c, 0xd5, 0xc7, 0x5e, 0xad, 0xc0, 0xd0, 0x37, 0x27, - 0x81, 0x7e, 0x23, 0x42, 0xb3, 0x66, 0x64, 0x46, 0x65, 0xe5, 0x21, 0x6c, 0x77, 0x43, 0x26, 0xc4, - 0xab, 0x15, 0x19, 0x52, 0x99, 0x04, 0xfa, 0x4e, 0x84, 0x8c, 0x0b, 0xc8, 0x4c, 0x20, 0xcf, 0x4a, - 0xdf, 0x9c, 0xe9, 0xb9, 0xcb, 0x33, 0x3d, 0x87, 0x3a, 0x70, 0x67, 0x41, 0x04, 0x13, 0xd3, 0x01, - 0xe9, 0x53, 0xac, 0xec, 0x43, 0x39, 0xd1, 0xef, 0xc8, 0xb1, 0x98, 0x26, 0x85, 0xe6, 0xde, 0x38, - 0xd0, 0x21, 0x81, 0x1e, 0x3c, 0x9f, 0xb2, 0x16, 0xa0, 0xc8, 0x84, 0xe4, 0xd7, 0x81, 0x85, 0x7e, - 0x92, 0xa1, 0xda, 0xa2, 0xf6, 0xbe, 0xe5, 0xf8, 0x5c, 0xe7, 0xab, 0x19, 0x9a, 0xdb, 0x25, 0x6f, - 0x60, 0x57, 0xfe, 0xaf, 0xd9, 0x55, 0xd8, 0xc8, 0xae, 0xe2, 0x6a, 0xbb, 0xde, 0x82, 0x2d, 0xea, - 0xd8, 0x21, 0x70, 0x8b, 0x01, 0x6f, 0x4d, 0x02, 0xbd, 0x12, 0x73, 0x65, 0xed, 0xc8, 0x8c, 0x01, - 0x82, 0x57, 0x77, 0xe0, 0xf6, 0x9c, 0x8c, 0x89, 0x53, 0xe8, 0x5b, 0x89, 0x85, 0xf9, 0x39, 0xee, - 0x61, 0x21, 0xcc, 0x57, 0x24, 0xf2, 0x74, 0xb1, 0x72, 0xf6, 0xc5, 0xbe, 0xc2, 0x82, 0x35, 0xbb, - 0x20, 0xbe, 0xdc, 0x1f, 0x64, 0x50, 0x78, 0xec, 0x3e, 0xa5, 0xd8, 0xfb, 0xc0, 0x23, 0xc3, 0xc1, - 0x7f, 0x24, 0x14, 0x1f, 0xc1, 0xae, 0x85, 0xbf, 0x68, 0x0f, 0x7b, 0xfe, 0xd1, 0x00, 0x7b, 0xae, - 0x43, 0xa9, 0x43, 0xfa, 0x94, 0xe5, 0xa3, 0xd2, 0xd4, 0x26, 0x81, 0xae, 0x26, 0x23, 0x2c, 0x80, - 0x90, 0xa9, 0xc4, 0xad, 0x1f, 0x4f, 0x1b, 0x37, 0xdb, 0xbb, 0xe8, 0x33, 0x50, 0x17, 0xa5, 0xe3, - 0x5b, 0xf6, 0x1d, 0x28, 0xd9, 0x61, 0x43, 0xa2, 0x5f, 0xa5, 0xa9, 0x8d, 0x03, 0x7d, 0x9b, 0x81, - 0x98, 0x78, 0x71, 0x78, 0x13, 0x10, 0x32, 0xb7, 0xd9, 0xe7, 0x81, 0x85, 0xbe, 0x97, 0xe1, 0x66, - 0x9c, 0xaf, 0x2b, 0xb7, 0x44, 0x5c, 0x96, 0xbc, 0xd1, 0xb2, 0xb8, 0x9b, 0xf9, 0x0d, 0xdc, 0x2c, - 0x64, 0x77, 0x73, 0x1a, 0xee, 0xe2, 0x9a, 0x70, 0x23, 0x15, 0x6a, 0xf3, 0xfa, 0xf0, 0x44, 0x9f, - 0xca, 0xcc, 0x96, 0x43, 0x3c, 0xad, 0x89, 0x16, 0xff, 0xfb, 0x32, 0x3e, 0x85, 0xb2, 0x98, 0xd6, - 0x3c, 0xeb, 0x2d, 0x28, 0x34, 0x93, 0x52, 0x11, 0x2a, 0x28, 0x54, 0x58, 0xa7, 0xd0, 0x1e, 0xa0, - 0x74, 0x11, 0xb8, 0x56, 0x3f, 0x4a, 0x6c, 0xf7, 0x47, 0x67, 0xc3, 0x75, 0x8a, 0xda, 0x94, 0x69, - 0x7e, 0x1d, 0xd3, 0x57, 0x99, 0xdd, 0x73, 0x14, 0x38, 0xc3, 0xdf, 0x24, 0x78, 0xa9, 0x45, 0xed, - 0x77, 0x2d, 0x2b, 0xac, 0x7d, 0x42, 0xae, 0xd9, 0x7e, 0x1a, 0x52, 0x4e, 0x51, 0xd8, 0x4f, 0x61, - 0x2b, 0x32, 0x59, 0x71, 0x13, 0xcf, 0x75, 0x78, 0x6d, 0x29, 0x55, 0x2e, 0xc6, 0xef, 0x12, 0xd3, - 0xca, 0xc4, 0x2e, 0x19, 0x31, 0xad, 0xde, 0xf7, 0x88, 0xfb, 0x7f, 0x56, 0x24, 0xda, 0x05, 0x29, - 0x7c, 0xb9, 0x2c, 0x97, 0x51, 0x46, 0xe2, 0xcd, 0xf2, 0x37, 0x1c, 0x16, 0x09, 0x2d, 0x79, 0x15, - 0xad, 0x7f, 0xe4, 0x58, 0x88, 0x22, 0xb2, 0xc8, 0x34, 0xd1, 0xa2, 0xf1, 0x47, 0x09, 0xf2, 0x2d, - 0x6a, 0x2b, 0xc7, 0xb0, 0x33, 0xf7, 0x1e, 0xbf, 0x57, 0x5f, 0xf2, 0xe6, 0xaf, 0x2f, 0x3c, 0x59, - 0xd5, 0x7a, 0x36, 0x1c, 0xbf, 0x27, 0x3b, 0x70, 0x63, 0xe6, 0x3d, 0xba, 0x97, 0xd6, 0x5f, 0x44, - 0xa9, 0x0f, 0xb3, 0xa0, 0xf8, 0x1c, 0xc7, 0xb0, 0x33, 0xf7, 0x20, 0x4b, 0x65, 0x33, 0x8b, 0x4b, - 0x67, 0xb3, 0xfc, 0x3d, 0xa5, 0x7c, 0x09, 0xd5, 0xf9, 0xb7, 0xd4, 0xfd, 0xd5, 0x82, 0x70, 0xa0, - 0x6a, 0x64, 0x04, 0xf2, 0xc9, 0x30, 0x54, 0x66, 0xdf, 0x08, 0x6f, 0xac, 0x52, 0x65, 0x3a, 0xd1, - 0xa3, 0x4c, 0x30, 0x3e, 0xcd, 0xa9, 0x04, 0xb7, 0xd3, 0xae, 0xd3, 0xd4, 0x35, 0xa7, 0x74, 0x50, - 0xdf, 0xde, 0xb0, 0x83, 0xa8, 0xec, 0xfc, 0x3d, 0x75, 0x7f, 0xb5, 0x39, 0x19, 0x94, 0x4d, 0xb9, - 0x36, 0x14, 0x1f, 0x94, 0x25, 0x57, 0xc6, 0x83, 0xb4, 0x61, 0x16, 0xb1, 0x6a, 0x23, 0x3b, 0x76, - 0x46, 0xe8, 0xb4, 0xc3, 0x39, 0x95, 0x42, 0x4a, 0x87, 0x74, 0xa1, 0xd7, 0x1c, 0x87, 0x21, 0xf7, - 0x25, 0x47, 0xe1, 0x83, 0x35, 0xbe, 0x89, 0x1e, 0x37, 0xb2, 0x63, 0x93, 0x59, 0x9b, 0x1f, 0xfe, - 0x3c, 0xd6, 0xa4, 0xf3, 0xb1, 0x26, 0xfd, 0x3a, 0xd6, 0xa4, 0xef, 0x2e, 0xb4, 0xdc, 0xf9, 0x85, - 0x96, 0xfb, 0xe5, 0x42, 0xcb, 0x7d, 0xde, 0xb0, 0x1d, 0xff, 0x78, 0xd8, 0xa9, 0x77, 0x89, 0x6b, - 0x44, 0xe3, 0x3e, 0xea, 0xb5, 0x3b, 0x34, 0xfe, 0x36, 0x46, 0x4f, 0x8c, 0xaf, 0x85, 0x3f, 0x17, - 0xfc, 0x93, 0x01, 0xa6, 0x9d, 0x2d, 0xf6, 0xcf, 0xc2, 0x93, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, - 0x07, 0x7e, 0x40, 0x3d, 0xc8, 0x10, 0x00, 0x00, +func (m *MsgMoveUserGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMoveUserGroupResponse.DiscardUnknown(m) } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +var xxx_messageInfo_MsgMoveUserGroupResponse proto.InternalMessageInfo -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // CreateSubspace allows to create a subspace - CreateSubspace(ctx context.Context, in *MsgCreateSubspace, opts ...grpc.CallOption) (*MsgCreateSubspaceResponse, error) - // EditSubspace allows to edit a subspace - EditSubspace(ctx context.Context, in *MsgEditSubspace, opts ...grpc.CallOption) (*MsgEditSubspaceResponse, error) - // DeleteSubspace allows to delete a subspace - DeleteSubspace(ctx context.Context, in *MsgDeleteSubspace, opts ...grpc.CallOption) (*MsgDeleteSubspaceResponse, error) - // CreateUserGroup allows to create a user group - CreateUserGroup(ctx context.Context, in *MsgCreateUserGroup, opts ...grpc.CallOption) (*MsgCreateUserGroupResponse, error) - // EditUserGroup allows to edit a user group - EditUserGroup(ctx context.Context, in *MsgEditUserGroup, opts ...grpc.CallOption) (*MsgEditUserGroupResponse, error) - // SetUserGroupPermissions allows to set the permissions for a specific group - SetUserGroupPermissions(ctx context.Context, in *MsgSetUserGroupPermissions, opts ...grpc.CallOption) (*MsgSetUserGroupPermissionsResponse, error) - // DeleteUserGroup allows to delete an existing user group - DeleteUserGroup(ctx context.Context, in *MsgDeleteUserGroup, opts ...grpc.CallOption) (*MsgDeleteUserGroupResponse, error) - // AddUserToUserGroup allows to add a specific user to a specific user group - AddUserToUserGroup(ctx context.Context, in *MsgAddUserToUserGroup, opts ...grpc.CallOption) (*MsgAddUserToUserGroupResponse, error) - // RemoveUserFromUserGroup allows to remove a specific user from a specific - // user group - RemoveUserFromUserGroup(ctx context.Context, in *MsgRemoveUserFromUserGroup, opts ...grpc.CallOption) (*MsgRemoveUserFromUserGroupResponse, error) - // SetUserPermissions allows to set the permissions for a specific user - SetUserPermissions(ctx context.Context, in *MsgSetUserPermissions, opts ...grpc.CallOption) (*MsgSetUserPermissionsResponse, error) +// MsgSetUserGroupPermissions represents the message used to set the permissions +// of a user group +type MsgSetUserGroupPermissions struct { + // Id of the subspace inside which the group is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the group for which to set the new permissions + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // New permissions to be set to the group + Permissions uint32 `protobuf:"varint,3,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` + // User setting the new permissions + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -type msgClient struct { - cc grpc1.ClientConn +func (m *MsgSetUserGroupPermissions) Reset() { *m = MsgSetUserGroupPermissions{} } +func (m *MsgSetUserGroupPermissions) String() string { return proto.CompactTextString(m) } +func (*MsgSetUserGroupPermissions) ProtoMessage() {} +func (*MsgSetUserGroupPermissions) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{20} } - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} +func (m *MsgSetUserGroupPermissions) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (c *msgClient) CreateSubspace(ctx context.Context, in *MsgCreateSubspace, opts ...grpc.CallOption) (*MsgCreateSubspaceResponse, error) { - out := new(MsgCreateSubspaceResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/CreateSubspace", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgSetUserGroupPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetUserGroupPermissions.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgSetUserGroupPermissions) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetUserGroupPermissions.Merge(m, src) +} +func (m *MsgSetUserGroupPermissions) XXX_Size() int { + return m.Size() +} +func (m *MsgSetUserGroupPermissions) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetUserGroupPermissions.DiscardUnknown(m) } -func (c *msgClient) EditSubspace(ctx context.Context, in *MsgEditSubspace, opts ...grpc.CallOption) (*MsgEditSubspaceResponse, error) { - out := new(MsgEditSubspaceResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/EditSubspace", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgSetUserGroupPermissions proto.InternalMessageInfo + +func (m *MsgSetUserGroupPermissions) GetSubspaceID() uint64 { + if m != nil { + return m.SubspaceID } - return out, nil + return 0 } -func (c *msgClient) DeleteSubspace(ctx context.Context, in *MsgDeleteSubspace, opts ...grpc.CallOption) (*MsgDeleteSubspaceResponse, error) { - out := new(MsgDeleteSubspaceResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/DeleteSubspace", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgSetUserGroupPermissions) GetGroupID() uint32 { + if m != nil { + return m.GroupID } - return out, nil + return 0 } -func (c *msgClient) CreateUserGroup(ctx context.Context, in *MsgCreateUserGroup, opts ...grpc.CallOption) (*MsgCreateUserGroupResponse, error) { - out := new(MsgCreateUserGroupResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/CreateUserGroup", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgSetUserGroupPermissions) GetPermissions() uint32 { + if m != nil { + return m.Permissions } - return out, nil + return 0 } -func (c *msgClient) EditUserGroup(ctx context.Context, in *MsgEditUserGroup, opts ...grpc.CallOption) (*MsgEditUserGroupResponse, error) { - out := new(MsgEditUserGroupResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/EditUserGroup", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgSetUserGroupPermissions) GetSigner() string { + if m != nil { + return m.Signer } - return out, nil + return "" } -func (c *msgClient) SetUserGroupPermissions(ctx context.Context, in *MsgSetUserGroupPermissions, opts ...grpc.CallOption) (*MsgSetUserGroupPermissionsResponse, error) { - out := new(MsgSetUserGroupPermissionsResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/SetUserGroupPermissions", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// MsgSetUserGroupPermissionsResponse defines the +// Msg/SetUserGroupPermissionsResponse response type +type MsgSetUserGroupPermissionsResponse struct { } -func (c *msgClient) DeleteUserGroup(ctx context.Context, in *MsgDeleteUserGroup, opts ...grpc.CallOption) (*MsgDeleteUserGroupResponse, error) { - out := new(MsgDeleteUserGroupResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/DeleteUserGroup", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgSetUserGroupPermissionsResponse) Reset() { *m = MsgSetUserGroupPermissionsResponse{} } +func (m *MsgSetUserGroupPermissionsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetUserGroupPermissionsResponse) ProtoMessage() {} +func (*MsgSetUserGroupPermissionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{21} +} +func (m *MsgSetUserGroupPermissionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetUserGroupPermissionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetUserGroupPermissionsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgSetUserGroupPermissionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetUserGroupPermissionsResponse.Merge(m, src) +} +func (m *MsgSetUserGroupPermissionsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetUserGroupPermissionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetUserGroupPermissionsResponse.DiscardUnknown(m) } -func (c *msgClient) AddUserToUserGroup(ctx context.Context, in *MsgAddUserToUserGroup, opts ...grpc.CallOption) (*MsgAddUserToUserGroupResponse, error) { - out := new(MsgAddUserToUserGroupResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/AddUserToUserGroup", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgSetUserGroupPermissionsResponse proto.InternalMessageInfo + +// MsgDeleteUserGroup represents the message used to delete a user group +type MsgDeleteUserGroup struct { + // Id of the subspace inside which the group to delete is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the group to be deleted + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // User deleting the group + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` +} + +func (m *MsgDeleteUserGroup) Reset() { *m = MsgDeleteUserGroup{} } +func (m *MsgDeleteUserGroup) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteUserGroup) ProtoMessage() {} +func (*MsgDeleteUserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{22} +} +func (m *MsgDeleteUserGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDeleteUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteUserGroup.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *MsgDeleteUserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteUserGroup.Merge(m, src) +} +func (m *MsgDeleteUserGroup) XXX_Size() int { + return m.Size() +} +func (m *MsgDeleteUserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteUserGroup.DiscardUnknown(m) } -func (c *msgClient) RemoveUserFromUserGroup(ctx context.Context, in *MsgRemoveUserFromUserGroup, opts ...grpc.CallOption) (*MsgRemoveUserFromUserGroupResponse, error) { - out := new(MsgRemoveUserFromUserGroupResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/RemoveUserFromUserGroup", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgDeleteUserGroup proto.InternalMessageInfo + +func (m *MsgDeleteUserGroup) GetSubspaceID() uint64 { + if m != nil { + return m.SubspaceID } - return out, nil + return 0 } -func (c *msgClient) SetUserPermissions(ctx context.Context, in *MsgSetUserPermissions, opts ...grpc.CallOption) (*MsgSetUserPermissionsResponse, error) { - out := new(MsgSetUserPermissionsResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Msg/SetUserPermissions", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgDeleteUserGroup) GetGroupID() uint32 { + if m != nil { + return m.GroupID } - return out, nil + return 0 } -// MsgServer is the server API for Msg service. -type MsgServer interface { - // CreateSubspace allows to create a subspace - CreateSubspace(context.Context, *MsgCreateSubspace) (*MsgCreateSubspaceResponse, error) - // EditSubspace allows to edit a subspace - EditSubspace(context.Context, *MsgEditSubspace) (*MsgEditSubspaceResponse, error) - // DeleteSubspace allows to delete a subspace - DeleteSubspace(context.Context, *MsgDeleteSubspace) (*MsgDeleteSubspaceResponse, error) - // CreateUserGroup allows to create a user group - CreateUserGroup(context.Context, *MsgCreateUserGroup) (*MsgCreateUserGroupResponse, error) - // EditUserGroup allows to edit a user group - EditUserGroup(context.Context, *MsgEditUserGroup) (*MsgEditUserGroupResponse, error) - // SetUserGroupPermissions allows to set the permissions for a specific group - SetUserGroupPermissions(context.Context, *MsgSetUserGroupPermissions) (*MsgSetUserGroupPermissionsResponse, error) - // DeleteUserGroup allows to delete an existing user group - DeleteUserGroup(context.Context, *MsgDeleteUserGroup) (*MsgDeleteUserGroupResponse, error) - // AddUserToUserGroup allows to add a specific user to a specific user group - AddUserToUserGroup(context.Context, *MsgAddUserToUserGroup) (*MsgAddUserToUserGroupResponse, error) - // RemoveUserFromUserGroup allows to remove a specific user from a specific - // user group - RemoveUserFromUserGroup(context.Context, *MsgRemoveUserFromUserGroup) (*MsgRemoveUserFromUserGroupResponse, error) - // SetUserPermissions allows to set the permissions for a specific user - SetUserPermissions(context.Context, *MsgSetUserPermissions) (*MsgSetUserPermissionsResponse, error) +func (m *MsgDeleteUserGroup) GetSigner() string { + if m != nil { + return m.Signer + } + return "" } -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { +// MsgDeleteUserGroupResponse defines the Msg/DeleteUserGroup response type +type MsgDeleteUserGroupResponse struct { } -func (*UnimplementedMsgServer) CreateSubspace(ctx context.Context, req *MsgCreateSubspace) (*MsgCreateSubspaceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateSubspace not implemented") +func (m *MsgDeleteUserGroupResponse) Reset() { *m = MsgDeleteUserGroupResponse{} } +func (m *MsgDeleteUserGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDeleteUserGroupResponse) ProtoMessage() {} +func (*MsgDeleteUserGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{23} } -func (*UnimplementedMsgServer) EditSubspace(ctx context.Context, req *MsgEditSubspace) (*MsgEditSubspaceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EditSubspace not implemented") +func (m *MsgDeleteUserGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedMsgServer) DeleteSubspace(ctx context.Context, req *MsgDeleteSubspace) (*MsgDeleteSubspaceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteSubspace not implemented") +func (m *MsgDeleteUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDeleteUserGroupResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } -func (*UnimplementedMsgServer) CreateUserGroup(ctx context.Context, req *MsgCreateUserGroup) (*MsgCreateUserGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateUserGroup not implemented") +func (m *MsgDeleteUserGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDeleteUserGroupResponse.Merge(m, src) } -func (*UnimplementedMsgServer) EditUserGroup(ctx context.Context, req *MsgEditUserGroup) (*MsgEditUserGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EditUserGroup not implemented") +func (m *MsgDeleteUserGroupResponse) XXX_Size() int { + return m.Size() } -func (*UnimplementedMsgServer) SetUserGroupPermissions(ctx context.Context, req *MsgSetUserGroupPermissions) (*MsgSetUserGroupPermissionsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetUserGroupPermissions not implemented") +func (m *MsgDeleteUserGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDeleteUserGroupResponse.DiscardUnknown(m) } -func (*UnimplementedMsgServer) DeleteUserGroup(ctx context.Context, req *MsgDeleteUserGroup) (*MsgDeleteUserGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteUserGroup not implemented") + +var xxx_messageInfo_MsgDeleteUserGroupResponse proto.InternalMessageInfo + +// MsgAddUserToUserGroup represents the message used to add a user to a user +// group +type MsgAddUserToUserGroup struct { + // Id of the subspace inside which the group is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the group to which to add the user + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // User to be added to the group + User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` + // User signing the message + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -func (*UnimplementedMsgServer) AddUserToUserGroup(ctx context.Context, req *MsgAddUserToUserGroup) (*MsgAddUserToUserGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddUserToUserGroup not implemented") + +func (m *MsgAddUserToUserGroup) Reset() { *m = MsgAddUserToUserGroup{} } +func (m *MsgAddUserToUserGroup) String() string { return proto.CompactTextString(m) } +func (*MsgAddUserToUserGroup) ProtoMessage() {} +func (*MsgAddUserToUserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{24} } -func (*UnimplementedMsgServer) RemoveUserFromUserGroup(ctx context.Context, req *MsgRemoveUserFromUserGroup) (*MsgRemoveUserFromUserGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveUserFromUserGroup not implemented") +func (m *MsgAddUserToUserGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedMsgServer) SetUserPermissions(ctx context.Context, req *MsgSetUserPermissions) (*MsgSetUserPermissionsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetUserPermissions not implemented") +func (m *MsgAddUserToUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddUserToUserGroup.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) +func (m *MsgAddUserToUserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddUserToUserGroup.Merge(m, src) +} +func (m *MsgAddUserToUserGroup) XXX_Size() int { + return m.Size() +} +func (m *MsgAddUserToUserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddUserToUserGroup.DiscardUnknown(m) } -func _Msg_CreateSubspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateSubspace) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateSubspace(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/CreateSubspace", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateSubspace(ctx, req.(*MsgCreateSubspace)) +var xxx_messageInfo_MsgAddUserToUserGroup proto.InternalMessageInfo + +func (m *MsgAddUserToUserGroup) GetSubspaceID() uint64 { + if m != nil { + return m.SubspaceID } - return interceptor(ctx, in, info, handler) + return 0 } -func _Msg_EditSubspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgEditSubspace) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).EditSubspace(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/EditSubspace", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).EditSubspace(ctx, req.(*MsgEditSubspace)) +func (m *MsgAddUserToUserGroup) GetGroupID() uint32 { + if m != nil { + return m.GroupID } - return interceptor(ctx, in, info, handler) + return 0 } -func _Msg_DeleteSubspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDeleteSubspace) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).DeleteSubspace(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/DeleteSubspace", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DeleteSubspace(ctx, req.(*MsgDeleteSubspace)) +func (m *MsgAddUserToUserGroup) GetUser() string { + if m != nil { + return m.User } - return interceptor(ctx, in, info, handler) + return "" } -func _Msg_CreateUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateUserGroup) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateUserGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/CreateUserGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateUserGroup(ctx, req.(*MsgCreateUserGroup)) +func (m *MsgAddUserToUserGroup) GetSigner() string { + if m != nil { + return m.Signer } - return interceptor(ctx, in, info, handler) + return "" } -func _Msg_EditUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgEditUserGroup) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).EditUserGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/EditUserGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).EditUserGroup(ctx, req.(*MsgEditUserGroup)) - } - return interceptor(ctx, in, info, handler) +// MsgAddUserToUserGroupResponse defines the Msg/AddUserToUserGroupResponse +// response type +type MsgAddUserToUserGroupResponse struct { } -func _Msg_SetUserGroupPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetUserGroupPermissions) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetUserGroupPermissions(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/SetUserGroupPermissions", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetUserGroupPermissions(ctx, req.(*MsgSetUserGroupPermissions)) +func (m *MsgAddUserToUserGroupResponse) Reset() { *m = MsgAddUserToUserGroupResponse{} } +func (m *MsgAddUserToUserGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddUserToUserGroupResponse) ProtoMessage() {} +func (*MsgAddUserToUserGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{25} +} +func (m *MsgAddUserToUserGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddUserToUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddUserToUserGroupResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *MsgAddUserToUserGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddUserToUserGroupResponse.Merge(m, src) +} +func (m *MsgAddUserToUserGroupResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddUserToUserGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddUserToUserGroupResponse.DiscardUnknown(m) } -func _Msg_DeleteUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDeleteUserGroup) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).DeleteUserGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/DeleteUserGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DeleteUserGroup(ctx, req.(*MsgDeleteUserGroup)) - } - return interceptor(ctx, in, info, handler) +var xxx_messageInfo_MsgAddUserToUserGroupResponse proto.InternalMessageInfo + +// MsgRemoveUserFromUserGroup represents the message used to remove a user from +// a user group +type MsgRemoveUserFromUserGroup struct { + // Id of the subspace inside which the group to remove the user from is + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the group from which to remove the user + GroupID uint32 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // User to be removed from the group + User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` + // User signing the message + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -func _Msg_AddUserToUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddUserToUserGroup) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).AddUserToUserGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/AddUserToUserGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddUserToUserGroup(ctx, req.(*MsgAddUserToUserGroup)) +func (m *MsgRemoveUserFromUserGroup) Reset() { *m = MsgRemoveUserFromUserGroup{} } +func (m *MsgRemoveUserFromUserGroup) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveUserFromUserGroup) ProtoMessage() {} +func (*MsgRemoveUserFromUserGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{26} +} +func (m *MsgRemoveUserFromUserGroup) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveUserFromUserGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveUserFromUserGroup.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *MsgRemoveUserFromUserGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveUserFromUserGroup.Merge(m, src) +} +func (m *MsgRemoveUserFromUserGroup) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveUserFromUserGroup) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveUserFromUserGroup.DiscardUnknown(m) } -func _Msg_RemoveUserFromUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRemoveUserFromUserGroup) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RemoveUserFromUserGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/RemoveUserFromUserGroup", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RemoveUserFromUserGroup(ctx, req.(*MsgRemoveUserFromUserGroup)) +var xxx_messageInfo_MsgRemoveUserFromUserGroup proto.InternalMessageInfo + +func (m *MsgRemoveUserFromUserGroup) GetSubspaceID() uint64 { + if m != nil { + return m.SubspaceID } - return interceptor(ctx, in, info, handler) + return 0 } -func _Msg_SetUserPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetUserPermissions) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetUserPermissions(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/desmos.subspaces.v1.Msg/SetUserPermissions", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetUserPermissions(ctx, req.(*MsgSetUserPermissions)) +func (m *MsgRemoveUserFromUserGroup) GetGroupID() uint32 { + if m != nil { + return m.GroupID } - return interceptor(ctx, in, info, handler) + return 0 } -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "desmos.subspaces.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateSubspace", - Handler: _Msg_CreateSubspace_Handler, - }, - { - MethodName: "EditSubspace", - Handler: _Msg_EditSubspace_Handler, - }, - { - MethodName: "DeleteSubspace", - Handler: _Msg_DeleteSubspace_Handler, - }, - { - MethodName: "CreateUserGroup", - Handler: _Msg_CreateUserGroup_Handler, - }, - { - MethodName: "EditUserGroup", - Handler: _Msg_EditUserGroup_Handler, - }, - { - MethodName: "SetUserGroupPermissions", - Handler: _Msg_SetUserGroupPermissions_Handler, - }, - { - MethodName: "DeleteUserGroup", - Handler: _Msg_DeleteUserGroup_Handler, - }, - { - MethodName: "AddUserToUserGroup", - Handler: _Msg_AddUserToUserGroup_Handler, - }, - { - MethodName: "RemoveUserFromUserGroup", - Handler: _Msg_RemoveUserFromUserGroup_Handler, - }, - { - MethodName: "SetUserPermissions", - Handler: _Msg_SetUserPermissions_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "desmos/subspaces/v1/msgs.proto", +func (m *MsgRemoveUserFromUserGroup) GetUser() string { + if m != nil { + return m.User + } + return "" } -func (m *MsgCreateSubspace) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgRemoveUserFromUserGroup) GetSigner() string { + if m != nil { + return m.Signer } - return dAtA[:n], nil + return "" } -func (m *MsgCreateSubspace) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// MsgRemoveUserFromUserGroupResponse defines the +// Msg/RemoveUserFromUserGroupResponse response type +type MsgRemoveUserFromUserGroupResponse struct { } -func (m *MsgCreateSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0x2a - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x22 - } - if len(m.Treasury) > 0 { - i -= len(m.Treasury) - copy(dAtA[i:], m.Treasury) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Treasury))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +func (m *MsgRemoveUserFromUserGroupResponse) Reset() { *m = MsgRemoveUserFromUserGroupResponse{} } +func (m *MsgRemoveUserFromUserGroupResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveUserFromUserGroupResponse) ProtoMessage() {} +func (*MsgRemoveUserFromUserGroupResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{27} } - -func (m *MsgCreateSubspaceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgRemoveUserFromUserGroupResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveUserFromUserGroupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveUserFromUserGroupResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *MsgCreateSubspaceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgRemoveUserFromUserGroupResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveUserFromUserGroupResponse.Merge(m, src) } - -func (m *MsgCreateSubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil +func (m *MsgRemoveUserFromUserGroupResponse) XXX_Size() int { + return m.Size() } - -func (m *MsgEditSubspace) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil +func (m *MsgRemoveUserFromUserGroupResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveUserFromUserGroupResponse.DiscardUnknown(m) } -func (m *MsgEditSubspace) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} +var xxx_messageInfo_MsgRemoveUserFromUserGroupResponse proto.InternalMessageInfo -func (m *MsgEditSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x32 - } - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x2a - } - if len(m.Treasury) > 0 { - i -= len(m.Treasury) - copy(dAtA[i:], m.Treasury) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Treasury))) - i-- - dAtA[i] = 0x22 - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x1a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil +// MsgSetUserPermissions represents the message used to set the permissions of a +// specific user +type MsgSetUserPermissions struct { + // Id of the subspace inside which to set the permissions + SubspaceID uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // Id of the section for which to set the permissions + SectionID uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + // User for which to set the permissions + User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` + // Permissions to be set to the user + Permissions uint32 `protobuf:"varint,4,opt,name=permissions,proto3" json:"permissions,omitempty" yaml:"permissions"` + // User signing the message + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty" yaml:"signer"` } -func (m *MsgEditSubspaceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgSetUserPermissions) Reset() { *m = MsgSetUserPermissions{} } +func (m *MsgSetUserPermissions) String() string { return proto.CompactTextString(m) } +func (*MsgSetUserPermissions) ProtoMessage() {} +func (*MsgSetUserPermissions) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{28} +} +func (m *MsgSetUserPermissions) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetUserPermissions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetUserPermissions.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *MsgEditSubspaceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgSetUserPermissions) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetUserPermissions.Merge(m, src) } - -func (m *MsgEditSubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (m *MsgSetUserPermissions) XXX_Size() int { + return m.Size() } - -func (m *MsgDeleteSubspace) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil +func (m *MsgSetUserPermissions) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetUserPermissions.DiscardUnknown(m) } -func (m *MsgDeleteSubspace) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} +var xxx_messageInfo_MsgSetUserPermissions proto.InternalMessageInfo -func (m *MsgDeleteSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x12 - } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 +func (m *MsgSetUserPermissions) GetSubspaceID() uint64 { + if m != nil { + return m.SubspaceID } - return len(dAtA) - i, nil + return 0 } -func (m *MsgDeleteSubspaceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgSetUserPermissions) GetSectionID() uint32 { + if m != nil { + return m.SectionID } - return dAtA[:n], nil + return 0 } -func (m *MsgDeleteSubspaceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgSetUserPermissions) GetUser() string { + if m != nil { + return m.User + } + return "" } -func (m *MsgDeleteSubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (m *MsgSetUserPermissions) GetPermissions() uint32 { + if m != nil { + return m.Permissions + } + return 0 } -func (m *MsgCreateUserGroup) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *MsgSetUserPermissions) GetSigner() string { + if m != nil { + return m.Signer } - return dAtA[:n], nil + return "" } -func (m *MsgCreateUserGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// MsgSetUserPermissionsResponse defines the Msg/SetPermissionsResponse +// response type +type MsgSetUserPermissionsResponse struct { } -func (m *MsgCreateUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0x2a - } - if m.DefaultPermissions != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.DefaultPermissions)) - i-- - dAtA[i] = 0x20 - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x1a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 +func (m *MsgSetUserPermissionsResponse) Reset() { *m = MsgSetUserPermissionsResponse{} } +func (m *MsgSetUserPermissionsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetUserPermissionsResponse) ProtoMessage() {} +func (*MsgSetUserPermissionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d549e2340fbe3f45, []int{29} +} +func (m *MsgSetUserPermissionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetUserPermissionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetUserPermissionsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return len(dAtA) - i, nil +} +func (m *MsgSetUserPermissionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetUserPermissionsResponse.Merge(m, src) +} +func (m *MsgSetUserPermissionsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetUserPermissionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetUserPermissionsResponse.DiscardUnknown(m) } -func (m *MsgCreateUserGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +var xxx_messageInfo_MsgSetUserPermissionsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateSubspace)(nil), "desmos.subspaces.v2.MsgCreateSubspace") + proto.RegisterType((*MsgCreateSubspaceResponse)(nil), "desmos.subspaces.v2.MsgCreateSubspaceResponse") + proto.RegisterType((*MsgEditSubspace)(nil), "desmos.subspaces.v2.MsgEditSubspace") + proto.RegisterType((*MsgEditSubspaceResponse)(nil), "desmos.subspaces.v2.MsgEditSubspaceResponse") + proto.RegisterType((*MsgDeleteSubspace)(nil), "desmos.subspaces.v2.MsgDeleteSubspace") + proto.RegisterType((*MsgDeleteSubspaceResponse)(nil), "desmos.subspaces.v2.MsgDeleteSubspaceResponse") + proto.RegisterType((*MsgCreateSection)(nil), "desmos.subspaces.v2.MsgCreateSection") + proto.RegisterType((*MsgCreateSectionResponse)(nil), "desmos.subspaces.v2.MsgCreateSectionResponse") + proto.RegisterType((*MsgEditSection)(nil), "desmos.subspaces.v2.MsgEditSection") + proto.RegisterType((*MsgEditSectionResponse)(nil), "desmos.subspaces.v2.MsgEditSectionResponse") + proto.RegisterType((*MsgMoveSection)(nil), "desmos.subspaces.v2.MsgMoveSection") + proto.RegisterType((*MsgMoveSectionResponse)(nil), "desmos.subspaces.v2.MsgMoveSectionResponse") + proto.RegisterType((*MsgDeleteSection)(nil), "desmos.subspaces.v2.MsgDeleteSection") + proto.RegisterType((*MsgDeleteSectionResponse)(nil), "desmos.subspaces.v2.MsgDeleteSectionResponse") + proto.RegisterType((*MsgCreateUserGroup)(nil), "desmos.subspaces.v2.MsgCreateUserGroup") + proto.RegisterType((*MsgCreateUserGroupResponse)(nil), "desmos.subspaces.v2.MsgCreateUserGroupResponse") + proto.RegisterType((*MsgEditUserGroup)(nil), "desmos.subspaces.v2.MsgEditUserGroup") + proto.RegisterType((*MsgEditUserGroupResponse)(nil), "desmos.subspaces.v2.MsgEditUserGroupResponse") + proto.RegisterType((*MsgMoveUserGroup)(nil), "desmos.subspaces.v2.MsgMoveUserGroup") + proto.RegisterType((*MsgMoveUserGroupResponse)(nil), "desmos.subspaces.v2.MsgMoveUserGroupResponse") + proto.RegisterType((*MsgSetUserGroupPermissions)(nil), "desmos.subspaces.v2.MsgSetUserGroupPermissions") + proto.RegisterType((*MsgSetUserGroupPermissionsResponse)(nil), "desmos.subspaces.v2.MsgSetUserGroupPermissionsResponse") + proto.RegisterType((*MsgDeleteUserGroup)(nil), "desmos.subspaces.v2.MsgDeleteUserGroup") + proto.RegisterType((*MsgDeleteUserGroupResponse)(nil), "desmos.subspaces.v2.MsgDeleteUserGroupResponse") + proto.RegisterType((*MsgAddUserToUserGroup)(nil), "desmos.subspaces.v2.MsgAddUserToUserGroup") + proto.RegisterType((*MsgAddUserToUserGroupResponse)(nil), "desmos.subspaces.v2.MsgAddUserToUserGroupResponse") + proto.RegisterType((*MsgRemoveUserFromUserGroup)(nil), "desmos.subspaces.v2.MsgRemoveUserFromUserGroup") + proto.RegisterType((*MsgRemoveUserFromUserGroupResponse)(nil), "desmos.subspaces.v2.MsgRemoveUserFromUserGroupResponse") + proto.RegisterType((*MsgSetUserPermissions)(nil), "desmos.subspaces.v2.MsgSetUserPermissions") + proto.RegisterType((*MsgSetUserPermissionsResponse)(nil), "desmos.subspaces.v2.MsgSetUserPermissionsResponse") +} + +func init() { proto.RegisterFile("desmos/subspaces/v2/msgs.proto", fileDescriptor_d549e2340fbe3f45) } + +var fileDescriptor_d549e2340fbe3f45 = []byte{ + // 1240 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x99, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xc7, 0x6b, 0x27, 0xed, 0xb6, 0x4f, 0x9a, 0xbe, 0xb8, 0xfb, 0x92, 0x35, 0x10, 0x57, 0xb3, + 0xed, 0x96, 0x2e, 0xdb, 0x44, 0xca, 0x1e, 0x58, 0x56, 0xe2, 0xb0, 0x61, 0x17, 0x54, 0x41, 0x77, + 0x57, 0x5e, 0x10, 0x12, 0x12, 0xaa, 0x92, 0x7a, 0x70, 0x23, 0x9a, 0x38, 0xf2, 0x38, 0x2d, 0x3d, + 0xf7, 0xc2, 0x8d, 0x15, 0x1f, 0x00, 0xed, 0x01, 0x4e, 0x7c, 0x0a, 0x0e, 0x08, 0x8e, 0x7b, 0xe4, + 0x64, 0xa1, 0xf4, 0x02, 0x07, 0x38, 0xe4, 0xcc, 0x01, 0x79, 0xc6, 0x1e, 0x8f, 0x93, 0x38, 0xb1, + 0xab, 0x00, 0x01, 0x6e, 0xce, 0xcc, 0xdf, 0x33, 0xf3, 0xfc, 0x9e, 0x97, 0x99, 0x71, 0xa0, 0x68, + 0x60, 0xd2, 0xb4, 0x48, 0x99, 0x74, 0xea, 0xa4, 0x5d, 0x3b, 0xc0, 0xa4, 0x7c, 0x5c, 0x29, 0x37, + 0x89, 0x49, 0x4a, 0x6d, 0xdb, 0x72, 0x2c, 0x65, 0x8d, 0xf5, 0x97, 0x78, 0x7f, 0xe9, 0xb8, 0xa2, + 0x5e, 0x36, 0x2d, 0xd3, 0xa2, 0xfd, 0x65, 0xef, 0x89, 0x49, 0xd5, 0xf5, 0xa1, 0x43, 0x59, 0x06, + 0x3e, 0xf2, 0x07, 0x43, 0x67, 0x32, 0xac, 0xee, 0x11, 0xf3, 0x2d, 0x1b, 0xd7, 0x1c, 0xfc, 0xd4, + 0x97, 0x29, 0x37, 0x20, 0xdb, 0xaa, 0x35, 0x71, 0x41, 0x5a, 0x97, 0x5e, 0x5d, 0xa8, 0x2e, 0xf7, + 0x5c, 0x2d, 0x77, 0x5a, 0x6b, 0x1e, 0xdd, 0x43, 0x5e, 0x2b, 0xd2, 0x69, 0xa7, 0x72, 0x17, 0x72, + 0x06, 0x26, 0x07, 0x76, 0xa3, 0xed, 0x34, 0xac, 0x56, 0x41, 0xa6, 0xda, 0xab, 0x3d, 0x57, 0x53, + 0x98, 0x56, 0xe8, 0x44, 0xba, 0x28, 0x55, 0xca, 0x30, 0xef, 0xd8, 0xb8, 0x46, 0x3a, 0xf6, 0x69, + 0x21, 0x43, 0x5f, 0x5b, 0xeb, 0xb9, 0xda, 0x32, 0x7b, 0x2d, 0xe8, 0x41, 0x3a, 0x17, 0x29, 0x37, + 0x61, 0xd6, 0x3a, 0x69, 0x61, 0xbb, 0x90, 0xa5, 0xea, 0x95, 0x9e, 0xab, 0x2d, 0x32, 0x35, 0x6d, + 0x46, 0x3a, 0xeb, 0x56, 0x6e, 0xc3, 0xa5, 0x03, 0xcf, 0x12, 0xcb, 0x2e, 0xcc, 0x52, 0xa5, 0xd2, + 0x73, 0xb5, 0x25, 0xa6, 0xf4, 0x3b, 0x90, 0x1e, 0x48, 0xee, 0xcd, 0x7f, 0xfe, 0x5c, 0x9b, 0xf9, + 0xe5, 0xb9, 0x36, 0x83, 0xea, 0x70, 0x7d, 0x00, 0x82, 0x8e, 0x49, 0xdb, 0x6a, 0x11, 0xac, 0x3c, + 0x84, 0x5c, 0xc0, 0x6f, 0xbf, 0x61, 0x50, 0x26, 0xd9, 0xea, 0x46, 0xd7, 0xd5, 0x20, 0x90, 0xee, + 0x3e, 0x08, 0xad, 0x16, 0xa4, 0x48, 0x87, 0xe0, 0xd7, 0xae, 0x81, 0xbe, 0x97, 0x61, 0x79, 0x8f, + 0x98, 0x0f, 0x8d, 0x86, 0xc3, 0x39, 0x4f, 0x66, 0x68, 0xee, 0x2e, 0x39, 0x85, 0xbb, 0x32, 0x17, + 0x73, 0x57, 0x36, 0x95, 0xbb, 0x66, 0x47, 0xbb, 0x6b, 0x1b, 0xe6, 0x48, 0xc3, 0xf4, 0x84, 0x73, + 0x54, 0xb8, 0xda, 0x73, 0xb5, 0xbc, 0x6f, 0x2b, 0x6d, 0x47, 0xba, 0x2f, 0x10, 0x7c, 0x75, 0x1d, + 0xae, 0xf5, 0x61, 0x0c, 0x3c, 0x85, 0xbe, 0x90, 0x68, 0x30, 0x3f, 0xc0, 0x47, 0x58, 0x08, 0xe6, + 0x09, 0x41, 0x0e, 0x17, 0x2b, 0x27, 0x5f, 0xec, 0x4b, 0x34, 0xb0, 0xa2, 0x0b, 0xe2, 0xcb, 0xfd, + 0x46, 0x86, 0x95, 0x30, 0xec, 0xf0, 0x01, 0x85, 0xfd, 0xef, 0x08, 0x89, 0x37, 0x61, 0xa1, 0x5d, + 0xb3, 0x71, 0xcb, 0xf1, 0xd6, 0xe8, 0xc5, 0x44, 0xbe, 0xba, 0xde, 0x75, 0xb5, 0xf9, 0x27, 0xb4, + 0x91, 0xae, 0x70, 0x85, 0x8d, 0xc1, 0x65, 0x48, 0x9f, 0x67, 0xcf, 0xbb, 0x46, 0xba, 0x3c, 0x45, + 0x1f, 0x43, 0xa1, 0x1f, 0x13, 0x4f, 0xce, 0xfb, 0x00, 0x84, 0x35, 0x05, 0xb4, 0xf2, 0x55, 0xd4, + 0x75, 0xb5, 0x05, 0x5f, 0x48, 0x97, 0xb2, 0xea, 0xc3, 0xe2, 0x42, 0xa4, 0x2f, 0xf8, 0x3f, 0x76, + 0x0d, 0xf4, 0xb5, 0x0c, 0x4b, 0x41, 0x44, 0x4d, 0xd6, 0x09, 0xd1, 0xc5, 0xc9, 0x17, 0x58, 0x1c, + 0xf7, 0x63, 0x26, 0x85, 0x1f, 0xb3, 0xc9, 0xfd, 0xb8, 0x0d, 0x73, 0xd8, 0x68, 0x84, 0x7e, 0x10, + 0x82, 0x9a, 0xb5, 0x23, 0xdd, 0x17, 0xa0, 0x02, 0x5c, 0x8d, 0x52, 0xe2, 0x71, 0xfc, 0x25, 0x03, + 0xb8, 0x67, 0x1d, 0xe3, 0xe9, 0x03, 0xf8, 0x2e, 0xe4, 0x5b, 0xf8, 0x64, 0x3f, 0x8c, 0xd6, 0x0c, + 0x1d, 0x65, 0xab, 0xeb, 0x6a, 0xb9, 0x47, 0xf8, 0x44, 0x08, 0xd8, 0xcb, 0x3e, 0x58, 0x51, 0x8d, + 0xf4, 0x5c, 0x8b, 0x8b, 0xc4, 0x1a, 0x90, 0x1d, 0x53, 0x03, 0x7c, 0x5c, 0x02, 0x13, 0x8e, 0xeb, + 0x07, 0x89, 0xa6, 0xbd, 0x5f, 0x14, 0xa6, 0x0e, 0x58, 0x68, 0x63, 0x66, 0x9c, 0x8d, 0x2a, 0x4d, + 0xcc, 0x88, 0x21, 0xdc, 0xca, 0x3f, 0x64, 0x50, 0x78, 0xd6, 0x7e, 0x40, 0xb0, 0xfd, 0x8e, 0x6d, + 0x75, 0xda, 0xff, 0x9f, 0xcc, 0x7a, 0x0c, 0x6b, 0x06, 0xfe, 0xa4, 0xd6, 0x39, 0x72, 0xf6, 0xdb, + 0xd8, 0x6e, 0x36, 0x08, 0x69, 0x58, 0x2d, 0x42, 0xd3, 0x2c, 0x5f, 0x2d, 0xf6, 0x5c, 0x4d, 0x0d, + 0x46, 0x18, 0x10, 0x21, 0x5d, 0xf1, 0x5b, 0x9f, 0x84, 0x8d, 0x62, 0xcd, 0x9c, 0x1b, 0x5f, 0x33, + 0x3f, 0x04, 0x75, 0x90, 0x3e, 0xaf, 0x9a, 0x6f, 0xc0, 0xbc, 0xe9, 0x35, 0x84, 0x35, 0xb3, 0xd8, + 0x75, 0xb5, 0x4b, 0x54, 0x44, 0xd1, 0xf9, 0x9b, 0x7b, 0x20, 0x42, 0xfa, 0x25, 0xfa, 0xb8, 0x6b, + 0xa0, 0xaf, 0xd8, 0xa6, 0xe5, 0xd5, 0x81, 0x89, 0x7b, 0x55, 0x5c, 0x96, 0x9c, 0x6a, 0x59, 0x7f, + 0x43, 0x9d, 0xf4, 0x93, 0x62, 0x36, 0x59, 0x52, 0x44, 0xf8, 0xf0, 0xa4, 0x78, 0xc6, 0xe0, 0x79, + 0x55, 0x61, 0x9a, 0xe0, 0x3d, 0x86, 0x25, 0xaf, 0xea, 0x09, 0x19, 0xc5, 0x8a, 0xe4, 0x76, 0xd7, + 0xd5, 0x16, 0x1f, 0xe1, 0x13, 0x31, 0xa9, 0xae, 0x84, 0x55, 0x52, 0x4c, 0xac, 0xc5, 0x56, 0x28, + 0x4b, 0x55, 0x27, 0x19, 0xae, 0x08, 0x11, 0x8e, 0xeb, 0x4c, 0xa6, 0x51, 0xfc, 0x14, 0x87, 0x28, + 0xc5, 0x8c, 0xf8, 0xe7, 0xc1, 0xdd, 0x85, 0x9c, 0x98, 0xdc, 0x8c, 0x9a, 0x10, 0x50, 0x91, 0xa4, + 0x16, 0xa5, 0x69, 0x08, 0x6d, 0x00, 0x8a, 0x87, 0xc0, 0x59, 0x7d, 0x27, 0xd1, 0x7a, 0xcb, 0x8a, + 0xf1, 0x34, 0x05, 0x57, 0x8a, 0xfd, 0xe4, 0x65, 0xea, 0xee, 0x3e, 0x13, 0xb8, 0x85, 0xbf, 0x4a, + 0x70, 0x65, 0x8f, 0x98, 0xf7, 0x0d, 0xc3, 0xeb, 0x7b, 0xdf, 0x9a, 0xb2, 0xf2, 0xd3, 0x21, 0xdc, + 0x44, 0xa1, 0xfc, 0x78, 0xad, 0x48, 0xa7, 0x9d, 0x69, 0x7c, 0xae, 0xc1, 0x2b, 0x43, 0x4d, 0xe5, + 0x30, 0x7e, 0x97, 0x28, 0x2b, 0x1d, 0x37, 0xfd, 0xcc, 0x79, 0xdb, 0xb6, 0x9a, 0xff, 0x65, 0x22, + 0x2c, 0x0b, 0x62, 0xec, 0xe5, 0x58, 0xbe, 0x95, 0x69, 0x8c, 0xf8, 0xc9, 0xf2, 0x17, 0x14, 0x8b, + 0xc9, 0x1c, 0x3c, 0xc6, 0x93, 0xe9, 0xab, 0x2c, 0xd9, 0x8b, 0x54, 0x96, 0xd9, 0x64, 0x51, 0x36, + 0x08, 0x2b, 0xc0, 0x59, 0xf9, 0x6d, 0x11, 0x32, 0x7b, 0xc4, 0x54, 0x0e, 0x61, 0xa9, 0xef, 0x0b, + 0xd1, 0xcd, 0xd2, 0x90, 0xaf, 0x50, 0xa5, 0x81, 0x8f, 0x28, 0x6a, 0x29, 0x99, 0x8e, 0x9f, 0x4c, + 0xea, 0xb0, 0x18, 0xf9, 0x42, 0xb2, 0x11, 0xf7, 0xbe, 0xa8, 0x52, 0x6f, 0x27, 0x51, 0xf1, 0x39, + 0x0e, 0x61, 0xa9, 0xef, 0x13, 0x41, 0xac, 0x35, 0x51, 0x5d, 0xbc, 0x35, 0xc3, 0x6f, 0xf8, 0x0a, + 0x86, 0x7c, 0xf4, 0x76, 0xbf, 0x39, 0x06, 0x07, 0x93, 0xa9, 0x3b, 0x89, 0x64, 0x7c, 0x9a, 0x7d, + 0xc8, 0x89, 0xb7, 0xd7, 0x1b, 0x23, 0x69, 0xf8, 0x53, 0xbc, 0x96, 0x40, 0x24, 0x4e, 0x20, 0xde, + 0xee, 0x62, 0x27, 0x10, 0x44, 0xf1, 0x13, 0x0c, 0xb9, 0x13, 0x79, 0xa0, 0xa2, 0xf7, 0xa1, 0xcd, + 0x31, 0xa4, 0xc7, 0x81, 0x1a, 0x7a, 0x29, 0x51, 0x3e, 0x85, 0xe5, 0xfe, 0x0b, 0xc9, 0xd6, 0x68, + 0xd4, 0x5c, 0xa8, 0x96, 0x13, 0x0a, 0x45, 0x9b, 0xa2, 0xa7, 0xe4, 0xcd, 0x51, 0xc8, 0xc3, 0x89, + 0x76, 0x12, 0xc9, 0xc4, 0x69, 0xa2, 0xe7, 0xc9, 0xcd, 0x51, 0xe0, 0x13, 0x4c, 0x33, 0xf4, 0x2c, + 0xa6, 0x9c, 0x49, 0x70, 0x2d, 0xee, 0x20, 0x16, 0x8b, 0x26, 0xe6, 0x05, 0xf5, 0xf5, 0x94, 0x2f, + 0x88, 0x0e, 0xec, 0x3f, 0xe1, 0x6c, 0x8d, 0x0e, 0x81, 0x04, 0x0e, 0x8c, 0x39, 0x70, 0x28, 0x0e, + 0x28, 0x43, 0x0e, 0x1b, 0xb7, 0xe2, 0x86, 0x19, 0xd4, 0xaa, 0x95, 0xe4, 0xda, 0x08, 0xe8, 0xb8, + 0x6d, 0x3d, 0xd6, 0x84, 0x98, 0x17, 0xe2, 0x41, 0x8f, 0xd9, 0x48, 0x3d, 0xdb, 0x87, 0x6c, 0xa2, + 0xb7, 0xc6, 0xf8, 0x4d, 0xf4, 0x71, 0x25, 0xb9, 0x36, 0x98, 0xb5, 0xfa, 0xde, 0x8f, 0xdd, 0xa2, + 0xf4, 0xa2, 0x5b, 0x94, 0x7e, 0xee, 0x16, 0xa5, 0x67, 0xe7, 0xc5, 0x99, 0x17, 0xe7, 0xc5, 0x99, + 0x9f, 0xce, 0x8b, 0x33, 0x1f, 0x55, 0xcc, 0x86, 0x73, 0xd8, 0xa9, 0x97, 0x0e, 0xac, 0x66, 0x99, + 0x8d, 0xbb, 0x73, 0x54, 0xab, 0x13, 0xff, 0xb9, 0x7c, 0x7c, 0xa7, 0xfc, 0x99, 0xf0, 0x2f, 0x87, + 0x73, 0xda, 0xc6, 0xa4, 0x3e, 0x47, 0xff, 0xe2, 0xb8, 0xf3, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x56, 0x84, 0xd9, 0xa5, 0x51, 0x19, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreateSubspace allows to create a subspace + CreateSubspace(ctx context.Context, in *MsgCreateSubspace, opts ...grpc.CallOption) (*MsgCreateSubspaceResponse, error) + // EditSubspace allows to edit a subspace + EditSubspace(ctx context.Context, in *MsgEditSubspace, opts ...grpc.CallOption) (*MsgEditSubspaceResponse, error) + // DeleteSubspace allows to delete a subspace + DeleteSubspace(ctx context.Context, in *MsgDeleteSubspace, opts ...grpc.CallOption) (*MsgDeleteSubspaceResponse, error) + // CreateSection allows to create a new subspace section + CreateSection(ctx context.Context, in *MsgCreateSection, opts ...grpc.CallOption) (*MsgCreateSectionResponse, error) + // EditSection allows to edit an existing section + EditSection(ctx context.Context, in *MsgEditSection, opts ...grpc.CallOption) (*MsgEditSectionResponse, error) + // MoveSection allows to move an existing section to another parent + MoveSection(ctx context.Context, in *MsgMoveSection, opts ...grpc.CallOption) (*MsgMoveSectionResponse, error) + // DeleteSection allows to delete an existing section + DeleteSection(ctx context.Context, in *MsgDeleteSection, opts ...grpc.CallOption) (*MsgDeleteSectionResponse, error) + // CreateUserGroup allows to create a user group + CreateUserGroup(ctx context.Context, in *MsgCreateUserGroup, opts ...grpc.CallOption) (*MsgCreateUserGroupResponse, error) + // EditUserGroup allows to edit a user group + EditUserGroup(ctx context.Context, in *MsgEditUserGroup, opts ...grpc.CallOption) (*MsgEditUserGroupResponse, error) + // MoveUserGroup allows to move a user group from a section to another + MoveUserGroup(ctx context.Context, in *MsgMoveUserGroup, opts ...grpc.CallOption) (*MsgMoveUserGroupResponse, error) + // SetUserGroupPermissions allows to set the permissions for a specific group + SetUserGroupPermissions(ctx context.Context, in *MsgSetUserGroupPermissions, opts ...grpc.CallOption) (*MsgSetUserGroupPermissionsResponse, error) + // DeleteUserGroup allows to delete an existing user group + DeleteUserGroup(ctx context.Context, in *MsgDeleteUserGroup, opts ...grpc.CallOption) (*MsgDeleteUserGroupResponse, error) + // AddUserToUserGroup allows to add a specific user to a specific user group + AddUserToUserGroup(ctx context.Context, in *MsgAddUserToUserGroup, opts ...grpc.CallOption) (*MsgAddUserToUserGroupResponse, error) + // RemoveUserFromUserGroup allows to remove a specific user from a specific + // user group + RemoveUserFromUserGroup(ctx context.Context, in *MsgRemoveUserFromUserGroup, opts ...grpc.CallOption) (*MsgRemoveUserFromUserGroupResponse, error) + // SetUserPermissions allows to set the permissions for a specific user + SetUserPermissions(ctx context.Context, in *MsgSetUserPermissions, opts ...grpc.CallOption) (*MsgSetUserPermissionsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateSubspace(ctx context.Context, in *MsgCreateSubspace, opts ...grpc.CallOption) (*MsgCreateSubspaceResponse, error) { + out := new(MsgCreateSubspaceResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/CreateSubspace", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgCreateUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) EditSubspace(ctx context.Context, in *MsgEditSubspace, opts ...grpc.CallOption) (*MsgEditSubspaceResponse, error) { + out := new(MsgEditSubspaceResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/EditSubspace", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgCreateUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.GroupID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) - i-- - dAtA[i] = 0x8 +func (c *msgClient) DeleteSubspace(ctx context.Context, in *MsgDeleteSubspace, opts ...grpc.CallOption) (*MsgDeleteSubspaceResponse, error) { + out := new(MsgDeleteSubspaceResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/DeleteSubspace", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *MsgEditUserGroup) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) CreateSection(ctx context.Context, in *MsgCreateSection, opts ...grpc.CallOption) (*MsgCreateSectionResponse, error) { + out := new(MsgCreateSectionResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/CreateSection", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgEditUserGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) EditSection(ctx context.Context, in *MsgEditSection, opts ...grpc.CallOption) (*MsgEditSectionResponse, error) { + out := new(MsgEditSectionResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/EditSection", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgEditUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x22 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x1a +func (c *msgClient) MoveSection(ctx context.Context, in *MsgMoveSection, opts ...grpc.CallOption) (*MsgMoveSectionResponse, error) { + out := new(MsgMoveSectionResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/MoveSection", in, out, opts...) + if err != nil { + return nil, err } - if m.GroupID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) - i-- - dAtA[i] = 0x10 + return out, nil +} + +func (c *msgClient) DeleteSection(ctx context.Context, in *MsgDeleteSection, opts ...grpc.CallOption) (*MsgDeleteSectionResponse, error) { + out := new(MsgDeleteSectionResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/DeleteSection", in, out, opts...) + if err != nil { + return nil, err } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 + return out, nil +} + +func (c *msgClient) CreateUserGroup(ctx context.Context, in *MsgCreateUserGroup, opts ...grpc.CallOption) (*MsgCreateUserGroupResponse, error) { + out := new(MsgCreateUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/CreateUserGroup", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *MsgEditUserGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) EditUserGroup(ctx context.Context, in *MsgEditUserGroup, opts ...grpc.CallOption) (*MsgEditUserGroupResponse, error) { + out := new(MsgEditUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/EditUserGroup", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgEditUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) MoveUserGroup(ctx context.Context, in *MsgMoveUserGroup, opts ...grpc.CallOption) (*MsgMoveUserGroupResponse, error) { + out := new(MsgMoveUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/MoveUserGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgEditUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (c *msgClient) SetUserGroupPermissions(ctx context.Context, in *MsgSetUserGroupPermissions, opts ...grpc.CallOption) (*MsgSetUserGroupPermissionsResponse, error) { + out := new(MsgSetUserGroupPermissionsResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/SetUserGroupPermissions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgSetUserGroupPermissions) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) DeleteUserGroup(ctx context.Context, in *MsgDeleteUserGroup, opts ...grpc.CallOption) (*MsgDeleteUserGroupResponse, error) { + out := new(MsgDeleteUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/DeleteUserGroup", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgSetUserGroupPermissions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) AddUserToUserGroup(ctx context.Context, in *MsgAddUserToUserGroup, opts ...grpc.CallOption) (*MsgAddUserToUserGroupResponse, error) { + out := new(MsgAddUserToUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/AddUserToUserGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgSetUserGroupPermissions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 - } - if m.Permissions != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.Permissions)) - i-- - dAtA[i] = 0x18 - } - if m.GroupID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) - i-- - dAtA[i] = 0x10 - } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 +func (c *msgClient) RemoveUserFromUserGroup(ctx context.Context, in *MsgRemoveUserFromUserGroup, opts ...grpc.CallOption) (*MsgRemoveUserFromUserGroupResponse, error) { + out := new(MsgRemoveUserFromUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/RemoveUserFromUserGroup", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *MsgSetUserGroupPermissionsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) SetUserPermissions(ctx context.Context, in *MsgSetUserPermissions, opts ...grpc.CallOption) (*MsgSetUserPermissionsResponse, error) { + out := new(MsgSetUserPermissionsResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Msg/SetUserPermissions", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgSetUserGroupPermissionsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateSubspace allows to create a subspace + CreateSubspace(context.Context, *MsgCreateSubspace) (*MsgCreateSubspaceResponse, error) + // EditSubspace allows to edit a subspace + EditSubspace(context.Context, *MsgEditSubspace) (*MsgEditSubspaceResponse, error) + // DeleteSubspace allows to delete a subspace + DeleteSubspace(context.Context, *MsgDeleteSubspace) (*MsgDeleteSubspaceResponse, error) + // CreateSection allows to create a new subspace section + CreateSection(context.Context, *MsgCreateSection) (*MsgCreateSectionResponse, error) + // EditSection allows to edit an existing section + EditSection(context.Context, *MsgEditSection) (*MsgEditSectionResponse, error) + // MoveSection allows to move an existing section to another parent + MoveSection(context.Context, *MsgMoveSection) (*MsgMoveSectionResponse, error) + // DeleteSection allows to delete an existing section + DeleteSection(context.Context, *MsgDeleteSection) (*MsgDeleteSectionResponse, error) + // CreateUserGroup allows to create a user group + CreateUserGroup(context.Context, *MsgCreateUserGroup) (*MsgCreateUserGroupResponse, error) + // EditUserGroup allows to edit a user group + EditUserGroup(context.Context, *MsgEditUserGroup) (*MsgEditUserGroupResponse, error) + // MoveUserGroup allows to move a user group from a section to another + MoveUserGroup(context.Context, *MsgMoveUserGroup) (*MsgMoveUserGroupResponse, error) + // SetUserGroupPermissions allows to set the permissions for a specific group + SetUserGroupPermissions(context.Context, *MsgSetUserGroupPermissions) (*MsgSetUserGroupPermissionsResponse, error) + // DeleteUserGroup allows to delete an existing user group + DeleteUserGroup(context.Context, *MsgDeleteUserGroup) (*MsgDeleteUserGroupResponse, error) + // AddUserToUserGroup allows to add a specific user to a specific user group + AddUserToUserGroup(context.Context, *MsgAddUserToUserGroup) (*MsgAddUserToUserGroupResponse, error) + // RemoveUserFromUserGroup allows to remove a specific user from a specific + // user group + RemoveUserFromUserGroup(context.Context, *MsgRemoveUserFromUserGroup) (*MsgRemoveUserFromUserGroupResponse, error) + // SetUserPermissions allows to set the permissions for a specific user + SetUserPermissions(context.Context, *MsgSetUserPermissions) (*MsgSetUserPermissionsResponse, error) } -func (m *MsgSetUserGroupPermissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { } -func (m *MsgDeleteUserGroup) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil +func (*UnimplementedMsgServer) CreateSubspace(ctx context.Context, req *MsgCreateSubspace) (*MsgCreateSubspaceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateSubspace not implemented") +} +func (*UnimplementedMsgServer) EditSubspace(ctx context.Context, req *MsgEditSubspace) (*MsgEditSubspaceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditSubspace not implemented") +} +func (*UnimplementedMsgServer) DeleteSubspace(ctx context.Context, req *MsgDeleteSubspace) (*MsgDeleteSubspaceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteSubspace not implemented") +} +func (*UnimplementedMsgServer) CreateSection(ctx context.Context, req *MsgCreateSection) (*MsgCreateSectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateSection not implemented") +} +func (*UnimplementedMsgServer) EditSection(ctx context.Context, req *MsgEditSection) (*MsgEditSectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditSection not implemented") +} +func (*UnimplementedMsgServer) MoveSection(ctx context.Context, req *MsgMoveSection) (*MsgMoveSectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MoveSection not implemented") +} +func (*UnimplementedMsgServer) DeleteSection(ctx context.Context, req *MsgDeleteSection) (*MsgDeleteSectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteSection not implemented") +} +func (*UnimplementedMsgServer) CreateUserGroup(ctx context.Context, req *MsgCreateUserGroup) (*MsgCreateUserGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUserGroup not implemented") +} +func (*UnimplementedMsgServer) EditUserGroup(ctx context.Context, req *MsgEditUserGroup) (*MsgEditUserGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditUserGroup not implemented") +} +func (*UnimplementedMsgServer) MoveUserGroup(ctx context.Context, req *MsgMoveUserGroup) (*MsgMoveUserGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MoveUserGroup not implemented") +} +func (*UnimplementedMsgServer) SetUserGroupPermissions(ctx context.Context, req *MsgSetUserGroupPermissions) (*MsgSetUserGroupPermissionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetUserGroupPermissions not implemented") +} +func (*UnimplementedMsgServer) DeleteUserGroup(ctx context.Context, req *MsgDeleteUserGroup) (*MsgDeleteUserGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteUserGroup not implemented") +} +func (*UnimplementedMsgServer) AddUserToUserGroup(ctx context.Context, req *MsgAddUserToUserGroup) (*MsgAddUserToUserGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddUserToUserGroup not implemented") +} +func (*UnimplementedMsgServer) RemoveUserFromUserGroup(ctx context.Context, req *MsgRemoveUserFromUserGroup) (*MsgRemoveUserFromUserGroupResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveUserFromUserGroup not implemented") +} +func (*UnimplementedMsgServer) SetUserPermissions(ctx context.Context, req *MsgSetUserPermissions) (*MsgSetUserPermissionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetUserPermissions not implemented") } -func (m *MsgDeleteUserGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) } -func (m *MsgDeleteUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a +func _Msg_CreateSubspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateSubspace) + if err := dec(in); err != nil { + return nil, err } - if m.GroupID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) - i-- - dAtA[i] = 0x10 + if interceptor == nil { + return srv.(MsgServer).CreateSubspace(ctx, in) } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/CreateSubspace", } - return len(dAtA) - i, nil + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateSubspace(ctx, req.(*MsgCreateSubspace)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgDeleteUserGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_EditSubspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditSubspace) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgDeleteUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgDeleteUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil + if interceptor == nil { + return srv.(MsgServer).EditSubspace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/EditSubspace", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditSubspace(ctx, req.(*MsgEditSubspace)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgAddUserToUserGroup) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_DeleteSubspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteSubspace) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *MsgAddUserToUserGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + if interceptor == nil { + return srv.(MsgServer).DeleteSubspace(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/DeleteSubspace", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteSubspace(ctx, req.(*MsgDeleteSubspace)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgAddUserToUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 +func _Msg_CreateSection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateSection) + if err := dec(in); err != nil { + return nil, err } - if len(m.User) > 0 { - i -= len(m.User) - copy(dAtA[i:], m.User) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.User))) - i-- - dAtA[i] = 0x1a + if interceptor == nil { + return srv.(MsgServer).CreateSection(ctx, in) } - if m.GroupID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) - i-- - dAtA[i] = 0x10 + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/CreateSection", } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateSection(ctx, req.(*MsgCreateSection)) } - return len(dAtA) - i, nil + return interceptor(ctx, in, info, handler) } -func (m *MsgAddUserToUserGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_EditSection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditSection) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(MsgServer).EditSection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/EditSection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditSection(ctx, req.(*MsgEditSection)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgAddUserToUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Msg_MoveSection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMoveSection) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MoveSection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/MoveSection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MoveSection(ctx, req.(*MsgMoveSection)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgAddUserToUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func _Msg_DeleteSection_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteSection) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteSection(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/DeleteSection", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteSection(ctx, req.(*MsgDeleteSection)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgRemoveUserFromUserGroup) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_CreateUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateUserGroup) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(MsgServer).CreateUserGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/CreateUserGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateUserGroup(ctx, req.(*MsgCreateUserGroup)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgRemoveUserFromUserGroup) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Msg_EditUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditUserGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EditUserGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/EditUserGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditUserGroup(ctx, req.(*MsgEditUserGroup)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgRemoveUserFromUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 +func _Msg_MoveUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMoveUserGroup) + if err := dec(in); err != nil { + return nil, err } - if len(m.User) > 0 { - i -= len(m.User) - copy(dAtA[i:], m.User) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.User))) - i-- - dAtA[i] = 0x1a + if interceptor == nil { + return srv.(MsgServer).MoveUserGroup(ctx, in) } - if m.GroupID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) - i-- - dAtA[i] = 0x10 + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/MoveUserGroup", } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) - i-- - dAtA[i] = 0x8 + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MoveUserGroup(ctx, req.(*MsgMoveUserGroup)) } - return len(dAtA) - i, nil + return interceptor(ctx, in, info, handler) } -func (m *MsgRemoveUserFromUserGroupResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Msg_SetUserGroupPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetUserGroupPermissions) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(MsgServer).SetUserGroupPermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/SetUserGroupPermissions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetUserGroupPermissions(ctx, req.(*MsgSetUserGroupPermissions)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgRemoveUserFromUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Msg_DeleteUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDeleteUserGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DeleteUserGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/DeleteUserGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DeleteUserGroup(ctx, req.(*MsgDeleteUserGroup)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgRemoveUserFromUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func _Msg_AddUserToUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddUserToUserGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddUserToUserGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/AddUserToUserGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddUserToUserGroup(ctx, req.(*MsgAddUserToUserGroup)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgSetUserPermissions) Marshal() (dAtA []byte, err error) { +func _Msg_RemoveUserFromUserGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveUserFromUserGroup) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveUserFromUserGroup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/RemoveUserFromUserGroup", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveUserFromUserGroup(ctx, req.(*MsgRemoveUserFromUserGroup)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetUserPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetUserPermissions) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetUserPermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Msg/SetUserPermissions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetUserPermissions(ctx, req.(*MsgSetUserPermissions)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "desmos.subspaces.v2.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateSubspace", + Handler: _Msg_CreateSubspace_Handler, + }, + { + MethodName: "EditSubspace", + Handler: _Msg_EditSubspace_Handler, + }, + { + MethodName: "DeleteSubspace", + Handler: _Msg_DeleteSubspace_Handler, + }, + { + MethodName: "CreateSection", + Handler: _Msg_CreateSection_Handler, + }, + { + MethodName: "EditSection", + Handler: _Msg_EditSection_Handler, + }, + { + MethodName: "MoveSection", + Handler: _Msg_MoveSection_Handler, + }, + { + MethodName: "DeleteSection", + Handler: _Msg_DeleteSection_Handler, + }, + { + MethodName: "CreateUserGroup", + Handler: _Msg_CreateUserGroup_Handler, + }, + { + MethodName: "EditUserGroup", + Handler: _Msg_EditUserGroup_Handler, + }, + { + MethodName: "MoveUserGroup", + Handler: _Msg_MoveUserGroup_Handler, + }, + { + MethodName: "SetUserGroupPermissions", + Handler: _Msg_SetUserGroupPermissions_Handler, + }, + { + MethodName: "DeleteUserGroup", + Handler: _Msg_DeleteUserGroup_Handler, + }, + { + MethodName: "AddUserToUserGroup", + Handler: _Msg_AddUserToUserGroup_Handler, + }, + { + MethodName: "RemoveUserFromUserGroup", + Handler: _Msg_RemoveUserFromUserGroup_Handler, + }, + { + MethodName: "SetUserPermissions", + Handler: _Msg_SetUserPermissions_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "desmos/subspaces/v2/msgs.proto", +} + +func (m *MsgCreateSubspace) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2224,44 +2399,55 @@ func (m *MsgSetUserPermissions) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetUserPermissions) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateSubspace) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetUserPermissions) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x2a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Owner))) i-- dAtA[i] = 0x22 } - if m.Permissions != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.Permissions)) + if len(m.Treasury) > 0 { + i -= len(m.Treasury) + copy(dAtA[i:], m.Treasury) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Treasury))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } - if len(m.User) > 0 { - i -= len(m.User) - copy(dAtA[i:], m.User) - i = encodeVarintMsgs(dAtA, i, uint64(len(m.User))) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) i-- dAtA[i] = 0x12 } - if m.SubspaceID != 0 { - i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgSetUserPermissionsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateSubspaceResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2271,374 +2457,2271 @@ func (m *MsgSetUserPermissionsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetUserPermissionsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateSubspaceResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetUserPermissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateSubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } -func encodeVarintMsgs(dAtA []byte, offset int, v uint64) int { - offset -= sovMsgs(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgCreateSubspace) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) - } - l = len(m.Treasury) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) - } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) - } - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) +func (m *MsgEditSubspace) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil } -func (m *MsgCreateSubspaceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) - } - return n +func (m *MsgEditSubspace) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgEditSubspace) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgEditSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x32 } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x2a } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Treasury) > 0 { + i -= len(m.Treasury) + copy(dAtA[i:], m.Treasury) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Treasury))) + i-- + dAtA[i] = 0x22 } - l = len(m.Treasury) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgEditSubspaceResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgEditSubspaceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgEditSubspaceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditSubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgDeleteSubspace) Size() (n int) { - if m == nil { - return 0 +func (m *MsgDeleteSubspace) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgDeleteSubspace) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteSubspace) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgDeleteSubspaceResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgDeleteSubspaceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgDeleteSubspaceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteSubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgCreateUserGroup) Size() (n int) { - if m == nil { - return 0 +func (m *MsgCreateSection) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgCreateSection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateSection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x2a } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.ParentID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.ParentID)) + i-- + dAtA[i] = 0x20 } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a } - if m.DefaultPermissions != 0 { - n += 1 + sovMsgs(uint64(m.DefaultPermissions)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 } - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgCreateUserGroupResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgCreateSectionResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgCreateSectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateSectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.GroupID != 0 { - n += 1 + sovMsgs(uint64(m.GroupID)) + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgEditUserGroup) Size() (n int) { - if m == nil { - return 0 +func (m *MsgEditSection) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgEditSection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditSection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Editor) > 0 { + i -= len(m.Editor) + copy(dAtA[i:], m.Editor) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Editor))) + i-- + dAtA[i] = 0x2a } - if m.GroupID != 0 { - n += 1 + sovMsgs(uint64(m.GroupID)) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgEditUserGroupResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgEditSectionResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgEditSectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditSectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgSetUserGroupPermissions) Size() (n int) { - if m == nil { - return 0 +func (m *MsgMoveSection) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgMoveSection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMoveSection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 } - if m.GroupID != 0 { - n += 1 + sovMsgs(uint64(m.GroupID)) + if m.NewParentID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.NewParentID)) + i-- + dAtA[i] = 0x18 } - if m.Permissions != 0 { - n += 1 + sovMsgs(uint64(m.Permissions)) + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgSetUserGroupPermissionsResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgMoveSectionResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgMoveSectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMoveSectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgDeleteUserGroup) Size() (n int) { - if m == nil { - return 0 +func (m *MsgDeleteSection) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgDeleteSection) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteSection) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a } - if m.GroupID != 0 { - n += 1 + sovMsgs(uint64(m.GroupID)) + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *MsgDeleteUserGroupResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgDeleteSectionResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *MsgAddUserToUserGroup) Size() (n int) { - if m == nil { - return 0 +func (m *MsgDeleteSectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteSectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgCreateUserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgCreateUserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x32 } - if m.GroupID != 0 { - n += 1 + sovMsgs(uint64(m.GroupID)) + if m.DefaultPermissions != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.DefaultPermissions)) + i-- + dAtA[i] = 0x28 } - l = len(m.User) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a } - return n + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgAddUserToUserGroupResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgCreateUserGroupResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgCreateUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgRemoveUserFromUserGroup) Size() (n int) { - if m == nil { - return 0 +func (m *MsgEditUserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgEditUserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a } - if m.GroupID != 0 { - n += 1 + sovMsgs(uint64(m.GroupID)) + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 } - l = len(m.User) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x1a } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x10 } - return n + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *MsgRemoveUserFromUserGroupResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgEditUserGroupResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgEditUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgSetUserPermissions) Size() (n int) { - if m == nil { - return 0 +func (m *MsgMoveUserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } + return dAtA[:n], nil +} + +func (m *MsgMoveUserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMoveUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if m.NewSectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.NewSectionID)) + i-- + dAtA[i] = 0x18 + } + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x10 + } if m.SubspaceID != 0 { - n += 1 + sovMsgs(uint64(m.SubspaceID)) + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 } - l = len(m.User) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + return len(dAtA) - i, nil +} + +func (m *MsgMoveUserGroupResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - if m.Permissions != 0 { - n += 1 + sovMsgs(uint64(m.Permissions)) + return dAtA[:n], nil +} + +func (m *MsgMoveUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMoveUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetUserGroupPermissions) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMsgs(uint64(l)) + return dAtA[:n], nil +} + +func (m *MsgSetUserGroupPermissions) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetUserGroupPermissions) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if m.Permissions != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.Permissions)) + i-- + dAtA[i] = 0x18 + } + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgSetUserGroupPermissionsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetUserGroupPermissionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetUserGroupPermissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgDeleteUserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeleteUserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgDeleteUserGroupResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgDeleteUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDeleteUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgAddUserToUserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddUserToUserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddUserToUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0x1a + } + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgAddUserToUserGroupResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddUserToUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddUserToUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRemoveUserFromUserGroup) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveUserFromUserGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveUserFromUserGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0x1a + } + if m.GroupID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveUserFromUserGroupResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveUserFromUserGroupResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveUserFromUserGroupResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetUserPermissions) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetUserPermissions) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetUserPermissions) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if m.Permissions != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.Permissions)) + i-- + dAtA[i] = 0x20 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintMsgs(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0x1a + } + if m.SectionID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SectionID)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceID != 0 { + i = encodeVarintMsgs(dAtA, i, uint64(m.SubspaceID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgSetUserPermissionsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetUserPermissionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetUserPermissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintMsgs(dAtA []byte, offset int, v uint64) int { + offset -= sovMsgs(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateSubspace) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Treasury) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgCreateSubspaceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + return n +} + +func (m *MsgEditSubspace) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Treasury) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgEditSubspaceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteSubspace) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgDeleteSubspaceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateSection) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + if m.ParentID != 0 { + n += 1 + sovMsgs(uint64(m.ParentID)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgCreateSectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } + return n +} + +func (m *MsgEditSection) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Editor) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgEditSectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMoveSection) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } + if m.NewParentID != 0 { + n += 1 + sovMsgs(uint64(m.NewParentID)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgMoveSectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteSection) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgDeleteSectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateUserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + if m.DefaultPermissions != 0 { + n += 1 + sovMsgs(uint64(m.DefaultPermissions)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgCreateUserGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + return n +} + +func (m *MsgEditUserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgEditUserGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMoveUserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + if m.NewSectionID != 0 { + n += 1 + sovMsgs(uint64(m.NewSectionID)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgMoveUserGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetUserGroupPermissions) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + if m.Permissions != 0 { + n += 1 + sovMsgs(uint64(m.Permissions)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgSetUserGroupPermissionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgDeleteUserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgDeleteUserGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgAddUserToUserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + l = len(m.User) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgAddUserToUserGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRemoveUserFromUserGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.GroupID != 0 { + n += 1 + sovMsgs(uint64(m.GroupID)) + } + l = len(m.User) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgRemoveUserFromUserGroupResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetUserPermissions) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceID != 0 { + n += 1 + sovMsgs(uint64(m.SubspaceID)) + } + if m.SectionID != 0 { + n += 1 + sovMsgs(uint64(m.SectionID)) + } + l = len(m.User) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + if m.Permissions != 0 { + n += 1 + sovMsgs(uint64(m.Permissions)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMsgs(uint64(l)) + } + return n +} + +func (m *MsgSetUserPermissionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovMsgs(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMsgs(x uint64) (n int) { + return sovMsgs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateSubspace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Treasury = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateSubspaceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateSubspaceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateSubspaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + } + m.SubspaceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEditSubspace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + } + m.SubspaceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Treasury = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditSubspaceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEditSubspaceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditSubspaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteSubspace) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeleteSubspace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + } + m.SubspaceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDeleteSubspaceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDeleteSubspaceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDeleteSubspaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - return n -} -func (m *MsgSetUserPermissionsResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n -} - -func sovMsgs(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMsgs(x uint64) (n int) { - return sovMsgs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { +func (m *MsgCreateSection) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2661,17 +4744,17 @@ func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateSubspace: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateSection: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateSection: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) } - var stringLen uint64 + m.SubspaceID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMsgs @@ -2681,27 +4764,14 @@ func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.SubspaceID |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMsgs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMsgs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2729,11 +4799,11 @@ func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Description = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2761,13 +4831,13 @@ func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Treasury = string(dAtA[iNdEx:postIndex]) + m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ParentID", wireType) } - var stringLen uint64 + m.ParentID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMsgs @@ -2777,24 +4847,11 @@ func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.ParentID |= uint32(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMsgs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMsgs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) @@ -2848,7 +4905,7 @@ func (m *MsgCreateSubspace) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateSubspaceResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreateSectionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2871,17 +4928,17 @@ func (m *MsgCreateSubspaceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateSubspaceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateSectionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateSubspaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateSectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) } - m.SubspaceID = 0 + m.SectionID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMsgs @@ -2891,7 +4948,7 @@ func (m *MsgCreateSubspaceResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SubspaceID |= uint64(b&0x7F) << shift + m.SectionID |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2917,7 +4974,7 @@ func (m *MsgCreateSubspaceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { +func (m *MsgEditSection) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2940,10 +4997,10 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgEditSubspace: wiretype end group for non-group") + return fmt.Errorf("proto: MsgEditSection: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEditSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgEditSection: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2966,6 +5023,25 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -2997,7 +5073,7 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } @@ -3029,9 +5105,9 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { } m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Editor", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3059,13 +5135,113 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Treasury = string(dAtA[iNdEx:postIndex]) + m.Editor = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err } - var stringLen uint64 + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditSectionResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEditSectionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditSectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgMoveSection) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgMoveSection: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMoveSection: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + } + m.SubspaceID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMsgs @@ -3075,25 +5251,50 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.SubspaceID |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMsgs + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMsgs + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - if postIndex > l { - return io.ErrUnexpectedEOF + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NewParentID", wireType) + } + m.NewParentID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NewParentID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -3146,7 +5347,7 @@ func (m *MsgEditSubspace) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgEditSubspaceResponse) Unmarshal(dAtA []byte) error { +func (m *MsgMoveSectionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3169,10 +5370,10 @@ func (m *MsgEditSubspaceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgEditSubspaceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgMoveSectionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEditSubspaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgMoveSectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3196,7 +5397,7 @@ func (m *MsgEditSubspaceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDeleteSubspace) Unmarshal(dAtA []byte) error { +func (m *MsgDeleteSection) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3219,10 +5420,10 @@ func (m *MsgDeleteSubspace) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDeleteSubspace: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDeleteSection: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDeleteSubspace: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDeleteSection: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3245,6 +5446,25 @@ func (m *MsgDeleteSubspace) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -3297,7 +5517,7 @@ func (m *MsgDeleteSubspace) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDeleteSubspaceResponse) Unmarshal(dAtA []byte) error { +func (m *MsgDeleteSectionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3320,10 +5540,10 @@ func (m *MsgDeleteSubspaceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDeleteSubspaceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgDeleteSectionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDeleteSubspaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgDeleteSectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3396,6 +5616,25 @@ func (m *MsgCreateUserGroup) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } @@ -3427,7 +5666,7 @@ func (m *MsgCreateUserGroup) Unmarshal(dAtA []byte) error { } m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } @@ -3459,7 +5698,7 @@ func (m *MsgCreateUserGroup) Unmarshal(dAtA []byte) error { } m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DefaultPermissions", wireType) } @@ -3478,7 +5717,7 @@ func (m *MsgCreateUserGroup) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } @@ -3834,6 +6073,195 @@ func (m *MsgEditUserGroupResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgMoveUserGroup) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgMoveUserGroup: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMoveUserGroup: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceID", wireType) + } + m.SubspaceID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupID", wireType) + } + m.GroupID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NewSectionID", wireType) + } + m.NewSectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NewSectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMsgs + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMsgs + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgMoveUserGroupResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgMoveUserGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMoveUserGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipMsgs(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMsgs + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgSetUserGroupPermissions) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -4646,6 +7074,25 @@ func (m *MsgSetUserPermissions) Unmarshal(dAtA []byte) error { } } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionID", wireType) + } + m.SectionID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMsgs + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) } @@ -4677,7 +7124,7 @@ func (m *MsgSetUserPermissions) Unmarshal(dAtA []byte) error { } m.User = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) } @@ -4696,7 +7143,7 @@ func (m *MsgSetUserPermissions) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } diff --git a/x/subspaces/types/msgs_test.go b/x/subspaces/types/msgs_test.go index 569e3ecb71..f7619b497c 100644 --- a/x/subspaces/types/msgs_test.go +++ b/x/subspaces/types/msgs_test.go @@ -244,8 +244,341 @@ func TestMsgDeleteSubspace_GetSigners(t *testing.T) { // -------------------------------------------------------------------------------------------------------------------- +var msgCreateSection = types.NewMsgCreateSection( + 1, + "Test section", + "This is a test section", + 0, + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", +) + +func TestMsgCreateSection_Route(t *testing.T) { + require.Equal(t, types.RouterKey, msgCreateSection.Route()) +} + +func TestMsgCreateSection_Type(t *testing.T) { + require.Equal(t, types.ActionCreateSection, msgCreateSection.Type()) +} + +func TestMsgCreateSection_ValidateBasic(t *testing.T) { + testCases := []struct { + name string + msg *types.MsgCreateSection + shouldErr bool + }{ + { + name: "invalid subspace id returns error", + msg: types.NewMsgCreateSection( + 0, + msgCreateSection.Name, + msgCreateSection.Description, + msgCreateSection.ParentID, + msgCreateSection.Creator, + ), + shouldErr: true, + }, + { + name: "invalid name returns error", + msg: types.NewMsgCreateSection( + msgCreateSection.SubspaceID, + "", + msgCreateSection.Description, + msgCreateSection.ParentID, + msgCreateSection.Creator, + ), + shouldErr: true, + }, + { + name: "invalid signer returns error", + msg: types.NewMsgCreateSection( + msgCreateSection.SubspaceID, + msgCreateSection.Name, + msgCreateSection.Description, + msgCreateSection.ParentID, + "", + ), + shouldErr: true, + }, + { + name: "valid message returns no error", + msg: msgCreateSection, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgCreateSection_GetSignBytes(t *testing.T) { + expected := `{"type":"desmos/MsgCreateSection","value":{"creator":"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5","description":"This is a test section","name":"Test section","subspace_id":"1"}}` + require.Equal(t, expected, string(msgCreateSection.GetSignBytes())) +} + +func TestMsgCreateSection_GetSigners(t *testing.T) { + addr, _ := sdk.AccAddressFromBech32(msgCreateSection.Creator) + require.Equal(t, []sdk.AccAddress{addr}, msgCreateSection.GetSigners()) +} + +// -------------------------------------------------------------------------------------------------------------------- + +var msgEditSection = types.NewMsgEditSection( + 1, + 1, + "Test section", + "This is a test section", + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", +) + +func TestMsgEditSection_Route(t *testing.T) { + require.Equal(t, types.RouterKey, msgEditSection.Route()) +} + +func TestMsgEditSection_Type(t *testing.T) { + require.Equal(t, types.ActionEditSection, msgEditSection.Type()) +} + +func TestMsgEditSection_ValidateBasic(t *testing.T) { + testCases := []struct { + name string + msg *types.MsgEditSection + shouldErr bool + }{ + { + name: "invalid subspace id returns error", + msg: types.NewMsgEditSection( + 0, + msgEditSection.SectionID, + msgEditSection.Name, + msgEditSection.Description, + msgEditSection.Editor, + ), + shouldErr: true, + }, + { + name: "invalid name returns error", + msg: types.NewMsgEditSection( + msgEditSection.SubspaceID, + msgEditSection.SectionID, + "", + msgEditSection.Description, + msgEditSection.Editor, + ), + shouldErr: true, + }, + { + name: "invalid editor returns error", + msg: types.NewMsgEditSection( + msgEditSection.SubspaceID, + msgEditSection.SectionID, + msgEditSection.Name, + msgEditSection.Description, + "", + ), + shouldErr: true, + }, + { + name: "valid message returns no error", + msg: msgEditSection, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgEditSection_GetSignBytes(t *testing.T) { + expected := `{"type":"desmos/MsgEditSection","value":{"description":"This is a test section","editor":"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5","name":"Test section","section_id":1,"subspace_id":"1"}}` + require.Equal(t, expected, string(msgEditSection.GetSignBytes())) +} + +func TestMsgEditSection_GetSigners(t *testing.T) { + addr, _ := sdk.AccAddressFromBech32(msgEditSection.Editor) + require.Equal(t, []sdk.AccAddress{addr}, msgEditSection.GetSigners()) +} + +// -------------------------------------------------------------------------------------------------------------------- + +var msgMoveSection = types.NewMsgMoveSection( + 1, + 1, + 1, + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", +) + +func TestMsgMoveSection_Route(t *testing.T) { + require.Equal(t, types.RouterKey, msgMoveSection.Route()) +} + +func TestMsgMoveSection_Type(t *testing.T) { + require.Equal(t, types.ActionMoveSection, msgMoveSection.Type()) +} + +func TestMsgMoveSection_ValidateBasic(t *testing.T) { + testCases := []struct { + name string + msg *types.MsgMoveSection + shouldErr bool + }{ + { + name: "invalid subspace id returns error", + msg: types.NewMsgMoveSection( + 0, + msgMoveSection.SectionID, + msgMoveSection.NewParentID, + msgMoveSection.Signer, + ), + shouldErr: true, + }, + { + name: "invalid section id returns error", + msg: types.NewMsgMoveSection( + msgMoveSection.SubspaceID, + 0, + msgMoveSection.NewParentID, + msgMoveSection.Signer, + ), + shouldErr: true, + }, + { + name: "invalid editor returns error", + msg: types.NewMsgMoveSection( + msgMoveSection.SubspaceID, + msgMoveSection.SectionID, + msgMoveSection.NewParentID, + "", + ), + shouldErr: true, + }, + { + name: "valid message returns no error", + msg: msgMoveSection, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgMoveSection_GetSignBytes(t *testing.T) { + expected := `{"type":"desmos/MsgMoveSection","value":{"new_parent_id":1,"section_id":1,"signer":"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5","subspace_id":"1"}}` + require.Equal(t, expected, string(msgMoveSection.GetSignBytes())) +} + +func TestMsgMoveSection_GetSigners(t *testing.T) { + addr, _ := sdk.AccAddressFromBech32(msgMoveSection.Signer) + require.Equal(t, []sdk.AccAddress{addr}, msgMoveSection.GetSigners()) +} + +// -------------------------------------------------------------------------------------------------------------------- + +var msgDeleteSection = types.NewMsgDeleteSection( + 1, + 1, + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", +) + +func TestMsgDeleteSection_Route(t *testing.T) { + require.Equal(t, types.RouterKey, msgDeleteSection.Route()) +} + +func TestMsgDeleteSection_Type(t *testing.T) { + require.Equal(t, types.ActionDeleteSection, msgDeleteSection.Type()) +} + +func TestMsgDeleteSection_ValidateBasic(t *testing.T) { + testCases := []struct { + name string + msg *types.MsgDeleteSection + shouldErr bool + }{ + { + name: "invalid subspace id returns error", + msg: types.NewMsgDeleteSection( + 0, + msgDeleteSection.SectionID, + msgDeleteSection.Signer, + ), + shouldErr: true, + }, + { + name: "invalid section id returns error", + msg: types.NewMsgDeleteSection( + msgDeleteSection.SubspaceID, + 0, + msgDeleteSection.Signer, + ), + shouldErr: true, + }, + { + name: "invalid editor returns error", + msg: types.NewMsgDeleteSection( + msgDeleteSection.SubspaceID, + msgDeleteSection.SectionID, + "", + ), + shouldErr: true, + }, + { + name: "valid message returns no error", + msg: msgDeleteSection, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgDeleteSection_GetSignBytes(t *testing.T) { + expected := `{"type":"desmos/MsgDeleteSection","value":{"section_id":1,"signer":"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5","subspace_id":"1"}}` + require.Equal(t, expected, string(msgDeleteSection.GetSignBytes())) +} + +func TestMsgDeleteSection_GetSigners(t *testing.T) { + addr, _ := sdk.AccAddressFromBech32(msgDeleteSection.Signer) + require.Equal(t, []sdk.AccAddress{addr}, msgDeleteSection.GetSigners()) +} + +// -------------------------------------------------------------------------------------------------------------------- + var msgCreateUserGroup = types.NewMsgCreateUserGroup( 1, + 0, "Group", "Description", types.PermissionWrite, @@ -270,6 +603,7 @@ func TestMsgCreateUserGroup_ValidateBasic(t *testing.T) { name: "invalid subspace id returns error", msg: types.NewMsgCreateUserGroup( 0, + 1, "group", "description", types.PermissionWrite, @@ -280,6 +614,7 @@ func TestMsgCreateUserGroup_ValidateBasic(t *testing.T) { { name: "invalid group name returns error", msg: types.NewMsgCreateUserGroup( + 1, 1, "", "description", @@ -291,6 +626,7 @@ func TestMsgCreateUserGroup_ValidateBasic(t *testing.T) { { name: "invalid creator returns error", msg: types.NewMsgCreateUserGroup( + 1, 1, "group", "description", @@ -405,6 +741,78 @@ func TestMsgEditUserGroup_GetSigners(t *testing.T) { // -------------------------------------------------------------------------------------------------------------------- +var msgMoveUserGroup = types.NewMsgMoveUserGroup( + 1, + 1, + 2, + "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", +) + +func TestMsgMoveUserGroup_Route(t *testing.T) { + require.Equal(t, types.RouterKey, msgMoveUserGroup.Route()) +} + +func TestMsgMoveUserGroup_Type(t *testing.T) { + require.Equal(t, types.ActionMoveUserGroup, msgMoveUserGroup.Type()) +} + +func TestMsgMoveUserGroup_ValidateBasic(t *testing.T) { + testCases := []struct { + name string + msg *types.MsgMoveUserGroup + shouldErr bool + }{ + { + name: "invalid subspace id returns error", + msg: types.NewMsgMoveUserGroup( + 0, + msgMoveUserGroup.GroupID, + msgMoveUserGroup.NewSectionID, + msgMoveUserGroup.Signer, + ), + shouldErr: true, + }, + { + name: "invalid creator returns error", + msg: types.NewMsgMoveUserGroup( + msgMoveUserGroup.SubspaceID, + msgMoveUserGroup.GroupID, + msgMoveUserGroup.NewSectionID, + "", + ), + shouldErr: true, + }, + { + name: "valid message returns no error", + msg: msgMoveUserGroup, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.shouldErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgMoveUserGroup_GetSignBytes(t *testing.T) { + expected := `{"type":"desmos/MsgMoveUserGroup","value":{"group_id":1,"new_section_id":2,"signer":"cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5","subspace_id":"1"}}` + require.Equal(t, expected, string(msgMoveUserGroup.GetSignBytes())) +} + +func TestMsgMoveUserGroup_GetSigners(t *testing.T) { + addr, _ := sdk.AccAddressFromBech32(msgMoveUserGroup.Signer) + require.Equal(t, []sdk.AccAddress{addr}, msgMoveUserGroup.GetSigners()) +} + +// -------------------------------------------------------------------------------------------------------------------- + var msgSetUserGroupPermissions = types.NewMsgSetUserGroupPermissions( 1, 1, @@ -740,6 +1148,7 @@ func TestMsgRemoveUserFromUserGroup_GetSigners(t *testing.T) { // -------------------------------------------------------------------------------------------------------------------- var msgSetUserPermissions = types.NewMsgSetUserPermissions( 1, + 0, "cosmos1x5pjlvufs4znnhhkwe8v4tw3kz30f3lxgwza53", types.PermissionWrite, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", @@ -763,6 +1172,7 @@ func TestMsgSetUserPermissions_ValidateBasic(t *testing.T) { name: "invalid subspace id returns error", msg: types.NewMsgSetUserPermissions( 0, + 1, "group", types.PermissionWrite, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", @@ -772,6 +1182,7 @@ func TestMsgSetUserPermissions_ValidateBasic(t *testing.T) { { name: "invalid target returns error", msg: types.NewMsgSetUserPermissions( + 1, 1, "", types.PermissionWrite, @@ -782,6 +1193,7 @@ func TestMsgSetUserPermissions_ValidateBasic(t *testing.T) { { name: "invalid signer returns error", msg: types.NewMsgSetUserPermissions( + 1, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", types.PermissionWrite, @@ -792,6 +1204,7 @@ func TestMsgSetUserPermissions_ValidateBasic(t *testing.T) { { name: "same user and signer returns error", msg: types.NewMsgSetUserPermissions( + 1, 1, "cosmos1m0czrla04f7rp3zg7dsgc4kla54q7pc4xt00l5", types.PermissionWrite, diff --git a/x/subspaces/types/permissions.go b/x/subspaces/types/permissions.go index 4cb5ba2d3b..990d901e48 100644 --- a/x/subspaces/types/permissions.go +++ b/x/subspaces/types/permissions.go @@ -32,15 +32,18 @@ const ( // PermissionDeleteSubspace allows users to delete the subspace. PermissionDeleteSubspace = Permission(0b100000) + // PermissionManageSections allows users to manage subspace sections. + PermissionManageSections = Permission(0b1000000) + // PermissionInteractWithContent allows users to interact with content inside the subspace (eg. polls) - PermissionInteractWithContent = Permission(0b1000000) + PermissionInteractWithContent = Permission(0b10000000) // PermissionEditOwnContent allows users to edit their own content inside the subspace - PermissionEditOwnContent = Permission(0b10000000) + PermissionEditOwnContent = Permission(0b100000000) // PermissionEverything allows to do everything. // This should usually be reserved only to the owner (which has it by default) - PermissionEverything = Permission(0b11111111) + PermissionEverything = Permission(0b111111111) ) var ( diff --git a/x/subspaces/types/permissions_test.go b/x/subspaces/types/permissions_test.go index cf96a7d54d..8472dac9c5 100644 --- a/x/subspaces/types/permissions_test.go +++ b/x/subspaces/types/permissions_test.go @@ -174,13 +174,13 @@ func TestSanitizePermission(t *testing.T) { }, { name: "invalid permission returns permission nothing", - permission: 256, + permission: 1024, expResult: types.PermissionNothing, }, { name: "extra bits are set to 0", - permission: 0b11111111111111111111111111111111, - expResult: types.PermissionEverything, + permission: 0b11111111111111111111111000000001, + expResult: types.PermissionWrite, }, } @@ -211,7 +211,7 @@ func TestIsPermissionValid(t *testing.T) { }, { name: "invalid permission returns false", - permission: 256, + permission: 1024, expValid: false, }, { diff --git a/x/subspaces/types/query.go b/x/subspaces/types/query.go index c81d0809b2..b3d17b6696 100644 --- a/x/subspaces/types/query.go +++ b/x/subspaces/types/query.go @@ -18,10 +18,27 @@ func NewQuerySubspacesRequest(pagination *query.PageRequest) *QuerySubspacesRequ } } +// NewQuerySectionsRequest returns a new QuerySectionsRequest instance +func NewQuerySectionsRequest(subspaceID uint64, pagination *query.PageRequest) *QuerySectionsRequest { + return &QuerySectionsRequest{ + SubspaceId: subspaceID, + Pagination: pagination, + } +} + +// NewQuerySectionRequest returns a new QuerySectionRequest instance +func NewQuerySectionRequest(subspaceID uint64, sectionID uint32) *QuerySectionRequest { + return &QuerySectionRequest{ + SubspaceId: subspaceID, + SectionId: sectionID, + } +} + // NewQueryUserGroupsRequest returns a new QueryUserGroupsRequest instance -func NewQueryUserGroupsRequest(subspaceID uint64, pagination *query.PageRequest) *QueryUserGroupsRequest { +func NewQueryUserGroupsRequest(subspaceID uint64, sectionID uint32, pagination *query.PageRequest) *QueryUserGroupsRequest { return &QueryUserGroupsRequest{ SubspaceId: subspaceID, + SectionId: sectionID, Pagination: pagination, } } @@ -52,3 +69,31 @@ func NewQueryUserPermissionsRequest(subspaceID uint64, user string) *QueryUserPe User: user, } } + +// NewPermissionDetailUser returns a new PermissionDetail for the user with the given address and permission value +func NewPermissionDetailUser(subspaceID uint64, sectionID uint32, user string, permission Permission) PermissionDetail { + return PermissionDetail{ + SubspaceId: subspaceID, + SectionId: sectionID, + Sum: &PermissionDetail_User_{ + User: &PermissionDetail_User{ + User: user, + Permission: permission, + }, + }, + } +} + +// NewPermissionDetailGroup returns a new PermissionDetail for the user with the given id and permission value +func NewPermissionDetailGroup(subspaceID uint64, sectionID uint32, groupID uint32, permission Permission) PermissionDetail { + return PermissionDetail{ + SubspaceId: subspaceID, + SectionId: sectionID, + Sum: &PermissionDetail_Group_{ + Group: &PermissionDetail_Group{ + GroupID: groupID, + Permission: permission, + }, + }, + } +} diff --git a/x/subspaces/types/query.pb.go b/x/subspaces/types/query.pb.go index 72a306ef46..95213339ec 100644 --- a/x/subspaces/types/query.pb.go +++ b/x/subspaces/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: desmos/subspaces/v1/query.proto +// source: desmos/subspaces/v2/query.proto package types @@ -40,7 +40,7 @@ func (m *QuerySubspacesRequest) Reset() { *m = QuerySubspacesRequest{} } func (m *QuerySubspacesRequest) String() string { return proto.CompactTextString(m) } func (*QuerySubspacesRequest) ProtoMessage() {} func (*QuerySubspacesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{0} + return fileDescriptor_acc17cc7a389b584, []int{0} } func (m *QuerySubspacesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -87,7 +87,7 @@ func (m *QuerySubspacesResponse) Reset() { *m = QuerySubspacesResponse{} func (m *QuerySubspacesResponse) String() string { return proto.CompactTextString(m) } func (*QuerySubspacesResponse) ProtoMessage() {} func (*QuerySubspacesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{1} + return fileDescriptor_acc17cc7a389b584, []int{1} } func (m *QuerySubspacesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -139,7 +139,7 @@ func (m *QuerySubspaceRequest) Reset() { *m = QuerySubspaceRequest{} } func (m *QuerySubspaceRequest) String() string { return proto.CompactTextString(m) } func (*QuerySubspaceRequest) ProtoMessage() {} func (*QuerySubspaceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{2} + return fileDescriptor_acc17cc7a389b584, []int{2} } func (m *QuerySubspaceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -177,7 +177,7 @@ func (m *QuerySubspaceResponse) Reset() { *m = QuerySubspaceResponse{} } func (m *QuerySubspaceResponse) String() string { return proto.CompactTextString(m) } func (*QuerySubspaceResponse) ProtoMessage() {} func (*QuerySubspaceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{3} + return fileDescriptor_acc17cc7a389b584, []int{3} } func (m *QuerySubspaceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -213,19 +213,230 @@ func (m *QuerySubspaceResponse) GetSubspace() Subspace { return Subspace{} } +// QuerySectionsRequest is the request type for Query/Sections RPC method +type QuerySectionsRequest struct { + // Id of the subspace to query the sections for + SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySectionsRequest) Reset() { *m = QuerySectionsRequest{} } +func (m *QuerySectionsRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySectionsRequest) ProtoMessage() {} +func (*QuerySectionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{4} +} +func (m *QuerySectionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySectionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySectionsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySectionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySectionsRequest.Merge(m, src) +} +func (m *QuerySectionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySectionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySectionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySectionsRequest proto.InternalMessageInfo + +func (m *QuerySectionsRequest) GetSubspaceId() uint64 { + if m != nil { + return m.SubspaceId + } + return 0 +} + +func (m *QuerySectionsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QuerySectionsResponse is the response type for Query/Sections RPC method +type QuerySectionsResponse struct { + Sections []Section `protobuf:"bytes,1,rep,name=sections,proto3" json:"sections"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySectionsResponse) Reset() { *m = QuerySectionsResponse{} } +func (m *QuerySectionsResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySectionsResponse) ProtoMessage() {} +func (*QuerySectionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{5} +} +func (m *QuerySectionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySectionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySectionsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySectionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySectionsResponse.Merge(m, src) +} +func (m *QuerySectionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySectionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySectionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySectionsResponse proto.InternalMessageInfo + +func (m *QuerySectionsResponse) GetSections() []Section { + if m != nil { + return m.Sections + } + return nil +} + +func (m *QuerySectionsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QuerySectionRequest is the request type for Query/Section RPC method +type QuerySectionRequest struct { + // Id of the subspace inside which to search for + SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Id of the searched section + SectionId uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` +} + +func (m *QuerySectionRequest) Reset() { *m = QuerySectionRequest{} } +func (m *QuerySectionRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySectionRequest) ProtoMessage() {} +func (*QuerySectionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{6} +} +func (m *QuerySectionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySectionRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySectionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySectionRequest.Merge(m, src) +} +func (m *QuerySectionRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySectionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySectionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySectionRequest proto.InternalMessageInfo + +func (m *QuerySectionRequest) GetSubspaceId() uint64 { + if m != nil { + return m.SubspaceId + } + return 0 +} + +func (m *QuerySectionRequest) GetSectionId() uint32 { + if m != nil { + return m.SectionId + } + return 0 +} + +// QuerySectionResponse is the response type for Query/Section RPC method +type QuerySectionResponse struct { + Section Section `protobuf:"bytes,1,opt,name=section,proto3" json:"section"` +} + +func (m *QuerySectionResponse) Reset() { *m = QuerySectionResponse{} } +func (m *QuerySectionResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySectionResponse) ProtoMessage() {} +func (*QuerySectionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{7} +} +func (m *QuerySectionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySectionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySectionResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySectionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySectionResponse.Merge(m, src) +} +func (m *QuerySectionResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySectionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySectionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySectionResponse proto.InternalMessageInfo + +func (m *QuerySectionResponse) GetSection() Section { + if m != nil { + return m.Section + } + return Section{} +} + // QueryUserGroupsRequest is the request type for the Query/UserGroups RPC // method type QueryUserGroupsRequest struct { + // Id of the subspace to query the groups for SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` + // (optional) Section id to query the groups for + SectionId uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryUserGroupsRequest) Reset() { *m = QueryUserGroupsRequest{} } func (m *QueryUserGroupsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUserGroupsRequest) ProtoMessage() {} func (*QueryUserGroupsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{4} + return fileDescriptor_acc17cc7a389b584, []int{8} } func (m *QueryUserGroupsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -261,6 +472,13 @@ func (m *QueryUserGroupsRequest) GetSubspaceId() uint64 { return 0 } +func (m *QueryUserGroupsRequest) GetSectionId() uint32 { + if m != nil { + return m.SectionId + } + return 0 +} + func (m *QueryUserGroupsRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination @@ -279,7 +497,7 @@ func (m *QueryUserGroupsResponse) Reset() { *m = QueryUserGroupsResponse func (m *QueryUserGroupsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUserGroupsResponse) ProtoMessage() {} func (*QueryUserGroupsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{5} + return fileDescriptor_acc17cc7a389b584, []int{9} } func (m *QueryUserGroupsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -332,7 +550,7 @@ func (m *QueryUserGroupRequest) Reset() { *m = QueryUserGroupRequest{} } func (m *QueryUserGroupRequest) String() string { return proto.CompactTextString(m) } func (*QueryUserGroupRequest) ProtoMessage() {} func (*QueryUserGroupRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{6} + return fileDescriptor_acc17cc7a389b584, []int{10} } func (m *QueryUserGroupRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -385,7 +603,7 @@ func (m *QueryUserGroupResponse) Reset() { *m = QueryUserGroupResponse{} func (m *QueryUserGroupResponse) String() string { return proto.CompactTextString(m) } func (*QueryUserGroupResponse) ProtoMessage() {} func (*QueryUserGroupResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{7} + return fileDescriptor_acc17cc7a389b584, []int{11} } func (m *QueryUserGroupResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -434,7 +652,7 @@ func (m *QueryUserGroupMembersRequest) Reset() { *m = QueryUserGroupMemb func (m *QueryUserGroupMembersRequest) String() string { return proto.CompactTextString(m) } func (*QueryUserGroupMembersRequest) ProtoMessage() {} func (*QueryUserGroupMembersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{8} + return fileDescriptor_acc17cc7a389b584, []int{12} } func (m *QueryUserGroupMembersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -495,7 +713,7 @@ func (m *QueryUserGroupMembersResponse) Reset() { *m = QueryUserGroupMem func (m *QueryUserGroupMembersResponse) String() string { return proto.CompactTextString(m) } func (*QueryUserGroupMembersResponse) ProtoMessage() {} func (*QueryUserGroupMembersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{9} + return fileDescriptor_acc17cc7a389b584, []int{13} } func (m *QueryUserGroupMembersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -542,14 +760,15 @@ func (m *QueryUserGroupMembersResponse) GetPagination() *query.PageResponse { // RPC method type QueryUserPermissionsRequest struct { SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty" yaml:"subspace_id"` - User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` + SectionId uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty" yaml:"section_id"` + User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` } func (m *QueryUserPermissionsRequest) Reset() { *m = QueryUserPermissionsRequest{} } func (m *QueryUserPermissionsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUserPermissionsRequest) ProtoMessage() {} func (*QueryUserPermissionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{10} + return fileDescriptor_acc17cc7a389b584, []int{14} } func (m *QueryUserPermissionsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -589,7 +808,7 @@ func (m *QueryUserPermissionsResponse) Reset() { *m = QueryUserPermissio func (m *QueryUserPermissionsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUserPermissionsResponse) ProtoMessage() {} func (*QueryUserPermissionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_883a12b013a133fc, []int{11} + return fileDescriptor_acc17cc7a389b584, []int{15} } func (m *QueryUserPermissionsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -632,79 +851,417 @@ func (m *QueryUserPermissionsResponse) GetDetails() []PermissionDetail { return nil } +// PermissionDetail contains the details data of a permission +type PermissionDetail struct { + // Id of the subspace for which this permission is valid + SubspaceId uint64 `protobuf:"varint,1,opt,name=subspace_id,json=subspaceId,proto3" json:"subspace_id,omitempty"` + // Id of the section for which this permission is valid + SectionId uint32 `protobuf:"varint,2,opt,name=section_id,json=sectionId,proto3" json:"section_id,omitempty"` + // sum is the oneof that specifies whether this represents a user or + // group permission detail + // + // Types that are valid to be assigned to Sum: + // *PermissionDetail_User_ + // *PermissionDetail_Group_ + Sum isPermissionDetail_Sum `protobuf_oneof:"sum"` +} + +func (m *PermissionDetail) Reset() { *m = PermissionDetail{} } +func (m *PermissionDetail) String() string { return proto.CompactTextString(m) } +func (*PermissionDetail) ProtoMessage() {} +func (*PermissionDetail) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{16} +} +func (m *PermissionDetail) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PermissionDetail) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PermissionDetail.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PermissionDetail) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDetail.Merge(m, src) +} +func (m *PermissionDetail) XXX_Size() int { + return m.Size() +} +func (m *PermissionDetail) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDetail.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDetail proto.InternalMessageInfo + +type isPermissionDetail_Sum interface { + isPermissionDetail_Sum() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type PermissionDetail_User_ struct { + User *PermissionDetail_User `protobuf:"bytes,3,opt,name=user,proto3,oneof" json:"user,omitempty"` +} +type PermissionDetail_Group_ struct { + Group *PermissionDetail_Group `protobuf:"bytes,4,opt,name=group,proto3,oneof" json:"group,omitempty"` +} + +func (*PermissionDetail_User_) isPermissionDetail_Sum() {} +func (*PermissionDetail_Group_) isPermissionDetail_Sum() {} + +func (m *PermissionDetail) GetSum() isPermissionDetail_Sum { + if m != nil { + return m.Sum + } + return nil +} + +func (m *PermissionDetail) GetUser() *PermissionDetail_User { + if x, ok := m.GetSum().(*PermissionDetail_User_); ok { + return x.User + } + return nil +} + +func (m *PermissionDetail) GetGroup() *PermissionDetail_Group { + if x, ok := m.GetSum().(*PermissionDetail_Group_); ok { + return x.Group + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*PermissionDetail) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*PermissionDetail_User_)(nil), + (*PermissionDetail_Group_)(nil), + } +} + +// User is a permission that has been set to a specific user +type PermissionDetail_User struct { + // User for which the permission was set + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty" yaml:"user"` + // Permission set to the user + Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty" yaml:"permission"` +} + +func (m *PermissionDetail_User) Reset() { *m = PermissionDetail_User{} } +func (m *PermissionDetail_User) String() string { return proto.CompactTextString(m) } +func (*PermissionDetail_User) ProtoMessage() {} +func (*PermissionDetail_User) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{16, 0} +} +func (m *PermissionDetail_User) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PermissionDetail_User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PermissionDetail_User.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PermissionDetail_User) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDetail_User.Merge(m, src) +} +func (m *PermissionDetail_User) XXX_Size() int { + return m.Size() +} +func (m *PermissionDetail_User) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDetail_User.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDetail_User proto.InternalMessageInfo + +// Group is a permission that has been set to a user group +type PermissionDetail_Group struct { + // Unique id of the group + GroupID uint32 `protobuf:"varint,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty" yaml:"group_id"` + // Permission set to the group + Permission uint32 `protobuf:"varint,2,opt,name=permission,proto3" json:"permission,omitempty"` +} + +func (m *PermissionDetail_Group) Reset() { *m = PermissionDetail_Group{} } +func (m *PermissionDetail_Group) String() string { return proto.CompactTextString(m) } +func (*PermissionDetail_Group) ProtoMessage() {} +func (*PermissionDetail_Group) Descriptor() ([]byte, []int) { + return fileDescriptor_acc17cc7a389b584, []int{16, 1} +} +func (m *PermissionDetail_Group) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PermissionDetail_Group) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PermissionDetail_Group.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PermissionDetail_Group) XXX_Merge(src proto.Message) { + xxx_messageInfo_PermissionDetail_Group.Merge(m, src) +} +func (m *PermissionDetail_Group) XXX_Size() int { + return m.Size() +} +func (m *PermissionDetail_Group) XXX_DiscardUnknown() { + xxx_messageInfo_PermissionDetail_Group.DiscardUnknown(m) +} + +var xxx_messageInfo_PermissionDetail_Group proto.InternalMessageInfo + func init() { - proto.RegisterType((*QuerySubspacesRequest)(nil), "desmos.subspaces.v1.QuerySubspacesRequest") - proto.RegisterType((*QuerySubspacesResponse)(nil), "desmos.subspaces.v1.QuerySubspacesResponse") - proto.RegisterType((*QuerySubspaceRequest)(nil), "desmos.subspaces.v1.QuerySubspaceRequest") - proto.RegisterType((*QuerySubspaceResponse)(nil), "desmos.subspaces.v1.QuerySubspaceResponse") - proto.RegisterType((*QueryUserGroupsRequest)(nil), "desmos.subspaces.v1.QueryUserGroupsRequest") - proto.RegisterType((*QueryUserGroupsResponse)(nil), "desmos.subspaces.v1.QueryUserGroupsResponse") - proto.RegisterType((*QueryUserGroupRequest)(nil), "desmos.subspaces.v1.QueryUserGroupRequest") - proto.RegisterType((*QueryUserGroupResponse)(nil), "desmos.subspaces.v1.QueryUserGroupResponse") - proto.RegisterType((*QueryUserGroupMembersRequest)(nil), "desmos.subspaces.v1.QueryUserGroupMembersRequest") - proto.RegisterType((*QueryUserGroupMembersResponse)(nil), "desmos.subspaces.v1.QueryUserGroupMembersResponse") - proto.RegisterType((*QueryUserPermissionsRequest)(nil), "desmos.subspaces.v1.QueryUserPermissionsRequest") - proto.RegisterType((*QueryUserPermissionsResponse)(nil), "desmos.subspaces.v1.QueryUserPermissionsResponse") -} - -func init() { proto.RegisterFile("desmos/subspaces/v1/query.proto", fileDescriptor_883a12b013a133fc) } - -var fileDescriptor_883a12b013a133fc = []byte{ - // 849 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x4f, 0x13, 0x41, - 0x14, 0xee, 0x94, 0x5f, 0xed, 0x34, 0x88, 0x19, 0x10, 0x9b, 0x0a, 0xbb, 0xcd, 0x1a, 0x11, 0x01, - 0x77, 0x6d, 0xd1, 0x68, 0xd0, 0x88, 0x34, 0x06, 0x24, 0x51, 0x83, 0xab, 0xc6, 0x1f, 0x17, 0xb2, - 0xa5, 0x93, 0xb5, 0x49, 0xdb, 0x5d, 0x3a, 0xdb, 0x46, 0x42, 0x48, 0x0c, 0x89, 0x89, 0x07, 0x0f, - 0x26, 0x9a, 0x18, 0x6f, 0x1c, 0x38, 0x7a, 0xf1, 0x2f, 0xf0, 0x8a, 0x27, 0x49, 0xbc, 0x78, 0x6a, - 0x0c, 0x78, 0xf0, 0xdc, 0xbf, 0xc0, 0xec, 0xec, 0xcc, 0x76, 0xbb, 0xd4, 0xd2, 0x52, 0xe2, 0xad, - 0x3b, 0xf3, 0x7d, 0xef, 0x7d, 0xdf, 0x7b, 0x8f, 0x37, 0x40, 0x31, 0x83, 0x49, 0xde, 0x20, 0x0a, - 0x29, 0xa5, 0x89, 0xa9, 0xad, 0x60, 0xa2, 0x94, 0x13, 0xca, 0x6a, 0x09, 0x17, 0xd7, 0x64, 0xb3, - 0x68, 0x58, 0x06, 0x1a, 0x74, 0x00, 0xb2, 0x0b, 0x90, 0xcb, 0x89, 0xd8, 0x90, 0x6e, 0xe8, 0x06, - 0xbd, 0x57, 0xec, 0x5f, 0x0e, 0x34, 0x36, 0xa2, 0x1b, 0x86, 0x9e, 0xc3, 0x8a, 0x66, 0x66, 0x15, - 0xad, 0x50, 0x30, 0x2c, 0xcd, 0xca, 0x1a, 0x05, 0xc2, 0x6e, 0xe3, 0x8d, 0x32, 0xe5, 0x8d, 0x0c, - 0xce, 0x71, 0xc4, 0xc4, 0x8a, 0x41, 0x11, 0x69, 0x8d, 0x60, 0x47, 0x83, 0x52, 0x4e, 0xa4, 0xb1, - 0xa5, 0x25, 0x14, 0x53, 0xd3, 0xb3, 0x05, 0x1a, 0xce, 0xc1, 0x4a, 0xcb, 0xf0, 0xd4, 0x03, 0x1b, - 0xf1, 0x90, 0x47, 0x53, 0xf1, 0x6a, 0x09, 0x13, 0x0b, 0xcd, 0x43, 0x58, 0x03, 0x47, 0x41, 0x1c, - 0x8c, 0x47, 0x92, 0x63, 0xb2, 0x13, 0x59, 0xb6, 0x23, 0xcb, 0x8e, 0x3b, 0x16, 0x59, 0x5e, 0xd2, - 0x74, 0xcc, 0xb8, 0xaa, 0x87, 0x29, 0x6d, 0x03, 0x38, 0xec, 0xcf, 0x40, 0x4c, 0xa3, 0x40, 0x30, - 0x9a, 0x83, 0x61, 0xd7, 0x44, 0x14, 0xc4, 0xbb, 0xc6, 0x23, 0xc9, 0x51, 0xb9, 0x41, 0x99, 0x64, - 0x4e, 0x4d, 0x75, 0xef, 0x54, 0xc4, 0x80, 0x5a, 0x63, 0xa1, 0x85, 0x3a, 0x95, 0x41, 0xaa, 0xf2, - 0xfc, 0xa1, 0x2a, 0x9d, 0xfc, 0x75, 0x32, 0x9f, 0xc1, 0xa1, 0x3a, 0x95, 0xbc, 0x0c, 0x57, 0x61, - 0x84, 0x67, 0x5b, 0xce, 0x66, 0x68, 0x1d, 0xba, 0x53, 0xc3, 0xd5, 0x8a, 0x88, 0xd6, 0xb4, 0x7c, - 0x6e, 0x46, 0xf2, 0x5c, 0x4a, 0x2a, 0xe4, 0x5f, 0x8b, 0x99, 0x99, 0xd0, 0x9b, 0x2d, 0x31, 0xf0, - 0x67, 0x4b, 0x0c, 0x48, 0x4f, 0x7d, 0x25, 0x76, 0xfd, 0xcf, 0xc2, 0x10, 0x27, 0xb0, 0x02, 0xb7, - 0x64, 0xdf, 0x25, 0x49, 0x9f, 0x78, 0x6d, 0x1f, 0x13, 0x5c, 0x5c, 0x28, 0x1a, 0x25, 0x93, 0x74, - 0xaa, 0xdb, 0xd7, 0xf7, 0xe0, 0x91, 0xfb, 0xbe, 0x05, 0xe0, 0xe9, 0x03, 0xda, 0x98, 0xf1, 0x1b, - 0xb0, 0x57, 0xa7, 0x27, 0xac, 0xeb, 0x42, 0x43, 0xdb, 0x2e, 0x91, 0xf9, 0x66, 0x9c, 0xe3, 0xeb, - 0xf9, 0x2b, 0xc0, 0x3a, 0xe3, 0x66, 0xea, 0xb8, 0x7a, 0x32, 0x0c, 0x51, 0x95, 0x36, 0xcb, 0x56, - 0xd6, 0x9f, 0x1a, 0xac, 0x56, 0xc4, 0x01, 0x87, 0xc5, 0x6f, 0x24, 0xb5, 0x8f, 0xfe, 0x5c, 0xcc, - 0x48, 0x8f, 0xfc, 0x0d, 0x74, 0x6b, 0x34, 0x03, 0x7b, 0x28, 0x88, 0x4d, 0x46, 0x6b, 0x25, 0x72, - 0x28, 0xd2, 0x77, 0x00, 0x47, 0xea, 0xc3, 0xde, 0xc3, 0xf9, 0x34, 0x2e, 0x92, 0xff, 0xed, 0xcf, - 0x37, 0x4d, 0x5d, 0x47, 0x9e, 0xa6, 0x4d, 0x00, 0x47, 0xff, 0xe1, 0x88, 0xd5, 0x2b, 0x0a, 0xfb, - 0xf2, 0xce, 0x11, 0x1d, 0xaa, 0xb0, 0xca, 0x3f, 0x8f, 0x6f, 0x5e, 0x5e, 0x03, 0x78, 0xc6, 0x15, - 0xb1, 0x84, 0x8b, 0xf9, 0x2c, 0x21, 0xf6, 0x62, 0xee, 0xb8, 0xaa, 0x67, 0x61, 0x77, 0x89, 0xe0, - 0x22, 0xd5, 0x16, 0x4e, 0x0d, 0x54, 0x2b, 0x62, 0xc4, 0x61, 0xd8, 0xa7, 0x92, 0x4a, 0x2f, 0x3d, - 0x0b, 0xe5, 0x8b, 0xb7, 0xbd, 0x75, 0x3a, 0x58, 0x2d, 0xae, 0xc1, 0x88, 0x59, 0x3b, 0xa6, 0x42, - 0xfa, 0xbd, 0x42, 0x3c, 0x97, 0x92, 0xea, 0x85, 0xa2, 0x27, 0xb0, 0x2f, 0x83, 0x2d, 0x2d, 0x9b, - 0x23, 0xd1, 0x20, 0xfd, 0xd3, 0x3c, 0xd7, 0x70, 0xee, 0x6a, 0x49, 0x6f, 0x53, 0x74, 0x6a, 0xd8, - 0x1e, 0xbf, 0x6a, 0x45, 0x3c, 0xe1, 0x24, 0x60, 0x31, 0x24, 0x95, 0x47, 0x4b, 0x7e, 0x08, 0xc1, - 0x1e, 0xaa, 0x19, 0xbd, 0x05, 0x30, 0xec, 0xbe, 0x05, 0x68, 0xa2, 0x61, 0xfc, 0x86, 0x4f, 0x52, - 0x6c, 0xb2, 0x25, 0xac, 0x53, 0x03, 0x69, 0x6c, 0xf3, 0xc7, 0xef, 0xf7, 0xc1, 0x38, 0x12, 0x94, - 0x46, 0xef, 0x65, 0xed, 0x05, 0xf9, 0x08, 0x60, 0x88, 0xb3, 0xd1, 0x85, 0xc3, 0x33, 0x70, 0x31, - 0x13, 0xad, 0x40, 0x99, 0x96, 0xcb, 0x54, 0x8b, 0x8c, 0xa6, 0x9a, 0x6b, 0x51, 0xd6, 0x3d, 0x13, - 0xb2, 0x81, 0xb6, 0x01, 0x84, 0xb5, 0xe5, 0x89, 0x9a, 0xb8, 0x3f, 0xb0, 0xfe, 0x63, 0x53, 0xad, - 0x81, 0x99, 0xbe, 0xeb, 0x54, 0xdf, 0x15, 0x34, 0xdd, 0x8e, 0x3e, 0x85, 0xad, 0xe3, 0xcf, 0x00, - 0x86, 0xdd, 0x98, 0xcd, 0xfa, 0xe9, 0xdf, 0xb2, 0xb1, 0xc9, 0x96, 0xb0, 0x4c, 0xe3, 0x3c, 0xd5, - 0x78, 0x0b, 0xdd, 0x3c, 0x82, 0x46, 0x65, 0x9d, 0xaf, 0xa6, 0x0d, 0xf4, 0x0d, 0xc0, 0x93, 0xfe, - 0x25, 0x82, 0x12, 0x2d, 0x28, 0xa9, 0x5f, 0xa1, 0xb1, 0x64, 0x3b, 0x14, 0xe6, 0xe1, 0x3e, 0xf5, - 0x70, 0x07, 0xcd, 0x77, 0xe6, 0x41, 0xe1, 0x9b, 0xed, 0x2b, 0x80, 0x03, 0xbe, 0x1d, 0x80, 0x2e, - 0x35, 0xd7, 0x75, 0x70, 0x6d, 0xc5, 0x12, 0x6d, 0x30, 0x98, 0x91, 0x05, 0x6a, 0x64, 0x0e, 0xcd, - 0xb6, 0x65, 0xc4, 0xb3, 0x68, 0x94, 0x75, 0x7b, 0xa7, 0x6d, 0xa4, 0xee, 0xee, 0xec, 0x09, 0x60, - 0x77, 0x4f, 0x00, 0xbf, 0xf6, 0x04, 0xf0, 0x6e, 0x5f, 0x08, 0xec, 0xee, 0x0b, 0x81, 0x9f, 0xfb, - 0x42, 0xe0, 0x79, 0x52, 0xcf, 0x5a, 0x2f, 0x4a, 0x69, 0x79, 0xc5, 0xc8, 0xb3, 0x24, 0x17, 0x73, - 0x5a, 0x9a, 0xf0, 0x84, 0xe5, 0x69, 0xe5, 0xa5, 0x27, 0x91, 0xb5, 0x66, 0x62, 0x92, 0xee, 0xa5, - 0xff, 0xd3, 0x4e, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x11, 0x9a, 0x70, 0xdd, 0x8d, 0x0b, 0x00, - 0x00, + proto.RegisterType((*QuerySubspacesRequest)(nil), "desmos.subspaces.v2.QuerySubspacesRequest") + proto.RegisterType((*QuerySubspacesResponse)(nil), "desmos.subspaces.v2.QuerySubspacesResponse") + proto.RegisterType((*QuerySubspaceRequest)(nil), "desmos.subspaces.v2.QuerySubspaceRequest") + proto.RegisterType((*QuerySubspaceResponse)(nil), "desmos.subspaces.v2.QuerySubspaceResponse") + proto.RegisterType((*QuerySectionsRequest)(nil), "desmos.subspaces.v2.QuerySectionsRequest") + proto.RegisterType((*QuerySectionsResponse)(nil), "desmos.subspaces.v2.QuerySectionsResponse") + proto.RegisterType((*QuerySectionRequest)(nil), "desmos.subspaces.v2.QuerySectionRequest") + proto.RegisterType((*QuerySectionResponse)(nil), "desmos.subspaces.v2.QuerySectionResponse") + proto.RegisterType((*QueryUserGroupsRequest)(nil), "desmos.subspaces.v2.QueryUserGroupsRequest") + proto.RegisterType((*QueryUserGroupsResponse)(nil), "desmos.subspaces.v2.QueryUserGroupsResponse") + proto.RegisterType((*QueryUserGroupRequest)(nil), "desmos.subspaces.v2.QueryUserGroupRequest") + proto.RegisterType((*QueryUserGroupResponse)(nil), "desmos.subspaces.v2.QueryUserGroupResponse") + proto.RegisterType((*QueryUserGroupMembersRequest)(nil), "desmos.subspaces.v2.QueryUserGroupMembersRequest") + proto.RegisterType((*QueryUserGroupMembersResponse)(nil), "desmos.subspaces.v2.QueryUserGroupMembersResponse") + proto.RegisterType((*QueryUserPermissionsRequest)(nil), "desmos.subspaces.v2.QueryUserPermissionsRequest") + proto.RegisterType((*QueryUserPermissionsResponse)(nil), "desmos.subspaces.v2.QueryUserPermissionsResponse") + proto.RegisterType((*PermissionDetail)(nil), "desmos.subspaces.v2.PermissionDetail") + proto.RegisterType((*PermissionDetail_User)(nil), "desmos.subspaces.v2.PermissionDetail.User") + proto.RegisterType((*PermissionDetail_Group)(nil), "desmos.subspaces.v2.PermissionDetail.Group") +} + +func init() { proto.RegisterFile("desmos/subspaces/v2/query.proto", fileDescriptor_acc17cc7a389b584) } + +var fileDescriptor_acc17cc7a389b584 = []byte{ + // 1113 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x3d, 0x89, 0x53, 0xdb, 0xcf, 0x2a, 0x29, 0x93, 0x36, 0x44, 0x26, 0xd9, 0x8d, 0x16, + 0x51, 0xd2, 0xa4, 0xdd, 0xc1, 0x4e, 0x2b, 0x4a, 0x40, 0x6d, 0x6a, 0xaa, 0xfc, 0x90, 0x00, 0x95, + 0x85, 0x8a, 0x1f, 0x97, 0x6a, 0x1d, 0x8f, 0x8c, 0x25, 0xdb, 0xeb, 0x7a, 0xec, 0x88, 0x28, 0x8a, + 0x40, 0x3d, 0x71, 0xe0, 0x80, 0x84, 0x04, 0xd7, 0x1c, 0x7a, 0xe4, 0xc2, 0x0d, 0x89, 0x03, 0x37, + 0x54, 0x4e, 0x44, 0xe2, 0xc2, 0xc9, 0x42, 0x09, 0x07, 0xce, 0xfe, 0x0b, 0xd0, 0xce, 0xce, 0xcc, + 0xae, 0xd7, 0x8b, 0xb3, 0x8e, 0xa3, 0xde, 0xec, 0x99, 0xf7, 0xe6, 0x7d, 0xde, 0x77, 0xde, 0xf3, + 0x3c, 0x83, 0x5e, 0xa6, 0xac, 0xee, 0x30, 0xc2, 0x3a, 0x25, 0xd6, 0xb4, 0x77, 0x28, 0x23, 0xbb, + 0x05, 0xf2, 0xb8, 0x43, 0x5b, 0x7b, 0x66, 0xb3, 0xe5, 0xb4, 0x1d, 0x3c, 0xe3, 0x19, 0x98, 0xca, + 0xc0, 0xdc, 0x2d, 0xe4, 0x2e, 0x57, 0x9c, 0x8a, 0xc3, 0xf7, 0x89, 0xfb, 0xc9, 0x33, 0xcd, 0xcd, + 0x57, 0x1c, 0xa7, 0x52, 0xa3, 0xc4, 0x6e, 0x56, 0x89, 0xdd, 0x68, 0x38, 0x6d, 0xbb, 0x5d, 0x75, + 0x1a, 0x4c, 0xec, 0x2e, 0xef, 0x38, 0x3c, 0x52, 0xc9, 0x66, 0xd4, 0x8b, 0x40, 0x76, 0xf3, 0x25, + 0xda, 0xb6, 0xf3, 0xa4, 0x69, 0x57, 0xaa, 0x0d, 0x6e, 0x2c, 0x6c, 0x17, 0xa3, 0xa8, 0xea, 0x4e, + 0x99, 0xd6, 0xc4, 0x69, 0xc6, 0x23, 0xb8, 0xf2, 0x81, 0x7b, 0xc6, 0x87, 0xd2, 0xc2, 0xa2, 0x8f, + 0x3b, 0x94, 0xb5, 0xf1, 0x06, 0x80, 0x7f, 0xdc, 0x1c, 0x5a, 0x44, 0x4b, 0xd9, 0xc2, 0x55, 0xd3, + 0x8b, 0x6d, 0xba, 0xb1, 0x4d, 0x2f, 0x3b, 0x11, 0xdb, 0x7c, 0x60, 0x57, 0xa8, 0xf0, 0xb5, 0x02, + 0x9e, 0xc6, 0x53, 0x04, 0xb3, 0xe1, 0x08, 0xac, 0xe9, 0x34, 0x18, 0xc5, 0xf7, 0x20, 0xa3, 0xc0, + 0xe6, 0xd0, 0xe2, 0xe4, 0x52, 0xb6, 0xb0, 0x60, 0x46, 0xc8, 0x64, 0x4a, 0xd7, 0x62, 0xf2, 0x59, + 0x57, 0x4f, 0x58, 0xbe, 0x17, 0xde, 0xec, 0xa3, 0x9c, 0xe0, 0x94, 0xaf, 0x9d, 0x4a, 0xe9, 0xc5, + 0xef, 0xc3, 0xfc, 0x14, 0x2e, 0xf7, 0x51, 0x4a, 0x19, 0xde, 0x80, 0xac, 0x8c, 0xf6, 0xa8, 0x5a, + 0xe6, 0x3a, 0x24, 0x8b, 0xb3, 0xbd, 0xae, 0x8e, 0xf7, 0xec, 0x7a, 0x6d, 0xcd, 0x08, 0x6c, 0x1a, + 0x16, 0xc8, 0x6f, 0xdb, 0xe5, 0xb5, 0xf4, 0xd7, 0x87, 0x7a, 0xe2, 0xdf, 0x43, 0x3d, 0x61, 0x7c, + 0x12, 0x92, 0x58, 0xe5, 0x7f, 0x17, 0xd2, 0xd2, 0x41, 0x08, 0x1c, 0x2b, 0x7d, 0xe5, 0x64, 0x7c, + 0x29, 0xa1, 0xe9, 0x0e, 0xaf, 0x10, 0x09, 0xad, 0x47, 0x40, 0x07, 0xe1, 0x42, 0x97, 0x3b, 0x71, + 0xe6, 0xcb, 0x3d, 0x44, 0x32, 0x37, 0x45, 0x20, 0x72, 0xbb, 0x03, 0x69, 0x26, 0xd6, 0xc4, 0xd5, + 0xce, 0x47, 0xe7, 0xe6, 0x19, 0xa9, 0xd4, 0x84, 0xcf, 0xf9, 0x5d, 0xec, 0x43, 0x98, 0x09, 0x12, + 0xc6, 0x96, 0x68, 0x01, 0x40, 0xc0, 0xb8, 0xfb, 0x2e, 0xc0, 0x45, 0x2b, 0x23, 0x56, 0xb6, 0xcb, + 0xc6, 0x47, 0xfd, 0xd2, 0xab, 0xbc, 0xdf, 0x86, 0x94, 0x30, 0x12, 0x57, 0x1a, 0x27, 0x6d, 0xe9, + 0x62, 0xfc, 0x2c, 0x9b, 0xe5, 0x21, 0xa3, 0xad, 0xcd, 0x96, 0xd3, 0x69, 0xb2, 0x71, 0x0b, 0xf1, + 0x94, 0x44, 0x42, 0xa5, 0x30, 0x39, 0x4e, 0x29, 0xbc, 0x34, 0x80, 0xae, 0x44, 0xb9, 0x50, 0xe1, + 0x2b, 0xa2, 0x14, 0xb4, 0x48, 0x4d, 0x94, 0xa3, 0x50, 0x45, 0xf8, 0x9c, 0x5f, 0x29, 0x7c, 0x25, + 0xab, 0x55, 0x45, 0x1a, 0x5b, 0x5c, 0x13, 0xd2, 0x9c, 0x52, 0x49, 0x5b, 0x9c, 0xe9, 0x75, 0xf5, + 0x69, 0xcf, 0x4b, 0xee, 0x18, 0x56, 0x8a, 0x7f, 0xe4, 0x65, 0x33, 0x1b, 0x26, 0x10, 0x1a, 0xad, + 0xc1, 0x14, 0x37, 0x12, 0x65, 0x13, 0x4f, 0x22, 0xcf, 0xc5, 0xf8, 0x03, 0xc1, 0x7c, 0xff, 0xb1, + 0xef, 0xd1, 0x7a, 0x89, 0xb6, 0xd8, 0xf3, 0xce, 0xef, 0xdc, 0xaa, 0xe9, 0x09, 0x82, 0x85, 0xff, + 0xc9, 0x48, 0xe8, 0x35, 0x07, 0xa9, 0xba, 0xb7, 0xc4, 0x8b, 0x2a, 0x63, 0xc9, 0xaf, 0xe7, 0x57, + 0x2f, 0xbf, 0x20, 0x78, 0x59, 0x41, 0x3c, 0xa0, 0xad, 0x7a, 0x95, 0xb1, 0xe0, 0xcf, 0xec, 0x99, + 0x55, 0xbd, 0x39, 0xd8, 0x92, 0xc5, 0x2b, 0xbd, 0xae, 0xfe, 0xa2, 0xf0, 0x53, 0x7b, 0x46, 0xb0, + 0x53, 0x5f, 0x81, 0x64, 0x87, 0xd1, 0x16, 0x57, 0x35, 0x53, 0x9c, 0xee, 0x75, 0xf5, 0xac, 0x67, + 0xef, 0xae, 0x1a, 0x16, 0xdf, 0x0c, 0x3c, 0x3b, 0x3f, 0x05, 0x8b, 0xa2, 0x8f, 0x5e, 0x28, 0x78, + 0x1b, 0xb2, 0x4d, 0x7f, 0x99, 0xe3, 0x5f, 0x0c, 0xe2, 0x07, 0x36, 0x0d, 0x2b, 0x68, 0x8a, 0x3f, + 0x86, 0x54, 0x99, 0xb6, 0xed, 0x6a, 0x8d, 0xcd, 0x4d, 0xf0, 0x86, 0x7e, 0x35, 0xb2, 0x5a, 0xfd, + 0xa0, 0xf7, 0xb9, 0x75, 0x71, 0xd6, 0x2d, 0xda, 0x5e, 0x57, 0x7f, 0xc1, 0x0b, 0x20, 0xce, 0x30, + 0x2c, 0x79, 0x9a, 0xf1, 0xdb, 0x24, 0x5c, 0x0a, 0x7b, 0x8d, 0xfb, 0x53, 0x8d, 0xd7, 0x03, 0xba, + 0x65, 0x0b, 0xcb, 0xb1, 0x50, 0x79, 0xa7, 0x6d, 0x25, 0x3c, 0x51, 0xf1, 0x3b, 0xb2, 0x37, 0x93, + 0xfc, 0x88, 0x95, 0x78, 0x47, 0xf0, 0xb2, 0xdd, 0x92, 0x4d, 0x9a, 0xab, 0x41, 0xd2, 0x3d, 0x54, + 0x5d, 0x23, 0x1a, 0x72, 0x8d, 0xf8, 0x16, 0x80, 0x2f, 0xf8, 0x60, 0x85, 0xf8, 0x7b, 0x86, 0x15, + 0x30, 0x54, 0xb7, 0x8f, 0x72, 0x35, 0x98, 0xe2, 0xf1, 0xf1, 0x9b, 0x81, 0x0e, 0xf6, 0xae, 0x58, + 0x3b, 0xee, 0xea, 0x29, 0xbe, 0xb9, 0x7d, 0x7f, 0x68, 0x33, 0x6b, 0x83, 0x10, 0xd1, 0xd1, 0xfc, + 0x4f, 0xc5, 0x29, 0x98, 0x64, 0x9d, 0x7a, 0xe1, 0x08, 0x60, 0x8a, 0x17, 0x1f, 0xfe, 0x06, 0x41, + 0x46, 0x8d, 0x7e, 0x38, 0x5a, 0xfd, 0xc8, 0x09, 0x34, 0xb7, 0x12, 0xcb, 0xd6, 0x2b, 0x66, 0xe3, + 0xea, 0x93, 0x3f, 0xff, 0xf9, 0x6e, 0x62, 0x11, 0x6b, 0x64, 0x70, 0xe4, 0xcd, 0xfb, 0x5f, 0xf0, + 0x0f, 0x08, 0xd2, 0xd2, 0x1b, 0x5f, 0x3b, 0x3d, 0x82, 0x84, 0x59, 0x8e, 0x63, 0x2a, 0x58, 0x6e, + 0x72, 0x16, 0x13, 0x5f, 0x1f, 0xce, 0x42, 0xf6, 0x03, 0x65, 0x7d, 0x80, 0xbf, 0x77, 0xc9, 0xe4, + 0xf8, 0x33, 0x8c, 0xac, 0x7f, 0xd8, 0x1b, 0x4a, 0x16, 0x9a, 0xca, 0x8c, 0x55, 0x4e, 0x76, 0x03, + 0xaf, 0x90, 0xa8, 0x3f, 0x06, 0x7d, 0x3c, 0x44, 0x8d, 0x62, 0x87, 0x08, 0x52, 0xe2, 0x24, 0xbc, + 0x74, 0x6a, 0x30, 0x89, 0x75, 0x2d, 0x86, 0xa5, 0xa0, 0x5a, 0xe7, 0x54, 0x6b, 0xf8, 0xf6, 0x08, + 0x54, 0x64, 0xdf, 0x6f, 0xf9, 0x03, 0xfc, 0x14, 0x01, 0xf8, 0x73, 0x07, 0x1e, 0x52, 0x39, 0x03, + 0x83, 0x55, 0xee, 0x7a, 0x3c, 0x63, 0xc1, 0xfa, 0x16, 0x67, 0xbd, 0x85, 0x57, 0x47, 0xb9, 0x5b, + 0x22, 0x26, 0x99, 0x1f, 0x11, 0x64, 0xd4, 0x99, 0xc3, 0x7a, 0x21, 0x3c, 0xa0, 0xe4, 0x56, 0x62, + 0xd9, 0x0a, 0xc6, 0x0d, 0xce, 0xb8, 0x8e, 0xef, 0x9c, 0x81, 0x91, 0xec, 0xcb, 0x1f, 0x82, 0x03, + 0xfc, 0x3b, 0x82, 0x4b, 0xe1, 0xf7, 0x17, 0xe7, 0x63, 0x90, 0xf4, 0x4f, 0x1f, 0xb9, 0xc2, 0x28, + 0x2e, 0x22, 0x87, 0xf7, 0x79, 0x0e, 0x5b, 0x78, 0x63, 0xbc, 0x1c, 0x88, 0x1c, 0x0a, 0x7e, 0x45, + 0x30, 0x1d, 0x7a, 0x08, 0xf1, 0xeb, 0xc3, 0xb9, 0x06, 0x5f, 0xfc, 0x5c, 0x7e, 0x04, 0x0f, 0x91, + 0xc8, 0x26, 0x4f, 0xe4, 0x1e, 0xbe, 0x3b, 0x52, 0x22, 0x81, 0xd7, 0x96, 0xec, 0xbb, 0x2f, 0xc2, + 0x41, 0xf1, 0xdd, 0x67, 0xc7, 0x1a, 0x3a, 0x3a, 0xd6, 0xd0, 0xdf, 0xc7, 0x1a, 0xfa, 0xf6, 0x44, + 0x4b, 0x1c, 0x9d, 0x68, 0x89, 0xbf, 0x4e, 0xb4, 0xc4, 0x67, 0x85, 0x4a, 0xb5, 0xfd, 0x79, 0xa7, + 0x64, 0xee, 0x38, 0x75, 0x11, 0xe4, 0x46, 0xcd, 0x2e, 0x31, 0x19, 0x70, 0x77, 0x95, 0x7c, 0x11, + 0x08, 0xd4, 0xde, 0x6b, 0x52, 0x56, 0xba, 0xc0, 0xff, 0xfe, 0xaf, 0xfe, 0x17, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x3a, 0x51, 0x65, 0xb8, 0x10, 0x00, 0x00, +} + +func (this *PermissionDetail) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail) + if !ok { + that2, ok := that.(PermissionDetail) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.SubspaceId != that1.SubspaceId { + return false + } + if this.SectionId != that1.SectionId { + return false + } + if that1.Sum == nil { + if this.Sum != nil { + return false + } + } else if this.Sum == nil { + return false + } else if !this.Sum.Equal(that1.Sum) { + return false + } + return true +} +func (this *PermissionDetail_User_) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_User_) + if !ok { + that2, ok := that.(PermissionDetail_User_) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.User.Equal(that1.User) { + return false + } + return true +} +func (this *PermissionDetail_Group_) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_Group_) + if !ok { + that2, ok := that.(PermissionDetail_Group_) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Group.Equal(that1.Group) { + return false + } + return true +} +func (this *PermissionDetail_User) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_User) + if !ok { + that2, ok := that.(PermissionDetail_User) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.User != that1.User { + return false + } + if this.Permission != that1.Permission { + return false + } + return true +} +func (this *PermissionDetail_Group) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PermissionDetail_Group) + if !ok { + that2, ok := that.(PermissionDetail_Group) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.GroupID != that1.GroupID { + return false + } + if this.Permission != that1.Permission { + return false + } + return true } // Reference imports to suppress errors if they are not otherwise used. @@ -723,6 +1280,10 @@ type QueryClient interface { Subspaces(ctx context.Context, in *QuerySubspacesRequest, opts ...grpc.CallOption) (*QuerySubspacesResponse, error) // Subspace queries all the information about the subspace with the given id Subspace(ctx context.Context, in *QuerySubspaceRequest, opts ...grpc.CallOption) (*QuerySubspaceResponse, error) + // Sections allows to query for the sections of a specific subspace + Sections(ctx context.Context, in *QuerySectionsRequest, opts ...grpc.CallOption) (*QuerySectionsResponse, error) + // Section queries all the information about the section with the given id + Section(ctx context.Context, in *QuerySectionRequest, opts ...grpc.CallOption) (*QuerySectionResponse, error) // UserGroups queries all the groups that are present inside the subspace with // the given id UserGroups(ctx context.Context, in *QueryUserGroupsRequest, opts ...grpc.CallOption) (*QueryUserGroupsResponse, error) @@ -745,7 +1306,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Subspaces(ctx context.Context, in *QuerySubspacesRequest, opts ...grpc.CallOption) (*QuerySubspacesResponse, error) { out := new(QuerySubspacesResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Query/Subspaces", in, out, opts...) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/Subspaces", in, out, opts...) if err != nil { return nil, err } @@ -754,34 +1315,52 @@ func (c *queryClient) Subspaces(ctx context.Context, in *QuerySubspacesRequest, func (c *queryClient) Subspace(ctx context.Context, in *QuerySubspaceRequest, opts ...grpc.CallOption) (*QuerySubspaceResponse, error) { out := new(QuerySubspaceResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Query/Subspace", in, out, opts...) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/Subspace", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) UserGroups(ctx context.Context, in *QueryUserGroupsRequest, opts ...grpc.CallOption) (*QueryUserGroupsResponse, error) { - out := new(QueryUserGroupsResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Query/UserGroups", in, out, opts...) +func (c *queryClient) Sections(ctx context.Context, in *QuerySectionsRequest, opts ...grpc.CallOption) (*QuerySectionsResponse, error) { + out := new(QuerySectionsResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/Sections", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) UserGroup(ctx context.Context, in *QueryUserGroupRequest, opts ...grpc.CallOption) (*QueryUserGroupResponse, error) { - out := new(QueryUserGroupResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Query/UserGroup", in, out, opts...) +func (c *queryClient) Section(ctx context.Context, in *QuerySectionRequest, opts ...grpc.CallOption) (*QuerySectionResponse, error) { + out := new(QuerySectionResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/Section", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) UserGroupMembers(ctx context.Context, in *QueryUserGroupMembersRequest, opts ...grpc.CallOption) (*QueryUserGroupMembersResponse, error) { +func (c *queryClient) UserGroups(ctx context.Context, in *QueryUserGroupsRequest, opts ...grpc.CallOption) (*QueryUserGroupsResponse, error) { + out := new(QueryUserGroupsResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/UserGroups", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) UserGroup(ctx context.Context, in *QueryUserGroupRequest, opts ...grpc.CallOption) (*QueryUserGroupResponse, error) { + out := new(QueryUserGroupResponse) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/UserGroup", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) UserGroupMembers(ctx context.Context, in *QueryUserGroupMembersRequest, opts ...grpc.CallOption) (*QueryUserGroupMembersResponse, error) { out := new(QueryUserGroupMembersResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Query/UserGroupMembers", in, out, opts...) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/UserGroupMembers", in, out, opts...) if err != nil { return nil, err } @@ -790,7 +1369,7 @@ func (c *queryClient) UserGroupMembers(ctx context.Context, in *QueryUserGroupMe func (c *queryClient) UserPermissions(ctx context.Context, in *QueryUserPermissionsRequest, opts ...grpc.CallOption) (*QueryUserPermissionsResponse, error) { out := new(QueryUserPermissionsResponse) - err := c.cc.Invoke(ctx, "/desmos.subspaces.v1.Query/UserPermissions", in, out, opts...) + err := c.cc.Invoke(ctx, "/desmos.subspaces.v2.Query/UserPermissions", in, out, opts...) if err != nil { return nil, err } @@ -803,6 +1382,10 @@ type QueryServer interface { Subspaces(context.Context, *QuerySubspacesRequest) (*QuerySubspacesResponse, error) // Subspace queries all the information about the subspace with the given id Subspace(context.Context, *QuerySubspaceRequest) (*QuerySubspaceResponse, error) + // Sections allows to query for the sections of a specific subspace + Sections(context.Context, *QuerySectionsRequest) (*QuerySectionsResponse, error) + // Section queries all the information about the section with the given id + Section(context.Context, *QuerySectionRequest) (*QuerySectionResponse, error) // UserGroups queries all the groups that are present inside the subspace with // the given id UserGroups(context.Context, *QueryUserGroupsRequest) (*QueryUserGroupsResponse, error) @@ -825,6 +1408,12 @@ func (*UnimplementedQueryServer) Subspaces(ctx context.Context, req *QuerySubspa func (*UnimplementedQueryServer) Subspace(ctx context.Context, req *QuerySubspaceRequest) (*QuerySubspaceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Subspace not implemented") } +func (*UnimplementedQueryServer) Sections(ctx context.Context, req *QuerySectionsRequest) (*QuerySectionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Sections not implemented") +} +func (*UnimplementedQueryServer) Section(ctx context.Context, req *QuerySectionRequest) (*QuerySectionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Section not implemented") +} func (*UnimplementedQueryServer) UserGroups(ctx context.Context, req *QueryUserGroupsRequest) (*QueryUserGroupsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UserGroups not implemented") } @@ -852,7 +1441,7 @@ func _Query_Subspaces_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.subspaces.v1.Query/Subspaces", + FullMethod: "/desmos.subspaces.v2.Query/Subspaces", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Subspaces(ctx, req.(*QuerySubspacesRequest)) @@ -870,7 +1459,7 @@ func _Query_Subspace_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.subspaces.v1.Query/Subspace", + FullMethod: "/desmos.subspaces.v2.Query/Subspace", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Subspace(ctx, req.(*QuerySubspaceRequest)) @@ -878,6 +1467,42 @@ func _Query_Subspace_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Query_Sections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySectionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Sections(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Query/Sections", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Sections(ctx, req.(*QuerySectionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Section_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySectionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Section(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/desmos.subspaces.v2.Query/Section", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Section(ctx, req.(*QuerySectionRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_UserGroups_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryUserGroupsRequest) if err := dec(in); err != nil { @@ -888,7 +1513,7 @@ func _Query_UserGroups_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.subspaces.v1.Query/UserGroups", + FullMethod: "/desmos.subspaces.v2.Query/UserGroups", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).UserGroups(ctx, req.(*QueryUserGroupsRequest)) @@ -906,7 +1531,7 @@ func _Query_UserGroup_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.subspaces.v1.Query/UserGroup", + FullMethod: "/desmos.subspaces.v2.Query/UserGroup", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).UserGroup(ctx, req.(*QueryUserGroupRequest)) @@ -924,7 +1549,7 @@ func _Query_UserGroupMembers_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.subspaces.v1.Query/UserGroupMembers", + FullMethod: "/desmos.subspaces.v2.Query/UserGroupMembers", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).UserGroupMembers(ctx, req.(*QueryUserGroupMembersRequest)) @@ -942,7 +1567,7 @@ func _Query_UserPermissions_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/desmos.subspaces.v1.Query/UserPermissions", + FullMethod: "/desmos.subspaces.v2.Query/UserPermissions", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).UserPermissions(ctx, req.(*QueryUserPermissionsRequest)) @@ -951,7 +1576,7 @@ func _Query_UserPermissions_Handler(srv interface{}, ctx context.Context, dec fu } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "desmos.subspaces.v1.Query", + ServiceName: "desmos.subspaces.v2.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -962,6 +1587,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Subspace", Handler: _Query_Subspace_Handler, }, + { + MethodName: "Sections", + Handler: _Query_Sections_Handler, + }, + { + MethodName: "Section", + Handler: _Query_Section_Handler, + }, { MethodName: "UserGroups", Handler: _Query_UserGroups_Handler, @@ -980,7 +1613,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "desmos/subspaces/v1/query.proto", + Metadata: "desmos/subspaces/v2/query.proto", } func (m *QuerySubspacesRequest) Marshal() (dAtA []byte, err error) { @@ -1128,6 +1761,161 @@ func (m *QuerySubspaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QuerySectionsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySectionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySectionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.SubspaceId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SubspaceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QuerySectionsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySectionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySectionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Sections) > 0 { + for iNdEx := len(m.Sections) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Sections[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QuerySectionRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySectionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySectionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SectionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SectionId)) + i-- + dAtA[i] = 0x10 + } + if m.SubspaceId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SubspaceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QuerySectionResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySectionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySectionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Section.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryUserGroupsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1158,7 +1946,12 @@ func (m *QueryUserGroupsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.SectionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SectionId)) + i-- + dAtA[i] = 0x10 } if m.SubspaceId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.SubspaceId)) @@ -1397,7 +2190,12 @@ func (m *QueryUserPermissionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, er copy(dAtA[i:], m.User) i = encodeVarintQuery(dAtA, i, uint64(len(m.User))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.SectionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SectionId)) + i-- + dAtA[i] = 0x10 } if m.SubspaceId != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.SubspaceId)) @@ -1449,54 +2247,206 @@ func (m *QueryUserPermissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *PermissionDetail) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QuerySubspacesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + +func (m *PermissionDetail) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySubspacesResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *PermissionDetail) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Subspaces) > 0 { - for _, e := range m.Subspaces { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Sum != nil { + { + size := m.Sum.Size() + i -= size + if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } } } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.SectionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SectionId)) + i-- + dAtA[i] = 0x10 } - return n + if m.SubspaceId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SubspaceId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *QuerySubspaceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int +func (m *PermissionDetail_User_) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_User_) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.User != nil { + { + size, err := m.User.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *PermissionDetail_Group_) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_Group_) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Group != nil { + { + size, err := m.Group.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *PermissionDetail_User) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PermissionDetail_User) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_User) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Permission != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Permission)) + i-- + dAtA[i] = 0x10 + } + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintQuery(dAtA, i, uint64(len(m.User))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PermissionDetail_Group) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PermissionDetail_Group) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PermissionDetail_Group) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Permission != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Permission)) + i-- + dAtA[i] = 0x10 + } + if m.GroupID != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.GroupID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QuerySubspacesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySubspacesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Subspaces) > 0 { + for _, e := range m.Subspaces { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySubspaceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int _ = l if m.SubspaceId != 0 { n += 1 + sovQuery(uint64(m.SubspaceId)) @@ -1515,6 +2465,67 @@ func (m *QuerySubspaceResponse) Size() (n int) { return n } +func (m *QuerySectionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceId != 0 { + n += 1 + sovQuery(uint64(m.SubspaceId)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySectionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Sections) > 0 { + for _, e := range m.Sections { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySectionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceId != 0 { + n += 1 + sovQuery(uint64(m.SubspaceId)) + } + if m.SectionId != 0 { + n += 1 + sovQuery(uint64(m.SectionId)) + } + return n +} + +func (m *QuerySectionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Section.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryUserGroupsRequest) Size() (n int) { if m == nil { return 0 @@ -1524,6 +2535,9 @@ func (m *QueryUserGroupsRequest) Size() (n int) { if m.SubspaceId != 0 { n += 1 + sovQuery(uint64(m.SubspaceId)) } + if m.SectionId != 0 { + n += 1 + sovQuery(uint64(m.SectionId)) + } if m.Pagination != nil { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) @@ -1623,6 +2637,9 @@ func (m *QueryUserPermissionsRequest) Size() (n int) { if m.SubspaceId != 0 { n += 1 + sovQuery(uint64(m.SubspaceId)) } + if m.SectionId != 0 { + n += 1 + sovQuery(uint64(m.SectionId)) + } l = len(m.User) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -1648,6 +2665,79 @@ func (m *QueryUserPermissionsResponse) Size() (n int) { return n } +func (m *PermissionDetail) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubspaceId != 0 { + n += 1 + sovQuery(uint64(m.SubspaceId)) + } + if m.SectionId != 0 { + n += 1 + sovQuery(uint64(m.SectionId)) + } + if m.Sum != nil { + n += m.Sum.Size() + } + return n +} + +func (m *PermissionDetail_User_) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.User != nil { + l = m.User.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *PermissionDetail_Group_) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Group != nil { + l = m.Group.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} +func (m *PermissionDetail_User) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.User) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Permission != 0 { + n += 1 + sovQuery(uint64(m.Permission)) + } + return n +} + +func (m *PermissionDetail_Group) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GroupID != 0 { + n += 1 + sovQuery(uint64(m.GroupID)) + } + if m.Permission != 0 { + n += 1 + sovQuery(uint64(m.Permission)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2012,7 +3102,7 @@ func (m *QuerySubspaceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserGroupsRequest) Unmarshal(dAtA []byte) error { +func (m *QuerySectionsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2035,10 +3125,10 @@ func (m *QueryUserGroupsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserGroupsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySectionsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserGroupsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySectionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2117,7 +3207,7 @@ func (m *QueryUserGroupsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserGroupsResponse) Unmarshal(dAtA []byte) error { +func (m *QuerySectionsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2140,17 +3230,847 @@ func (m *QueryUserGroupsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserGroupsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySectionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySectionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sections", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sections = append(m.Sections, Section{}) + if err := m.Sections[len(m.Sections)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySectionRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySectionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySectionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceId", wireType) + } + m.SubspaceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionId", wireType) + } + m.SectionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySectionResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuerySectionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySectionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Section", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Section.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUserGroupsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUserGroupsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserGroupsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceId", wireType) + } + m.SubspaceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SectionId", wireType) + } + m.SectionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SectionId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUserGroupsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUserGroupsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserGroupsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Groups", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Groups = append(m.Groups, UserGroup{}) + if err := m.Groups[len(m.Groups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUserGroupRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUserGroupRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceId", wireType) + } + m.SubspaceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUserGroupResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUserGroupResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Group.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUserGroupMembersRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUserGroupMembersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUserGroupMembersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SubspaceId", wireType) + } + m.SubspaceId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SubspaceId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + } + m.GroupId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GroupId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUserGroupMembersResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryUserGroupMembersResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserGroupsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryUserGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Groups", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2160,25 +4080,23 @@ func (m *QueryUserGroupsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Groups = append(m.Groups, UserGroup{}) - if err := m.Groups[len(m.Groups)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Members = append(m.Members, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { @@ -2237,7 +4155,7 @@ func (m *QueryUserGroupsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserGroupRequest) Unmarshal(dAtA []byte) error { +func (m *QueryUserPermissionsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2260,10 +4178,10 @@ func (m *QueryUserGroupRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserGroupRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryUserPermissionsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserGroupRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryUserPermissionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2287,9 +4205,9 @@ func (m *QueryUserGroupRequest) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SectionId", wireType) } - m.GroupId = 0 + m.SectionId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2299,11 +4217,43 @@ func (m *QueryUserGroupRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint32(b&0x7F) << shift + m.SectionId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2325,7 +4275,7 @@ func (m *QueryUserGroupRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserGroupResponse) Unmarshal(dAtA []byte) error { +func (m *QueryUserPermissionsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2348,15 +4298,34 @@ func (m *QueryUserGroupResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserGroupResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryUserPermissionsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserGroupResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryUserPermissionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2383,7 +4352,8 @@ func (m *QueryUserGroupResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Group.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Details = append(m.Details, PermissionDetail{}) + if err := m.Details[len(m.Details)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2408,7 +4378,7 @@ func (m *QueryUserGroupResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserGroupMembersRequest) Unmarshal(dAtA []byte) error { +func (m *PermissionDetail) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2431,10 +4401,10 @@ func (m *QueryUserGroupMembersRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserGroupMembersRequest: wiretype end group for non-group") + return fmt.Errorf("proto: PermissionDetail: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserGroupMembersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PermissionDetail: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2458,9 +4428,9 @@ func (m *QueryUserGroupMembersRequest) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GroupId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SectionId", wireType) } - m.GroupId = 0 + m.SectionId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2470,14 +4440,14 @@ func (m *QueryUserGroupMembersRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.GroupId |= uint32(b&0x7F) << shift + m.SectionId |= uint32(b&0x7F) << shift if b < 0x80 { break } } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2504,98 +4474,15 @@ func (m *QueryUserGroupMembersRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { + v := &PermissionDetail_User{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryUserGroupMembersResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryUserGroupMembersResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserGroupMembersResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Members = append(m.Members, string(dAtA[iNdEx:postIndex])) + m.Sum = &PermissionDetail_User_{v} iNdEx = postIndex - case 2: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2622,12 +4509,11 @@ func (m *QueryUserGroupMembersResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + v := &PermissionDetail_Group{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } + m.Sum = &PermissionDetail_Group_{v} iNdEx = postIndex default: iNdEx = preIndex @@ -2650,7 +4536,7 @@ func (m *QueryUserGroupMembersResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserPermissionsRequest) Unmarshal(dAtA []byte) error { +func (m *PermissionDetail_User) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2673,32 +4559,13 @@ func (m *QueryUserPermissionsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserPermissionsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: User: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserPermissionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: User: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SubspaceId", wireType) - } - m.SubspaceId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SubspaceId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) } @@ -2730,6 +4597,25 @@ func (m *QueryUserPermissionsRequest) Unmarshal(dAtA []byte) error { } m.User = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + } + m.Permission = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permission |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2751,7 +4637,7 @@ func (m *QueryUserPermissionsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserPermissionsResponse) Unmarshal(dAtA []byte) error { +func (m *PermissionDetail_Group) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2774,17 +4660,17 @@ func (m *QueryUserPermissionsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserPermissionsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: Group: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserPermissionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Group: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field GroupID", wireType) } - m.Permissions = 0 + m.GroupID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2794,16 +4680,16 @@ func (m *QueryUserPermissionsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= uint32(b&0x7F) << shift + m.GroupID |= uint32(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) } - var msglen int + m.Permission = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2813,26 +4699,11 @@ func (m *QueryUserPermissionsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Permission |= uint32(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Details = append(m.Details, PermissionDetail{}) - if err := m.Details[len(m.Details)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/subspaces/types/query.pb.gw.go b/x/subspaces/types/query.pb.gw.go index 9970076688..617fcb8841 100644 --- a/x/subspaces/types/query.pb.gw.go +++ b/x/subspaces/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: desmos/subspaces/v1/query.proto +// source: desmos/subspaces/v2/query.proto /* Package types is a reverse proxy. @@ -121,6 +121,154 @@ func local_request_Query_Subspace_0(ctx context.Context, marshaler runtime.Marsh } +var ( + filter_Query_Sections_0 = &utilities.DoubleArray{Encoding: map[string]int{"subspace_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_Sections_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySectionsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subspace_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subspace_id") + } + + protoReq.SubspaceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subspace_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Sections_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Sections(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Sections_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySectionsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subspace_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subspace_id") + } + + protoReq.SubspaceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subspace_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Sections_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Sections(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Section_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySectionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subspace_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subspace_id") + } + + protoReq.SubspaceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subspace_id", err) + } + + val, ok = pathParams["section_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "section_id") + } + + protoReq.SectionId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "section_id", err) + } + + msg, err := client.Section(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Section_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySectionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["subspace_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "subspace_id") + } + + protoReq.SubspaceId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "subspace_id", err) + } + + val, ok = pathParams["section_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "section_id") + } + + protoReq.SectionId, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "section_id", err) + } + + msg, err := server.Section(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_UserGroups_0 = &utilities.DoubleArray{Encoding: map[string]int{"subspace_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -363,6 +511,10 @@ func local_request_Query_UserGroupMembers_0(ctx context.Context, marshaler runti } +var ( + filter_Query_UserPermissions_0 = &utilities.DoubleArray{Encoding: map[string]int{"subspace_id": 0, "user": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + func request_Query_UserPermissions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryUserPermissionsRequest var metadata runtime.ServerMetadata @@ -396,6 +548,13 @@ func request_Query_UserPermissions_0(ctx context.Context, marshaler runtime.Mars return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_UserPermissions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UserPermissions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -434,6 +593,13 @@ func local_request_Query_UserPermissions_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_UserPermissions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UserPermissions(ctx, &protoReq) return msg, metadata, err @@ -485,6 +651,46 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_Sections_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Sections_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Sections_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Section_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Section_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Section_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_UserGroups_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -646,6 +852,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_Sections_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Sections_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Sections_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Section_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Section_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Section_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_UserGroups_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -734,6 +980,10 @@ var ( pattern_Query_Subspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3}, []string{"desmos", "subspaces", "v1", "subspace_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Sections_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"desmos", "subspaces", "v2", "subspace_id", "sections"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Section_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"desmos", "subspaces", "v2", "subspace_id", "sections", "section_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_UserGroups_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"desmos", "subspaces", "v1", "subspace_id", "groups"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_UserGroup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"desmos", "subspaces", "v1", "subspace_id", "groups", "group_id"}, "", runtime.AssumeColonVerbOpt(true))) @@ -748,6 +998,10 @@ var ( forward_Query_Subspace_0 = runtime.ForwardResponseMessage + forward_Query_Sections_0 = runtime.ForwardResponseMessage + + forward_Query_Section_0 = runtime.ForwardResponseMessage + forward_Query_UserGroups_0 = runtime.ForwardResponseMessage forward_Query_UserGroup_0 = runtime.ForwardResponseMessage