Additional registry module commands #6
@ -82,8 +82,19 @@ func (k Keeper) LookupNameRecord(ctx sdk.Context, crn string) (*registrytypes.Na
|
||||
}
|
||||
|
||||
// ListNameRecords - get all name records.
|
||||
func (k Keeper) ListNameRecords(ctx sdk.Context) []registrytypes.NameEntry {
|
||||
panic("unimplemented")
|
||||
func (k Keeper) ListNameRecords(ctx sdk.Context) ([]registrytypes.NameEntry, error) {
|
||||
var nameEntries []registrytypes.NameEntry
|
||||
|
||||
err := k.NameRecords.Walk(ctx, nil, func(key string, value registrytypes.NameRecord) (stop bool, err error) {
|
||||
nameEntries = append(nameEntries, registrytypes.NameEntry{
|
||||
Name: key,
|
||||
Entry: &value,
|
||||
})
|
||||
|
||||
return false, nil
|
||||
})
|
||||
|
||||
return nameEntries, err
|
||||
}
|
||||
|
||||
// SaveNameRecord - sets a name record.
|
||||
|
@ -100,7 +100,12 @@ func (qs queryServer) GetRegistryModuleBalance(c context.Context,
|
||||
|
||||
func (qs queryServer) NameRecords(c context.Context, _ *registrytypes.QueryNameRecordsRequest) (*registrytypes.QueryNameRecordsResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
nameRecords := qs.k.ListNameRecords(ctx)
|
||||
|
||||
nameRecords, err := qs.k.ListNameRecords(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ®istrytypes.QueryNameRecordsResponse{Names: nameRecords}, nil
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,12 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
|
||||
{ProtoField: "name"},
|
||||
},
|
||||
},
|
||||
{
|
||||
RpcMethod: "NameRecords",
|
||||
Use: "names",
|
||||
Short: "List name records",
|
||||
PositionalArgs: []*autocliv1.PositionalArgDescriptor{},
|
||||
},
|
||||
{
|
||||
RpcMethod: "LookupCrn",
|
||||
Use: "lookup [crn]",
|
||||
|
Loading…
Reference in New Issue
Block a user