diff --git a/lib/ain-grpc/src/rpc/eth.rs b/lib/ain-grpc/src/rpc/eth.rs index a87b9f656b..51063b5b09 100644 --- a/lib/ain-grpc/src/rpc/eth.rs +++ b/lib/ain-grpc/src/rpc/eth.rs @@ -676,7 +676,7 @@ fn sign( let priv_key = get_eth_priv_key(key_id).unwrap(); let secret_key = SecretKey::parse(&priv_key).unwrap(); - let transaction = match message { + match message { TransactionMessage::Legacy(m) => { let signing_message = libsecp256k1::Message::parse_slice(&m.hash()[..]) .map_err(|_| Error::Custom(String::from("invalid signing message")))?; @@ -688,17 +688,18 @@ fn sign( let rs = signature.serialize(); let r = H256::from_slice(&rs[0..32]); let s = H256::from_slice(&rs[32..64]); - TransactionV2::Legacy(ethereum::LegacyTransaction { + + Ok(TransactionV2::Legacy(ethereum::LegacyTransaction { nonce: m.nonce, - gas_price: m.gas_price, - gas_limit: m.gas_limit, - action: m.action, value: m.value, input: m.input, signature: ethereum::TransactionSignature::new(v, r, s).ok_or_else(|| { Error::Custom(String::from("signer generated invalid signature")) })?, - }) + gas_price: m.gas_price, + gas_limit: m.gas_limit, + action: m.action, + })) } TransactionMessage::EIP2930(m) => { let signing_message = libsecp256k1::Message::parse_slice(&m.hash()[..]) @@ -707,7 +708,8 @@ fn sign( let rs = signature.serialize(); let r = H256::from_slice(&rs[0..32]); let s = H256::from_slice(&rs[32..64]); - TransactionV2::EIP2930(ethereum::EIP2930Transaction { + + Ok(TransactionV2::EIP2930(ethereum::EIP2930Transaction { chain_id: m.chain_id, nonce: m.nonce, gas_price: m.gas_price, @@ -719,7 +721,7 @@ fn sign( odd_y_parity: recid.serialize() != 0, r, s, - }) + })) } TransactionMessage::EIP1559(m) => { let signing_message = libsecp256k1::Message::parse_slice(&m.hash()[..]) @@ -728,7 +730,8 @@ fn sign( let rs = signature.serialize(); let r = H256::from_slice(&rs[0..32]); let s = H256::from_slice(&rs[32..64]); - TransactionV2::EIP1559(ethereum::EIP1559Transaction { + + Ok(TransactionV2::EIP1559(ethereum::EIP1559Transaction { chain_id: m.chain_id, nonce: m.nonce, max_priority_fee_per_gas: m.max_priority_fee_per_gas, @@ -741,9 +744,7 @@ fn sign( odd_y_parity: recid.serialize() != 0, r, s, - }) + })) } - }; - - Ok(transaction) + } }