Skip to content

Commit

Permalink
HexString PlutusType has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
MIxAxIM committed Dec 10, 2023
1 parent 2a14273 commit b5291fb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions plutusencoder/plutus.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,29 @@ func MarshalPlutus(v interface{}) (*PlutusData.PlutusData, error) {
overallContainer = append(overallContainer.(PlutusData.PlutusDefArray), pdsb)
}
}
case "HexString":
if values.Field(i).Kind() != reflect.String {
return nil, fmt.Errorf("error: HexString field is not string")
}
hexString, err := hex.DecodeString(values.Field(i).Interface().(string))
if err != nil {
return nil, fmt.Errorf("error: HexString field is not hex")
}
pdsb := PlutusData.PlutusData{
PlutusDataType: PlutusData.PlutusBytes,
Value: hexString,
TagNr: constr,
}
if isMap {
nameBytes := serialization.CustomBytes{Value: name}
overallContainer.(map[serialization.CustomBytes]PlutusData.PlutusData)[nameBytes] = pdsb
} else {
if isIndef {
overallContainer = append(overallContainer.(PlutusData.PlutusIndefArray), pdsb)
} else {
overallContainer = append(overallContainer.(PlutusData.PlutusDefArray), pdsb)
}
}
case "Address":
addpd, err := GetAddressPlutusData(values.Field(i).Interface().(Address.Address))
if err != nil {
Expand Down

0 comments on commit b5291fb

Please sign in to comment.