diff --git a/x/registry/keeper/naming_keeper.go b/x/registry/keeper/naming_keeper.go index 51e8ce7a..1f2e032c 100644 --- a/x/registry/keeper/naming_keeper.go +++ b/x/registry/keeper/naming_keeper.go @@ -40,8 +40,8 @@ func (k Keeper) GetNameAuthority(ctx sdk.Context, name string) (registrytypes.Na } // HasNameRecord - checks if a name record exists. -func (k Keeper) HasNameRecord(ctx sdk.Context, crn string) bool { - panic("unimplemented") +func (k Keeper) HasNameRecord(ctx sdk.Context, crn string) (bool, error) { + return k.NameRecords.Has(ctx, crn) } // GetNameRecord - gets a name record from the store. diff --git a/x/registry/keeper/query_server.go b/x/registry/keeper/query_server.go index ab6999d4..c242fafd 100644 --- a/x/registry/keeper/query_server.go +++ b/x/registry/keeper/query_server.go @@ -118,13 +118,20 @@ func (qs queryServer) Whois(c context.Context, request *registrytypes.QueryWhois func (qs queryServer) LookupCrn(c context.Context, req *registrytypes.QueryLookupCrnRequest) (*registrytypes.QueryLookupCrnResponse, error) { ctx := sdk.UnwrapSDKContext(c) crn := req.GetCrn() - if !qs.k.HasNameRecord(ctx, crn) { + + crnExists, err := qs.k.HasNameRecord(ctx, crn) + if err != nil { + return nil, err + } + if !crnExists { return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "CRN not found.") } + nameRecord, _ := qs.k.LookupNameRecord(ctx, crn) if nameRecord == nil { return nil, errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "name record not found.") } + return ®istrytypes.QueryLookupCrnResponse{Name: nameRecord}, nil } diff --git a/x/registry/module/autocli.go b/x/registry/module/autocli.go index 177ed29d..1419565f 100644 --- a/x/registry/module/autocli.go +++ b/x/registry/module/autocli.go @@ -51,6 +51,14 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { {ProtoField: "name"}, }, }, + { + RpcMethod: "LookupCrn", + Use: "lookup [crn]", + Short: "Get naming info for CRN", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "crn"}, + }, + }, { RpcMethod: "GetRegistryModuleBalance", Use: "balance",