Update comments and reg ABI (#4787)

* Update comments.

* Fix up new ABI.
This commit is contained in:
Gav Wood 2017-03-06 21:37:38 +01:00 committed by Arkadiy Paronyan
parent 344b5b120f
commit cec37207be
3 changed files with 169 additions and 91 deletions

File diff suppressed because one or more lines are too long

View File

@ -42,13 +42,13 @@ fn load(b: &[u8]) -> Spec {
Spec::load(b).expect("chain spec is invalid")
}
/// Create a new Olympic chain spec.
/// Create a new Foundation Olympic chain spec.
pub fn new_olympic() -> Spec { load(include_bytes!("../../res/ethereum/olympic.json")) }
/// Create a new Frontier mainnet chain spec.
/// Create a new Foundation Mainnet chain spec.
pub fn new_foundation() -> Spec { load(include_bytes!("../../res/ethereum/foundation.json")) }
/// Create a new Frontier mainnet chain spec without the DAO hardfork.
/// Create a new Classic Mainnet chain spec without the DAO hardfork.
pub fn new_classic() -> Spec { load(include_bytes!("../../res/ethereum/classic.json")) }
/// Create a new Expanse mainnet chain spec.
@ -57,25 +57,25 @@ pub fn new_expanse() -> Spec { load(include_bytes!("../../res/ethereum/expanse.j
/// Create a new Kovan testnet chain spec.
pub fn new_kovan() -> Spec { load(include_bytes!("../../res/ethereum/kovan.json")) }
/// Create a new Frontier chain spec as though it never changes to Homestead.
/// Create a new Foundation Frontier-era chain spec as though it never changes to Homestead.
pub fn new_frontier_test() -> Spec { load(include_bytes!("../../res/ethereum/frontier_test.json")) }
/// Create a new Homestead chain spec as though it never changed from Frontier.
/// Create a new Foundation Homestead-era chain spec as though it never changed from Frontier.
pub fn new_homestead_test() -> Spec { load(include_bytes!("../../res/ethereum/homestead_test.json")) }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
/// Create a new Foundation Homestead-EIP150-era chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip150_test() -> Spec { load(include_bytes!("../../res/ethereum/eip150_test.json")) }
/// Create a new Homestead-EIP150 chain spec as though it never changed from Homestead/Frontier.
/// Create a new Foundation Homestead-EIP161-era chain spec as though it never changed from Homestead/Frontier.
pub fn new_eip161_test() -> Spec { load(include_bytes!("../../res/ethereum/eip161_test.json")) }
/// Create a new Frontier/Homestead/DAO chain spec with transition points at #5 and #8.
/// Create a new Foundation Frontier/Homestead/DAO chain spec with transition points at #5 and #8.
pub fn new_transition_test() -> Spec { load(include_bytes!("../../res/ethereum/transition_test.json")) }
/// Create a new Frontier main net chain spec without genesis accounts.
/// Create a new Foundation Mainnet chain spec without genesis accounts.
pub fn new_mainnet_like() -> Spec { load(include_bytes!("../../res/ethereum/frontier_like_test.json")) }
/// Create a new Ropsten chain spec.
/// Create a new Foundation Ropsten chain spec.
pub fn new_ropsten() -> Spec { load(include_bytes!("../../res/ethereum/ropsten.json")) }
/// Create a new Morden chain spec.

View File

@ -41,11 +41,11 @@ ${convertContract(name, json, prefs)}
function convertContract(name, json, prefs) {
return `${prefs._pub ? "pub " : ""}struct ${name} {
contract: ethabi::Contract,
address: util::Address,
pub address: util::Address,
${prefs._explicit_do_call ? "" : `do_call: Box<Fn(util::Address, Vec<u8>) -> Result<Vec<u8>, String> + Send${prefs._sync ? " + Sync " : ""}+ 'static>,`}
}
impl ${name} {
pub fn new${prefs._explicit_do_call ? "" : "<F>"}(address: util::Address${prefs._explicit_do_call ? "" : `", do_call: F"`}) -> Self
pub fn new${prefs._explicit_do_call ? "" : "<F>"}(address: util::Address${prefs._explicit_do_call ? "" : `, do_call: F`}) -> Self
${prefs._explicit_do_call ? "" : `where F: Fn(util::Address, Vec<u8>) -> Result<Vec<u8>, String> + Send ${prefs._sync ? "+ Sync " : ""}+ 'static`} {
${name} {
contract: ethabi::Contract::new(ethabi::Interface::load(b"${JSON.stringify(json.filter(a => a.type == 'function')).replaceAll('"', '\\"')}").expect("JSON is autogenerated; qed")),
@ -233,19 +233,23 @@ function convertFunction(json, _prefs) {
let prefs = {"_pub": true, "_": {"_client": {"string": true}, "_platform": {"string": true}}, "_sync": true};
// default contract json ABI
let jsonabi = [{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"}];
// default name
let name = 'Contract';
// parse command line options
for (let i = 1; i < process.argv.length; ++i) {
let arg = process.argv[i];
if (arg.indexOf("--jsonabi") == 0) {
if (arg.indexOf("--jsonabi=") == 0) {
jsonabi = arg.slice(10);
if (fs.existsSync(jsonabi)) {
jsonabi = JSON.parse(fs.readFileSync(jsonabi).toString());
}
} else if (arg.indexOf("--explicit-do-call") == 0) {
prefs._explicit_do_call = true;
} else if (arg.indexOf("--name=") == 0) {
name = arg.slice(7);
}
}
let out = makeContractFile("Contract", jsonabi, prefs);
let out = makeContractFile(name, jsonabi, prefs);
console.log(`${out}`);