diff --git a/proto/mycel/registry/top_level_domain.proto b/proto/mycel/registry/top_level_domain.proto index a03082d6..a5defcbc 100644 --- a/proto/mycel/registry/top_level_domain.proto +++ b/proto/mycel/registry/top_level_domain.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package mycel.registry; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "cosmos/base/v1beta1/coin.proto"; import "mycel/registry/subdomain_config.proto"; import "mycel/registry/role.proto"; @@ -10,7 +11,10 @@ option go_package = "github.com/mycel-domain/mycel/x/registry/types"; message TopLevelDomain { string name = 1; - int64 expirationDateInUnixNano = 2; + google.protobuf.Timestamp expirationDate = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; map metadata = 3; SubdomainConfig subdomainConfig = 4; uint64 subdomainCount = 5; diff --git a/x/registry/keeper/events.go b/x/registry/keeper/events.go index ce6adf87..7a53f53a 100644 --- a/x/registry/keeper/events.go +++ b/x/registry/keeper/events.go @@ -1,7 +1,6 @@ package keeper import ( - "time" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,12 +10,11 @@ import ( // Register top-level-domain event func EmitRegisterTopLevelDomainEvent(ctx sdk.Context, domain types.TopLevelDomain, fee types.TopLevelDomainFee) { - expirationDate := time.Unix(0, domain.ExpirationDateInUnixNano) ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeRegisterTopLevelDomain, sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventName, domain.Name), - sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventExpirationDate, expirationDate.String()), + sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventExpirationDate, domain.ExpirationDate.String()), sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventMaxSubdomainRegistrations, fmt.Sprintf("%d", domain.SubdomainConfig.MaxSubdomainRegistrations)), sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventTotalRegistrationFee, fee.TotalFee.String()), sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventBurnWeight, fee.BurnWeight), @@ -74,11 +72,10 @@ func EmitWithdrawRegistrationFeeEvent(ctx sdk.Context, msg types.MsgWithdrawRegi // Extend top-level-domain expiration date event func EmitExtendTopLevelDomainExpirationDateEvent(ctx sdk.Context, domain types.TopLevelDomain, fee types.TopLevelDomainFee) { - expirationDate := time.Unix(0, domain.ExpirationDateInUnixNano) ctx.EventManager().EmitEvent( sdk.NewEvent(types.EventTypeExtendTopLevelDomainExpirationDate, sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventDomainName, domain.Name), - sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventExpirationDate, expirationDate.String()), + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventExpirationDate, domain.ExpirationDate.String()), sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventTotalRegistrationFee, fee.TotalFee.String()), sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventBurnWeight, fee.BurnWeight), sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventRegistrationFeeToBurn, fee.FeeToBurn.String()), diff --git a/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go b/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go index 1cc7d733..a6079339 100644 --- a/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go +++ b/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "fmt" - "time" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -51,7 +50,6 @@ func (suite *KeeperTestSuite) TestExtendTopLevelDomain() { suite.Require().Nil(err) beforeDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, name) suite.Require().True(found) - beforeExpirationDate := time.Unix(0, beforeDomain.ExpirationDateInUnixNano) // Run test case function tc.fn() @@ -77,15 +75,12 @@ func (suite *KeeperTestSuite) TestExtendTopLevelDomain() { suite.Require().Nil(err) // Evaluate if domain is extended // Response - registerExpirationDate := time.Unix(0, registerRsp.TopLevelDomain.ExpirationDateInUnixNano) - extendExpirationDate := time.Unix(0, extendRsp.TopLevelDomain.ExpirationDateInUnixNano) - suite.Require().Equal(registerExpirationDate.AddDate(0, 0, int(tc.extensionPeriodInYear)*params.OneYearInDays), extendExpirationDate) + suite.Require().Equal(registerRsp.TopLevelDomain.ExpirationDate.AddDate(0, 0, int(tc.extensionPeriodInYear)*params.OneYearInDays), extendRsp.TopLevelDomain.ExpirationDate) // Store afterDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, name) suite.Require().True(found) - expAfterExpirationDate := beforeExpirationDate.AddDate(0, 0, int(tc.extensionPeriodInYear)*params.OneYearInDays) - afterExpirationDate := time.Unix(0, afterDomain.ExpirationDateInUnixNano) - suite.Require().Equal(expAfterExpirationDate, afterExpirationDate) + expAfterExpirationDate := beforeDomain.ExpirationDate.AddDate(0, 0, int(tc.extensionPeriodInYear)*params.OneYearInDays) + suite.Require().Equal(expAfterExpirationDate, afterDomain.ExpirationDate) // Evalute events events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeExtendTopLevelDomainExpirationDate) diff --git a/x/registry/keeper/msg_server_register_top_level_domain.go b/x/registry/keeper/msg_server_register_top_level_domain.go index 6a395f6b..a9c23ea9 100644 --- a/x/registry/keeper/msg_server_register_top_level_domain.go +++ b/x/registry/keeper/msg_server_register_top_level_domain.go @@ -25,12 +25,12 @@ func (k msgServer) RegisterTopLevelDomain(goCtx context.Context, msg *types.MsgR defaultRegistrationConfig := types.GetDefaultSubdomainConfig(3030) domain := types.TopLevelDomain{ - Name: msg.Name, - ExpirationDateInUnixNano: expirationDate.UnixNano(), - Metadata: nil, - SubdomainConfig: &defaultRegistrationConfig, - AccessControl: accessControl, - TotalWithdrawalAmount: sdk.NewCoins(), + Name: msg.Name, + ExpirationDate: expirationDate, + Metadata: nil, + SubdomainConfig: &defaultRegistrationConfig, + AccessControl: accessControl, + TotalWithdrawalAmount: sdk.NewCoins(), } fee, err := k.Keeper.RegisterTopLevelDomain(ctx, domain, msg.Creator, msg.RegistrationPeriodInYear) diff --git a/x/registry/keeper/top_level_domain.go b/x/registry/keeper/top_level_domain.go index 8fcf83d0..789c2eaf 100644 --- a/x/registry/keeper/top_level_domain.go +++ b/x/registry/keeper/top_level_domain.go @@ -85,8 +85,7 @@ func (k Keeper) GetValidTopLevelDomain(ctx sdk.Context, name string) (topLevelDo } // Check if domain is not expired - expirationDate := time.Unix(0, topLevelDomain.ExpirationDateInUnixNano) - if ctx.BlockTime().After(expirationDate) && topLevelDomain.ExpirationDateInUnixNano != 0 { + if ctx.BlockTime().After(topLevelDomain.ExpirationDate) && topLevelDomain.ExpirationDate != (time.Time{}) { return topLevelDomain, errorsmod.Wrapf(types.ErrDomainExpired, "%s", name) } @@ -219,8 +218,7 @@ func (k Keeper) ExtendTopLevelDomainExpirationDate(ctx sdk.Context, creator stri } // Update domain store - currentExpirationDate := time.Unix(0, domain.ExpirationDateInUnixNano) - domain.ExtendExpirationDate(currentExpirationDate, extensionPeriodInYear) + domain.ExtendExpirationDate(domain.ExpirationDate, extensionPeriodInYear) k.SetTopLevelDomain(ctx, *domain) // Emit event diff --git a/x/registry/keeper/top_level_domain_test.go b/x/registry/keeper/top_level_domain_test.go index 2c087136..c0d47dee 100644 --- a/x/registry/keeper/top_level_domain_test.go +++ b/x/registry/keeper/top_level_domain_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "fmt" + "time" "strconv" "testing" @@ -73,21 +74,21 @@ func (suite *KeeperTestSuite) TestGetValidTopLevelDomain() { { topLevelDomain: types.TopLevelDomain{ Name: "test", - ExpirationDateInUnixNano: suite.ctx.BlockTime().AddDate(0, 0, 20).UnixNano(), + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20), }, expErr: nil, }, { topLevelDomain: types.TopLevelDomain{ Name: "test", - ExpirationDateInUnixNano: 0, + ExpirationDate: time.Time{}, }, expErr: nil, }, { topLevelDomain: types.TopLevelDomain{ Name: "test", - ExpirationDateInUnixNano: suite.ctx.BlockTime().AddDate(0, 0, -20).UnixNano(), + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20), }, expErr: errorsmod.Wrapf(types.ErrDomainExpired, "test"), }, diff --git a/x/registry/types/top_level_domain.go b/x/registry/types/top_level_domain.go index ba5164c4..5798807c 100644 --- a/x/registry/types/top_level_domain.go +++ b/x/registry/types/top_level_domain.go @@ -53,10 +53,9 @@ func (topLevelDomain TopLevelDomain) IsEditable(sender string) (isEditable bool, return isEditable, err } -func (topLevelDomain *TopLevelDomain) ExtendExpirationDate(from time.Time, extensionPeriodInYear uint64) (expirationDateInUnixNano int64) { - newExpirationDate := from.AddDate(0, 0, params.OneYearInDays*int(extensionPeriodInYear)) - expirationDateInUnixNano = newExpirationDate.UnixNano() - topLevelDomain.ExpirationDateInUnixNano = expirationDateInUnixNano +func (topLevelDomain *TopLevelDomain) ExtendExpirationDate(from time.Time, extensionPeriodInYear uint64) (expirationDate time.Time) { + expirationDate = from.AddDate(0, 0, params.OneYearInDays*int(extensionPeriodInYear)) + topLevelDomain.ExpirationDate = expirationDate - return expirationDateInUnixNano + return expirationDate } diff --git a/x/registry/types/top_level_domain.pb.go b/x/registry/types/top_level_domain.pb.go index ba9fbd0e..7344dd9e 100644 --- a/x/registry/types/top_level_domain.pb.go +++ b/x/registry/types/top_level_domain.pb.go @@ -9,15 +9,19 @@ import ( types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -26,13 +30,13 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TopLevelDomain struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ExpirationDateInUnixNano int64 `protobuf:"varint,2,opt,name=expirationDateInUnixNano,proto3" json:"expirationDateInUnixNano,omitempty"` - Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SubdomainConfig *SubdomainConfig `protobuf:"bytes,4,opt,name=subdomainConfig,proto3" json:"subdomainConfig,omitempty"` - SubdomainCount uint64 `protobuf:"varint,5,opt,name=subdomainCount,proto3" json:"subdomainCount,omitempty"` - AccessControl map[string]DomainRole `protobuf:"bytes,6,rep,name=accessControl,proto3" json:"accessControl,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=mycel.registry.DomainRole"` - TotalWithdrawalAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=totalWithdrawalAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"totalWithdrawalAmount"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + ExpirationDate time.Time `protobuf:"bytes,2,opt,name=expirationDate,proto3,stdtime" json:"expirationDate"` + Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SubdomainConfig *SubdomainConfig `protobuf:"bytes,4,opt,name=subdomainConfig,proto3" json:"subdomainConfig,omitempty"` + SubdomainCount uint64 `protobuf:"varint,5,opt,name=subdomainCount,proto3" json:"subdomainCount,omitempty"` + AccessControl map[string]DomainRole `protobuf:"bytes,6,rep,name=accessControl,proto3" json:"accessControl,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=mycel.registry.DomainRole"` + TotalWithdrawalAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=totalWithdrawalAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"totalWithdrawalAmount"` } func (m *TopLevelDomain) Reset() { *m = TopLevelDomain{} } @@ -75,11 +79,11 @@ func (m *TopLevelDomain) GetName() string { return "" } -func (m *TopLevelDomain) GetExpirationDateInUnixNano() int64 { +func (m *TopLevelDomain) GetExpirationDate() time.Time { if m != nil { - return m.ExpirationDateInUnixNano + return m.ExpirationDate } - return 0 + return time.Time{} } func (m *TopLevelDomain) GetMetadata() map[string]string { @@ -197,44 +201,46 @@ func init() { } var fileDescriptor_0136e389ac8054f7 = []byte{ - // 587 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0xf3, 0xd3, 0xaf, 0x99, 0x2a, 0xf9, 0x60, 0x54, 0x24, 0xd7, 0x0b, 0x27, 0xaa, 0x04, - 0x78, 0x41, 0xed, 0x26, 0x6c, 0x50, 0x59, 0x35, 0x29, 0x55, 0x2b, 0x01, 0x0b, 0x13, 0x14, 0x09, - 0x21, 0x45, 0x63, 0x67, 0xea, 0x58, 0xb5, 0x67, 0xac, 0xf1, 0x38, 0xc4, 0x4b, 0xb6, 0xac, 0xd8, - 0xf0, 0x12, 0x3c, 0x49, 0x97, 0x5d, 0xb2, 0xa2, 0x28, 0x79, 0x09, 0x96, 0xc8, 0x63, 0x37, 0xd8, - 0xa6, 0xfc, 0x2c, 0xba, 0xf2, 0xfc, 0x9c, 0x7b, 0xee, 0x3d, 0xf7, 0x5c, 0x0f, 0xb8, 0xef, 0xc7, - 0x36, 0xf6, 0x0c, 0x86, 0x1d, 0x37, 0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6, 0xe4, 0x50, 0x05, 0xc0, 0x8a, 0x18, 0x19, 0x63, 0xd7, 0x99, 0xf1, 0x4c, - 0x7b, 0xee, 0x04, 0xce, 0x40, 0xf3, 0x0c, 0xe3, 0x11, 0x1d, 0x44, 0x8c, 0xc8, 0x35, 0x31, 0x83, - 0x7f, 0xa8, 0xc4, 0x48, 0x2a, 0xf9, 0x70, 0xd5, 0x79, 0xf8, 0x8f, 0x95, 0x98, 0x3f, 0xc9, 0x61, - 0x00, 0x5a, 0x62, 0x33, 0x62, 0x18, 0x85, 0x11, 0x8b, 0xb3, 0x89, 0xbf, 0xcd, 0x6c, 0xc5, 0x04, - 0x83, 0x93, 0x8b, 0xa5, 0x2a, 0x5d, 0x2e, 0x55, 0xe9, 0xdb, 0x52, 0x95, 0x3e, 0xae, 0xd4, 0xca, - 0xe5, 0x4a, 0xad, 0x7c, 0x59, 0xa9, 0x95, 0x37, 0x7a, 0x8e, 0x51, 0xb8, 0xb8, 0x97, 0xfe, 0x2a, - 0xe9, 0xc6, 0x58, 0xe4, 0x5e, 0xbd, 0x84, 0xdd, 0xda, 0x10, 0x6f, 0xcc, 0xe3, 0x1f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xa0, 0xff, 0x47, 0xe6, 0x14, 0x05, 0x00, 0x00, + // 609 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x4f, 0xd4, 0x40, + 0x14, 0xde, 0xb2, 0x80, 0x30, 0x84, 0x55, 0x27, 0x98, 0x94, 0x1e, 0xba, 0x1b, 0x12, 0x75, 0x0f, + 0x32, 0x05, 0xbc, 0x18, 0x3d, 0xb1, 0x20, 0xc1, 0x04, 0x2f, 0x75, 0x13, 0x12, 0x63, 0x42, 0xa6, + 0xdd, 0x47, 0xb7, 0xa1, 0xed, 0x34, 0x33, 0x53, 0xa4, 0x47, 0xaf, 0x9e, 0xf8, 0x17, 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3, 0x50, 0x1c, 0xf1, + 0x0a, 0x9a, 0x3b, 0xa5, 0x51, 0xa6, 0x13, 0xb0, 0xe8, 0xea, 0xe2, 0xe5, 0xcc, 0x0b, 0xc3, 0xfa, + 0x80, 0xf0, 0x9f, 0x2e, 0x6f, 0x61, 0xd8, 0xa8, 0x32, 0x74, 0xb6, 0xac, 0xe6, 0xe6, 0xf4, 0xc6, + 0x5c, 0x16, 0x41, 0x85, 0x7d, 0xed, 0xe7, 0x0c, 0x7a, 0x58, 0xdf, 0xe9, 0x1e, 0x00, 0x0e, 0xd0, + 0x82, 0x72, 0xb2, 0x07, 0x45, 0x60, 0xef, 0x7c, 0x4d, 0x53, 0x72, 0x6c, 0x23, 0xe4, 0x65, 0x3c, + 0x39, 0x84, 0x30, 0x18, 0xcb, 0xd2, 0x7b, 0xe5, 0x06, 0x8f, 0xd1, 0xe2, 0x31, 0xc0, 0x90, 0x0d, + 0x32, 0x9e, 0x98, 0x6d, 0x95, 0xc1, 0xbf, 0x28, 0x71, 0x0a, 0x25, 0x9f, 0xaf, 0xba, 0x4f, 0xff, + 0x53, 0x89, 0xfb, 0x9b, 0x1c, 0xa7, 0x68, 0x59, 0x15, 0x43, 0x0e, 0x54, 0x64, 0x3c, 0x2f, 0x13, + 0x7f, 0x97, 0xd3, 0xea, 0x03, 0x06, 0xfb, 0x17, 0xd7, 0xb6, 0x71, 0x79, 0x6d, 0x1b, 0x3f, 0xae, + 0x6d, 0xe3, 0xfc, 0xc6, 0x6e, 0x5d, 0xde, 0xd8, 0xad, 0x6f, 0x37, 0x76, 0xeb, 0x3d, 0xa9, 0x30, + 0xaa, 0x7f, 0x71, 0x5d, 0xbf, 0x2a, 0xba, 0x70, 0xce, 0x2a, 0x1f, 0xca, 0x82, 0xdd, 0x9b, 0x57, + 0xdf, 0x89, 0xe7, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x71, 0x7d, 0x7a, 0x07, 0x47, 0x05, 0x00, + 0x00, } func (m *TopLevelDomain) Marshal() (dAtA []byte, err error) { @@ -324,11 +330,14 @@ func (m *TopLevelDomain) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if m.ExpirationDateInUnixNano != 0 { - i = encodeVarintTopLevelDomain(dAtA, i, uint64(m.ExpirationDateInUnixNano)) - i-- - dAtA[i] = 0x10 + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationDate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate):]) + if err2 != nil { + return 0, err2 } + i -= n2 + i = encodeVarintTopLevelDomain(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x12 if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) @@ -424,9 +433,8 @@ func (m *TopLevelDomain) Size() (n int) { if l > 0 { n += 1 + l + sovTopLevelDomain(uint64(l)) } - if m.ExpirationDateInUnixNano != 0 { - n += 1 + sovTopLevelDomain(uint64(m.ExpirationDateInUnixNano)) - } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate) + n += 1 + l + sovTopLevelDomain(uint64(l)) if len(m.Metadata) > 0 { for k, v := range m.Metadata { _ = k @@ -550,10 +558,10 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExpirationDateInUnixNano", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationDate", wireType) } - m.ExpirationDateInUnixNano = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTopLevelDomain @@ -563,11 +571,25 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExpirationDateInUnixNano |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTopLevelDomain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationDate, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) diff --git a/x/registry/types/top_level_domain_test.go b/x/registry/types/top_level_domain_test.go index aa3a93d9..70eb1141 100644 --- a/x/registry/types/top_level_domain_test.go +++ b/x/registry/types/top_level_domain_test.go @@ -67,8 +67,8 @@ func TestExtendExpirationDate(t *testing.T) { domain := TopLevelDomain{ Name: "myc", } - extendExpirationDateInUnixNano := domain.ExtendExpirationDate(tc.from, tc.extensionPeriodInYear) - require.Equal(t, tc.expectedExpirationDate.UnixNano(), domain.ExpirationDateInUnixNano) - require.Equal(t, tc.expectedExpirationDate.UnixNano(), extendExpirationDateInUnixNano) + extendExpirationDate := domain.ExtendExpirationDate(tc.from, tc.extensionPeriodInYear) + require.Equal(t, tc.expectedExpirationDate, domain.ExpirationDate) + require.Equal(t, tc.expectedExpirationDate, extendExpirationDate) } }