forked from TrueCloudLab/neoneo-go
smartcontract: use base64 encoding for verifiable items
See neo-project/neo#1199.
This commit is contained in:
parent
096f48caf0
commit
3e9bd0be72
1 changed files with 3 additions and 7 deletions
|
@ -32,7 +32,7 @@ type ParameterContext struct {
|
||||||
|
|
||||||
type paramContext struct {
|
type paramContext struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Hex string `json:"hex"`
|
Hex []byte `json:"hex"`
|
||||||
Items map[string]json.RawMessage `json:"items"`
|
Items map[string]json.RawMessage `json:"items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ func (c ParameterContext) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
pc := ¶mContext{
|
pc := ¶mContext{
|
||||||
Type: c.Type,
|
Type: c.Type,
|
||||||
Hex: hex.EncodeToString(verif),
|
Hex: verif,
|
||||||
Items: items,
|
Items: items,
|
||||||
}
|
}
|
||||||
return json.Marshal(pc)
|
return json.Marshal(pc)
|
||||||
|
@ -176,10 +176,6 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
|
||||||
if err := json.Unmarshal(data, pc); err != nil {
|
if err := json.Unmarshal(data, pc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
data, err := hex.DecodeString(pc.Hex)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var verif crypto.VerifiableDecodable
|
var verif crypto.VerifiableDecodable
|
||||||
switch pc.Type {
|
switch pc.Type {
|
||||||
|
@ -188,7 +184,7 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported type: %s", c.Type)
|
return fmt.Errorf("unsupported type: %s", c.Type)
|
||||||
}
|
}
|
||||||
err = verif.DecodeSignedPart(data)
|
err := verif.DecodeSignedPart(pc.Hex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue