Skip to content

Commit

Permalink
fix left padding
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Feb 21, 2025
1 parent 75ff342 commit 1be4a73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vyper/builtins/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ def to_bytes_m(expr, arg, out_typ):
if isinstance(arg.typ, StringT):
val = val.encode("utf-8")

arg = shl(256 - out_typ.m_bits, int(val.hex(), 16))
# bytes_m types are left padded with zeros
val = int(val.hex(), 16) << 8 * (out_typ.m - arg.typ.length)
arg = shl(256 - out_typ.m_bits, val)

elif isinstance(arg.typ, BytesT):
bytes_val = LOAD(bytes_data_ptr(arg))
Expand Down

0 comments on commit 1be4a73

Please sign in to comment.