Skip to content

Commit

Permalink
fix(API): gas limit conversion error (#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Aug 22, 2023
1 parent 21785f7 commit 306e327
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/api/src/jsonrpc/web3_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};

use protocol::codec::ProtocolCodec;
use protocol::types::{
AccessList, Block, Bloom, Bytes, Hash, Header, Hex, Public, Receipt, SignedTransaction, H160,
H256, H64, MAX_PRIORITY_FEE_PER_GAS, U256, U64,
AccessList, Block, Bloom, Bytes, Hash, Header, Hex, Public, Receipt, SignedTransaction,
UnsignedTransaction, H160, H256, H64, MAX_PRIORITY_FEE_PER_GAS, U256, U64,
};

pub const EMPTY_UNCLE_HASH: H256 = H256([
Expand Down Expand Up @@ -97,13 +97,19 @@ impl From<SignedTransaction> for Web3Transaction {
)
};

let gas_limit = match stx.transaction.unsigned {
UnsignedTransaction::Legacy(ref inner) => inner.gas_limit,
UnsignedTransaction::Eip1559(ref inner) => inner.gas_limit,
UnsignedTransaction::Eip2930(ref inner) => inner.gas_limit,
};

Web3Transaction {
type_: Some(stx.type_().into()),
block_number: None,
block_hash: None,
raw: Hex::encode(stx.transaction.encode().unwrap()),
public_key: stx.public,
gas: U256::zero(),
gas: gas_limit,
gas_price: stx.transaction.unsigned.gas_price(),
max_fee_per_gas: if is_eip1559 {
Some(U256::from(MAX_PRIORITY_FEE_PER_GAS))
Expand Down

0 comments on commit 306e327

Please sign in to comment.