var parseConfig=function(data){var total_compiled={};var addresses={};var templates={};var options={};Object.keys(data["contracts"]).map(function(contract_name){$.ajax({url:data["contracts"][contract_name].path,dataType:"text",cache:false,async:false,success:function(contract){var compiled=web3.eth.compile.solidity(contract);console.log(compiled);console.log(data["contracts"]);Object.keys(compiled).map(function(compiled_contract_name){if(compiled_contract_name in data["contracts"]){if(total_compiled.hasOwnProperty(compiled_contract_name)==false){addresses[compiled_contract_name]=data["contracts"][compiled_contract_name].address;templates[compiled_contract_name]=data["contracts"][compiled_contract_name].template;options[compiled_contract_name]={template_overlay:data["contracts"][compiled_contract_name].template_overlay};var comp={};comp[compiled_contract_name]=compiled[compiled_contract_name];$.extend(total_compiled,comp)}}})}})});console.log(total_compiled);console.log(addresses);console.log(templates);console.log(options);var config={};config.total_compiled=total_compiled;config.addresses=addresses;config.templates=templates;config.options=options;return config};var ContainerHelper=React.createClass({displayName:"ContainerHelper",render:function(){return React.createElement("div",null,Object.keys(this.props.compiled).map(function(result){var contract=web3.eth.contract(this.props.compiled[result].info.abiDefinition);var instance=contract.at(this.props.addresses[result]);React.createElement("hr",null);var contract_template={};var new_compiled=this.props.compiled;var abi=this.props.compiled[result].info.abiDefinition;if(this.props.templates.hasOwnProperty(result)){if(this.props.templates[result]!=undefined){contract_template=this.props.templates[result];if(this.props.options[result]["template_overlay"]==false){$.each(abi,function(i,obj){if(obj.name!=undefined){if(this.props.templates[result].hasOwnProperty(obj.name)==false){console.log("deleting part of abi");console.log(abi[i]);delete abi[i]}}}.bind(this));console.log("false")}}var deploy=false;if(this.props.options[result].hasOwnProperty("deploy_overlay")){console.log(this.props.options[result].deploy_overlay);deploy=this.props.options[result].deploy_overlay}}return React.createElement("div",{key:result},React.createElement(ContractWrapper,{key:result,deploy:deploy,name:result,contract_template:contract_template,compiled:this.props.compiled[result],instance:instance}))},this))}});var ContractWrapper=React.createClass({displayName:"ContractWrapper",render:function(){var dep="";if(this.props.deploy==true){dep=React.createElement(DeployWrapper,{compiled:this.props.compiled,name:this.props.name,instance:this.props.instance})}return React.createElement("div",null,dep,React.createElement("ul",null,this.props.compiled.info.abiDefinition.map(function(result){if(result.type=="function"){var function_template={};if(this.props.contract_template.hasOwnProperty(result.name)){function_template=this.props.contract_template[result.name]}var args="";$.each(result.inputs,function(i,obj){args+=obj.type});var key=result.name+args;return React.createElement(FunctionWrapper,{function_template:function_template,instance:this.props.instance,key:key,data:result})}},this)))}});var FunctionWrapper=React.createClass({displayName:"FunctionWrapper",executeFunction:function(type){args={};args_array=[];$.each(this.refs,function(i,obj){args[obj.props.arg]=obj.state.value;args_array.push(obj.state.value)});var function_name=this.props.data.name.split("(")[0];var from=web3.eth.defaultAccount==undefined?web3.eth.accounts[0]:web3.eth.defaultAccount;var data={from:from};var callback=function(err,result){console.log("internal callback");console.log(err);console.log(result)};args_array.push(data);args_array.push(callback);if(type=="call"){this.props.instance[function_name].call.apply(this,args_array)}else if(type=="transact"){this.props.instance[function_name].sendTransaction.apply(this,args_array)}},render:function(){if(this.props.function_template.button!=undefined){var button=React.createElement("div",null,React.createElement("button",{className:"btn btn-default",onClick:this.executeFunction.bind(this,"transact")},this.props.function_template.button))}else{var button=React.createElement("div",null,React.createElement("button",{className:"btn btn-default",onClick:this.executeFunction.bind(this,"call")},"Call() ",this.props.data.name)," - ",React.createElement("button",{className:"btn btn-default",onClick:this.executeFunction.bind(this,"transact")},"Transact() ",this.props.data.name))}return React.createElement("div",null,this.props.data.inputs.map(function(result){var input_template={};var arg=result.name;if("inputs"in this.props.function_template){if(this.props.function_template.inputs.hasOwnProperty(result.name)){input_template=this.props.function_template.inputs[result.name];arg=this.props.function_template.inputs[result.name].default_value}}return React.createElement("div",{key:result.name},React.createElement(InputWrapper,{input_template:input_template,ref:result.name,arg:arg}))},this),React.createElement("br",null),button,React.createElement("br",null))}});var InputWrapper=React.createClass({displayName:"InputWrapper",getInitialState:function(){return{value:""}},handleChange:function(event){this.setState({value:event.target.value})},render:function(){return React.createElement("div",null," ",this.props.input_template.label," ",React.createElement("input",{className:"form-control",type:"text",value:this.state.value,placeholder:this.props.arg,onChange:this.handleChange})," ")}});var DeployWrapper=React.createClass({displayName:"DeployWrapper",getInitialState:function(){codeOnChain=web3.eth.getCode(this.props.instance.address);var submitted=true;if(this.props.compiled.code.indexOf(codeOnChain.substring(2))==-1||codeOnChain=="0x"){submitted=false}return{submitted:submitted}},deployContract:function(){var address=web3.eth.sendTransaction({gas:"3141592",from:web3.eth.accounts[0],data:this.props.compiled.code});console.log(address)},render:function(){if(this.state.submitted==true){return React.createElement("div",null,"Contract exists on the blockchain.")}else{return React.createElement("div",null,"Specified address of contract is ",this.props.instance.address,"."+" "+"Contract does not exist on the blockchain. ",React.createElement("button",{className:"btn btn-default",onClick:this.deployContract},"Deploy Contract ",this.props.name))}}});