Allow contract constructors in chain spec (#3932)
* constructor spec * execute under wrong address * create under correct address * revert * move genesis block lookup * remove env_logger
This commit is contained in:
@@ -32,8 +32,10 @@ pub struct Account {
|
||||
pub nonce: Option<Uint>,
|
||||
/// Code.
|
||||
pub code: Option<Bytes>,
|
||||
/// Storage
|
||||
/// Storage.
|
||||
pub storage: Option<BTreeMap<Uint, Uint>>,
|
||||
/// Constructor.
|
||||
pub constructor: Option<Bytes>,
|
||||
}
|
||||
|
||||
impl Account {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use hash::Address;
|
||||
use bytes::Bytes;
|
||||
use spec::{Account, Builtin};
|
||||
|
||||
/// Blockchain test state deserializer.
|
||||
@@ -29,7 +30,15 @@ impl State {
|
||||
pub fn builtins(&self) -> BTreeMap<Address, Builtin> {
|
||||
self.0
|
||||
.iter()
|
||||
.filter_map(|ref pair| pair.1.builtin.clone().map(|b| (pair.0.clone(), b.clone())))
|
||||
.filter_map(|(add, ref acc)| acc.builtin.clone().map(|b| (add.clone(), b)))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns all constructors.
|
||||
pub fn constructors(&self) -> BTreeMap<Address, Bytes> {
|
||||
self.0
|
||||
.iter()
|
||||
.filter_map(|(add, ref acc)| acc.constructor.clone().map(|b| (add.clone(), b)))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user