Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
fix compilation err
Browse files Browse the repository at this point in the history
  • Loading branch information
taryune committed Nov 2, 2023
1 parent 2750a85 commit e0ad2b6
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 94 deletions.
10 changes: 5 additions & 5 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50700,7 +50700,7 @@ paths:
type: string
expirationDate:
type: string
format: int64
format: date-time
pagination:
type: object
properties:
Expand Down Expand Up @@ -50825,7 +50825,7 @@ paths:
type: string
expirationDate:
type: string
format: int64
format: date-time
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -81590,7 +81590,7 @@ definitions:
type: string
expirationDate:
type: string
format: int64
format: date-time
pagination:
type: object
properties:
Expand Down Expand Up @@ -81815,7 +81815,7 @@ definitions:
type: string
expirationDate:
type: string
format: int64
format: date-time
mycel.registry.QueryGetTopLevelDomainResponse:
type: object
properties:
Expand Down Expand Up @@ -81953,7 +81953,7 @@ definitions:
type: string
expirationDate:
type: string
format: int64
format: date-time
mycel.registry.SubdomainConfig:
type: object
properties:
Expand Down
6 changes: 5 additions & 1 deletion proto/mycel/registry/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package mycel.registry;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "mycel/registry/params.proto";
Expand Down Expand Up @@ -93,7 +94,10 @@ message QueryGetSecondLevelDomainRequest {
message SecondLevelDomainResponse {
string name = 1;
string parent = 2;
int64 expirationDate = 3;
google.protobuf.Timestamp expirationDate = 3 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
}

message QueryGetSecondLevelDomainResponse {
Expand Down
3 changes: 1 addition & 2 deletions x/registry/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/mycel-domain/mycel/x/registry/types"
"strconv"
)

// Register top-level-domain event
Expand All @@ -30,7 +29,7 @@ func EmitRegisterSecondLevelDomainEvent(ctx sdk.Context, domain types.SecondLeve
sdk.NewEvent(types.EventTypeRegisterSecondLevelDomain,
sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventName, domain.Name),
sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventParent, domain.Parent),
sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventExpirationDate, strconv.FormatInt(domain.ExpirationDate, 10)),
sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventExpirationDate, domain.ExpirationDate.String()),
sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventRegistrationFee, fee.String()),
),
)
Expand Down
3 changes: 2 additions & 1 deletion x/registry/keeper/msg_server_register_second_level_domain.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"time"
"context"

"github.com/mycel-domain/mycel/x/registry/types"
Expand All @@ -23,7 +24,7 @@ func (k msgServer) RegisterSecondLevelDomain(goCtx context.Context, msg *types.M
domain := types.SecondLevelDomain{
Name: msg.Name,
Owner: msg.Creator,
ExpirationDate: 0,
ExpirationDate: time.Time{},
Parent: msg.Parent,
Records: nil,
AccessControl: accessControl,
Expand Down
3 changes: 1 addition & 2 deletions x/registry/keeper/second_level_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ func (k Keeper) GetValidSecondLevelDomain(ctx sdk.Context, name string, parent s
}

// Check if second-level-domain is not expired
expirationDate := time.Unix(0, secondLevelDomain.ExpirationDate)
if ctx.BlockTime().After(expirationDate) && secondLevelDomain.ExpirationDate != 0 {
if ctx.BlockTime().After(secondLevelDomain.ExpirationDate) && secondLevelDomain.ExpirationDate != (time.Time{}){
return types.SecondLevelDomain{}, errorsmod.Wrapf(types.ErrSecondLevelDomainExpired, "%s", name)
}

Expand Down
7 changes: 4 additions & 3 deletions x/registry/keeper/second_level_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper_test

import (
"fmt"
"time"
"strconv"
"testing"

Expand Down Expand Up @@ -89,23 +90,23 @@ func (suite *KeeperTestSuite) TestGetValidSecondLevelDomain() {
secondLevelDomain: types.SecondLevelDomain{
Name: "test",
Parent: "cel",
ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20).UnixNano(),
ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20),
},
expErr: nil,
},
{
secondLevelDomain: types.SecondLevelDomain{
Name: "test",
Parent: "cel",
ExpirationDate: 0,
ExpirationDate: time.Time{},
},
expErr: nil,
},
{
secondLevelDomain: types.SecondLevelDomain{
Name: "test",
Parent: "test",
ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20).UnixNano(),
ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20),
},
expErr: errorsmod.Wrapf(types.ErrTopLevelDomainNotFound, "test"),
},
Expand Down
Loading

0 comments on commit e0ad2b6

Please sign in to comment.