Skip to content

Commit

Permalink
Merge pull request #11 from Andamio-Platform/master
Browse files Browse the repository at this point in the history
HexString PlutusType has been added
  • Loading branch information
Salvionied authored Dec 14, 2023
2 parents 437ff6d + fbd2ce0 commit f193fe0
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 f193fe0

Please sign in to comment.