From fb7354b44c6bcc2623a3bcd99dd41e5d5551d545 Mon Sep 17 00:00:00 2001 From: Roman Serikov Date: Wed, 3 Mar 2021 14:43:33 +0300 Subject: [PATCH] Fix jsonschema current int and address values from storage --- internal/jsonschema/maker.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/jsonschema/maker.go b/internal/jsonschema/maker.go index a9c2b1906..b87330e5f 100644 --- a/internal/jsonschema/maker.go +++ b/internal/jsonschema/maker.go @@ -132,10 +132,22 @@ func (model DefaultModel) fill(data gjson.Result, metadata meta.Metadata, node * case consts.INT, consts.NAT, consts.MUTEZ: jsonPath := getGJSONPath(path, binPath, indices...) i := getDataByPath(jsonPath, consts.INT, data) - model[path] = i.Int() - case consts.STRING, consts.KEY, consts.KEYHASH, consts.CONTRACT, consts.ADDRESS, consts.SIGNATURE: + model[path] = i.Value() + case consts.ADDRESS: jsonPath := getGJSONPath(path, binPath, indices...) + str := getDataByPath(jsonPath, consts.STRING, data) + if !str.Exists() { + str = getDataByPath(jsonPath, consts.BYTES, data) + } + address, err := unpack.Address(str.String()) + if err != nil { + model[path] = str.Value() + } else { + model[path] = address + } + case consts.STRING, consts.KEY, consts.KEYHASH, consts.CONTRACT, consts.SIGNATURE: + jsonPath := getGJSONPath(path, binPath, indices...) str := getDataByPath(jsonPath, consts.STRING, data) s := str.String() if !str.Exists() {