Skip to content

Commit

Permalink
feat: add update-object-info for updateobject's visibility (cherry pick
Browse files Browse the repository at this point in the history
#138) (#215)

* feat: add update-object-info for updateobject's visibility (#138)

* add update-object-info for updateobject's visibility
fix ACTION_UPDATE_OBJECT_INFO
add e2e test
fix protobuf check
fix updateobjectinfo bug
modify operator_address to operator

* add pb

* run make proto-swagger-gen

* fix conflict *pb.go
  • Loading branch information
jingjunLi authored Apr 26, 2023
1 parent 6d9b275 commit 11d65e8
Show file tree
Hide file tree
Showing 13 changed files with 1,493 additions and 257 deletions.
13 changes: 13 additions & 0 deletions e2e/tests/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ func (s *StorageTestSuite) TestCreateObject() {
s.Require().Equal(len(queryListObjectsResponse.ObjectInfos), 1)
s.Require().Equal(queryListObjectsResponse.ObjectInfos[0].ObjectName, objectName)

// UpdateObjectInfo
updateObjectInfo := storagetypes.NewMsgUpdateObjectInfo(
user.GetAddr(), bucketName, objectName, storagetypes.VISIBILITY_TYPE_INHERIT)
s.Require().NoError(err)
s.SendTxBlock(updateObjectInfo, user)
s.Require().NoError(err)

// verify modified objectinfo
// head object
queryHeadObjectAfterUpdateObjectResponse, err := s.Client.HeadObject(context.Background(), &queryHeadObjectRequest)
s.Require().NoError(err)
s.Require().Equal(queryHeadObjectAfterUpdateObjectResponse.ObjectInfo.Visibility, storagetypes.VISIBILITY_TYPE_INHERIT)

// DeleteObject
msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName)
s.SendTxBlock(msgDeleteObject, user)
Expand Down
2 changes: 2 additions & 0 deletions proto/greenfield/permission/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ enum ActionType {
ACTION_UPDATE_GROUP_MEMBER = 9;
ACTION_DELETE_GROUP = 10;

ACTION_UPDATE_OBJECT_INFO = 11;

ACTION_TYPE_ALL = 99;
}

Expand Down
18 changes: 18 additions & 0 deletions proto/greenfield/storage/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,24 @@ message EventDiscontinueObject {
int64 delete_at = 4;
}

// EventUpdateObjectInfo is emitted on MsgUpdateObjectInfo
message EventUpdateObjectInfo {
// operator define the account address of operator who update the bucket
string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// bucket_name define the name of the bucket
string bucket_name = 2;
// object_name define the name of the object
string object_name = 3;
// object_id define an u256 id for object
string object_id = 4 [
(cosmos_proto.scalar) = "cosmos.Uint",
(gogoproto.customtype) = "Uint",
(gogoproto.nullable) = false
];
// visibility defines the highest permission of object.
VisibilityType visibility = 5;
}

// EventCreateGroup is emitted on MsgCreateGroup
message EventCreateGroup {
// owner define the account address of group owner
Expand Down
17 changes: 17 additions & 0 deletions proto/greenfield/storage/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ service Msg {
rpc CancelCreateObject(MsgCancelCreateObject) returns (MsgCancelCreateObjectResponse);
rpc MirrorObject(MsgMirrorObject) returns (MsgMirrorObjectResponse);
rpc DiscontinueObject(MsgDiscontinueObject) returns (MsgDiscontinueObjectResponse);
rpc UpdateObjectInfo(MsgUpdateObjectInfo) returns (MsgUpdateObjectInfoResponse);

// basic operation of group
rpc CreateGroup(MsgCreateGroup) returns (MsgCreateGroupResponse);
Expand Down Expand Up @@ -391,6 +392,22 @@ message MsgMirrorBucket {
];
}

message MsgUpdateObjectInfoResponse {}

message MsgUpdateObjectInfo {
option (cosmos.msg.v1.signer) = "operator";

// operator defines the account address of the operator
string operator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// bucket_name is the name of the bucket
string bucket_name = 2;
// object_name defines the name of bucket which you'll update
string object_name = 3;
// visibility means the object is private or public. if private, only bucket owner or grantee can read it,
// otherwise every greenfield user can read it.
VisibilityType visibility = 4;
}

message MsgMirrorBucketResponse {}

message MsgMirrorGroup {
Expand Down
Loading

0 comments on commit 11d65e8

Please sign in to comment.