From 77dfae7adcdb079b202ffe538145051d56f4ddb1 Mon Sep 17 00:00:00 2001 From: constwz Date: Mon, 8 Jul 2024 09:41:24 +0800 Subject: [PATCH 1/7] feat: Support msg to create policy by cross chain --- x/storage/keeper/cross_app_permission.go | 129 ++++++++++++++++++++-- x/storage/types/expected_keepers.go | 2 + x/storage/types/expected_keepers_mocks.go | 30 +++++ 3 files changed, 154 insertions(+), 7 deletions(-) diff --git a/x/storage/keeper/cross_app_permission.go b/x/storage/keeper/cross_app_permission.go index 681d5f24d..d2764cd12 100644 --- a/x/storage/keeper/cross_app_permission.go +++ b/x/storage/keeper/cross_app_permission.go @@ -4,6 +4,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + types2 "github.com/bnb-chain/greenfield/types" gnfderrors "github.com/bnb-chain/greenfield/types/errors" gnfdresource "github.com/bnb-chain/greenfield/types/resource" permtypes "github.com/bnb-chain/greenfield/x/permission/types" @@ -146,16 +147,88 @@ func (app *PermissionApp) handleCreatePolicySynPackage(ctx sdk.Context, createPo } var policy permtypes.Policy + var grn types2.GRN err = policy.Unmarshal(createPolicyPackage.Data) if err != nil { - return sdk.ExecuteResult{ - Payload: types.CreatePolicyAckPackage{ - Status: types.StatusFail, - Creator: createPolicyPackage.Operator, - ExtraData: createPolicyPackage.ExtraData, - }.MustSerialize(), - Err: err, + var msgPutPolicy types.MsgPutPolicy + err = msgPutPolicy.Unmarshal(createPolicyPackage.Data) + if err != nil { + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: err, + } + } + if msgPutPolicy.GetOperator() != createPolicyPackage.Operator.String() { + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: types.ErrAccessDenied.Wrapf( + "Only resource owner can put policy, operator (%s)", + msgPutPolicy.GetOperator()), + } + } + + err = grn.ParseFromString(msgPutPolicy.Resource, true) + if err != nil { + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: err, + } } + + if msgPutPolicy.ExpirationTime != nil && msgPutPolicy.ExpirationTime.Before(ctx.BlockTime()) { + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: permtypes.ErrPermissionExpired.Wrapf("The specified policy expiration time is less than the current block time, block time: %s", ctx.BlockTime().String()), + } + } + + for _, s := range msgPutPolicy.Statements { + if s.ExpirationTime != nil && s.ExpirationTime.Before(ctx.BlockTime()) { + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: permtypes.ErrPermissionExpired.Wrapf("The specified statement expiration time is less than the current block time, block time: %s", ctx.BlockTime().String()), + } + } + } + + policy = permtypes.Policy{ + ResourceType: grn.ResourceType(), + Principal: msgPutPolicy.Principal, + Statements: msgPutPolicy.Statements, + ExpirationTime: msgPutPolicy.ExpirationTime, + } + _, resID, err := app.getResourceOwnerAndIdFromGRN(ctx, grn) + if err != nil { + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: err, + } + } + policy.ResourceId = resID } resOwner, err := app.getResourceOwner(ctx, &policy) @@ -243,3 +316,45 @@ func (app *PermissionApp) getResourceOwner(ctx sdk.Context, policy *permtypes.Po } return resOwner, nil } + +func (app *PermissionApp) getResourceOwnerAndIdFromGRN(ctx sdk.Context, grn types2.GRN) (resOwner sdk.AccAddress, resID math.Uint, err error) { + switch grn.ResourceType() { + case gnfdresource.RESOURCE_TYPE_BUCKET: + bucketName, grnErr := grn.GetBucketName() + if grnErr != nil { + return resOwner, resID, grnErr + } + bucketInfo, found := app.storageKeeper.GetBucketInfo(ctx, bucketName) + if !found { + return resOwner, resID, types.ErrNoSuchBucket.Wrapf("bucketName: %s", bucketName) + } + resOwner = sdk.MustAccAddressFromHex(bucketInfo.Owner) + resID = bucketInfo.Id + case gnfdresource.RESOURCE_TYPE_OBJECT: + bucketName, objectName, grnErr := grn.GetBucketAndObjectName() + if grnErr != nil { + return resOwner, resID, grnErr + } + objectInfo, found := app.storageKeeper.GetObjectInfo(ctx, bucketName, objectName) + if !found { + return resOwner, resID, types.ErrNoSuchObject.Wrapf("BucketName: %s, objectName: %s", bucketName, objectName) + } + resOwner = sdk.MustAccAddressFromHex(objectInfo.Owner) + resID = objectInfo.Id + case gnfdresource.RESOURCE_TYPE_GROUP: + groupOwner, groupName, grnErr := grn.GetGroupOwnerAndAccount() + if grnErr != nil { + return resOwner, resID, grnErr + } + groupInfo, found := app.storageKeeper.GetGroupInfo(ctx, groupOwner, groupName) + if !found { + return resOwner, resID, types.ErrNoSuchBucket.Wrapf("groupOwner: %s, groupName: %s", groupOwner.String(), groupName) + } + resOwner = sdk.MustAccAddressFromHex(groupInfo.Owner) + resID = groupInfo.Id + default: + return resOwner, resID, gnfderrors.ErrInvalidGRN.Wrap("Unknown resource type in greenfield resource name") + } + + return resOwner, resID, nil +} diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 5cddd04ae..352cd5cd1 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -105,6 +105,8 @@ type VirtualGroupKeeper interface { type StorageKeeper interface { Logger(ctx sdk.Context) log.Logger GetBucketInfoById(ctx sdk.Context, bucketId sdkmath.Uint) (*BucketInfo, bool) + GetBucketInfo(ctx sdk.Context, bucketName string) (*BucketInfo, bool) + GetObjectInfo(ctx sdk.Context, bucketName, objectName string) (*ObjectInfo, bool) SetBucketInfo(ctx sdk.Context, bucketInfo *BucketInfo) CreateBucket( ctx sdk.Context, ownerAcc sdk.AccAddress, bucketName string, diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 67aae3609..669695ffd 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -1015,6 +1015,21 @@ func (mr *MockStorageKeeperMockRecorder) DeleteObject(ctx, operator, bucketName, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteObject", reflect.TypeOf((*MockStorageKeeper)(nil).DeleteObject), ctx, operator, bucketName, objectName, opts) } +// GetBucketInfo mocks base method. +func (m *MockStorageKeeper) GetBucketInfo(ctx types3.Context, bucketName string) (*BucketInfo, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBucketInfo", ctx, bucketName) + ret0, _ := ret[0].(*BucketInfo) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetBucketInfo indicates an expected call of GetBucketInfo. +func (mr *MockStorageKeeperMockRecorder) GetBucketInfo(ctx, bucketName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBucketInfo", reflect.TypeOf((*MockStorageKeeper)(nil).GetBucketInfo), ctx, bucketName) +} + // GetBucketInfoById mocks base method. func (m *MockStorageKeeper) GetBucketInfoById(ctx types3.Context, bucketId math.Uint) (*BucketInfo, bool) { m.ctrl.T.Helper() @@ -1060,6 +1075,21 @@ func (mr *MockStorageKeeperMockRecorder) GetGroupInfoById(ctx, groupId interface return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupInfoById", reflect.TypeOf((*MockStorageKeeper)(nil).GetGroupInfoById), ctx, groupId) } +// GetObjectInfo mocks base method. +func (m *MockStorageKeeper) GetObjectInfo(ctx types3.Context, bucketName, objectName string) (*ObjectInfo, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetObjectInfo", ctx, bucketName, objectName) + ret0, _ := ret[0].(*ObjectInfo) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// GetObjectInfo indicates an expected call of GetObjectInfo. +func (mr *MockStorageKeeperMockRecorder) GetObjectInfo(ctx, bucketName, objectName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectInfo", reflect.TypeOf((*MockStorageKeeper)(nil).GetObjectInfo), ctx, bucketName, objectName) +} + // GetObjectInfoById mocks base method. func (m *MockStorageKeeper) GetObjectInfoById(ctx types3.Context, objectId math.Uint) (*ObjectInfo, bool) { m.ctrl.T.Helper() From 86a744a186cf7e06b39f2767810341e0f118900e Mon Sep 17 00:00:00 2001 From: constwz Date: Mon, 8 Jul 2024 14:46:58 +0800 Subject: [PATCH 2/7] feat: add ut --- x/storage/keeper/cross_app_permission_test.go | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/x/storage/keeper/cross_app_permission_test.go b/x/storage/keeper/cross_app_permission_test.go index 44b94ed5d..ad2cc3faf 100644 --- a/x/storage/keeper/cross_app_permission_test.go +++ b/x/storage/keeper/cross_app_permission_test.go @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/bnb-chain/greenfield/testutil/sample" + types2 "github.com/bnb-chain/greenfield/types" "github.com/bnb-chain/greenfield/x/permission/types" "github.com/bnb-chain/greenfield/x/storage/keeper" storageTypes "github.com/bnb-chain/greenfield/x/storage/types" @@ -71,3 +72,89 @@ func (s *TestSuite) TestSynDeletePolicy() { s.Require().ErrorIs(res.Err, storageTypes.ErrNoSuchPolicy) s.Require().NotEmpty(res.Payload) } + +func (s *TestSuite) TestSynCreatePolicyByMsgErr() { + ctrl := gomock.NewController(s.T()) + storageKeeper := storageTypes.NewMockStorageKeeper(ctrl) + permissionKeeper := storageTypes.NewMockPermissionKeeper(ctrl) + + //resourceIds := []math.Uint{math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64())} + // policy without expiry + op := sample.RandAccAddress() + resource := types2.NewBucketGRN("test-bucket").String() + policy := storageTypes.MsgPutPolicy{ + Principal: &types.Principal{ + Type: types.PRINCIPAL_TYPE_GNFD_GROUP, + Value: sample.RandAccAddressHex(), + }, + Operator: op.String(), + Resource: resource, + Statements: nil, + ExpirationTime: nil, + } + + app := keeper.NewPermissionApp(storageKeeper, permissionKeeper) + data, err := policy.Marshal() + s.NoError(err) + + synPackage := storageTypes.CreatePolicySynPackage{ + Operator: op, + Data: data, + ExtraData: []byte("extra data"), + } + serializedSynPackage := synPackage.MustSerialize() + serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) + + // case 1: bucket not found + storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()).Return(nil, false) + res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorIs(res.Err, storageTypes.ErrNoSuchBucket) +} + +func (s *TestSuite) TestSynCreatePolicyByMsg() { + ctrl := gomock.NewController(s.T()) + storageKeeper := storageTypes.NewMockStorageKeeper(ctrl) + permissionKeeper := storageTypes.NewMockPermissionKeeper(ctrl) + + //resourceIds := []math.Uint{math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64())} + // policy without expiry + op := sample.RandAccAddress() + resource := types2.NewBucketGRN("test-bucket").String() + policy := storageTypes.MsgPutPolicy{ + Principal: &types.Principal{ + Type: types.PRINCIPAL_TYPE_GNFD_GROUP, + Value: sample.RandAccAddressHex(), + }, + Operator: op.String(), + Resource: resource, + Statements: nil, + ExpirationTime: nil, + } + + app := keeper.NewPermissionApp(storageKeeper, permissionKeeper) + data, err := policy.Marshal() + s.NoError(err) + + synPackage := storageTypes.CreatePolicySynPackage{ + Operator: op, + Data: data, + ExtraData: []byte("extra data"), + } + serializedSynPackage := synPackage.MustSerialize() + serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) + + // case 1: bucket not found + storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ + Owner: op.String(), + BucketName: "test-bucket", + }, true) + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ + Owner: op.String(), + BucketName: "test-bucket", + }, true) + storageKeeper.EXPECT().NormalizePrincipal(gomock.Any(), gomock.Any()).Return().AnyTimes() + storageKeeper.EXPECT().ValidatePrincipal(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + permissionKeeper.EXPECT().PutPolicy(gomock.Any(), gomock.Any()).Return(math.NewUint(1), nil).AnyTimes() + res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) + s.Require().ErrorIs(res.Err, nil) +} From 54daf844e07bc096a289871664252381b17b5fab Mon Sep 17 00:00:00 2001 From: constwz Date: Wed, 10 Jul 2024 11:42:57 +0800 Subject: [PATCH 3/7] fix: Remove cross-chain operation restrictions --- x/storage/keeper/keeper.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 199424d12..55ae29e7f 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -221,7 +221,7 @@ func (k Keeper) DeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketNam if !found { return types.ErrNoSuchBucket } - if bucketInfo.SourceType != opts.SourceType { + if bucketInfo.SourceType != types.SOURCE_TYPE_ORIGIN && bucketInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } @@ -417,10 +417,6 @@ func (k Keeper) UpdateBucketInfo(ctx sdk.Context, operator sdk.AccAddress, bucke if !found { return types.ErrNoSuchBucket } - // check bucket source - if bucketInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch - } if ctx.IsUpgraded(upgradetypes.Hulunbeier) { sp := k.MustGetPrimarySPForBucket(ctx, bucketInfo) @@ -987,10 +983,6 @@ func (k Keeper) CancelCreateObject( return types.ErrObjectNotCreated.Wrapf("Object status: %s", objectInfo.ObjectStatus.String()) } - if objectInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch - } - var creator sdk.AccAddress owner := sdk.MustAccAddressFromHex(objectInfo.Owner) if objectInfo.Creator != "" { @@ -1056,7 +1048,7 @@ func (k Keeper) DeleteObject( objectInfo.ObjectName) } - if objectInfo.SourceType != opts.SourceType { + if objectInfo.SourceType != types.SOURCE_TYPE_ORIGIN && objectInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } @@ -1211,10 +1203,6 @@ func (k Keeper) CopyObject( return sdkmath.ZeroUint(), errors.Wrapf(types.ErrNoSuchObject, "src object name (%s)", srcObjectName) } - if srcObjectInfo.SourceType != opts.SourceType { - return sdkmath.ZeroUint(), types.ErrSourceTypeMismatch - } - if srcObjectInfo.IsUpdating { return sdkmath.ZeroUint(), types.ErrAccessDenied.Wrapf("the object is being updated, can not be copied") } @@ -1552,7 +1540,7 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName if !found { return types.ErrNoSuchGroup } - if groupInfo.SourceType != opts.SourceType { + if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } // check permission @@ -1588,7 +1576,7 @@ func (k Keeper) LeaveGroup( if !found { return types.ErrNoSuchGroup } - if groupInfo.SourceType != opts.SourceType { + if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } @@ -1610,7 +1598,7 @@ func (k Keeper) LeaveGroup( } func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts types.UpdateGroupMemberOptions) error { - if groupInfo.SourceType != opts.SourceType { + if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } @@ -1665,7 +1653,7 @@ func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, grou } func (k Keeper) RenewGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts types.RenewGroupMemberOptions) error { - if groupInfo.SourceType != opts.SourceType { + if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { return types.ErrSourceTypeMismatch } From f7155524b7f324e9d66426ab86c9a411730d92f8 Mon Sep 17 00:00:00 2001 From: constwz Date: Wed, 10 Jul 2024 18:36:54 +0800 Subject: [PATCH 4/7] fix: add cross chain policy --- proto/greenfield/permission/types.proto | 28 + x/permission/types/types.pb.go | 628 ++++++++++++++++-- x/storage/keeper/cross_app_permission.go | 147 +--- x/storage/keeper/cross_app_permission_test.go | 48 +- x/storage/keeper/permission.go | 8 +- x/storage/types/expected_keepers.go | 3 + x/storage/types/expected_keepers_mocks.go | 249 +++---- 7 files changed, 807 insertions(+), 304 deletions(-) diff --git a/proto/greenfield/permission/types.proto b/proto/greenfield/permission/types.proto index ec4870dac..4b95065c9 100644 --- a/proto/greenfield/permission/types.proto +++ b/proto/greenfield/permission/types.proto @@ -36,6 +36,34 @@ message Policy { ]; } +message CrossChainPolicy { + // id is an unique u256 sequence for each policy. It also be used as NFT tokenID + string id = 1 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; + // principal defines the accounts/group which the permission grants to + Principal principal = 2; + // resource_type defines the type of resource that grants permission for + resource.ResourceType resource_type = 3; + // resource_id defines the bucket/object/group id of the resource that grants permission for + string resource_id = 4 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "Uint", + (gogoproto.nullable) = false + ]; + // statements defines the details content of the permission, including effect/actions/sub-resources + repeated Statement statements = 5; + // expiration_time defines the whole expiration time of all the statements. + // Notices: Its priority is higher than the expiration time inside the Statement + google.protobuf.Timestamp expiration_time = 6 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = true + ]; + optional string resourceGRN = 7; +} + // PolicyGroup refers to a group of policies which grant permission to Group, which is limited to MaxGroupNum (default 10). // This means that a single resource can only grant permission to 10 groups. The reason for // this is to enable on-chain determination of whether an operator has permission within a limited time. diff --git a/x/permission/types/types.pb.go b/x/permission/types/types.pb.go index 2a979af77..3710e9663 100644 --- a/x/permission/types/types.pb.go +++ b/x/permission/types/types.pb.go @@ -106,6 +106,119 @@ func (m *Policy) GetExpirationTime() *time.Time { return nil } +type CrossChainPolicy struct { + // id is an unique u256 sequence for each policy. It also be used as NFT tokenID + Id Uint `protobuf:"bytes,1,opt,name=id,proto3,customtype=Uint" json:"id"` + // principal defines the accounts/group which the permission grants to + Principal *Principal `protobuf:"bytes,2,opt,name=principal,proto3" json:"principal,omitempty"` + // resource_type defines the type of resource that grants permission for + ResourceType resource.ResourceType `protobuf:"varint,3,opt,name=resource_type,json=resourceType,proto3,enum=greenfield.resource.ResourceType" json:"resource_type,omitempty"` + // resource_id defines the bucket/object/group id of the resource that grants permission for + ResourceId Uint `protobuf:"bytes,4,opt,name=resource_id,json=resourceId,proto3,customtype=Uint" json:"resource_id"` + // statements defines the details content of the permission, including effect/actions/sub-resources + Statements []*Statement `protobuf:"bytes,5,rep,name=statements,proto3" json:"statements,omitempty"` + // expiration_time defines the whole expiration time of all the statements. + // Notices: Its priority is higher than the expiration time inside the Statement + ExpirationTime *time.Time `protobuf:"bytes,6,opt,name=expiration_time,json=expirationTime,proto3,stdtime" json:"expiration_time,omitempty"` + // Types that are valid to be assigned to XResourceGRN: + // *CrossChainPolicy_ResourceGRN + XResourceGRN isCrossChainPolicy_XResourceGRN `protobuf_oneof:"_resourceGRN"` +} + +func (m *CrossChainPolicy) Reset() { *m = CrossChainPolicy{} } +func (m *CrossChainPolicy) String() string { return proto.CompactTextString(m) } +func (*CrossChainPolicy) ProtoMessage() {} +func (*CrossChainPolicy) Descriptor() ([]byte, []int) { + return fileDescriptor_0d2afeea9f743f03, []int{1} +} +func (m *CrossChainPolicy) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CrossChainPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CrossChainPolicy.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 *CrossChainPolicy) XXX_Merge(src proto.Message) { + xxx_messageInfo_CrossChainPolicy.Merge(m, src) +} +func (m *CrossChainPolicy) XXX_Size() int { + return m.Size() +} +func (m *CrossChainPolicy) XXX_DiscardUnknown() { + xxx_messageInfo_CrossChainPolicy.DiscardUnknown(m) +} + +var xxx_messageInfo_CrossChainPolicy proto.InternalMessageInfo + +type isCrossChainPolicy_XResourceGRN interface { + isCrossChainPolicy_XResourceGRN() + MarshalTo([]byte) (int, error) + Size() int +} + +type CrossChainPolicy_ResourceGRN struct { + ResourceGRN string `protobuf:"bytes,7,opt,name=resourceGRN,proto3,oneof" json:"resourceGRN,omitempty"` +} + +func (*CrossChainPolicy_ResourceGRN) isCrossChainPolicy_XResourceGRN() {} + +func (m *CrossChainPolicy) GetXResourceGRN() isCrossChainPolicy_XResourceGRN { + if m != nil { + return m.XResourceGRN + } + return nil +} + +func (m *CrossChainPolicy) GetPrincipal() *Principal { + if m != nil { + return m.Principal + } + return nil +} + +func (m *CrossChainPolicy) GetResourceType() resource.ResourceType { + if m != nil { + return m.ResourceType + } + return resource.RESOURCE_TYPE_UNSPECIFIED +} + +func (m *CrossChainPolicy) GetStatements() []*Statement { + if m != nil { + return m.Statements + } + return nil +} + +func (m *CrossChainPolicy) GetExpirationTime() *time.Time { + if m != nil { + return m.ExpirationTime + } + return nil +} + +func (m *CrossChainPolicy) GetResourceGRN() string { + if x, ok := m.GetXResourceGRN().(*CrossChainPolicy_ResourceGRN); ok { + return x.ResourceGRN + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*CrossChainPolicy) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*CrossChainPolicy_ResourceGRN)(nil), + } +} + // PolicyGroup refers to a group of policies which grant permission to Group, which is limited to MaxGroupNum (default 10). // This means that a single resource can only grant permission to 10 groups. The reason for // this is to enable on-chain determination of whether an operator has permission within a limited time. @@ -118,7 +231,7 @@ func (m *PolicyGroup) Reset() { *m = PolicyGroup{} } func (m *PolicyGroup) String() string { return proto.CompactTextString(m) } func (*PolicyGroup) ProtoMessage() {} func (*PolicyGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2afeea9f743f03, []int{1} + return fileDescriptor_0d2afeea9f743f03, []int{2} } func (m *PolicyGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -163,7 +276,7 @@ func (m *PolicyGroup_Item) Reset() { *m = PolicyGroup_Item{} } func (m *PolicyGroup_Item) String() string { return proto.CompactTextString(m) } func (*PolicyGroup_Item) ProtoMessage() {} func (*PolicyGroup_Item) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2afeea9f743f03, []int{1, 0} + return fileDescriptor_0d2afeea9f743f03, []int{2, 0} } func (m *PolicyGroup_Item) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -207,7 +320,7 @@ func (m *GroupMember) Reset() { *m = GroupMember{} } func (m *GroupMember) String() string { return proto.CompactTextString(m) } func (*GroupMember) ProtoMessage() {} func (*GroupMember) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2afeea9f743f03, []int{2} + return fileDescriptor_0d2afeea9f743f03, []int{3} } func (m *GroupMember) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,6 +365,7 @@ func (m *GroupMember) GetExpirationTime() *time.Time { func init() { proto.RegisterType((*Policy)(nil), "greenfield.permission.Policy") + proto.RegisterType((*CrossChainPolicy)(nil), "greenfield.permission.CrossChainPolicy") proto.RegisterType((*PolicyGroup)(nil), "greenfield.permission.PolicyGroup") proto.RegisterType((*PolicyGroup_Item)(nil), "greenfield.permission.PolicyGroup.Item") proto.RegisterType((*GroupMember)(nil), "greenfield.permission.GroupMember") @@ -260,41 +374,44 @@ func init() { func init() { proto.RegisterFile("greenfield/permission/types.proto", fileDescriptor_0d2afeea9f743f03) } var fileDescriptor_0d2afeea9f743f03 = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6b, 0x13, 0x41, - 0x18, 0xc6, 0x33, 0x49, 0x1a, 0x93, 0x89, 0x56, 0x18, 0x2a, 0xac, 0x11, 0x36, 0x69, 0x2e, 0x06, - 0x24, 0xbb, 0x12, 0x41, 0x3c, 0xa8, 0x68, 0x0e, 0x4a, 0xc0, 0x42, 0xd9, 0xd6, 0x8b, 0x97, 0x90, - 0xdd, 0x9d, 0x6e, 0x07, 0x32, 0x7f, 0x98, 0x99, 0x40, 0xf2, 0x1d, 0x3c, 0xf4, 0xc3, 0xf4, 0x33, - 0x48, 0x8e, 0xa5, 0x27, 0xf1, 0x10, 0x25, 0xf9, 0x00, 0x7e, 0x05, 0xd9, 0xd9, 0xdd, 0xee, 0x42, - 0xa3, 0x51, 0x6f, 0xf3, 0x4e, 0x7e, 0xcf, 0xfb, 0x3e, 0x33, 0xcf, 0x64, 0xe1, 0x61, 0x24, 0x31, - 0x66, 0x67, 0x04, 0x4f, 0x43, 0x57, 0x60, 0x49, 0x89, 0x52, 0x84, 0x33, 0x57, 0x2f, 0x04, 0x56, - 0x8e, 0x90, 0x5c, 0x73, 0xf4, 0x20, 0x47, 0x9c, 0x1c, 0x69, 0x3d, 0x0c, 0xb8, 0xa2, 0x5c, 0x8d, - 0x0d, 0xe4, 0x26, 0x45, 0xa2, 0x68, 0x1d, 0x44, 0x3c, 0xe2, 0xc9, 0x7e, 0xbc, 0x4a, 0x77, 0xdb, - 0x11, 0xe7, 0xd1, 0x14, 0xbb, 0xa6, 0xf2, 0x67, 0x67, 0xae, 0x26, 0x14, 0x2b, 0x3d, 0xa1, 0x22, - 0x05, 0xba, 0xdb, 0xbd, 0x04, 0x9c, 0x52, 0xce, 0x6e, 0x9a, 0xe4, 0x8c, 0xc4, 0x8a, 0xcf, 0x64, - 0x80, 0x8b, 0x6e, 0xbb, 0x9f, 0x2b, 0xb0, 0x76, 0xcc, 0xa7, 0x24, 0x58, 0xa0, 0x27, 0xb0, 0x4c, - 0x42, 0x0b, 0x74, 0x40, 0xaf, 0x31, 0x7c, 0xb4, 0x5c, 0xb5, 0x4b, 0xdf, 0x56, 0xed, 0xea, 0x47, - 0xc2, 0xf4, 0xf5, 0x65, 0xbf, 0x99, 0x1a, 0x8e, 0x4b, 0xaf, 0x4c, 0x42, 0xf4, 0x1a, 0x36, 0x84, - 0x24, 0x2c, 0x20, 0x62, 0x32, 0xb5, 0xca, 0x1d, 0xd0, 0x6b, 0x0e, 0x3a, 0xce, 0xd6, 0x93, 0x3b, - 0xc7, 0x19, 0xe7, 0xe5, 0x12, 0xf4, 0x0e, 0xde, 0xcb, 0xfc, 0x8c, 0x63, 0x3f, 0x56, 0xa5, 0x03, - 0x7a, 0xfb, 0x83, 0xc3, 0x62, 0x8f, 0x0c, 0x70, 0xbc, 0x74, 0x71, 0xba, 0x10, 0xd8, 0xbb, 0x2b, - 0x0b, 0x15, 0x7a, 0x09, 0x9b, 0x37, 0x7d, 0x48, 0x68, 0x55, 0x77, 0xbb, 0x87, 0x19, 0x3f, 0x0a, - 0xd1, 0x1b, 0x08, 0x95, 0x9e, 0x68, 0x4c, 0x31, 0xd3, 0xca, 0xda, 0xeb, 0x54, 0xfe, 0x70, 0x8c, - 0x93, 0x0c, 0xf4, 0x0a, 0x1a, 0x74, 0x04, 0xef, 0xe3, 0xb9, 0x20, 0x72, 0xa2, 0x09, 0x67, 0xe3, - 0x38, 0x22, 0xab, 0x66, 0x6e, 0xa3, 0xe5, 0x24, 0xf9, 0x39, 0x59, 0x7e, 0xce, 0x69, 0x96, 0xdf, - 0xb0, 0xbe, 0x5c, 0xb5, 0xc1, 0xc5, 0xf7, 0x36, 0xf0, 0xf6, 0x73, 0x71, 0xfc, 0x73, 0xf7, 0x0b, - 0x80, 0xcd, 0x24, 0x8e, 0xf7, 0x92, 0xcf, 0x04, 0x7a, 0x05, 0xf7, 0x88, 0xc6, 0x54, 0x59, 0xc0, - 0x78, 0x7b, 0xfc, 0xbb, 0x2b, 0xce, 0x25, 0xce, 0x48, 0x63, 0xea, 0x25, 0xaa, 0xd6, 0x1c, 0x56, - 0xe3, 0x12, 0xbd, 0x80, 0x0d, 0x61, 0x90, 0xf1, 0xdf, 0x25, 0x5c, 0x4f, 0xe8, 0x51, 0x88, 0x9e, - 0xc3, 0x7a, 0x14, 0xb7, 0x8d, 0x85, 0xe5, 0xdd, 0xc2, 0x3b, 0x06, 0x1e, 0x85, 0xdd, 0x9f, 0x00, - 0x36, 0x8d, 0x9f, 0x23, 0x4c, 0x7d, 0x2c, 0xff, 0xed, 0x71, 0xfd, 0xe7, 0x50, 0xf4, 0x14, 0xd6, - 0xa8, 0x19, 0x67, 0x5e, 0x53, 0x63, 0x68, 0x5d, 0x5f, 0xf6, 0x0f, 0x52, 0xf2, 0x6d, 0x18, 0x4a, - 0xac, 0xd4, 0x89, 0x96, 0x84, 0x45, 0x5e, 0xca, 0xa1, 0xd1, 0xed, 0xf8, 0xaa, 0x3b, 0xe3, 0xab, - 0x6e, 0x8b, 0x6e, 0xf8, 0x61, 0xb9, 0xb6, 0xc1, 0xd5, 0xda, 0x06, 0x3f, 0xd6, 0x36, 0xb8, 0xd8, - 0xd8, 0xa5, 0xab, 0x8d, 0x5d, 0xfa, 0xba, 0xb1, 0x4b, 0x9f, 0x06, 0x11, 0xd1, 0xe7, 0x33, 0xdf, - 0x09, 0x38, 0x75, 0x7d, 0xe6, 0xf7, 0x83, 0xf3, 0x09, 0x61, 0x6e, 0xe1, 0x9f, 0x39, 0xbf, 0xf5, - 0x2d, 0xf1, 0x6b, 0x66, 0xee, 0xb3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x27, 0x84, 0xb6, - 0x71, 0x04, 0x00, 0x00, + // 580 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xc1, 0x6a, 0x13, 0x41, + 0x18, 0xc7, 0x33, 0x49, 0x9a, 0x26, 0x93, 0x1a, 0x65, 0xa8, 0xb0, 0x46, 0xd8, 0xa4, 0x01, 0x31, + 0x20, 0xd9, 0x95, 0x08, 0xe2, 0x41, 0x45, 0x53, 0xb0, 0x06, 0xac, 0x94, 0x6d, 0xbd, 0x78, 0x09, + 0xd9, 0xdd, 0xe9, 0x76, 0x20, 0xb3, 0xb3, 0xcc, 0x4c, 0x20, 0x79, 0x03, 0x0f, 0x1e, 0xfa, 0x30, + 0x7d, 0x06, 0xc9, 0x45, 0x28, 0x3d, 0x89, 0x87, 0x28, 0xc9, 0x03, 0xf8, 0x0a, 0xb2, 0xb3, 0xbb, + 0xdd, 0x85, 0x46, 0xa3, 0x9e, 0x3c, 0xf4, 0xb6, 0xdf, 0x97, 0xdf, 0xff, 0x9b, 0xff, 0x97, 0xff, + 0x24, 0x0b, 0x77, 0x3c, 0x8e, 0xb1, 0x7f, 0x4c, 0xf0, 0xc8, 0x35, 0x03, 0xcc, 0x29, 0x11, 0x82, + 0x30, 0xdf, 0x94, 0xd3, 0x00, 0x0b, 0x23, 0xe0, 0x4c, 0x32, 0x74, 0x3b, 0x45, 0x8c, 0x14, 0xa9, + 0xdf, 0x71, 0x98, 0xa0, 0x4c, 0x0c, 0x14, 0x64, 0x46, 0x45, 0xa4, 0xa8, 0x6f, 0x7b, 0xcc, 0x63, + 0x51, 0x3f, 0x7c, 0x8a, 0xbb, 0x0d, 0x8f, 0x31, 0x6f, 0x84, 0x4d, 0x55, 0xd9, 0xe3, 0x63, 0x53, + 0x12, 0x8a, 0x85, 0x1c, 0xd2, 0x20, 0x06, 0x5a, 0xab, 0xbd, 0x38, 0x8c, 0x52, 0xe6, 0x5f, 0x0e, + 0x49, 0x19, 0x8e, 0x05, 0x1b, 0x73, 0x07, 0x67, 0xdd, 0xb6, 0x3e, 0x16, 0x60, 0xe9, 0x80, 0x8d, + 0x88, 0x33, 0x45, 0x0f, 0x60, 0x9e, 0xb8, 0x1a, 0x68, 0x82, 0x76, 0xa5, 0x77, 0x77, 0x36, 0x6f, + 0xe4, 0xbe, 0xce, 0x1b, 0xc5, 0x77, 0xc4, 0x97, 0x17, 0x67, 0x9d, 0x6a, 0x6c, 0x38, 0x2c, 0xad, + 0x3c, 0x71, 0xd1, 0x73, 0x58, 0x09, 0x38, 0xf1, 0x1d, 0x12, 0x0c, 0x47, 0x5a, 0xbe, 0x09, 0xda, + 0xd5, 0x6e, 0xd3, 0x58, 0xb9, 0xb9, 0x71, 0x90, 0x70, 0x56, 0x2a, 0x41, 0xaf, 0xe0, 0x8d, 0xc4, + 0xcf, 0x20, 0xf4, 0xa3, 0x15, 0x9a, 0xa0, 0x5d, 0xeb, 0xee, 0x64, 0x67, 0x24, 0x80, 0x61, 0xc5, + 0x0f, 0x47, 0xd3, 0x00, 0x5b, 0x5b, 0x3c, 0x53, 0xa1, 0xa7, 0xb0, 0x7a, 0x39, 0x87, 0xb8, 0x5a, + 0x71, 0xbd, 0x7b, 0x98, 0xf0, 0x7d, 0x17, 0xbd, 0x80, 0x50, 0xc8, 0xa1, 0xc4, 0x14, 0xfb, 0x52, + 0x68, 0x1b, 0xcd, 0xc2, 0x6f, 0xd6, 0x38, 0x4c, 0x40, 0x2b, 0xa3, 0x41, 0xfb, 0xf0, 0x26, 0x9e, + 0x04, 0x84, 0x0f, 0x25, 0x61, 0xfe, 0x20, 0x8c, 0x48, 0x2b, 0xa9, 0x6f, 0xa3, 0x6e, 0x44, 0xf9, + 0x19, 0x49, 0x7e, 0xc6, 0x51, 0x92, 0x5f, 0xaf, 0x3c, 0x9b, 0x37, 0xc0, 0xe9, 0xb7, 0x06, 0xb0, + 0x6a, 0xa9, 0x38, 0xfc, 0xb8, 0xf5, 0xb9, 0x00, 0x6f, 0xed, 0x72, 0x26, 0xc4, 0xee, 0xc9, 0x90, + 0xf8, 0xd7, 0xc1, 0xfc, 0x2f, 0xc1, 0xa0, 0x7b, 0xe9, 0x3a, 0x7b, 0xd6, 0x5b, 0x6d, 0x33, 0x5c, + 0xe7, 0x75, 0xce, 0xca, 0x36, 0x3f, 0x00, 0xd0, 0xab, 0xc1, 0xad, 0x41, 0xa6, 0xd5, 0xfa, 0x04, + 0x60, 0x35, 0x4a, 0x71, 0x8f, 0xb3, 0x71, 0x80, 0x9e, 0xc1, 0x0d, 0x22, 0x31, 0x15, 0x1a, 0x50, + 0x2b, 0xdd, 0xff, 0x55, 0x32, 0xa9, 0xc4, 0xe8, 0x4b, 0x4c, 0xad, 0x48, 0x55, 0x9f, 0xc0, 0x62, + 0x58, 0xa2, 0x27, 0xb0, 0x12, 0x28, 0x64, 0xf0, 0x67, 0x17, 0xa3, 0x1c, 0xd1, 0x7d, 0x17, 0x3d, + 0x86, 0x65, 0x2f, 0x1c, 0x1b, 0x0a, 0xf3, 0xeb, 0x85, 0x9b, 0x0a, 0xee, 0xbb, 0xad, 0x1f, 0x00, + 0x56, 0x95, 0x9f, 0x7d, 0x4c, 0x6d, 0xcc, 0xff, 0xee, 0x4e, 0xfe, 0xe3, 0xa1, 0xe8, 0x21, 0x2c, + 0x51, 0x75, 0x9c, 0xba, 0x84, 0x95, 0x9e, 0x76, 0x71, 0xd6, 0xd9, 0x8e, 0xc9, 0x97, 0xae, 0xcb, + 0xb1, 0x10, 0x87, 0x92, 0x13, 0xdf, 0xb3, 0x62, 0x0e, 0xf5, 0xaf, 0xa6, 0x5e, 0x5c, 0x9b, 0x7a, + 0x71, 0x55, 0xe2, 0xbd, 0x37, 0xb3, 0x85, 0x0e, 0xce, 0x17, 0x3a, 0xf8, 0xbe, 0xd0, 0xc1, 0xe9, + 0x52, 0xcf, 0x9d, 0x2f, 0xf5, 0xdc, 0x97, 0xa5, 0x9e, 0x7b, 0xdf, 0xf5, 0x88, 0x3c, 0x19, 0xdb, + 0x86, 0xc3, 0xa8, 0x69, 0xfb, 0x76, 0xc7, 0x09, 0x7f, 0xab, 0x66, 0xe6, 0x9f, 0x76, 0x72, 0xe5, + 0xdd, 0x60, 0x97, 0xd4, 0xb9, 0x8f, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0x75, 0x35, 0x21, 0xda, + 0x41, 0x06, 0x00, 0x00, } func (m *Policy) Marshal() (dAtA []byte, err error) { @@ -381,6 +498,113 @@ func (m *Policy) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *CrossChainPolicy) 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 *CrossChainPolicy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CrossChainPolicy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XResourceGRN != nil { + { + size := m.XResourceGRN.Size() + i -= size + if _, err := m.XResourceGRN.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + if m.ExpirationTime != nil { + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.ExpirationTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintTypes(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x32 + } + if len(m.Statements) > 0 { + for iNdEx := len(m.Statements) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Statements[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + { + size := m.ResourceId.Size() + i -= size + if _, err := m.ResourceId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.ResourceType != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ResourceType)) + i-- + dAtA[i] = 0x18 + } + if m.Principal != nil { + { + size, err := m.Principal.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + { + size := m.Id.Size() + i -= size + if _, err := m.Id.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CrossChainPolicy_ResourceGRN) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CrossChainPolicy_ResourceGRN) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.ResourceGRN) + copy(dAtA[i:], m.ResourceGRN) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ResourceGRN))) + i-- + dAtA[i] = 0x3a + return len(dAtA) - i, nil +} func (m *PolicyGroup) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -482,12 +706,12 @@ func (m *GroupMember) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.ExpirationTime != nil { - n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.ExpirationTime):]) - if err3 != nil { - return 0, err3 + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.ExpirationTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.ExpirationTime):]) + if err5 != nil { + return 0, err5 } - i -= n3 - i = encodeVarintTypes(dAtA, i, uint64(n3)) + i -= n5 + i = encodeVarintTypes(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x22 } @@ -562,6 +786,49 @@ func (m *Policy) Size() (n int) { return n } +func (m *CrossChainPolicy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Id.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.Principal != nil { + l = m.Principal.Size() + n += 1 + l + sovTypes(uint64(l)) + } + if m.ResourceType != 0 { + n += 1 + sovTypes(uint64(m.ResourceType)) + } + l = m.ResourceId.Size() + n += 1 + l + sovTypes(uint64(l)) + if len(m.Statements) > 0 { + for _, e := range m.Statements { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + if m.ExpirationTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.ExpirationTime) + n += 1 + l + sovTypes(uint64(l)) + } + if m.XResourceGRN != nil { + n += m.XResourceGRN.Size() + } + return n +} + +func (m *CrossChainPolicy_ResourceGRN) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ResourceGRN) + n += 1 + l + sovTypes(uint64(l)) + return n +} func (m *PolicyGroup) Size() (n int) { if m == nil { return 0 @@ -860,6 +1127,281 @@ func (m *Policy) Unmarshal(dAtA []byte) error { } return nil } +func (m *CrossChainPolicy) 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 ErrIntOverflowTypes + } + 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: CrossChainPolicy: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CrossChainPolicy: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Principal", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Principal == nil { + m.Principal = &Principal{} + } + if err := m.Principal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceType", wireType) + } + m.ResourceType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResourceType |= resource.ResourceType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ResourceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Statements", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Statements = append(m.Statements, &Statement{}) + if err := m.Statements[len(m.Statements)-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 ExpirationTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ExpirationTime == nil { + m.ExpirationTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.ExpirationTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceGRN", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.XResourceGRN = &CrossChainPolicy_ResourceGRN{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *PolicyGroup) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/storage/keeper/cross_app_permission.go b/x/storage/keeper/cross_app_permission.go index d2764cd12..a759f2ca2 100644 --- a/x/storage/keeper/cross_app_permission.go +++ b/x/storage/keeper/cross_app_permission.go @@ -2,13 +2,12 @@ package keeper import ( "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - types2 "github.com/bnb-chain/greenfield/types" gnfderrors "github.com/bnb-chain/greenfield/types/errors" gnfdresource "github.com/bnb-chain/greenfield/types/resource" permtypes "github.com/bnb-chain/greenfield/x/permission/types" "github.com/bnb-chain/greenfield/x/storage/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) var _ sdk.CrossChainApplication = &PermissionApp{} @@ -146,36 +145,29 @@ func (app *PermissionApp) handleCreatePolicySynPackage(ctx sdk.Context, createPo } } + var crossChainPolicy permtypes.CrossChainPolicy var policy permtypes.Policy var grn types2.GRN - err = policy.Unmarshal(createPolicyPackage.Data) + err = crossChainPolicy.Unmarshal(createPolicyPackage.Data) if err != nil { - var msgPutPolicy types.MsgPutPolicy - err = msgPutPolicy.Unmarshal(createPolicyPackage.Data) - if err != nil { - return sdk.ExecuteResult{ - Payload: types.CreatePolicyAckPackage{ - Status: types.StatusFail, - Creator: createPolicyPackage.Operator, - ExtraData: createPolicyPackage.ExtraData, - }.MustSerialize(), - Err: err, - } - } - if msgPutPolicy.GetOperator() != createPolicyPackage.Operator.String() { - return sdk.ExecuteResult{ - Payload: types.CreatePolicyAckPackage{ - Status: types.StatusFail, - Creator: createPolicyPackage.Operator, - ExtraData: createPolicyPackage.ExtraData, - }.MustSerialize(), - Err: types.ErrAccessDenied.Wrapf( - "Only resource owner can put policy, operator (%s)", - msgPutPolicy.GetOperator()), - } + return sdk.ExecuteResult{ + Payload: types.CreatePolicyAckPackage{ + Status: types.StatusFail, + Creator: createPolicyPackage.Operator, + ExtraData: createPolicyPackage.ExtraData, + }.MustSerialize(), + Err: err, } + } - err = grn.ParseFromString(msgPutPolicy.Resource, true) + policy.Id = crossChainPolicy.Id + policy.Principal = crossChainPolicy.Principal + policy.ExpirationTime = crossChainPolicy.ExpirationTime + policy.Statements = crossChainPolicy.Statements + var resOwner sdk.AccAddress + var resId math.Uint + if crossChainPolicy.GetResourceGRN() != "" { + err = grn.ParseFromString(crossChainPolicy.GetResourceGRN(), true) if err != nil { return sdk.ExecuteResult{ Payload: types.CreatePolicyAckPackage{ @@ -186,38 +178,23 @@ func (app *PermissionApp) handleCreatePolicySynPackage(ctx sdk.Context, createPo Err: err, } } - - if msgPutPolicy.ExpirationTime != nil && msgPutPolicy.ExpirationTime.Before(ctx.BlockTime()) { + resOwner, resId, err = app.storageKeeper.GetResourceOwnerAndIdFromGRN(ctx, grn) + policy.ResourceId = resId + if err != nil { return sdk.ExecuteResult{ Payload: types.CreatePolicyAckPackage{ Status: types.StatusFail, Creator: createPolicyPackage.Operator, ExtraData: createPolicyPackage.ExtraData, }.MustSerialize(), - Err: permtypes.ErrPermissionExpired.Wrapf("The specified policy expiration time is less than the current block time, block time: %s", ctx.BlockTime().String()), - } - } - - for _, s := range msgPutPolicy.Statements { - if s.ExpirationTime != nil && s.ExpirationTime.Before(ctx.BlockTime()) { - return sdk.ExecuteResult{ - Payload: types.CreatePolicyAckPackage{ - Status: types.StatusFail, - Creator: createPolicyPackage.Operator, - ExtraData: createPolicyPackage.ExtraData, - }.MustSerialize(), - Err: permtypes.ErrPermissionExpired.Wrapf("The specified statement expiration time is less than the current block time, block time: %s", ctx.BlockTime().String()), - } + Err: err, } } - - policy = permtypes.Policy{ - ResourceType: grn.ResourceType(), - Principal: msgPutPolicy.Principal, - Statements: msgPutPolicy.Statements, - ExpirationTime: msgPutPolicy.ExpirationTime, - } - _, resID, err := app.getResourceOwnerAndIdFromGRN(ctx, grn) + policy.ResourceType = grn.ResourceType() + } else { + policy.ResourceId = crossChainPolicy.ResourceId + policy.ResourceType = crossChainPolicy.ResourceType + resOwner, err = app.getResourceOwner(ctx, &policy) if err != nil { return sdk.ExecuteResult{ Payload: types.CreatePolicyAckPackage{ @@ -228,32 +205,6 @@ func (app *PermissionApp) handleCreatePolicySynPackage(ctx sdk.Context, createPo Err: err, } } - policy.ResourceId = resID - } - - resOwner, err := app.getResourceOwner(ctx, &policy) - if err != nil { - return sdk.ExecuteResult{ - Payload: types.CreatePolicyAckPackage{ - Status: types.StatusFail, - Creator: createPolicyPackage.Operator, - ExtraData: createPolicyPackage.ExtraData, - }.MustSerialize(), - Err: err, - } - } - - if !createPolicyPackage.Operator.Equals(resOwner) { - return sdk.ExecuteResult{ - Payload: types.CreatePolicyAckPackage{ - Status: types.StatusFail, - Creator: createPolicyPackage.Operator, - ExtraData: createPolicyPackage.ExtraData, - }.MustSerialize(), - Err: types.ErrAccessDenied.Wrapf( - "Only resource owner can put policy, operator (%s), owner(%s)", - createPolicyPackage.Operator.String(), resOwner.String()), - } } app.storageKeeper.NormalizePrincipal(ctx, policy.Principal) @@ -316,45 +267,3 @@ func (app *PermissionApp) getResourceOwner(ctx sdk.Context, policy *permtypes.Po } return resOwner, nil } - -func (app *PermissionApp) getResourceOwnerAndIdFromGRN(ctx sdk.Context, grn types2.GRN) (resOwner sdk.AccAddress, resID math.Uint, err error) { - switch grn.ResourceType() { - case gnfdresource.RESOURCE_TYPE_BUCKET: - bucketName, grnErr := grn.GetBucketName() - if grnErr != nil { - return resOwner, resID, grnErr - } - bucketInfo, found := app.storageKeeper.GetBucketInfo(ctx, bucketName) - if !found { - return resOwner, resID, types.ErrNoSuchBucket.Wrapf("bucketName: %s", bucketName) - } - resOwner = sdk.MustAccAddressFromHex(bucketInfo.Owner) - resID = bucketInfo.Id - case gnfdresource.RESOURCE_TYPE_OBJECT: - bucketName, objectName, grnErr := grn.GetBucketAndObjectName() - if grnErr != nil { - return resOwner, resID, grnErr - } - objectInfo, found := app.storageKeeper.GetObjectInfo(ctx, bucketName, objectName) - if !found { - return resOwner, resID, types.ErrNoSuchObject.Wrapf("BucketName: %s, objectName: %s", bucketName, objectName) - } - resOwner = sdk.MustAccAddressFromHex(objectInfo.Owner) - resID = objectInfo.Id - case gnfdresource.RESOURCE_TYPE_GROUP: - groupOwner, groupName, grnErr := grn.GetGroupOwnerAndAccount() - if grnErr != nil { - return resOwner, resID, grnErr - } - groupInfo, found := app.storageKeeper.GetGroupInfo(ctx, groupOwner, groupName) - if !found { - return resOwner, resID, types.ErrNoSuchBucket.Wrapf("groupOwner: %s, groupName: %s", groupOwner.String(), groupName) - } - resOwner = sdk.MustAccAddressFromHex(groupInfo.Owner) - resID = groupInfo.Id - default: - return resOwner, resID, gnfderrors.ErrInvalidGRN.Wrap("Unknown resource type in greenfield resource name") - } - - return resOwner, resID, nil -} diff --git a/x/storage/keeper/cross_app_permission_test.go b/x/storage/keeper/cross_app_permission_test.go index ad2cc3faf..fedf4919a 100644 --- a/x/storage/keeper/cross_app_permission_test.go +++ b/x/storage/keeper/cross_app_permission_test.go @@ -78,19 +78,21 @@ func (s *TestSuite) TestSynCreatePolicyByMsgErr() { storageKeeper := storageTypes.NewMockStorageKeeper(ctrl) permissionKeeper := storageTypes.NewMockPermissionKeeper(ctrl) - //resourceIds := []math.Uint{math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64())} + resourceIds := []math.Uint{math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64())} // policy without expiry op := sample.RandAccAddress() - resource := types2.NewBucketGRN("test-bucket").String() - policy := storageTypes.MsgPutPolicy{ + policy := types.CrossChainPolicy{ Principal: &types.Principal{ - Type: types.PRINCIPAL_TYPE_GNFD_GROUP, + Type: types.PRINCIPAL_TYPE_GNFD_ACCOUNT, Value: sample.RandAccAddressHex(), }, - Operator: op.String(), - Resource: resource, + ResourceType: 1, + ResourceId: resourceIds[0], Statements: nil, ExpirationTime: nil, + XResourceGRN: &types.CrossChainPolicy_ResourceGRN{ + ResourceGRN: types2.NewBucketGRN("test-bucket").String(), + }, } app := keeper.NewPermissionApp(storageKeeper, permissionKeeper) @@ -106,7 +108,7 @@ func (s *TestSuite) TestSynCreatePolicyByMsgErr() { serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) // case 1: bucket not found - storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()).Return(nil, false) + storageKeeper.EXPECT().GetResourceOwnerAndIdFromGRN(gomock.Any(), gomock.Any()).Return(op, resourceIds[0], storageTypes.ErrNoSuchBucket.Wrapf("bucketName: test-bucket")).AnyTimes() res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) s.Require().ErrorIs(res.Err, storageTypes.ErrNoSuchBucket) } @@ -116,19 +118,21 @@ func (s *TestSuite) TestSynCreatePolicyByMsg() { storageKeeper := storageTypes.NewMockStorageKeeper(ctrl) permissionKeeper := storageTypes.NewMockPermissionKeeper(ctrl) - //resourceIds := []math.Uint{math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64())} + resourceIds := []math.Uint{math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64()), math.NewUint(rand.Uint64())} // policy without expiry op := sample.RandAccAddress() - resource := types2.NewBucketGRN("test-bucket").String() - policy := storageTypes.MsgPutPolicy{ + policy := types.CrossChainPolicy{ Principal: &types.Principal{ - Type: types.PRINCIPAL_TYPE_GNFD_GROUP, + Type: types.PRINCIPAL_TYPE_GNFD_ACCOUNT, Value: sample.RandAccAddressHex(), }, - Operator: op.String(), - Resource: resource, + ResourceType: 1, + ResourceId: resourceIds[0], Statements: nil, ExpirationTime: nil, + XResourceGRN: &types.CrossChainPolicy_ResourceGRN{ + ResourceGRN: types2.NewBucketGRN("test-bucket").String(), + }, } app := keeper.NewPermissionApp(storageKeeper, permissionKeeper) @@ -143,15 +147,15 @@ func (s *TestSuite) TestSynCreatePolicyByMsg() { serializedSynPackage := synPackage.MustSerialize() serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) - // case 1: bucket not found - storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ - Owner: op.String(), - BucketName: "test-bucket", - }, true) - storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ - Owner: op.String(), - BucketName: "test-bucket", - }, true) + storageKeeper.EXPECT().GetResourceOwnerAndIdFromGRN(gomock.Any(), gomock.Any()).Return(op, resourceIds[0], nil).AnyTimes() + //storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ + // Owner: op.String(), + // BucketName: "test-bucket", + //}, true) + //storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ + // Owner: op.String(), + // BucketName: "test-bucket", + //}, true) storageKeeper.EXPECT().NormalizePrincipal(gomock.Any(), gomock.Any()).Return().AnyTimes() storageKeeper.EXPECT().ValidatePrincipal(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() permissionKeeper.EXPECT().PutPolicy(gomock.Any(), gomock.Any()).Return(math.NewUint(1), nil).AnyTimes() diff --git a/x/storage/keeper/permission.go b/x/storage/keeper/permission.go index 317b2e952..377128d82 100644 --- a/x/storage/keeper/permission.go +++ b/x/storage/keeper/permission.go @@ -188,7 +188,7 @@ func (k Keeper) VerifyPolicy(ctx sdk.Context, resourceID math.Uint, resourceType } func (k Keeper) GetPolicy(ctx sdk.Context, grn types2.GRN, principal *permtypes.Principal) (*permtypes.Policy, error) { - _, resID, err := k.getResourceOwnerAndIdFromGRN(ctx, grn) + _, resID, err := k.GetResourceOwnerAndIdFromGRN(ctx, grn) if err != nil { return nil, err } @@ -213,7 +213,7 @@ func (k Keeper) GetPolicy(ctx sdk.Context, grn types2.GRN, principal *permtypes. func (k Keeper) PutPolicy(ctx sdk.Context, operator sdk.AccAddress, grn types2.GRN, policy *permtypes.Policy, ) (math.Uint, error) { - resOwner, resID, err := k.getResourceOwnerAndIdFromGRN(ctx, grn) + resOwner, resID, err := k.GetResourceOwnerAndIdFromGRN(ctx, grn) if err != nil { return math.ZeroUint(), err } @@ -235,7 +235,7 @@ func (k Keeper) PutPolicy(ctx sdk.Context, operator sdk.AccAddress, grn types2.G func (k Keeper) DeletePolicy( ctx sdk.Context, operator sdk.AccAddress, principal *permtypes.Principal, grn types2.GRN, ) (math.Uint, error) { - resOwner, resID, err := k.getResourceOwnerAndIdFromGRN(ctx, grn) + resOwner, resID, err := k.GetResourceOwnerAndIdFromGRN(ctx, grn) if err != nil { return math.ZeroUint(), err } @@ -292,7 +292,7 @@ func (k Keeper) ValidatePrincipal(ctx sdk.Context, resOwner sdk.AccAddress, prin return nil } -func (k Keeper) getResourceOwnerAndIdFromGRN(ctx sdk.Context, grn types2.GRN) (resOwner sdk.AccAddress, resID math.Uint, err error) { +func (k Keeper) GetResourceOwnerAndIdFromGRN(ctx sdk.Context, grn types2.GRN) (resOwner sdk.AccAddress, resID math.Uint, err error) { switch grn.ResourceType() { case gnfdresource.RESOURCE_TYPE_BUCKET: bucketName, grnErr := grn.GetBucketName() diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 352cd5cd1..2833aae56 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -11,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + types2 "github.com/bnb-chain/greenfield/types" "github.com/bnb-chain/greenfield/types/resource" paymenttypes "github.com/bnb-chain/greenfield/x/payment/types" permtypes "github.com/bnb-chain/greenfield/x/permission/types" @@ -129,6 +130,8 @@ type StorageKeeper interface { NormalizePrincipal(ctx sdk.Context, principal *permtypes.Principal) ValidatePrincipal(ctx sdk.Context, resOwner sdk.AccAddress, principal *permtypes.Principal) error + + GetResourceOwnerAndIdFromGRN(ctx sdk.Context, grn types2.GRN) (resOwner sdk.AccAddress, resID math.Uint, err error) } type PaymentMsgServer interface { diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 669695ffd..ec56e24d9 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -11,14 +11,15 @@ import ( time "time" math "cosmossdk.io/math" + types "github.com/bnb-chain/greenfield/types" resource "github.com/bnb-chain/greenfield/types/resource" - types "github.com/bnb-chain/greenfield/x/payment/types" - types0 "github.com/bnb-chain/greenfield/x/permission/types" - types1 "github.com/bnb-chain/greenfield/x/sp/types" - types2 "github.com/bnb-chain/greenfield/x/virtualgroup/types" + types0 "github.com/bnb-chain/greenfield/x/payment/types" + types1 "github.com/bnb-chain/greenfield/x/permission/types" + types2 "github.com/bnb-chain/greenfield/x/sp/types" + types3 "github.com/bnb-chain/greenfield/x/virtualgroup/types" log "github.com/cometbft/cometbft/libs/log" - types3 "github.com/cosmos/cosmos-sdk/types" - types4 "github.com/cosmos/cosmos-sdk/x/auth/types" + types4 "github.com/cosmos/cosmos-sdk/types" + types5 "github.com/cosmos/cosmos-sdk/x/auth/types" gomock "github.com/golang/mock/gomock" ) @@ -46,10 +47,10 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetAccount mocks base method. -func (m *MockAccountKeeper) GetAccount(ctx types3.Context, addr types3.AccAddress) types4.AccountI { +func (m *MockAccountKeeper) GetAccount(ctx types4.Context, addr types4.AccAddress) types5.AccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccount", ctx, addr) - ret0, _ := ret[0].(types4.AccountI) + ret0, _ := ret[0].(types5.AccountI) return ret0 } @@ -60,10 +61,10 @@ func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomo } // GetModuleAddress mocks base method. -func (m *MockAccountKeeper) GetModuleAddress(name string) types3.AccAddress { +func (m *MockAccountKeeper) GetModuleAddress(name string) types4.AccAddress { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAddress", name) - ret0, _ := ret[0].(types3.AccAddress) + ret0, _ := ret[0].(types4.AccAddress) return ret0 } @@ -97,10 +98,10 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { } // GetAllBalances mocks base method. -func (m *MockBankKeeper) GetAllBalances(ctx types3.Context, addr types3.AccAddress) types3.Coins { +func (m *MockBankKeeper) GetAllBalances(ctx types4.Context, addr types4.AccAddress) types4.Coins { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) - ret0, _ := ret[0].(types3.Coins) + ret0, _ := ret[0].(types4.Coins) return ret0 } @@ -111,10 +112,10 @@ func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gom } // GetBalance mocks base method. -func (m *MockBankKeeper) GetBalance(ctx types3.Context, addr types3.AccAddress, denom string) types3.Coin { +func (m *MockBankKeeper) GetBalance(ctx types4.Context, addr types4.AccAddress, denom string) types4.Coin { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom) - ret0, _ := ret[0].(types3.Coin) + ret0, _ := ret[0].(types4.Coin) return ret0 } @@ -125,7 +126,7 @@ func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) * } // SendCoinsFromModuleToAccount mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types3.Context, senderModule string, recipientAddr types3.AccAddress, amt types3.Coins) error { +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types4.Context, senderModule string, recipientAddr types4.AccAddress, amt types4.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) ret0, _ := ret[0].(error) @@ -139,10 +140,10 @@ func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderMo } // SpendableCoins mocks base method. -func (m *MockBankKeeper) SpendableCoins(ctx types3.Context, addr types3.AccAddress) types3.Coins { +func (m *MockBankKeeper) SpendableCoins(ctx types4.Context, addr types4.AccAddress) types4.Coins { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) - ret0, _ := ret[0].(types3.Coins) + ret0, _ := ret[0].(types4.Coins) return ret0 } @@ -176,10 +177,10 @@ func (m *MockSpKeeper) EXPECT() *MockSpKeeperMockRecorder { } // GetGlobalSpStorePriceByTime mocks base method. -func (m *MockSpKeeper) GetGlobalSpStorePriceByTime(ctx types3.Context, time int64) (types1.GlobalSpStorePrice, error) { +func (m *MockSpKeeper) GetGlobalSpStorePriceByTime(ctx types4.Context, time int64) (types2.GlobalSpStorePrice, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGlobalSpStorePriceByTime", ctx, time) - ret0, _ := ret[0].(types1.GlobalSpStorePrice) + ret0, _ := ret[0].(types2.GlobalSpStorePrice) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -191,10 +192,10 @@ func (mr *MockSpKeeperMockRecorder) GetGlobalSpStorePriceByTime(ctx, time interf } // GetStorageProvider mocks base method. -func (m *MockSpKeeper) GetStorageProvider(ctx types3.Context, id uint32) (*types1.StorageProvider, bool) { +func (m *MockSpKeeper) GetStorageProvider(ctx types4.Context, id uint32) (*types2.StorageProvider, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStorageProvider", ctx, id) - ret0, _ := ret[0].(*types1.StorageProvider) + ret0, _ := ret[0].(*types2.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -206,10 +207,10 @@ func (mr *MockSpKeeperMockRecorder) GetStorageProvider(ctx, id interface{}) *gom } // GetStorageProviderByGcAddr mocks base method. -func (m *MockSpKeeper) GetStorageProviderByGcAddr(ctx types3.Context, gcAddr types3.AccAddress) (*types1.StorageProvider, bool) { +func (m *MockSpKeeper) GetStorageProviderByGcAddr(ctx types4.Context, gcAddr types4.AccAddress) (*types2.StorageProvider, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStorageProviderByGcAddr", ctx, gcAddr) - ret0, _ := ret[0].(*types1.StorageProvider) + ret0, _ := ret[0].(*types2.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -221,10 +222,10 @@ func (mr *MockSpKeeperMockRecorder) GetStorageProviderByGcAddr(ctx, gcAddr inter } // GetStorageProviderByOperatorAddr mocks base method. -func (m *MockSpKeeper) GetStorageProviderByOperatorAddr(ctx types3.Context, addr types3.AccAddress) (*types1.StorageProvider, bool) { +func (m *MockSpKeeper) GetStorageProviderByOperatorAddr(ctx types4.Context, addr types4.AccAddress) (*types2.StorageProvider, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStorageProviderByOperatorAddr", ctx, addr) - ret0, _ := ret[0].(*types1.StorageProvider) + ret0, _ := ret[0].(*types2.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -236,10 +237,10 @@ func (mr *MockSpKeeperMockRecorder) GetStorageProviderByOperatorAddr(ctx, addr i } // GetStorageProviderBySealAddr mocks base method. -func (m *MockSpKeeper) GetStorageProviderBySealAddr(ctx types3.Context, sealAddr types3.AccAddress) (*types1.StorageProvider, bool) { +func (m *MockSpKeeper) GetStorageProviderBySealAddr(ctx types4.Context, sealAddr types4.AccAddress) (*types2.StorageProvider, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStorageProviderBySealAddr", ctx, sealAddr) - ret0, _ := ret[0].(*types1.StorageProvider) + ret0, _ := ret[0].(*types2.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -251,10 +252,10 @@ func (mr *MockSpKeeperMockRecorder) GetStorageProviderBySealAddr(ctx, sealAddr i } // MustGetStorageProvider mocks base method. -func (m *MockSpKeeper) MustGetStorageProvider(ctx types3.Context, id uint32) *types1.StorageProvider { +func (m *MockSpKeeper) MustGetStorageProvider(ctx types4.Context, id uint32) *types2.StorageProvider { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MustGetStorageProvider", ctx, id) - ret0, _ := ret[0].(*types1.StorageProvider) + ret0, _ := ret[0].(*types2.StorageProvider) return ret0 } @@ -288,7 +289,7 @@ func (m *MockPaymentKeeper) EXPECT() *MockPaymentKeeperMockRecorder { } // ApplyUserFlowsList mocks base method. -func (m *MockPaymentKeeper) ApplyUserFlowsList(ctx types3.Context, userFlows []types.UserFlows) error { +func (m *MockPaymentKeeper) ApplyUserFlowsList(ctx types4.Context, userFlows []types0.UserFlows) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ApplyUserFlowsList", ctx, userFlows) ret0, _ := ret[0].(error) @@ -302,10 +303,10 @@ func (mr *MockPaymentKeeperMockRecorder) ApplyUserFlowsList(ctx, userFlows inter } // GetAllStreamRecord mocks base method. -func (m *MockPaymentKeeper) GetAllStreamRecord(ctx types3.Context) []types.StreamRecord { +func (m *MockPaymentKeeper) GetAllStreamRecord(ctx types4.Context) []types0.StreamRecord { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllStreamRecord", ctx) - ret0, _ := ret[0].([]types.StreamRecord) + ret0, _ := ret[0].([]types0.StreamRecord) return ret0 } @@ -316,10 +317,10 @@ func (mr *MockPaymentKeeperMockRecorder) GetAllStreamRecord(ctx interface{}) *go } // GetOutFlows mocks base method. -func (m *MockPaymentKeeper) GetOutFlows(ctx types3.Context, addr types3.AccAddress) []types.OutFlow { +func (m *MockPaymentKeeper) GetOutFlows(ctx types4.Context, addr types4.AccAddress) []types0.OutFlow { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetOutFlows", ctx, addr) - ret0, _ := ret[0].([]types.OutFlow) + ret0, _ := ret[0].([]types0.OutFlow) return ret0 } @@ -330,10 +331,10 @@ func (mr *MockPaymentKeeperMockRecorder) GetOutFlows(ctx, addr interface{}) *gom } // GetStreamRecord mocks base method. -func (m *MockPaymentKeeper) GetStreamRecord(ctx types3.Context, account types3.AccAddress) (*types.StreamRecord, bool) { +func (m *MockPaymentKeeper) GetStreamRecord(ctx types4.Context, account types4.AccAddress) (*types0.StreamRecord, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStreamRecord", ctx, account) - ret0, _ := ret[0].(*types.StreamRecord) + ret0, _ := ret[0].(*types0.StreamRecord) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -345,10 +346,10 @@ func (mr *MockPaymentKeeperMockRecorder) GetStreamRecord(ctx, account interface{ } // GetVersionedParamsWithTs mocks base method. -func (m *MockPaymentKeeper) GetVersionedParamsWithTs(ctx types3.Context, time int64) (types.VersionedParams, error) { +func (m *MockPaymentKeeper) GetVersionedParamsWithTs(ctx types4.Context, time int64) (types0.VersionedParams, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetVersionedParamsWithTs", ctx, time) - ret0, _ := ret[0].(types.VersionedParams) + ret0, _ := ret[0].(types0.VersionedParams) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -360,7 +361,7 @@ func (mr *MockPaymentKeeperMockRecorder) GetVersionedParamsWithTs(ctx, time inte } // IsPaymentAccountOwner mocks base method. -func (m *MockPaymentKeeper) IsPaymentAccountOwner(ctx types3.Context, addr, owner types3.AccAddress) bool { +func (m *MockPaymentKeeper) IsPaymentAccountOwner(ctx types4.Context, addr, owner types4.AccAddress) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsPaymentAccountOwner", ctx, addr, owner) ret0, _ := ret[0].(bool) @@ -374,10 +375,10 @@ func (mr *MockPaymentKeeperMockRecorder) IsPaymentAccountOwner(ctx, addr, owner } // MergeOutFlows mocks base method. -func (m *MockPaymentKeeper) MergeOutFlows(flows []types.OutFlow) []types.OutFlow { +func (m *MockPaymentKeeper) MergeOutFlows(flows []types0.OutFlow) []types0.OutFlow { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MergeOutFlows", flows) - ret0, _ := ret[0].([]types.OutFlow) + ret0, _ := ret[0].([]types0.OutFlow) return ret0 } @@ -388,10 +389,10 @@ func (mr *MockPaymentKeeperMockRecorder) MergeOutFlows(flows interface{}) *gomoc } // UpdateStreamRecordByAddr mocks base method. -func (m *MockPaymentKeeper) UpdateStreamRecordByAddr(ctx types3.Context, change *types.StreamRecordChange) (*types.StreamRecord, error) { +func (m *MockPaymentKeeper) UpdateStreamRecordByAddr(ctx types4.Context, change *types0.StreamRecordChange) (*types0.StreamRecord, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateStreamRecordByAddr", ctx, change) - ret0, _ := ret[0].(*types.StreamRecord) + ret0, _ := ret[0].(*types0.StreamRecord) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -426,7 +427,7 @@ func (m *MockPermissionKeeper) EXPECT() *MockPermissionKeeperMockRecorder { } // AddGroupMember mocks base method. -func (m *MockPermissionKeeper) AddGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress, expiration *time.Time) error { +func (m *MockPermissionKeeper) AddGroupMember(ctx types4.Context, groupID math.Uint, member types4.AccAddress, expiration *time.Time) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AddGroupMember", ctx, groupID, member, expiration) ret0, _ := ret[0].(error) @@ -440,7 +441,7 @@ func (mr *MockPermissionKeeperMockRecorder) AddGroupMember(ctx, groupID, member, } // DeletePolicy mocks base method. -func (m *MockPermissionKeeper) DeletePolicy(ctx types3.Context, principal *types0.Principal, resourceType resource.ResourceType, resourceID math.Uint) (math.Uint, error) { +func (m *MockPermissionKeeper) DeletePolicy(ctx types4.Context, principal *types1.Principal, resourceType resource.ResourceType, resourceID math.Uint) (math.Uint, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeletePolicy", ctx, principal, resourceType, resourceID) ret0, _ := ret[0].(math.Uint) @@ -455,7 +456,7 @@ func (mr *MockPermissionKeeperMockRecorder) DeletePolicy(ctx, principal, resourc } // ExistAccountPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ExistAccountPolicyForResource(ctx types3.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { +func (m *MockPermissionKeeper) ExistAccountPolicyForResource(ctx types4.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ExistAccountPolicyForResource", ctx, resourceType, resourceID) ret0, _ := ret[0].(bool) @@ -469,7 +470,7 @@ func (mr *MockPermissionKeeperMockRecorder) ExistAccountPolicyForResource(ctx, r } // ExistGroupMemberForGroup mocks base method. -func (m *MockPermissionKeeper) ExistGroupMemberForGroup(ctx types3.Context, groupId math.Uint) bool { +func (m *MockPermissionKeeper) ExistGroupMemberForGroup(ctx types4.Context, groupId math.Uint) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ExistGroupMemberForGroup", ctx, groupId) ret0, _ := ret[0].(bool) @@ -483,7 +484,7 @@ func (mr *MockPermissionKeeperMockRecorder) ExistGroupMemberForGroup(ctx, groupI } // ExistGroupPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ExistGroupPolicyForResource(ctx types3.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { +func (m *MockPermissionKeeper) ExistGroupPolicyForResource(ctx types4.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ExistGroupPolicyForResource", ctx, resourceType, resourceID) ret0, _ := ret[0].(bool) @@ -497,7 +498,7 @@ func (mr *MockPermissionKeeperMockRecorder) ExistGroupPolicyForResource(ctx, res } // ForceDeleteAccountPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types3.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { +func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types4.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ForceDeleteAccountPolicyForResource", ctx, maxDelete, deletedCount, resourceType, resourceID) ret0, _ := ret[0].(uint64) @@ -512,7 +513,7 @@ func (mr *MockPermissionKeeperMockRecorder) ForceDeleteAccountPolicyForResource( } // ForceDeleteGroupMembers mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types3.Context, maxDelete, deletedTotal uint64, groupId math.Uint) (uint64, bool) { +func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types4.Context, maxDelete, deletedTotal uint64, groupId math.Uint) (uint64, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, maxDelete, deletedTotal, groupId) ret0, _ := ret[0].(uint64) @@ -527,7 +528,7 @@ func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, maxDele } // ForceDeleteGroupPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types3.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { +func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types4.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ForceDeleteGroupPolicyForResource", ctx, maxDelete, deletedCount, resourceType, resourceID) ret0, _ := ret[0].(uint64) @@ -542,10 +543,10 @@ func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ct } // GetGroupMember mocks base method. -func (m *MockPermissionKeeper) GetGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress) (*types0.GroupMember, bool) { +func (m *MockPermissionKeeper) GetGroupMember(ctx types4.Context, groupID math.Uint, member types4.AccAddress) (*types1.GroupMember, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGroupMember", ctx, groupID, member) - ret0, _ := ret[0].(*types0.GroupMember) + ret0, _ := ret[0].(*types1.GroupMember) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -557,10 +558,10 @@ func (mr *MockPermissionKeeperMockRecorder) GetGroupMember(ctx, groupID, member } // GetGroupMemberByID mocks base method. -func (m *MockPermissionKeeper) GetGroupMemberByID(ctx types3.Context, groupMemberID math.Uint) (*types0.GroupMember, bool) { +func (m *MockPermissionKeeper) GetGroupMemberByID(ctx types4.Context, groupMemberID math.Uint) (*types1.GroupMember, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGroupMemberByID", ctx, groupMemberID) - ret0, _ := ret[0].(*types0.GroupMember) + ret0, _ := ret[0].(*types1.GroupMember) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -572,10 +573,10 @@ func (mr *MockPermissionKeeperMockRecorder) GetGroupMemberByID(ctx, groupMemberI } // GetPolicyByID mocks base method. -func (m *MockPermissionKeeper) GetPolicyByID(ctx types3.Context, policyID math.Uint) (*types0.Policy, bool) { +func (m *MockPermissionKeeper) GetPolicyByID(ctx types4.Context, policyID math.Uint) (*types1.Policy, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPolicyByID", ctx, policyID) - ret0, _ := ret[0].(*types0.Policy) + ret0, _ := ret[0].(*types1.Policy) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -587,10 +588,10 @@ func (mr *MockPermissionKeeperMockRecorder) GetPolicyByID(ctx, policyID interfac } // GetPolicyForAccount mocks base method. -func (m *MockPermissionKeeper) GetPolicyForAccount(ctx types3.Context, resourceID math.Uint, resourceType resource.ResourceType, addr types3.AccAddress) (*types0.Policy, bool) { +func (m *MockPermissionKeeper) GetPolicyForAccount(ctx types4.Context, resourceID math.Uint, resourceType resource.ResourceType, addr types4.AccAddress) (*types1.Policy, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPolicyForAccount", ctx, resourceID, resourceType, addr) - ret0, _ := ret[0].(*types0.Policy) + ret0, _ := ret[0].(*types1.Policy) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -602,10 +603,10 @@ func (mr *MockPermissionKeeperMockRecorder) GetPolicyForAccount(ctx, resourceID, } // GetPolicyForGroup mocks base method. -func (m *MockPermissionKeeper) GetPolicyForGroup(ctx types3.Context, resourceID math.Uint, resourceType resource.ResourceType, groupID math.Uint) (*types0.Policy, bool) { +func (m *MockPermissionKeeper) GetPolicyForGroup(ctx types4.Context, resourceID math.Uint, resourceType resource.ResourceType, groupID math.Uint) (*types1.Policy, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPolicyForGroup", ctx, resourceID, resourceType, groupID) - ret0, _ := ret[0].(*types0.Policy) + ret0, _ := ret[0].(*types1.Policy) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -617,10 +618,10 @@ func (mr *MockPermissionKeeperMockRecorder) GetPolicyForGroup(ctx, resourceID, r } // GetPolicyGroupForResource mocks base method. -func (m *MockPermissionKeeper) GetPolicyGroupForResource(ctx types3.Context, resourceID math.Uint, resourceType resource.ResourceType) (*types0.PolicyGroup, bool) { +func (m *MockPermissionKeeper) GetPolicyGroupForResource(ctx types4.Context, resourceID math.Uint, resourceType resource.ResourceType) (*types1.PolicyGroup, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPolicyGroupForResource", ctx, resourceID, resourceType) - ret0, _ := ret[0].(*types0.PolicyGroup) + ret0, _ := ret[0].(*types1.PolicyGroup) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -632,10 +633,10 @@ func (mr *MockPermissionKeeperMockRecorder) GetPolicyGroupForResource(ctx, resou } // MustGetPolicyByID mocks base method. -func (m *MockPermissionKeeper) MustGetPolicyByID(ctx types3.Context, policyID math.Uint) *types0.Policy { +func (m *MockPermissionKeeper) MustGetPolicyByID(ctx types4.Context, policyID math.Uint) *types1.Policy { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MustGetPolicyByID", ctx, policyID) - ret0, _ := ret[0].(*types0.Policy) + ret0, _ := ret[0].(*types1.Policy) return ret0 } @@ -646,7 +647,7 @@ func (mr *MockPermissionKeeperMockRecorder) MustGetPolicyByID(ctx, policyID inte } // PutPolicy mocks base method. -func (m *MockPermissionKeeper) PutPolicy(ctx types3.Context, policy *types0.Policy) (math.Uint, error) { +func (m *MockPermissionKeeper) PutPolicy(ctx types4.Context, policy *types1.Policy) (math.Uint, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PutPolicy", ctx, policy) ret0, _ := ret[0].(math.Uint) @@ -661,7 +662,7 @@ func (mr *MockPermissionKeeperMockRecorder) PutPolicy(ctx, policy interface{}) * } // RemoveGroupMember mocks base method. -func (m *MockPermissionKeeper) RemoveGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress) error { +func (m *MockPermissionKeeper) RemoveGroupMember(ctx types4.Context, groupID math.Uint, member types4.AccAddress) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RemoveGroupMember", ctx, groupID, member) ret0, _ := ret[0].(error) @@ -675,7 +676,7 @@ func (mr *MockPermissionKeeperMockRecorder) RemoveGroupMember(ctx, groupID, memb } // UpdateGroupMember mocks base method. -func (m *MockPermissionKeeper) UpdateGroupMember(ctx types3.Context, groupID math.Uint, member types3.AccAddress, memberID math.Uint, expiration *time.Time) { +func (m *MockPermissionKeeper) UpdateGroupMember(ctx types4.Context, groupID math.Uint, member types4.AccAddress, memberID math.Uint, expiration *time.Time) { m.ctrl.T.Helper() m.ctrl.Call(m, "UpdateGroupMember", ctx, groupID, member, memberID, expiration) } @@ -710,7 +711,7 @@ func (m *MockCrossChainKeeper) EXPECT() *MockCrossChainKeeperMockRecorder { } // CreateRawIBCPackageWithFee mocks base method. -func (m *MockCrossChainKeeper) CreateRawIBCPackageWithFee(ctx types3.Context, chainID types3.ChainID, channelID types3.ChannelID, packageType types3.CrossChainPackageType, packageLoad []byte, relayerFee, ackRelayerFee *big.Int) (uint64, error) { +func (m *MockCrossChainKeeper) CreateRawIBCPackageWithFee(ctx types4.Context, chainID types4.ChainID, channelID types4.ChannelID, packageType types4.CrossChainPackageType, packageLoad []byte, relayerFee, ackRelayerFee *big.Int) (uint64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateRawIBCPackageWithFee", ctx, chainID, channelID, packageType, packageLoad, relayerFee, ackRelayerFee) ret0, _ := ret[0].(uint64) @@ -725,10 +726,10 @@ func (mr *MockCrossChainKeeperMockRecorder) CreateRawIBCPackageWithFee(ctx, chai } // GetDestBscChainID mocks base method. -func (m *MockCrossChainKeeper) GetDestBscChainID() types3.ChainID { +func (m *MockCrossChainKeeper) GetDestBscChainID() types4.ChainID { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetDestBscChainID") - ret0, _ := ret[0].(types3.ChainID) + ret0, _ := ret[0].(types4.ChainID) return ret0 } @@ -739,10 +740,10 @@ func (mr *MockCrossChainKeeperMockRecorder) GetDestBscChainID() *gomock.Call { } // GetDestOpChainID mocks base method. -func (m *MockCrossChainKeeper) GetDestOpChainID() types3.ChainID { +func (m *MockCrossChainKeeper) GetDestOpChainID() types4.ChainID { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetDestOpChainID") - ret0, _ := ret[0].(types3.ChainID) + ret0, _ := ret[0].(types4.ChainID) return ret0 } @@ -753,7 +754,7 @@ func (mr *MockCrossChainKeeperMockRecorder) GetDestOpChainID() *gomock.Call { } // IsDestChainSupported mocks base method. -func (m *MockCrossChainKeeper) IsDestChainSupported(chainID types3.ChainID) bool { +func (m *MockCrossChainKeeper) IsDestChainSupported(chainID types4.ChainID) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsDestChainSupported", chainID) ret0, _ := ret[0].(bool) @@ -767,7 +768,7 @@ func (mr *MockCrossChainKeeperMockRecorder) IsDestChainSupported(chainID interfa } // RegisterChannel mocks base method. -func (m *MockCrossChainKeeper) RegisterChannel(name string, id types3.ChannelID, app types3.CrossChainApplication) error { +func (m *MockCrossChainKeeper) RegisterChannel(name string, id types4.ChannelID, app types4.CrossChainApplication) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RegisterChannel", name, id, app) ret0, _ := ret[0].(error) @@ -804,10 +805,10 @@ func (m *MockVirtualGroupKeeper) EXPECT() *MockVirtualGroupKeeperMockRecorder { } // GetAndCheckGVGFamilyAvailableForNewBucket mocks base method. -func (m *MockVirtualGroupKeeper) GetAndCheckGVGFamilyAvailableForNewBucket(ctx types3.Context, familyID uint32) (*types2.GlobalVirtualGroupFamily, error) { +func (m *MockVirtualGroupKeeper) GetAndCheckGVGFamilyAvailableForNewBucket(ctx types4.Context, familyID uint32) (*types3.GlobalVirtualGroupFamily, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAndCheckGVGFamilyAvailableForNewBucket", ctx, familyID) - ret0, _ := ret[0].(*types2.GlobalVirtualGroupFamily) + ret0, _ := ret[0].(*types3.GlobalVirtualGroupFamily) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -819,10 +820,10 @@ func (mr *MockVirtualGroupKeeperMockRecorder) GetAndCheckGVGFamilyAvailableForNe } // GetGVG mocks base method. -func (m *MockVirtualGroupKeeper) GetGVG(ctx types3.Context, gvgID uint32) (*types2.GlobalVirtualGroup, bool) { +func (m *MockVirtualGroupKeeper) GetGVG(ctx types4.Context, gvgID uint32) (*types3.GlobalVirtualGroup, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGVG", ctx, gvgID) - ret0, _ := ret[0].(*types2.GlobalVirtualGroup) + ret0, _ := ret[0].(*types3.GlobalVirtualGroup) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -834,10 +835,10 @@ func (mr *MockVirtualGroupKeeperMockRecorder) GetGVG(ctx, gvgID interface{}) *go } // GetGVGFamily mocks base method. -func (m *MockVirtualGroupKeeper) GetGVGFamily(ctx types3.Context, familyID uint32) (*types2.GlobalVirtualGroupFamily, bool) { +func (m *MockVirtualGroupKeeper) GetGVGFamily(ctx types4.Context, familyID uint32) (*types3.GlobalVirtualGroupFamily, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGVGFamily", ctx, familyID) - ret0, _ := ret[0].(*types2.GlobalVirtualGroupFamily) + ret0, _ := ret[0].(*types3.GlobalVirtualGroupFamily) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -849,10 +850,10 @@ func (mr *MockVirtualGroupKeeperMockRecorder) GetGVGFamily(ctx, familyID interfa } // GetGlobalVirtualGroupIfAvailable mocks base method. -func (m *MockVirtualGroupKeeper) GetGlobalVirtualGroupIfAvailable(ctx types3.Context, gvgID uint32, expectedStoreSize uint64) (*types2.GlobalVirtualGroup, error) { +func (m *MockVirtualGroupKeeper) GetGlobalVirtualGroupIfAvailable(ctx types4.Context, gvgID uint32, expectedStoreSize uint64) (*types3.GlobalVirtualGroup, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGlobalVirtualGroupIfAvailable", ctx, gvgID, expectedStoreSize) - ret0, _ := ret[0].(*types2.GlobalVirtualGroup) + ret0, _ := ret[0].(*types3.GlobalVirtualGroup) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -864,10 +865,10 @@ func (mr *MockVirtualGroupKeeperMockRecorder) GetGlobalVirtualGroupIfAvailable(c } // GetSwapInInfo mocks base method. -func (m *MockVirtualGroupKeeper) GetSwapInInfo(ctx types3.Context, familyID, gvgID uint32) (*types2.SwapInInfo, bool) { +func (m *MockVirtualGroupKeeper) GetSwapInInfo(ctx types4.Context, familyID, gvgID uint32) (*types3.SwapInInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSwapInInfo", ctx, familyID, gvgID) - ret0, _ := ret[0].(*types2.SwapInInfo) + ret0, _ := ret[0].(*types3.SwapInInfo) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -879,7 +880,7 @@ func (mr *MockVirtualGroupKeeperMockRecorder) GetSwapInInfo(ctx, familyID, gvgID } // SetGVGAndEmitUpdateEvent mocks base method. -func (m *MockVirtualGroupKeeper) SetGVGAndEmitUpdateEvent(ctx types3.Context, gvg *types2.GlobalVirtualGroup) error { +func (m *MockVirtualGroupKeeper) SetGVGAndEmitUpdateEvent(ctx types4.Context, gvg *types3.GlobalVirtualGroup) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetGVGAndEmitUpdateEvent", ctx, gvg) ret0, _ := ret[0].(error) @@ -893,7 +894,7 @@ func (mr *MockVirtualGroupKeeperMockRecorder) SetGVGAndEmitUpdateEvent(ctx, gvg } // SettleAndDistributeGVG mocks base method. -func (m *MockVirtualGroupKeeper) SettleAndDistributeGVG(ctx types3.Context, gvg *types2.GlobalVirtualGroup) error { +func (m *MockVirtualGroupKeeper) SettleAndDistributeGVG(ctx types4.Context, gvg *types3.GlobalVirtualGroup) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SettleAndDistributeGVG", ctx, gvg) ret0, _ := ret[0].(error) @@ -907,7 +908,7 @@ func (mr *MockVirtualGroupKeeperMockRecorder) SettleAndDistributeGVG(ctx, gvg in } // SettleAndDistributeGVGFamily mocks base method. -func (m *MockVirtualGroupKeeper) SettleAndDistributeGVGFamily(ctx types3.Context, sp *types1.StorageProvider, family *types2.GlobalVirtualGroupFamily) error { +func (m *MockVirtualGroupKeeper) SettleAndDistributeGVGFamily(ctx types4.Context, sp *types2.StorageProvider, family *types3.GlobalVirtualGroupFamily) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SettleAndDistributeGVGFamily", ctx, sp, family) ret0, _ := ret[0].(error) @@ -944,7 +945,7 @@ func (m *MockStorageKeeper) EXPECT() *MockStorageKeeperMockRecorder { } // CreateBucket mocks base method. -func (m *MockStorageKeeper) CreateBucket(ctx types3.Context, ownerAcc types3.AccAddress, bucketName string, primarySpAcc types3.AccAddress, opts *CreateBucketOptions) (math.Uint, error) { +func (m *MockStorageKeeper) CreateBucket(ctx types4.Context, ownerAcc types4.AccAddress, bucketName string, primarySpAcc types4.AccAddress, opts *CreateBucketOptions) (math.Uint, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateBucket", ctx, ownerAcc, bucketName, primarySpAcc, opts) ret0, _ := ret[0].(math.Uint) @@ -959,7 +960,7 @@ func (mr *MockStorageKeeperMockRecorder) CreateBucket(ctx, ownerAcc, bucketName, } // CreateGroup mocks base method. -func (m *MockStorageKeeper) CreateGroup(ctx types3.Context, owner types3.AccAddress, groupName string, opts CreateGroupOptions) (math.Uint, error) { +func (m *MockStorageKeeper) CreateGroup(ctx types4.Context, owner types4.AccAddress, groupName string, opts CreateGroupOptions) (math.Uint, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateGroup", ctx, owner, groupName, opts) ret0, _ := ret[0].(math.Uint) @@ -974,7 +975,7 @@ func (mr *MockStorageKeeperMockRecorder) CreateGroup(ctx, owner, groupName, opts } // DeleteBucket mocks base method. -func (m *MockStorageKeeper) DeleteBucket(ctx types3.Context, operator types3.AccAddress, bucketName string, opts DeleteBucketOptions) error { +func (m *MockStorageKeeper) DeleteBucket(ctx types4.Context, operator types4.AccAddress, bucketName string, opts DeleteBucketOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteBucket", ctx, operator, bucketName, opts) ret0, _ := ret[0].(error) @@ -988,7 +989,7 @@ func (mr *MockStorageKeeperMockRecorder) DeleteBucket(ctx, operator, bucketName, } // DeleteGroup mocks base method. -func (m *MockStorageKeeper) DeleteGroup(ctx types3.Context, operator types3.AccAddress, groupName string, opts DeleteGroupOptions) error { +func (m *MockStorageKeeper) DeleteGroup(ctx types4.Context, operator types4.AccAddress, groupName string, opts DeleteGroupOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteGroup", ctx, operator, groupName, opts) ret0, _ := ret[0].(error) @@ -1002,7 +1003,7 @@ func (mr *MockStorageKeeperMockRecorder) DeleteGroup(ctx, operator, groupName, o } // DeleteObject mocks base method. -func (m *MockStorageKeeper) DeleteObject(ctx types3.Context, operator types3.AccAddress, bucketName, objectName string, opts DeleteObjectOptions) error { +func (m *MockStorageKeeper) DeleteObject(ctx types4.Context, operator types4.AccAddress, bucketName, objectName string, opts DeleteObjectOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteObject", ctx, operator, bucketName, objectName, opts) ret0, _ := ret[0].(error) @@ -1016,7 +1017,7 @@ func (mr *MockStorageKeeperMockRecorder) DeleteObject(ctx, operator, bucketName, } // GetBucketInfo mocks base method. -func (m *MockStorageKeeper) GetBucketInfo(ctx types3.Context, bucketName string) (*BucketInfo, bool) { +func (m *MockStorageKeeper) GetBucketInfo(ctx types4.Context, bucketName string) (*BucketInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBucketInfo", ctx, bucketName) ret0, _ := ret[0].(*BucketInfo) @@ -1031,7 +1032,7 @@ func (mr *MockStorageKeeperMockRecorder) GetBucketInfo(ctx, bucketName interface } // GetBucketInfoById mocks base method. -func (m *MockStorageKeeper) GetBucketInfoById(ctx types3.Context, bucketId math.Uint) (*BucketInfo, bool) { +func (m *MockStorageKeeper) GetBucketInfoById(ctx types4.Context, bucketId math.Uint) (*BucketInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBucketInfoById", ctx, bucketId) ret0, _ := ret[0].(*BucketInfo) @@ -1046,7 +1047,7 @@ func (mr *MockStorageKeeperMockRecorder) GetBucketInfoById(ctx, bucketId interfa } // GetGroupInfo mocks base method. -func (m *MockStorageKeeper) GetGroupInfo(ctx types3.Context, ownerAddr types3.AccAddress, groupName string) (*GroupInfo, bool) { +func (m *MockStorageKeeper) GetGroupInfo(ctx types4.Context, ownerAddr types4.AccAddress, groupName string) (*GroupInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGroupInfo", ctx, ownerAddr, groupName) ret0, _ := ret[0].(*GroupInfo) @@ -1061,7 +1062,7 @@ func (mr *MockStorageKeeperMockRecorder) GetGroupInfo(ctx, ownerAddr, groupName } // GetGroupInfoById mocks base method. -func (m *MockStorageKeeper) GetGroupInfoById(ctx types3.Context, groupId math.Uint) (*GroupInfo, bool) { +func (m *MockStorageKeeper) GetGroupInfoById(ctx types4.Context, groupId math.Uint) (*GroupInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetGroupInfoById", ctx, groupId) ret0, _ := ret[0].(*GroupInfo) @@ -1076,7 +1077,7 @@ func (mr *MockStorageKeeperMockRecorder) GetGroupInfoById(ctx, groupId interface } // GetObjectInfo mocks base method. -func (m *MockStorageKeeper) GetObjectInfo(ctx types3.Context, bucketName, objectName string) (*ObjectInfo, bool) { +func (m *MockStorageKeeper) GetObjectInfo(ctx types4.Context, bucketName, objectName string) (*ObjectInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetObjectInfo", ctx, bucketName, objectName) ret0, _ := ret[0].(*ObjectInfo) @@ -1091,7 +1092,7 @@ func (mr *MockStorageKeeperMockRecorder) GetObjectInfo(ctx, bucketName, objectNa } // GetObjectInfoById mocks base method. -func (m *MockStorageKeeper) GetObjectInfoById(ctx types3.Context, objectId math.Uint) (*ObjectInfo, bool) { +func (m *MockStorageKeeper) GetObjectInfoById(ctx types4.Context, objectId math.Uint) (*ObjectInfo, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetObjectInfoById", ctx, objectId) ret0, _ := ret[0].(*ObjectInfo) @@ -1105,8 +1106,24 @@ func (mr *MockStorageKeeperMockRecorder) GetObjectInfoById(ctx, objectId interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectInfoById", reflect.TypeOf((*MockStorageKeeper)(nil).GetObjectInfoById), ctx, objectId) } +// GetResourceOwnerAndIdFromGRN mocks base method. +func (m *MockStorageKeeper) GetResourceOwnerAndIdFromGRN(ctx types4.Context, grn types.GRN) (types4.AccAddress, math.Uint, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetResourceOwnerAndIdFromGRN", ctx, grn) + ret0, _ := ret[0].(types4.AccAddress) + ret1, _ := ret[1].(math.Uint) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetResourceOwnerAndIdFromGRN indicates an expected call of GetResourceOwnerAndIdFromGRN. +func (mr *MockStorageKeeperMockRecorder) GetResourceOwnerAndIdFromGRN(ctx, grn interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResourceOwnerAndIdFromGRN", reflect.TypeOf((*MockStorageKeeper)(nil).GetResourceOwnerAndIdFromGRN), ctx, grn) +} + // GetSourceTypeByChainId mocks base method. -func (m *MockStorageKeeper) GetSourceTypeByChainId(ctx types3.Context, chainId types3.ChainID) (SourceType, error) { +func (m *MockStorageKeeper) GetSourceTypeByChainId(ctx types4.Context, chainId types4.ChainID) (SourceType, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSourceTypeByChainId", ctx, chainId) ret0, _ := ret[0].(SourceType) @@ -1121,7 +1138,7 @@ func (mr *MockStorageKeeperMockRecorder) GetSourceTypeByChainId(ctx, chainId int } // Logger mocks base method. -func (m *MockStorageKeeper) Logger(ctx types3.Context) log.Logger { +func (m *MockStorageKeeper) Logger(ctx types4.Context) log.Logger { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Logger", ctx) ret0, _ := ret[0].(log.Logger) @@ -1135,7 +1152,7 @@ func (mr *MockStorageKeeperMockRecorder) Logger(ctx interface{}) *gomock.Call { } // NormalizePrincipal mocks base method. -func (m *MockStorageKeeper) NormalizePrincipal(ctx types3.Context, principal *types0.Principal) { +func (m *MockStorageKeeper) NormalizePrincipal(ctx types4.Context, principal *types1.Principal) { m.ctrl.T.Helper() m.ctrl.Call(m, "NormalizePrincipal", ctx, principal) } @@ -1147,7 +1164,7 @@ func (mr *MockStorageKeeperMockRecorder) NormalizePrincipal(ctx, principal inter } // RenewGroupMember mocks base method. -func (m *MockStorageKeeper) RenewGroupMember(ctx types3.Context, operator types3.AccAddress, groupInfo *GroupInfo, opts RenewGroupMemberOptions) error { +func (m *MockStorageKeeper) RenewGroupMember(ctx types4.Context, operator types4.AccAddress, groupInfo *GroupInfo, opts RenewGroupMemberOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RenewGroupMember", ctx, operator, groupInfo, opts) ret0, _ := ret[0].(error) @@ -1161,7 +1178,7 @@ func (mr *MockStorageKeeperMockRecorder) RenewGroupMember(ctx, operator, groupIn } // SetBucketInfo mocks base method. -func (m *MockStorageKeeper) SetBucketInfo(ctx types3.Context, bucketInfo *BucketInfo) { +func (m *MockStorageKeeper) SetBucketInfo(ctx types4.Context, bucketInfo *BucketInfo) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetBucketInfo", ctx, bucketInfo) } @@ -1173,7 +1190,7 @@ func (mr *MockStorageKeeperMockRecorder) SetBucketInfo(ctx, bucketInfo interface } // SetGroupInfo mocks base method. -func (m *MockStorageKeeper) SetGroupInfo(ctx types3.Context, groupInfo *GroupInfo) { +func (m *MockStorageKeeper) SetGroupInfo(ctx types4.Context, groupInfo *GroupInfo) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetGroupInfo", ctx, groupInfo) } @@ -1185,7 +1202,7 @@ func (mr *MockStorageKeeperMockRecorder) SetGroupInfo(ctx, groupInfo interface{} } // SetObjectInfo mocks base method. -func (m *MockStorageKeeper) SetObjectInfo(ctx types3.Context, objectInfo *ObjectInfo) { +func (m *MockStorageKeeper) SetObjectInfo(ctx types4.Context, objectInfo *ObjectInfo) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetObjectInfo", ctx, objectInfo) } @@ -1197,7 +1214,7 @@ func (mr *MockStorageKeeperMockRecorder) SetObjectInfo(ctx, objectInfo interface } // UpdateGroupMember mocks base method. -func (m *MockStorageKeeper) UpdateGroupMember(ctx types3.Context, operator types3.AccAddress, groupInfo *GroupInfo, opts UpdateGroupMemberOptions) error { +func (m *MockStorageKeeper) UpdateGroupMember(ctx types4.Context, operator types4.AccAddress, groupInfo *GroupInfo, opts UpdateGroupMemberOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateGroupMember", ctx, operator, groupInfo, opts) ret0, _ := ret[0].(error) @@ -1211,7 +1228,7 @@ func (mr *MockStorageKeeperMockRecorder) UpdateGroupMember(ctx, operator, groupI } // ValidatePrincipal mocks base method. -func (m *MockStorageKeeper) ValidatePrincipal(ctx types3.Context, resOwner types3.AccAddress, principal *types0.Principal) error { +func (m *MockStorageKeeper) ValidatePrincipal(ctx types4.Context, resOwner types4.AccAddress, principal *types1.Principal) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatePrincipal", ctx, resOwner, principal) ret0, _ := ret[0].(error) @@ -1248,10 +1265,10 @@ func (m *MockPaymentMsgServer) EXPECT() *MockPaymentMsgServerMockRecorder { } // CreatePaymentAccount mocks base method. -func (m *MockPaymentMsgServer) CreatePaymentAccount(arg0 context.Context, arg1 *types.MsgCreatePaymentAccount) (*types.MsgCreatePaymentAccountResponse, error) { +func (m *MockPaymentMsgServer) CreatePaymentAccount(arg0 context.Context, arg1 *types0.MsgCreatePaymentAccount) (*types0.MsgCreatePaymentAccountResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreatePaymentAccount", arg0, arg1) - ret0, _ := ret[0].(*types.MsgCreatePaymentAccountResponse) + ret0, _ := ret[0].(*types0.MsgCreatePaymentAccountResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1263,10 +1280,10 @@ func (mr *MockPaymentMsgServerMockRecorder) CreatePaymentAccount(arg0, arg1 inte } // Deposit mocks base method. -func (m *MockPaymentMsgServer) Deposit(arg0 context.Context, arg1 *types.MsgDeposit) (*types.MsgDepositResponse, error) { +func (m *MockPaymentMsgServer) Deposit(arg0 context.Context, arg1 *types0.MsgDeposit) (*types0.MsgDepositResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Deposit", arg0, arg1) - ret0, _ := ret[0].(*types.MsgDepositResponse) + ret0, _ := ret[0].(*types0.MsgDepositResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1278,10 +1295,10 @@ func (mr *MockPaymentMsgServerMockRecorder) Deposit(arg0, arg1 interface{}) *gom } // DisableRefund mocks base method. -func (m *MockPaymentMsgServer) DisableRefund(arg0 context.Context, arg1 *types.MsgDisableRefund) (*types.MsgDisableRefundResponse, error) { +func (m *MockPaymentMsgServer) DisableRefund(arg0 context.Context, arg1 *types0.MsgDisableRefund) (*types0.MsgDisableRefundResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DisableRefund", arg0, arg1) - ret0, _ := ret[0].(*types.MsgDisableRefundResponse) + ret0, _ := ret[0].(*types0.MsgDisableRefundResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1293,10 +1310,10 @@ func (mr *MockPaymentMsgServerMockRecorder) DisableRefund(arg0, arg1 interface{} } // Withdraw mocks base method. -func (m *MockPaymentMsgServer) Withdraw(arg0 context.Context, arg1 *types.MsgWithdraw) (*types.MsgWithdrawResponse, error) { +func (m *MockPaymentMsgServer) Withdraw(arg0 context.Context, arg1 *types0.MsgWithdraw) (*types0.MsgWithdrawResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Withdraw", arg0, arg1) - ret0, _ := ret[0].(*types.MsgWithdrawResponse) + ret0, _ := ret[0].(*types0.MsgWithdrawResponse) ret1, _ := ret[1].(error) return ret0, ret1 } From d35a9cecd19e0860e8013e641d3e133e767a0516 Mon Sep 17 00:00:00 2001 From: constwz Date: Thu, 11 Jul 2024 12:30:16 +0800 Subject: [PATCH 5/7] feat: add hardfork logic --- app/upgrade.go | 17 +++++++ deployment/localup/localup.sh | 1 + go.mod | 2 +- go.sum | 4 +- x/storage/keeper/cross_app_permission.go | 3 +- x/storage/keeper/keeper.go | 62 +++++++++++++++++++----- 6 files changed, 73 insertions(+), 16 deletions(-) diff --git a/app/upgrade.go b/app/upgrade.go index c69031dc0..73404a44d 100644 --- a/app/upgrade.go +++ b/app/upgrade.go @@ -35,6 +35,7 @@ func (app *App) RegisterUpgradeHandlers(chainID string, serverCfg *serverconfig. app.registerSerengetiUpgradeHandler() app.registerErdosUpgradeHandler() app.registerVeldUpgradeHandler() + app.registerMongolianUpgradeHandler() // app.register...() // ... return nil @@ -279,3 +280,19 @@ func (app *App) registerVeldUpgradeHandler() { return nil }) } + +func (app *App) registerMongolianUpgradeHandler() { + // Register the upgrade handler + app.UpgradeKeeper.SetUpgradeHandler(upgradetypes.Mongolian, + func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.Logger().Info("upgrade to ", plan.Name) + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) + + // Register the upgrade initializer + app.UpgradeKeeper.SetUpgradeInitializer(upgradetypes.Mongolian, + func() error { + app.Logger().Info("Init Veld upgrade") + return nil + }) +} diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index 40e8ab56d..d3c7221bb 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -181,6 +181,7 @@ function generate_genesis() { echo -e '[[upgrade]]\nname = "Serengeti"\nheight = 24\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml echo -e '[[upgrade]]\nname = "Erdos"\nheight = 25\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml echo -e '[[upgrade]]\nname = "Veld"\nheight = 26\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml + echo -e '[[upgrade]]\nname = "Mongolian"\nheight = 27\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml done # enable swagger API for validator0 diff --git a/go.mod b/go.mod index f47ae89ba..2f52c7a54 100644 --- a/go.mod +++ b/go.mod @@ -176,7 +176,7 @@ replace ( github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v1.3.0 github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.8.0 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.8.1-0.20240711041516-7fd2f478ff35 github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/wercker/journalhook => github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 diff --git a/go.sum b/go.sum index aa9b9a98b..8ebc39001 100644 --- a/go.sum +++ b/go.sum @@ -163,8 +163,8 @@ github.com/bnb-chain/greenfield-cometbft v1.3.0 h1:v3nZ16ledTZGF5Csys7fTQGZcEV78 github.com/bnb-chain/greenfield-cometbft v1.3.0/go.mod h1:0D+VPivZTeBldjtGGi9LKbBnKEO/RtMRJikie92LkYI= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI= -github.com/bnb-chain/greenfield-cosmos-sdk v1.8.0 h1:XaHBYnlAJNIEVTr9dXp3jzw12gCoIEL5jHiAMp+PX0s= -github.com/bnb-chain/greenfield-cosmos-sdk v1.8.0/go.mod h1:2bwmwdXYBISnQoMwgAcZTVGt21lMsHZSeeeMByTvDlQ= +github.com/bnb-chain/greenfield-cosmos-sdk v1.8.1-0.20240711041516-7fd2f478ff35 h1:9VZdnAqCBFCGzNxzV7jnxqSpUwIDwH7UcUMl1nfCEY4= +github.com/bnb-chain/greenfield-cosmos-sdk v1.8.1-0.20240711041516-7fd2f478ff35/go.mod h1:2bwmwdXYBISnQoMwgAcZTVGt21lMsHZSeeeMByTvDlQ= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210 h1:GHPbV2bC+gmuO6/sG0Tm8oGal3KKSRlyE+zPscDjlA8= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210/go.mod h1:vhsZxXE9tYJeYB5JR4hPhd6Pc/uPf7j1T8IJ7p9FdeM= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210 h1:FLVOn4+OVbsKi2+YJX5kmD27/4dRu4FW7xCXFhzDO5s= diff --git a/x/storage/keeper/cross_app_permission.go b/x/storage/keeper/cross_app_permission.go index a759f2ca2..3dd878f4d 100644 --- a/x/storage/keeper/cross_app_permission.go +++ b/x/storage/keeper/cross_app_permission.go @@ -2,12 +2,13 @@ package keeper import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + types2 "github.com/bnb-chain/greenfield/types" gnfderrors "github.com/bnb-chain/greenfield/types/errors" gnfdresource "github.com/bnb-chain/greenfield/types/resource" permtypes "github.com/bnb-chain/greenfield/x/permission/types" "github.com/bnb-chain/greenfield/x/storage/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) var _ sdk.CrossChainApplication = &PermissionApp{} diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 55ae29e7f..0490ad226 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -221,8 +221,13 @@ func (k Keeper) DeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketNam if !found { return types.ErrNoSuchBucket } - if bucketInfo.SourceType != types.SOURCE_TYPE_ORIGIN && bucketInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch + + if bucketInfo.SourceType != opts.SourceType { + if !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } else if bucketInfo.SourceType != types.SOURCE_TYPE_ORIGIN { + return types.ErrSourceTypeMismatch + } } // check permission @@ -417,6 +422,10 @@ func (k Keeper) UpdateBucketInfo(ctx sdk.Context, operator sdk.AccAddress, bucke if !found { return types.ErrNoSuchBucket } + // check bucket source + if bucketInfo.SourceType != opts.SourceType && !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } if ctx.IsUpgraded(upgradetypes.Hulunbeier) { sp := k.MustGetPrimarySPForBucket(ctx, bucketInfo) @@ -983,6 +992,10 @@ func (k Keeper) CancelCreateObject( return types.ErrObjectNotCreated.Wrapf("Object status: %s", objectInfo.ObjectStatus.String()) } + if objectInfo.SourceType != opts.SourceType && !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } + var creator sdk.AccAddress owner := sdk.MustAccAddressFromHex(objectInfo.Owner) if objectInfo.Creator != "" { @@ -1048,8 +1061,12 @@ func (k Keeper) DeleteObject( objectInfo.ObjectName) } - if objectInfo.SourceType != types.SOURCE_TYPE_ORIGIN && objectInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch + if objectInfo.SourceType != opts.SourceType { + if !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } else if objectInfo.SourceType != types.SOURCE_TYPE_ORIGIN { + return types.ErrSourceTypeMismatch + } } if objectInfo.ObjectStatus == types.OBJECT_STATUS_CREATED { @@ -1203,6 +1220,10 @@ func (k Keeper) CopyObject( return sdkmath.ZeroUint(), errors.Wrapf(types.ErrNoSuchObject, "src object name (%s)", srcObjectName) } + if srcObjectInfo.SourceType != opts.SourceType && !ctx.IsUpgraded(upgradetypes.Mongolian) { + return sdkmath.ZeroUint(), types.ErrSourceTypeMismatch + } + if srcObjectInfo.IsUpdating { return sdkmath.ZeroUint(), types.ErrAccessDenied.Wrapf("the object is being updated, can not be copied") } @@ -1540,8 +1561,12 @@ func (k Keeper) DeleteGroup(ctx sdk.Context, operator sdk.AccAddress, groupName if !found { return types.ErrNoSuchGroup } - if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch + if groupInfo.SourceType != opts.SourceType { + if !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } else if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN { + return types.ErrSourceTypeMismatch + } } // check permission effect := k.VerifyGroupPermission(ctx, groupInfo, operator, permtypes.ACTION_DELETE_GROUP) @@ -1576,8 +1601,13 @@ func (k Keeper) LeaveGroup( if !found { return types.ErrNoSuchGroup } - if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch + + if groupInfo.SourceType != opts.SourceType { + if !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } else if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN { + return types.ErrSourceTypeMismatch + } } // Note: Delete group does not require the group is empty. The group member will be deleted by on-chain GC. @@ -1598,8 +1628,12 @@ func (k Keeper) LeaveGroup( } func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts types.UpdateGroupMemberOptions) error { - if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch + if groupInfo.SourceType != opts.SourceType { + if !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } else if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN { + return types.ErrSourceTypeMismatch + } } // check permission @@ -1653,8 +1687,12 @@ func (k Keeper) UpdateGroupMember(ctx sdk.Context, operator sdk.AccAddress, grou } func (k Keeper) RenewGroupMember(ctx sdk.Context, operator sdk.AccAddress, groupInfo *types.GroupInfo, opts types.RenewGroupMemberOptions) error { - if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN && groupInfo.SourceType != opts.SourceType { - return types.ErrSourceTypeMismatch + if groupInfo.SourceType != opts.SourceType { + if !ctx.IsUpgraded(upgradetypes.Mongolian) { + return types.ErrSourceTypeMismatch + } else if groupInfo.SourceType != types.SOURCE_TYPE_ORIGIN { + return types.ErrSourceTypeMismatch + } } // check permission From 3f3e62606bbac2ec68de028b2faffc5e711e4630 Mon Sep 17 00:00:00 2001 From: constwz Date: Thu, 11 Jul 2024 15:34:24 +0800 Subject: [PATCH 6/7] fix: hardfork bug --- x/storage/keeper/cross_app_permission.go | 4 +++- x/storage/keeper/cross_app_permission_test.go | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/x/storage/keeper/cross_app_permission.go b/x/storage/keeper/cross_app_permission.go index 3dd878f4d..17d552e8b 100644 --- a/x/storage/keeper/cross_app_permission.go +++ b/x/storage/keeper/cross_app_permission.go @@ -2,7 +2,9 @@ package keeper import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" types2 "github.com/bnb-chain/greenfield/types" gnfderrors "github.com/bnb-chain/greenfield/types/errors" @@ -167,7 +169,7 @@ func (app *PermissionApp) handleCreatePolicySynPackage(ctx sdk.Context, createPo policy.Statements = crossChainPolicy.Statements var resOwner sdk.AccAddress var resId math.Uint - if crossChainPolicy.GetResourceGRN() != "" { + if ctx.IsUpgraded(upgradetypes.Mongolian) && crossChainPolicy.GetResourceGRN() != "" { err = grn.ParseFromString(crossChainPolicy.GetResourceGRN(), true) if err != nil { return sdk.ExecuteResult{ diff --git a/x/storage/keeper/cross_app_permission_test.go b/x/storage/keeper/cross_app_permission_test.go index fedf4919a..15f1faafb 100644 --- a/x/storage/keeper/cross_app_permission_test.go +++ b/x/storage/keeper/cross_app_permission_test.go @@ -148,14 +148,6 @@ func (s *TestSuite) TestSynCreatePolicyByMsg() { serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) storageKeeper.EXPECT().GetResourceOwnerAndIdFromGRN(gomock.Any(), gomock.Any()).Return(op, resourceIds[0], nil).AnyTimes() - //storageKeeper.EXPECT().GetBucketInfo(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ - // Owner: op.String(), - // BucketName: "test-bucket", - //}, true) - //storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ - // Owner: op.String(), - // BucketName: "test-bucket", - //}, true) storageKeeper.EXPECT().NormalizePrincipal(gomock.Any(), gomock.Any()).Return().AnyTimes() storageKeeper.EXPECT().ValidatePrincipal(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() permissionKeeper.EXPECT().PutPolicy(gomock.Any(), gomock.Any()).Return(math.NewUint(1), nil).AnyTimes() From 3500eec950befd3ee7c69e8160e2bdddd859b86c Mon Sep 17 00:00:00 2001 From: constwz Date: Thu, 11 Jul 2024 18:09:12 +0800 Subject: [PATCH 7/7] fix: ut --- x/storage/keeper/cross_app_permission_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/x/storage/keeper/cross_app_permission_test.go b/x/storage/keeper/cross_app_permission_test.go index 15f1faafb..739ccc1d3 100644 --- a/x/storage/keeper/cross_app_permission_test.go +++ b/x/storage/keeper/cross_app_permission_test.go @@ -108,6 +108,10 @@ func (s *TestSuite) TestSynCreatePolicyByMsgErr() { serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) // case 1: bucket not found + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ + Owner: op.String(), + BucketName: "test-bucket", + }, false).AnyTimes() storageKeeper.EXPECT().GetResourceOwnerAndIdFromGRN(gomock.Any(), gomock.Any()).Return(op, resourceIds[0], storageTypes.ErrNoSuchBucket.Wrapf("bucketName: test-bucket")).AnyTimes() res := app.ExecuteSynPackage(s.ctx, &sdk.CrossChainAppContext{}, serializedSynPackage) s.Require().ErrorIs(res.Err, storageTypes.ErrNoSuchBucket) @@ -146,7 +150,10 @@ func (s *TestSuite) TestSynCreatePolicyByMsg() { } serializedSynPackage := synPackage.MustSerialize() serializedSynPackage = append([]byte{storageTypes.OperationCreatePolicy}, serializedSynPackage...) - + storageKeeper.EXPECT().GetBucketInfoById(gomock.Any(), gomock.Any()).Return(&storageTypes.BucketInfo{ + Owner: op.String(), + BucketName: "test-bucket", + }, true) storageKeeper.EXPECT().GetResourceOwnerAndIdFromGRN(gomock.Any(), gomock.Any()).Return(op, resourceIds[0], nil).AnyTimes() storageKeeper.EXPECT().NormalizePrincipal(gomock.Any(), gomock.Any()).Return().AnyTimes() storageKeeper.EXPECT().ValidatePrincipal(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()