Commit 7c2ae58c authored by jianhua.zhang's avatar jianhua.zhang

合约验证接口调整

parent ea59170d
......@@ -86,6 +86,7 @@ public class ContractController {
if (con != null) {
BeanUtils.copyProperties(con, model, "id");
model.setId(con.getContractAddress());
model.setAddress(con.getContractAddress());
model.setCode(con.getBytecode());
}
......@@ -96,11 +97,34 @@ public class ContractController {
public ApiResponse compileSolidityOne(@RequestBody @Valid ContractModel reqParam) {
boolean flag = false;
Contract con = this.tronService.getContract(reqParam.getId());
if (con != null) {
if (con.getBytecode().equals(reqParam.getCode())) {
// 编译合约、获取code
String code = this.contractCompilerService.compiler(reqParam.getName(), reqParam.getValue(), reqParam.getCompiler());
// 根据合约地址获取合约内容
Contract con = this.tronService.getContract(reqParam.getAddress());
// 验证合约code,如果一致,持久化到数据库中
if (con != null && !StringUtils.isEmpty(con.getBytecode())) {
/* if (con.getBytecode().equals(code)) {
Contract contract = new Contract();
BeanUtils.copyProperties(reqParam, contract);
if (contract != null) {
this.contractService.insert(contract);
}
flag = true;
}*/
con.setName(reqParam.getName());
con.setContractAddress(reqParam.getAddress());
con.setVersion(reqParam.getCompiler());
con.setOptimization(reqParam.getOptimization());
con.setSource(reqParam.getValue());
con.setRuns(reqParam.getRuns());
con.setLicenseType(reqParam.getLicense_type());
con.setEvmVersion(reqParam.getEvm_version());
if (con != null) {
this.contractService.insert(con);
}
flag = true;
}
return ResponseKit.success(flag);
......
......@@ -16,6 +16,11 @@ public class ContractModel {
*/
private String id;
/**
* 合约地址
*/
private String address;
/**
* 合约名称
*/
......@@ -26,11 +31,18 @@ public class ContractModel {
*/
private String version;
/**
* solidity版本号
*/
private String compiler;
/**
* 合约代码
*/
private String source;
private String value;
/**
* 合约ABI
*/
......@@ -56,11 +68,11 @@ public class ContractModel {
/**
*
*/
private String evmVersion;
private String evm_version;
/**
*
*/
private String licenseType;
private String license_type;
/**
*
*/
......
......@@ -5,7 +5,7 @@ tron:
contract:
complier:
site: http://47.115.200.174:8080/api/explorer/v1/compileSolidity
site: http://47.115.200.174:9090/api/explorer/v1/compileSolidity
spring:
datasource:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment