forked from cerc-io/laconicd-deprecated
use sum type in protobuf query
This commit is contained in:
parent
4adce81981
commit
16d9291bc2
@ -67,17 +67,25 @@ message QueryParamsResponse {
|
||||
|
||||
// QueryListRecordsRequest is request type for registry records list
|
||||
message QueryListRecordsRequest {
|
||||
message ReferenceInput {
|
||||
message LinkInput {
|
||||
string id = 1;
|
||||
}
|
||||
message ArrayInput {
|
||||
repeated ValueInput values = 1;
|
||||
}
|
||||
message MapInput {
|
||||
map<string, ValueInput> values = 1;
|
||||
}
|
||||
message ValueInput {
|
||||
string type = 1;
|
||||
string string = 2;
|
||||
int64 int = 3;
|
||||
double float = 4;
|
||||
bool boolean = 5;
|
||||
ReferenceInput reference = 6;
|
||||
repeated ValueInput values = 7;
|
||||
oneof value {
|
||||
string string = 1;
|
||||
int64 int = 2;
|
||||
double float = 3;
|
||||
bool boolean = 4;
|
||||
string link = 5;
|
||||
ArrayInput array = 6;
|
||||
MapInput map = 7;
|
||||
}
|
||||
}
|
||||
message KeyValueInput {
|
||||
string key = 1;
|
||||
|
@ -179,22 +179,26 @@ func (k Keeper) RecordsFromAttributes(ctx sdk.Context, attributes []*types.Query
|
||||
}
|
||||
|
||||
func GetAttributeValue(input *types.QueryListRecordsRequest_ValueInput) interface{} {
|
||||
if input.Type == "int" {
|
||||
return input.GetInt()
|
||||
}
|
||||
if input.Type == "float" {
|
||||
return input.GetFloat()
|
||||
}
|
||||
if input.Type == "string" {
|
||||
return input.GetString_()
|
||||
}
|
||||
if input.Type == "boolean" {
|
||||
return input.GetBoolean()
|
||||
}
|
||||
if input.Type == "reference" {
|
||||
return input.GetReference().GetId()
|
||||
}
|
||||
switch value := input.GetValue().(type) {
|
||||
case *types.QueryListRecordsRequest_ValueInput_String_:
|
||||
return value.String_
|
||||
case *types.QueryListRecordsRequest_ValueInput_Int:
|
||||
return value.Int
|
||||
case *types.QueryListRecordsRequest_ValueInput_Float:
|
||||
return value.Float
|
||||
case *types.QueryListRecordsRequest_ValueInput_Boolean:
|
||||
return value.Boolean
|
||||
case *types.QueryListRecordsRequest_ValueInput_Link:
|
||||
return value.Link
|
||||
case *types.QueryListRecordsRequest_ValueInput_Array:
|
||||
return value.Array
|
||||
case *types.QueryListRecordsRequest_ValueInput_Map:
|
||||
return value.Map
|
||||
case nil:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("Value has unepxpected type %T", value)
|
||||
}
|
||||
}
|
||||
|
||||
func getIntersection(a []string, b []string) []string {
|
||||
|
1375
x/registry/types/query.pb.go
generated
1375
x/registry/types/query.pb.go
generated
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user