Skip to content

Commit

Permalink
update to encode dynamic arrays correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrell-code committed Jun 15, 2022
1 parent feb3f6a commit d005bf5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions runtime/common/src/precompile/incentives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
cost: gas_cost,
output: Output::default().encode_u128(value),
output: Output::encode_uint(value),
logs: Default::default(),
})
}
Expand All @@ -119,7 +119,7 @@ where
Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
cost: gas_cost,
output: Output::default().encode_u128(value.into_inner()),
output: Output::encode_uint(value.into_inner()),
logs: Default::default(),
})
}
Expand Down Expand Up @@ -211,7 +211,7 @@ where
Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
cost: gas_cost,
output: Output::default().encode_u128(value.into_inner()),
output: Output::encode_uint(value.into_inner()),
logs: Default::default(),
})
}
Expand All @@ -237,7 +237,7 @@ where
Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
cost: gas_cost,
output: Output::default().encode_u128_array(value),
output: Output::encode_uint_array(value),
logs: Default::default(),
})
}
Expand Down Expand Up @@ -677,7 +677,13 @@ mod tests {
"};

// encoded array of [1000, 500]
// offset
// array_len
// value_1
// value_2
let expected_output = hex! {"
00000000000000000000000000000000 00000000000000000000000000000020
00000000000000000000000000000000 00000000000000000000000000000002
00000000000000000000000000000000 000000000000000000000000000003e8
00000000000000000000000000000000 000000000000000000000000000001f4
"};
Expand Down

0 comments on commit d005bf5

Please sign in to comment.