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

合约验证接口调整

parent ea59170d
...@@ -86,6 +86,7 @@ public class ContractController { ...@@ -86,6 +86,7 @@ public class ContractController {
if (con != null) { if (con != null) {
BeanUtils.copyProperties(con, model, "id"); BeanUtils.copyProperties(con, model, "id");
model.setId(con.getContractAddress()); model.setId(con.getContractAddress());
model.setAddress(con.getContractAddress());
model.setCode(con.getBytecode()); model.setCode(con.getBytecode());
} }
...@@ -96,11 +97,34 @@ public class ContractController { ...@@ -96,11 +97,34 @@ public class ContractController {
public ApiResponse compileSolidityOne(@RequestBody @Valid ContractModel reqParam) { public ApiResponse compileSolidityOne(@RequestBody @Valid ContractModel reqParam) {
boolean flag = false; boolean flag = false;
Contract con = this.tronService.getContract(reqParam.getId()); // 编译合约、获取code
if (con != null) { String code = this.contractCompilerService.compiler(reqParam.getName(), reqParam.getValue(), reqParam.getCompiler());
if (con.getBytecode().equals(reqParam.getCode())) {
// 根据合约地址获取合约内容
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; 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); return ResponseKit.success(flag);
......
...@@ -16,6 +16,11 @@ public class ContractModel { ...@@ -16,6 +16,11 @@ public class ContractModel {
*/ */
private String id; private String id;
/**
* 合约地址
*/
private String address;
/** /**
* 合约名称 * 合约名称
*/ */
...@@ -26,11 +31,18 @@ public class ContractModel { ...@@ -26,11 +31,18 @@ public class ContractModel {
*/ */
private String version; private String version;
/**
* solidity版本号
*/
private String compiler;
/** /**
* 合约代码 * 合约代码
*/ */
private String source; private String source;
private String value;
/** /**
* 合约ABI * 合约ABI
*/ */
...@@ -56,11 +68,11 @@ public class ContractModel { ...@@ -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: ...@@ -5,7 +5,7 @@ tron:
contract: contract:
complier: complier:
site: http://47.115.200.174:8080/api/explorer/v1/compileSolidity site: http://47.115.200.174:9090/api/explorer/v1/compileSolidity
spring: spring:
datasource: 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