Skip to content

Commit c61c36a

Browse files
committed
runtime: Fix FixedBytes conversion to respect size parameter
1 parent e150b02 commit c61c36a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

runtime/wasm/src/to_from/external.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ impl ToAscObj<AscEnum<EthereumValueKind>> for abi::DynSolValue {
166166

167167
asc_new(heap, &n, gas)?.to_payload()
168168
}
169-
Self::FixedBytes(val, _) => {
170-
asc_new::<Uint8Array, _, _>(heap, val.as_slice(), gas)?.to_payload()
169+
Self::FixedBytes(val, size) => {
170+
// FixedBytes stores the value in a 32-byte word, but we only want the first `size` bytes
171+
asc_new::<Uint8Array, _, _>(heap, &val.as_slice()[..*size], gas)?.to_payload()
171172
}
172173
Self::Address(val) => {
173174
asc_new::<AscAddress, _, _>(heap, val.as_slice(), gas)?.to_payload()

0 commit comments

Comments
 (0)