diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2022-02-26 20:57:37 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2022-02-26 20:57:37 +0100 |
| commit | 2af023138b4182c60563903a542cca39c6ecf28c (patch) | |
| tree | c31ba906e4ab47b0eda611794ef5b1cb12f6f8a4 | |
| parent | bcdb96ba0bdba139670c74b0e5eb0964f9a1c72a (diff) | |
Fix name of transaction gas paramter
| -rw-r--r-- | src/transaction.rs | 8 | ||||
| -rw-r--r-- | src/transaction/eip1559.rs | 13 | ||||
| -rw-r--r-- | src/transaction/eip2930.rs | 13 | ||||
| -rw-r--r-- | src/transaction/legacy.rs | 14 |
4 files changed, 23 insertions, 25 deletions
diff --git a/src/transaction.rs b/src/transaction.rs index cab34bc..cbc0e4f 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -87,7 +87,7 @@ mod tests { sign_encode(json!({ "nonce": 0, "gasPrice": 0, - "gasLimit": 21000, + "gas": 21000, "to": "0x0000000000000000000000000000000000000000", "value": 0, "data": "0x", @@ -104,7 +104,7 @@ mod tests { "chainId": 1, "nonce": 0, "gasPrice": 0, - "gasLimit": 21000, + "gas": 21000, "to": "0x0000000000000000000000000000000000000000", "value": 0, "data": "0x", @@ -121,7 +121,7 @@ mod tests { "chainId": 1, "nonce": 0, "gasPrice": 0, - "gasLimit": 21000, + "gas": 21000, "to": "0x0000000000000000000000000000000000000000", "value": 0, "data": "0x", @@ -140,7 +140,7 @@ mod tests { "nonce": 0, "maxPriorityFeePerGas": 0, "maxFeePerGas": 0, - "gasLimit": 21000, + "gas": 21000, "to": "0x0000000000000000000000000000000000000000", "value": 0, "data": "0x", diff --git a/src/transaction/eip1559.rs b/src/transaction/eip1559.rs index d8fa713..c6acf8b 100644 --- a/src/transaction/eip1559.rs +++ b/src/transaction/eip1559.rs @@ -27,9 +27,8 @@ pub struct Eip1559Transaction { #[serde(with = "serialization::u256")] pub max_fee_per_gas: U256, /// The gas limit for the transaction. - #[serde(rename = "gasLimit")] #[serde(with = "serialization::u256")] - pub gas_limit: U256, + pub gas: U256, /// The target address for the transaction. This can also be `None` to /// indicate a contract creation transaction. pub to: Option<Address>, @@ -53,7 +52,7 @@ impl Eip1559Transaction { rlp::uint(self.nonce), rlp::uint(self.max_priority_fee_per_gas), rlp::uint(self.max_fee_per_gas), - rlp::uint(self.gas_limit), + rlp::uint(self.gas), self.to .map_or_else(|| rlp::bytes(b""), |to| rlp::bytes(&*to)), rlp::uint(self.value), @@ -91,7 +90,7 @@ mod tests { "nonce": 42, "maxPriorityFeePerGas": 13.37e9, "maxFeePerGas": 42e9, - "gasLimit": 21000, + "gas": 21000, "value": "13370000000000000000", "data": "0x", }); @@ -102,7 +101,7 @@ mod tests { nonce: 42.as_u256(), max_priority_fee_per_gas: 13.37e9.as_u256(), max_fee_per_gas: 42e9.as_u256(), - gas_limit: 21_000.as_u256(), + gas: 21_000.as_u256(), to: None, value: 13.37e18.as_u256(), data: vec![], @@ -134,7 +133,7 @@ mod tests { nonce: 66.as_u256(), max_priority_fee_per_gas: 28e9.as_u256(), max_fee_per_gas: 42e9.as_u256(), - gas_limit: 30_000.as_u256(), + gas: 30_000.as_u256(), to: Some(Address(hex!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"))), value: 13.37e18.as_u256(), data: vec![], @@ -153,7 +152,7 @@ mod tests { nonce: 777.as_u256(), max_priority_fee_per_gas: 28e9.as_u256(), max_fee_per_gas: 42e9.as_u256(), - gas_limit: 100_000.as_u256(), + gas: 100_000.as_u256(), to: None, value: 0.as_u256(), data: hex!( diff --git a/src/transaction/eip2930.rs b/src/transaction/eip2930.rs index 17ba2a1..9de2d2c 100644 --- a/src/transaction/eip2930.rs +++ b/src/transaction/eip2930.rs @@ -24,9 +24,8 @@ pub struct Eip2930Transaction { #[serde(with = "serialization::u256")] pub gas_price: U256, /// The gas limit for the transaction. - #[serde(rename = "gasLimit")] #[serde(with = "serialization::u256")] - pub gas_limit: U256, + pub gas: U256, /// The target address for the transaction. This can also be `None` to /// indicate a contract creation transaction. pub to: Option<Address>, @@ -48,7 +47,7 @@ impl Eip2930Transaction { rlp::uint(self.chain_id), rlp::uint(self.nonce), rlp::uint(self.gas_price), - rlp::uint(self.gas_limit), + rlp::uint(self.gas), self.to .map_or_else(|| rlp::bytes(b""), |to| rlp::bytes(&*to)), rlp::uint(self.value), @@ -85,7 +84,7 @@ mod tests { "chainId": "0xff", "nonce": 42, "gasPrice": 13.37e9, - "gasLimit": 21000, + "gas": 21000, "value": "13370000000000000000", "data": "0x", "accessList": [], @@ -96,7 +95,7 @@ mod tests { chain_id: 255.as_u256(), nonce: 42.as_u256(), gas_price: 13.37e9.as_u256(), - gas_limit: 21_000.as_u256(), + gas: 21_000.as_u256(), to: None, value: 13.37e18.as_u256(), data: vec![], @@ -121,7 +120,7 @@ mod tests { chain_id: 1.as_u256(), nonce: 66.as_u256(), gas_price: 42e9.as_u256(), - gas_limit: 30_000.as_u256(), + gas: 30_000.as_u256(), to: Some(Address(hex!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"))), value: 13.37e18.as_u256(), data: vec![], @@ -139,7 +138,7 @@ mod tests { chain_id: 1.as_u256(), nonce: 777.as_u256(), gas_price: 42e9.as_u256(), - gas_limit: 100_000.as_u256(), + gas: 100_000.as_u256(), to: None, value: 0.as_u256(), data: hex!( diff --git a/src/transaction/legacy.rs b/src/transaction/legacy.rs index 71eb1d6..6680c74 100644 --- a/src/transaction/legacy.rs +++ b/src/transaction/legacy.rs @@ -18,8 +18,8 @@ pub struct LegacyTransaction { #[serde(rename = "gasPrice", with = "serialization::u256")] pub gas_price: U256, /// The gas limit for the transaction. - #[serde(rename = "gasLimit", with = "serialization::u256")] - pub gas_limit: U256, + #[serde(with = "serialization::u256")] + pub gas: U256, /// The target address for the transaction. This can also be `None` to /// indicate a contract creation transaction. pub to: Option<Address>, @@ -40,7 +40,7 @@ impl LegacyTransaction { let fields = [ rlp::uint(self.nonce), rlp::uint(self.gas_price), - rlp::uint(self.gas_limit), + rlp::uint(self.gas), self.to .map_or_else(|| rlp::bytes(b""), |to| rlp::bytes(&*to)), rlp::uint(self.value), @@ -76,7 +76,7 @@ mod tests { "chainId": "0xff", "nonce": 42, "gasPrice": 13.37e9, - "gasLimit": 21000, + "gas": 21000, "value": "13370000000000000000", "data": "0x", }); @@ -86,7 +86,7 @@ mod tests { chain_id: Some(255.as_u256()), nonce: 42.as_u256(), gas_price: 13.37e9.as_u256(), - gas_limit: 21_000.as_u256(), + gas: 21_000.as_u256(), to: None, value: 13.37e18.as_u256(), data: vec![], @@ -110,7 +110,7 @@ mod tests { chain_id: Some(1.as_u256()), nonce: 66.as_u256(), gas_price: 42e9.as_u256(), - gas_limit: 30_000.as_u256(), + gas: 30_000.as_u256(), to: Some(Address(hex!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"))), value: 13.37e18.as_u256(), data: vec![], @@ -127,7 +127,7 @@ mod tests { chain_id: Some(1.as_u256()), nonce: 777.as_u256(), gas_price: 42e9.as_u256(), - gas_limit: 100_000.as_u256(), + gas: 100_000.as_u256(), to: None, value: 0.as_u256(), data: hex!( |
