if instead of switch
Some checks failed
Build / cleanup-runs (pull_request) Failing after 2s
Build / build (pull_request) Successful in 39s
Deploy Contract / cleanup-runs (pull_request) Failing after 5s
Dependency Review / dependency-review (pull_request) Successful in 1m24s
CodeQL / Analyze (go) (pull_request) Successful in 1m45s
Pull Request Labeler / triage (pull_request) Successful in 19s
Deploy Contract / deploy (pull_request) Failing after 1m2s
Lint / Run flake8 on python integration tests (pull_request) Failing after 23s
Run Gosec / Gosec (pull_request) Successful in 27s
Tests / cleanup-runs (pull_request) Failing after 2s
Lint / Run golangci-lint (pull_request) Successful in 36s
Semgrep / Scan (pull_request) Failing after 16s
Tests / test-importer (pull_request) Successful in 1m14s
Tests / test-unit-cover (pull_request) Successful in 1m18s
Tests / test-rpc (pull_request) Successful in 1m15s
Tests / sdk_tests (pull_request) Failing after 2m24s

This commit is contained in:
Thomas E Lackey 2023-12-18 16:37:45 -06:00
parent 61169a43c0
commit 911f4ec252

View File

@ -351,25 +351,19 @@ func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) erro
// #nosec G705 // #nosec G705
for key := range record.Attributes { for key := range record.Attributes {
attr := record.Attributes[key] attr := record.Attributes[key]
rt := reflect.TypeOf(attr) if reflect.Slice == reflect.TypeOf(attr).Kind() {
switch rt.Kind() { av := attr.([]interface{})
case reflect.Slice: for i := range av {
{ indexKey := GetAttributesIndexKey(key, av[i])
av := attr.([]interface{})
for i := range av {
indexKey := GetAttributesIndexKey(key, av[i])
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err
}
}
}
default:
{
indexKey := GetAttributesIndexKey(key, attr)
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil { if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err return err
} }
} }
} else {
indexKey := GetAttributesIndexKey(key, attr)
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
return err
}
} }
} }
} }