Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: make gasPrice optional (since Type 2 transactions) (#374)
Browse files Browse the repository at this point in the history
* fix: make gasPrice optional (since Type 2 transactions)

* chore: use new pkey for testnet txs to avoid nonce conflicts
  • Loading branch information
gakonst authored Aug 12, 2021
1 parent 4cae828 commit 99e9a68
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
11 changes: 5 additions & 6 deletions ethers-core/src/types/transaction/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ pub struct Transaction {
/// Transfered value
pub value: U256,

/// Gas Price
/// Gas Price, null for Type 2 transactions
#[serde(rename = "gasPrice")]
// TODO: Should this be deprecated?
// https://twitter.com/TimBeiko/status/1413536062429794304
// If yes, how will we handle pre-calculating the transaction's hash keccak256(rlp(tx)),
// given that it contains the gas price?
pub gas_price: U256,
pub gas_price: Option<U256>,

/// Gas amount
pub gas: U256,
Expand Down Expand Up @@ -123,6 +119,9 @@ pub struct Transaction {
/// Represents the maximum amount that a user is willing to pay for their tx (inclusive of baseFeePerGas and maxPriorityFeePerGas).
/// The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded” to the user.
pub max_fee_per_gas: Option<U256>,

#[serde(rename = "chainId", default, skip_serializing_if = "Option::is_none")]
pub chain_id: Option<U256>,
}

impl Transaction {
Expand Down
2 changes: 1 addition & 1 deletion ethers-middleware/tests/gas_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn using_gas_oracle() {
let tx_hash = provider.send_transaction(tx, None).await.unwrap();

let tx = provider.get_transaction(*tx_hash).await.unwrap().unwrap();
assert_eq!(tx.gas_price, expected_gas_price);
assert_eq!(tx.gas_price, Some(expected_gas_price));
}

#[tokio::test]
Expand Down
5 changes: 4 additions & 1 deletion ethers-middleware/tests/nonce_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ async fn nonce_manager() {
let mut tx_hashes = Vec::new();
for _ in 0..10 {
let tx = provider
.send_transaction(TransactionRequest::pay(address, 100u64), None)
.send_transaction(
Eip1559TransactionRequest::new().to(address).value(100u64),
None,
)
.await
.unwrap();
tx_hashes.push(*tx);
Expand Down
2 changes: 1 addition & 1 deletion ethers-providers/tests/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ mod eth_tests {
.unwrap();

let chain_id = provider.get_chainid().await.unwrap();
let wallet = "59c37cb6b16fa2de30675f034c8008f890f4b2696c729d6267946d29736d73e4"
let wallet = "87203087aed9246e0b2417e248752a1a0df4fdaf65085c11a2b48087ba036b41"
.parse::<LocalWallet>()
.unwrap()
.with_chain_id(chain_id.as_u64());
Expand Down

0 comments on commit 99e9a68

Please sign in to comment.