X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=asset%2Fannotate.go;h=723e0bb9778214f184577e32e1dec7202d756807;hb=e278744e6d00511a70af4e03161151fb88d1f542;hp=514166eb9fb680e7cac5ecc274b70da2ad116aba;hpb=db158dcf09436b003defd333f1a665e7e051d820;p=bytom%2Fvapor.git diff --git a/asset/annotate.go b/asset/annotate.go index 514166eb..723e0bb9 100644 --- a/asset/annotate.go +++ b/asset/annotate.go @@ -5,22 +5,15 @@ import ( "github.com/vapor/blockchain/query" chainjson "github.com/vapor/encoding/json" - "github.com/vapor/protocol/vm/vmutil" ) -func isValidJSON(b []byte) bool { - var v interface{} - err := json.Unmarshal(b, &v) - return err == nil -} - //Annotated annotate the asset func Annotated(a *Asset) (*query.AnnotatedAsset, error) { jsonDefinition := json.RawMessage(`{}`) // a.RawDefinitionByte is the asset definition as it appears on the // blockchain, so it's untrusted and may not be valid json. - if isValidJSON(a.RawDefinitionByte) { + if chainjson.IsValidJSON(a.RawDefinitionByte) { jsonDefinition = json.RawMessage(a.RawDefinitionByte) } @@ -30,18 +23,7 @@ func Annotated(a *Asset) (*query.AnnotatedAsset, error) { VMVersion: a.VMVersion, RawDefinitionByte: a.RawDefinitionByte, Definition: &jsonDefinition, - IssuanceProgram: chainjson.HexBytes(a.IssuanceProgram), } - annotatedAsset.LimitHeight = vmutil.GetIssuanceProgramRestrictHeight(a.IssuanceProgram) - if a.Signer != nil { - annotatedAsset.AnnotatedSigner = query.AnnotatedSigner{ - Type: a.Signer.Type, - XPubs: a.Signer.XPubs, - Quorum: a.Signer.Quorum, - KeyIndex: a.Signer.KeyIndex, - DeriveRule: a.Signer.DeriveRule, - } - } return annotatedAsset, nil }