diff --git a/daemon/algod/api/server/v2/account.go b/daemon/algod/api/server/v2/account.go index 96385c191c..6ab51e549b 100644 --- a/daemon/algod/api/server/v2/account.go +++ b/daemon/algod/api/server/v2/account.go @@ -147,14 +147,18 @@ func convertTKVToGenerated(tkv *basics.TealKeyValue) *model.TealKeyValueStore { converted := make(model.TealKeyValueStore, 0, len(*tkv)) for k, v := range *tkv { - converted = append(converted, model.TealKeyValue{ + convertedKv := model.TealKeyValue{ Key: []byte(k), Value: model.TealValue{ Type: uint64(v.Type), Bytes: []byte(v.Bytes), Uint: v.Uint, }, - }) + } + if len(convertedKv.Value.Bytes) == 0 { + convertedKv.Value.Bytes = nil + } + converted = append(converted, convertedKv) } sort.Slice(converted, func(i, j int) bool { return bytes.Compare(converted[i].Key, converted[j].Key) < 0 diff --git a/daemon/algod/api/server/v2/account_test.go b/daemon/algod/api/server/v2/account_test.go index b3b049d2d4..32def1c34b 100644 --- a/daemon/algod/api/server/v2/account_test.go +++ b/daemon/algod/api/server/v2/account_test.go @@ -137,12 +137,12 @@ func TestAccount(t *testing.T) { makeTKV := func(k string, v interface{}) model.TealKeyValue { value := model.TealValue{} - switch v.(type) { + switch vKnown := v.(type) { case int: - value.Uint = uint64(v.(int)) + value.Uint = uint64(vKnown) value.Type = uint64(basics.TealUintType) case string: - value.Bytes = []byte(v.(string)) + value.Bytes = []byte(vKnown) value.Type = uint64(basics.TealBytesType) default: panic(fmt.Sprintf("Unknown teal type %v", t))