EIP-2930 RPC and TypedTransactionView support (#245)
* TypedTransactionView for EIP-2930 * Enable EIP-2930 in RPC calls * type field added to TypedTransactionView
This commit is contained in:
@@ -120,7 +120,7 @@ impl<C: miner::BlockChainClient + BlockChainClient, M: MinerService> Dispatcher
|
||||
};
|
||||
|
||||
Box::new(future::ok(FilledTransactionRequest {
|
||||
tx_type: request.tx_type,
|
||||
transaction_type: request.transaction_type,
|
||||
from,
|
||||
used_default_from: request.from.is_none(),
|
||||
to: request.to,
|
||||
|
||||
@@ -59,7 +59,7 @@ impl super::Accounts for Signer {
|
||||
value: filled.value,
|
||||
data: filled.data,
|
||||
};
|
||||
let t = match filled.tx_type {
|
||||
let t = match filled.transaction_type {
|
||||
TypedTxId::Legacy => TypedTransaction::Legacy(legacy_tx),
|
||||
TypedTxId::AccessList => {
|
||||
if filled.access_list.is_none() {
|
||||
|
||||
@@ -256,7 +256,7 @@ mod test {
|
||||
|
||||
fn request() -> ConfirmationPayload {
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Address::from(1),
|
||||
used_default_from: false,
|
||||
to: Some(Address::from(2)),
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn sign_call(request: CallRequest) -> Result<SignedTransaction, Error> {
|
||||
value: request.value.unwrap_or_default(),
|
||||
data: request.data.unwrap_or_default(),
|
||||
};
|
||||
let tx_typed = match request.tx_type {
|
||||
let tx_typed = match request.transaction_type {
|
||||
TypedTxId::Legacy => TypedTransaction::Legacy(tx_legacy),
|
||||
TypedTxId::AccessList => TypedTransaction::AccessList(AccessListTx::new(
|
||||
tx_legacy,
|
||||
|
||||
@@ -24,7 +24,7 @@ use v1::types::{Origin, TransactionCondition};
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash)]
|
||||
pub struct TransactionRequest {
|
||||
/// type of transaction.
|
||||
pub tx_type: TypedTxId,
|
||||
pub transaction_type: TypedTxId,
|
||||
/// Sender
|
||||
pub from: Option<Address>,
|
||||
/// Recipient
|
||||
@@ -49,7 +49,7 @@ pub struct TransactionRequest {
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash)]
|
||||
pub struct FilledTransactionRequest {
|
||||
/// type of transaction.
|
||||
pub tx_type: TypedTxId,
|
||||
pub transaction_type: TypedTxId,
|
||||
/// Sender
|
||||
pub from: Address,
|
||||
/// Indicates if the sender was filled by default value.
|
||||
@@ -75,7 +75,7 @@ pub struct FilledTransactionRequest {
|
||||
impl From<FilledTransactionRequest> for TransactionRequest {
|
||||
fn from(r: FilledTransactionRequest) -> Self {
|
||||
TransactionRequest {
|
||||
tx_type: r.tx_type,
|
||||
transaction_type: r.transaction_type,
|
||||
from: Some(r.from),
|
||||
to: r.to,
|
||||
gas_price: Some(r.gas_price),
|
||||
@@ -93,7 +93,7 @@ impl From<FilledTransactionRequest> for TransactionRequest {
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub struct CallRequest {
|
||||
/// type of transaction.
|
||||
pub tx_type: TypedTxId,
|
||||
pub transaction_type: TypedTxId,
|
||||
/// From
|
||||
pub from: Option<Address>,
|
||||
/// To
|
||||
|
||||
@@ -91,7 +91,7 @@ fn should_return_list_of_items_to_confirm() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Address::from(1),
|
||||
used_default_from: false,
|
||||
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
@@ -138,7 +138,7 @@ fn should_reject_transaction_from_queue_without_dispatching() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Address::from(1),
|
||||
used_default_from: false,
|
||||
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
@@ -176,7 +176,7 @@ fn should_not_remove_transaction_if_password_is_invalid() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Address::from(1),
|
||||
used_default_from: false,
|
||||
to: Some(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
@@ -242,7 +242,7 @@ fn should_confirm_transaction_and_dispatch() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: address,
|
||||
used_default_from: false,
|
||||
to: Some(recipient),
|
||||
@@ -307,7 +307,7 @@ fn should_alter_the_sender_and_nonce() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: 0.into(),
|
||||
used_default_from: false,
|
||||
to: Some(recipient),
|
||||
@@ -373,7 +373,7 @@ fn should_confirm_transaction_with_token() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: address,
|
||||
used_default_from: false,
|
||||
to: Some(recipient),
|
||||
@@ -441,7 +441,7 @@ fn should_confirm_transaction_with_rlp() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: address,
|
||||
used_default_from: false,
|
||||
to: Some(recipient),
|
||||
@@ -507,7 +507,7 @@ fn should_return_error_when_sender_does_not_match() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SendTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Address::default(),
|
||||
used_default_from: false,
|
||||
to: Some(recipient),
|
||||
@@ -574,7 +574,7 @@ fn should_confirm_sign_transaction_with_rlp() {
|
||||
.signer
|
||||
.add_request(
|
||||
ConfirmationPayload::SignTransaction(FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: address,
|
||||
used_default_from: false,
|
||||
to: Some(recipient),
|
||||
|
||||
@@ -25,7 +25,8 @@ use v1::{helpers::CallRequest as Request, types::Bytes};
|
||||
pub struct CallRequest {
|
||||
/// transaction type
|
||||
#[serde(default)]
|
||||
pub tx_type: TypedTxId,
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: TypedTxId,
|
||||
/// From
|
||||
pub from: Option<H160>,
|
||||
/// To
|
||||
@@ -47,7 +48,7 @@ pub struct CallRequest {
|
||||
impl Into<Request> for CallRequest {
|
||||
fn into(self) -> Request {
|
||||
Request {
|
||||
tx_type: self.tx_type,
|
||||
transaction_type: self.transaction_type,
|
||||
from: self.from.map(Into::into),
|
||||
to: self.to.map(Into::into),
|
||||
gas_price: self.gas_price.map(Into::into),
|
||||
@@ -84,7 +85,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
deserialized,
|
||||
CallRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from(1)),
|
||||
to: Some(H160::from(2)),
|
||||
gas_price: Some(U256::from(1)),
|
||||
@@ -110,7 +111,7 @@ mod tests {
|
||||
let deserialized: CallRequest = serde_json::from_str(s).unwrap();
|
||||
|
||||
assert_eq!(deserialized, CallRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from_str("b60e8dd61c5d32be8058bb8eb970870f07233155").unwrap()),
|
||||
to: Some(H160::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
gas_price: Some(U256::from_str("9184e72a000").unwrap()),
|
||||
@@ -130,7 +131,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
deserialized,
|
||||
CallRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from(1)),
|
||||
to: None,
|
||||
gas_price: None,
|
||||
|
||||
@@ -331,7 +331,7 @@ mod tests {
|
||||
id: 15.into(),
|
||||
payload: helpers::ConfirmationPayload::SendTransaction(
|
||||
helpers::FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: 0.into(),
|
||||
used_default_from: false,
|
||||
to: None,
|
||||
@@ -362,7 +362,7 @@ mod tests {
|
||||
id: 15.into(),
|
||||
payload: helpers::ConfirmationPayload::SignTransaction(
|
||||
helpers::FilledTransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: 0.into(),
|
||||
used_default_from: false,
|
||||
to: None,
|
||||
|
||||
@@ -26,7 +26,7 @@ use v1::types::Log;
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Receipt {
|
||||
/// Transaction Type
|
||||
#[serde(skip_serializing)]
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: TypedTxId,
|
||||
/// Transaction Hash
|
||||
pub transaction_hash: Option<H256>,
|
||||
|
||||
@@ -30,6 +30,9 @@ use v1::types::{Bytes, TransactionCondition};
|
||||
#[derive(Debug, Default, Clone, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Transaction {
|
||||
/// transaction type
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: u8,
|
||||
/// Hash
|
||||
pub hash: H256,
|
||||
/// Nonce
|
||||
@@ -70,11 +73,7 @@ pub struct Transaction {
|
||||
pub s: U256,
|
||||
/// Transaction activates at specified block.
|
||||
pub condition: Option<TransactionCondition>,
|
||||
/// transaction type
|
||||
#[serde(skip_serializing)]
|
||||
pub transaction_type: u8,
|
||||
/// optional access list
|
||||
#[serde(skip_serializing)]
|
||||
pub access_list: AccessList,
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ use std::fmt;
|
||||
pub struct TransactionRequest {
|
||||
/// type of transaction. If none we assume it is legacy
|
||||
#[serde(default)]
|
||||
#[serde(skip_serializing)]
|
||||
pub tx_type: TypedTxId,
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: TypedTxId,
|
||||
/// Sender
|
||||
pub from: Option<H160>,
|
||||
/// Recipient
|
||||
@@ -52,7 +52,6 @@ pub struct TransactionRequest {
|
||||
/// Delay until this block condition.
|
||||
pub condition: Option<TransactionCondition>,
|
||||
/// Access list
|
||||
#[serde(skip_serializing)]
|
||||
pub access_list: Option<AccessList>,
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ impl fmt::Display for TransactionRequest {
|
||||
impl From<helpers::TransactionRequest> for TransactionRequest {
|
||||
fn from(r: helpers::TransactionRequest) -> Self {
|
||||
TransactionRequest {
|
||||
tx_type: r.tx_type,
|
||||
transaction_type: r.transaction_type,
|
||||
from: r.from.map(Into::into),
|
||||
to: r.to.map(Into::into),
|
||||
gas_price: r.gas_price.map(Into::into),
|
||||
@@ -122,7 +121,7 @@ impl From<helpers::TransactionRequest> for TransactionRequest {
|
||||
impl From<helpers::FilledTransactionRequest> for TransactionRequest {
|
||||
fn from(r: helpers::FilledTransactionRequest) -> Self {
|
||||
TransactionRequest {
|
||||
tx_type: r.tx_type,
|
||||
transaction_type: r.transaction_type,
|
||||
from: Some(r.from),
|
||||
to: r.to,
|
||||
gas_price: Some(r.gas_price),
|
||||
@@ -139,7 +138,7 @@ impl From<helpers::FilledTransactionRequest> for TransactionRequest {
|
||||
impl Into<helpers::TransactionRequest> for TransactionRequest {
|
||||
fn into(self) -> helpers::TransactionRequest {
|
||||
helpers::TransactionRequest {
|
||||
tx_type: self.tx_type,
|
||||
transaction_type: self.transaction_type,
|
||||
from: self.from.map(Into::into),
|
||||
to: self.to.map(Into::into),
|
||||
gas_price: self.gas_price.map(Into::into),
|
||||
@@ -179,7 +178,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
deserialized,
|
||||
TransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from(1)),
|
||||
to: Some(H160::from(2)),
|
||||
gas_price: Some(U256::from(1)),
|
||||
@@ -206,7 +205,7 @@ mod tests {
|
||||
let deserialized: TransactionRequest = serde_json::from_str(s).unwrap();
|
||||
|
||||
assert_eq!(deserialized, TransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from_str("b60e8dd61c5d32be8058bb8eb970870f07233155").unwrap()),
|
||||
to: Some(H160::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
gas_price: Some(U256::from_str("9184e72a000").unwrap()),
|
||||
@@ -227,7 +226,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
deserialized,
|
||||
TransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from(1).into()),
|
||||
to: None,
|
||||
gas_price: None,
|
||||
@@ -256,7 +255,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
deserialized,
|
||||
TransactionRequest {
|
||||
tx_type: Default::default(),
|
||||
transaction_type: Default::default(),
|
||||
from: Some(H160::from_str("b5f7502a2807cb23615c7456055e1d65b2508625").unwrap()),
|
||||
to: Some(H160::from_str("895d32f2db7d01ebb50053f9e48aacf26584fe40").unwrap()),
|
||||
gas_price: Some(U256::from_str("0ba43b7400").unwrap()),
|
||||
|
||||
Reference in New Issue
Block a user