Skip to content

Commit 642c9dd

Browse files
authored
fix: support bytestrings in map keys when encoding PlutusData (#105)
Signed-off-by: Aurora Gaffney <[email protected]>
1 parent 4abf91e commit 642c9dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

data/encode.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ func encodeByteString(bs *ByteString) (any, error) {
151151
// The Rust code shows special handling for byte strings longer than 64 bytes
152152
// using indefinite-length encoding, but the Go CBOR library handles this automatically
153153
// when using cbor.Marshal, so we can just return the bytes directly
154-
return bs.Inner, nil
154+
// NOTE: we use cbor.ByteString to allow it to be used as a map key
155+
return cbor.ByteString(string(bs.Inner)), nil
155156
}
156157

157158
// encodeList encodes a List to CBOR array format.

0 commit comments

Comments
 (0)