Fix max-value calls and add "creates" field to getTransaction.

This commit is contained in:
Gav Wood
2016-05-30 22:27:28 +02:00
parent 79503e4f14
commit 8082fdb3ff
9 changed files with 26 additions and 14 deletions

View File

@@ -102,7 +102,7 @@ fn vm_trace_to_object(t: &VMTrace) -> Value {
"val".to_owned() => to_value(&sd.value).unwrap()
]));
}
m.insert("executed".to_owned(), Value::Object(em));
m.insert("ex".to_owned(), Value::Object(em));
}
if next_sub.is_some() && next_sub.unwrap().parent_step == i {
m.insert("sub".to_owned(), vm_trace_to_object(next_sub.unwrap()));

View File

@@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::numbers::*;
use ethcore::contract_address;
use ethcore::transaction::{LocalizedTransaction, Action, SignedTransaction};
use v1::types::{Bytes, OptionalValue};
@@ -46,7 +47,9 @@ pub struct Transaction {
/// Gas
pub gas: U256,
/// Data
pub input: Bytes
pub input: Bytes,
/// Creates contract
pub creates: OptionalValue<Address>,
}
impl From<LocalizedTransaction> for Transaction {
@@ -65,7 +68,11 @@ impl From<LocalizedTransaction> for Transaction {
value: t.value,
gas_price: t.gas_price,
gas: t.gas,
input: Bytes::new(t.data.clone())
input: Bytes::new(t.data.clone()),
creates: match t.action {
Action::Create => OptionalValue::Value(contract_address(&t.sender().unwrap(), &t.nonce)),
Action::Call(_) => OptionalValue::Null,
},
}
}
}
@@ -86,7 +93,11 @@ impl From<SignedTransaction> for Transaction {
value: t.value,
gas_price: t.gas_price,
gas: t.gas,
input: Bytes::new(t.data.clone())
input: Bytes::new(t.data.clone()),
creates: match t.action {
Action::Create => OptionalValue::Value(contract_address(&t.sender().unwrap(), &t.nonce)),
Action::Call(_) => OptionalValue::Null,
},
}
}
}
@@ -100,6 +111,7 @@ mod tests {
fn test_transaction_serialize() {
let t = Transaction::default();
let serialized = serde_json::to_string(&t).unwrap();
// TODO: fix create.
assert_eq!(serialized, r#"{"hash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x00","blockHash":null,"blockNumber":null,"transactionIndex":null,"from":"0x0000000000000000000000000000000000000000","to":null,"value":"0x00","gasPrice":"0x00","gas":"0x00","input":"0x"}"#);
}
}