Skip to content

Commit

Permalink
smartcontract: use base64 encoding for verifiable items
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov committed Mar 11, 2021
1 parent 096f48c commit 3e9bd0b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/smartcontract/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ParameterContext struct {

type paramContext struct {
Type string `json:"type"`
Hex string `json:"hex"`
Hex []byte `json:"hex"`
Items map[string]json.RawMessage `json:"items"`
}

Expand Down Expand Up @@ -164,7 +164,7 @@ func (c ParameterContext) MarshalJSON() ([]byte, error) {
}
pc := &paramContext{
Type: c.Type,
Hex: hex.EncodeToString(verif),
Hex: verif,
Items: items,
}
return json.Marshal(pc)
Expand All @@ -176,10 +176,6 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, pc); err != nil {
return err
}
data, err := hex.DecodeString(pc.Hex)
if err != nil {
return err
}

var verif crypto.VerifiableDecodable
switch pc.Type {
Expand All @@ -188,7 +184,7 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
default:
return fmt.Errorf("unsupported type: %s", c.Type)
}
err = verif.DecodeSignedPart(data)
err := verif.DecodeSignedPart(pc.Hex)
if err != nil {
return err
}
Expand Down

0 comments on commit 3e9bd0b

Please sign in to comment.