Skip to content

Commit

Permalink
fix value
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoAtwill committed Dec 13, 2024
1 parent ddbc2e0 commit b41e31a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fendermint/eth/api/src/conv/from_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod tests {

#[test]
fn test_legacy_transaction() {
let raw_tx = "f86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83";
let raw_tx = "f8ac821dac850df8475800830186a09465292eeadf1426cd2df1c4793a3d7519f253913b80b844a9059cbb000000000000000000000000cd50511c4e355f2bc3c084d854253cc17b2230bf00000000000000000000000000000000000000000000148a616ad7f95aa0000025a0a4f3a70a01cfb3969c4a12510ebccd7d08250a4d34181123bebae3f865392643a063116147193f2badc611fa20dfa1c339bca299f50e470353ee4f676bc236479d";
let raw_tx = hex::decode(raw_tx).unwrap();

let rlp = rlp::Rlp::new(raw_tx.as_ref());
Expand Down
8 changes: 2 additions & 6 deletions fendermint/vm/message/src/conv/from_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,13 @@ pub fn fvm_message_from_legacy(tx: &TransactionRequest) -> anyhow::Result<Messag
let params = RawBytes::serialize(BytesSer(&calldata))?;

let gas_price = tx.gas_price.unwrap_or_default();
let value = if let Some(v) = tx.value {
to_fvm_tokens(&v)
} else {
TokenAmount::from_atto(-1)
};

let msg = Message {
version: 0,
from,
to,
sequence: tx.nonce.unwrap_or_default().as_u64(),
value,
value: to_fvm_tokens(&tx.value.unwrap_or_default()),
method_num,
params,
gas_limit: tx
Expand Down
5 changes: 2 additions & 3 deletions fendermint/vm/message/src/conv/from_fvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ pub fn to_eth_legacy_request(

// NOTE: It's impossible to tell if the original Ethereum transaction sent None or Some(0).
// The ethers deployer sends None, so let's assume that's the useful behavour to match.
// TODO: review, if value is None, it's set to -1 for intermediate conversion
// TODO: or we just assume Some(0) will not occur in fendermint.
if !value.is_negative() {
// Luckily the RLP encoding at some point seems to resolve them to the same thing.
if !value.is_zero() {
tx.value = Some(to_eth_tokens(value)?);
}

Expand Down

0 comments on commit b41e31a

Please sign in to comment.