Remove hard-coded record types #132

Merged
ashwin merged 17 commits from deep-stack/laconicd-deprecated:ng-rm-record-types into main 2024-01-15 04:20:39 +00:00
3 changed files with 1052 additions and 385 deletions
Showing only changes of commit 8d7e26515b - Show all commits

View File

@ -67,17 +67,25 @@ message QueryParamsResponse {
// QueryListRecordsRequest is request type for registry records list // QueryListRecordsRequest is request type for registry records list
message QueryListRecordsRequest { message QueryListRecordsRequest {
message ReferenceInput { message LinkInput {
string id = 1; string id = 1;
} }
message ArrayInput {
repeated ValueInput values = 1;
}
message MapInput {
map<string, ValueInput> values = 1;
}
message ValueInput { message ValueInput {
string type = 1; oneof value {
string string = 2; string string = 1;
int64 int = 3; int64 int = 2;
double float = 4; double float = 3;
bool boolean = 5; bool boolean = 4;
ReferenceInput reference = 6; string link = 5;
repeated ValueInput values = 7; ArrayInput array = 6;
MapInput map = 7;
}
} }
message KeyValueInput { message KeyValueInput {
string key = 1; string key = 1;

View File

@ -179,22 +179,26 @@ func (k Keeper) RecordsFromAttributes(ctx sdk.Context, attributes []*types.Query
} }
func GetAttributeValue(input *types.QueryListRecordsRequest_ValueInput) interface{} { func GetAttributeValue(input *types.QueryListRecordsRequest_ValueInput) interface{} {
if input.Type == "int" { switch value := input.GetValue().(type) {
return input.GetInt() case *types.QueryListRecordsRequest_ValueInput_String_:
} return value.String_
if input.Type == "float" { case *types.QueryListRecordsRequest_ValueInput_Int:
return input.GetFloat() return value.Int
} case *types.QueryListRecordsRequest_ValueInput_Float:
if input.Type == "string" { return value.Float
return input.GetString_() case *types.QueryListRecordsRequest_ValueInput_Boolean:
} return value.Boolean
if input.Type == "boolean" { case *types.QueryListRecordsRequest_ValueInput_Link:
return input.GetBoolean() return value.Link
} case *types.QueryListRecordsRequest_ValueInput_Array:
if input.Type == "reference" { return value.Array
return input.GetReference().GetId() case *types.QueryListRecordsRequest_ValueInput_Map:
} return value.Map
case nil:
return nil return nil
default:
return fmt.Errorf("Value has unepxpected type %T", value)
}
} }
func getIntersection(a []string, b []string) []string { func getIntersection(a []string, b []string) []string {

File diff suppressed because it is too large Load Diff