Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tron-explore
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张建华@五瓣科技
tron-explore
Commits
46768dc1
Commit
46768dc1
authored
Dec 01, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增solidity版本功能接口开发,新增合约校验、验证接口开发
parent
9a9d02a5
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1578 additions
and
138 deletions
+1578
-138
ContractController.java
...com/wuban/tron/explore/controller/ContractController.java
+98
-9
TransactionControllerV1.java
...n/tron/explore/controller/v1/TransactionControllerV1.java
+7
-3
SolidityVersionRepository.java
...com/wuban/tron/explore/dao/SolidityVersionRepository.java
+27
-0
DataSourceConfigEx.java
...com/wuban/tron/explore/dao/config/DataSourceConfigEx.java
+9
-9
Contract.java
src/main/java/com/wuban/tron/explore/entity/Contract.java
+81
-35
SolidityVersion.java
...n/java/com/wuban/tron/explore/entity/SolidityVersion.java
+37
-0
ContractExample.java
...om/wuban/tron/explore/entity/example/ContractExample.java
+510
-60
SolidityVersionExample.java
...n/tron/explore/entity/example/SolidityVersionExample.java
+386
-0
Executor.java
src/main/java/com/wuban/tron/explore/fetch/Executor.java
+1
-1
ContractCompilerRequest.java
...n/tron/explore/param/request/ContractCompilerRequest.java
+18
-0
CensusModel.java
...va/com/wuban/tron/explore/param/response/CensusModel.java
+3
-1
ContractModel.java
.../com/wuban/tron/explore/param/response/ContractModel.java
+73
-0
ContractCompilerService.java
...m/wuban/tron/explore/service/ContractCompilerService.java
+3
-3
SolidityVersionService.java
...om/wuban/tron/explore/service/SolidityVersionService.java
+24
-0
ContractCompilerServiceImpl.java
...ron/explore/service/impl/ContractCompilerServiceImpl.java
+4
-4
SolidityVersionServiceImpl.java
...tron/explore/service/impl/SolidityVersionServiceImpl.java
+30
-0
ContractMapper.xml
src/main/resources/mapper/ContractMapper.xml
+50
-5
SolidityVersionMapper.xml
src/main/resources/mapper/SolidityVersionMapper.xml
+209
-0
ContractCompilerServiceImplTest.java
...explore/service/impl/ContractCompilerServiceImplTest.java
+7
-7
tron-explore.sql
tron-explore.sql
+1
-1
No files found.
src/main/java/com/wuban/tron/explore/controller/ContractController.java
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
controller
;
import
com.wuban.tron.explore.entity.Contract
;
import
com.wuban.tron.explore.entity.SolidityVersion
;
import
com.wuban.tron.explore.entity.example.ContractExample
;
import
com.wuban.tron.explore.param.request.ContractCompilerRequest
;
import
com.wuban.tron.explore.param.request.ContractRequest
;
import
com.wuban.tron.explore.service.ContractComplierService
;
import
com.wuban.tron.explore.param.response.ContractModel
;
import
com.wuban.tron.explore.service.ContractCompilerService
;
import
com.wuban.tron.explore.service.ContractService
;
import
com.wuban.tron.explore.service.SolidityVersionService
;
import
com.wuban.tron.explore.service.TronService
;
import
com.wuban.tron.explore.util.ApiResponse
;
import
com.wuban.tron.explore.util.BizExceptionEnum
;
import
com.wuban.tron.explore.util.ResponseKit
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
java.util.List
;
/**
* <core>合约校验API接口</core>
...
...
@@ -36,10 +39,97 @@ public class ContractController {
private
final
TronService
tronService
;
private
final
ContractComplierService
contractComplierService
;
private
final
ContractCompilerService
contractCompilerService
;
private
final
SolidityVersionService
solidityVersionService
;
@RequestMapping
(
value
=
"getVersion"
,
method
=
RequestMethod
.
GET
)
public
ApiResponse
getVersion
()
{
List
<
SolidityVersion
>
list
=
this
.
solidityVersionService
.
selectByExample
(
null
);
return
ResponseKit
.
success
(
list
);
}
@RequestMapping
(
value
=
"checkContract/{address}"
,
method
=
RequestMethod
.
GET
)
public
ApiResponse
checkContract
(
@PathVariable
(
"address"
)
String
address
)
{
if
(
StringUtils
.
isEmpty
(
address
))
{
return
ResponseKit
.
fail
(
BizExceptionEnum
.
REQUEST_NULL
.
getCode
(),
BizExceptionEnum
.
REQUEST_NULL
.
getMessage
());
}
/*
按照合约地址查询DB中是否存在此合约
*/
ContractExample
example
=
new
ContractExample
();
example
.
createCriteria
().
andContractAddressEqualTo
(
address
);
Contract
con
=
this
.
contractService
.
selectOneByExample
(
example
);
// 未编译
int
isCompiler
=
0
;
if
(
con
!=
null
)
{
isCompiler
=
1
;
}
return
ResponseKit
.
success
(
isCompiler
);
}
@RequestMapping
(
value
=
"getContractInfoById/{address}"
,
method
=
RequestMethod
.
GET
)
public
ApiResponse
getContractInfoById
(
@PathVariable
(
"address"
)
String
address
)
{
if
(
StringUtils
.
isEmpty
(
address
))
{
return
ResponseKit
.
fail
(
BizExceptionEnum
.
REQUEST_NULL
.
getCode
(),
BizExceptionEnum
.
REQUEST_NULL
.
getMessage
());
}
ContractExample
example
=
new
ContractExample
();
example
.
createCriteria
().
andContractAddressEqualTo
(
address
);
Contract
con
=
this
.
contractService
.
selectOneByExample
(
example
);
ContractModel
model
=
new
ContractModel
();
if
(
con
!=
null
)
{
BeanUtils
.
copyProperties
(
con
,
model
,
"id"
);
model
.
setId
(
con
.
getContractAddress
());
model
.
setCode
(
con
.
getBytecode
());
}
return
ResponseKit
.
success
(
model
);
}
@RequestMapping
(
value
=
"compileSolidityOne"
,
method
=
RequestMethod
.
POST
)
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
()))
{
flag
=
true
;
}
}
return
ResponseKit
.
success
(
flag
);
}
@RequestMapping
(
value
=
"compileSolidity"
,
method
=
RequestMethod
.
POST
)
public
ApiResponse
checkContract
(
@RequestBody
@Valid
ContractRequest
reqParam
)
{
public
ApiResponse
compileSolidity
(
@RequestBody
@Valid
ContractCompilerRequest
reqParam
)
{
String
code
=
this
.
contractCompilerService
.
compiler
(
reqParam
.
getName
(),
reqParam
.
getValue
(),
reqParam
.
getCompiler
());
return
ResponseKit
.
success
(
code
);
}
@Deprecated
@RequestMapping
(
value
=
"compileSolidityAll"
,
method
=
RequestMethod
.
POST
)
public
ApiResponse
compileSolidityAll
(
@RequestBody
@Valid
ContractRequest
reqParam
)
{
String
address
=
reqParam
.
getAddress
();
if
(
StringUtils
.
isEmpty
(
address
))
{
...
...
@@ -63,7 +153,7 @@ public class ContractController {
}
// 编译合约
String
code
=
this
.
contractComp
lierService
.
compli
er
(
reqParam
.
getName
(),
reqParam
.
getValue
(),
reqParam
.
getCompiler
());
String
code
=
this
.
contractComp
ilerService
.
compil
er
(
reqParam
.
getName
(),
reqParam
.
getValue
(),
reqParam
.
getCompiler
());
// 校验btyecode是否一致,不一致返回,一致持久化
if
(!
contract
.
getBytecode
().
equals
(
code
))
{
...
...
@@ -75,5 +165,4 @@ public class ContractController {
return
ResponseKit
.
success
();
}
}
src/main/java/com/wuban/tron/explore/controller/v1/TransactionControllerV1.java
View file @
46768dc1
...
...
@@ -422,9 +422,11 @@ public class TransactionControllerV1 {
pageInfo
.
getList
().
forEach
(
o
->
{
AccountInfoModel
infoModel
=
AccountInfoModel
.
getInstance
();
infoModel
.
setAddress
(
o
.
getAddress
());
//BigDecimal balance = BigDecimalUtil.getDevide(new BigDecimal(o.getBalance()), BigDecimalUtil.NUM);
// 账户余额 = 可用余额+冻结余额
/*
BigDecimal balance = BigDecimalUtil.getDevide(new BigDecimal(o.getBalance()), BigDecimalUtil.NUM);
账户余额 = 可用余额+冻结余额
*/
BigDecimal
accountBalance
=
new
BigDecimal
(
0
);
if
(
o
.
getBalance
()
!=
null
)
{
accountBalance
=
BigDecimalUtil
.
getAdd
(
accountBalance
,
new
BigDecimal
(
o
.
getBalance
()));
...
...
@@ -592,7 +594,9 @@ public class TransactionControllerV1 {
censusModel
.
setTransNumber
(
totalVolume
.
toString
());
}
//censusModel.setDifficulty("");
/*
censusModel.setDifficulty("");
*/
return
ResponseKit
.
success
(
censusModel
);
}
...
...
src/main/java/com/wuban/tron/explore/dao/SolidityVersionRepository.java
0 → 100644
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
dao
;
import
com.wuban.tron.explore.entity.SolidityVersion
;
import
com.wuban.tron.explore.entity.example.SolidityVersionExample
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
/**
* <core>solidity版本号DAO</core>
*
* @author sky
* @date 2020/11/02
*/
@Repository
public
interface
SolidityVersionRepository
{
/**
* 获取solidity版本号列表
*
* @param example 检索条件
* @return
*/
List
<
SolidityVersion
>
selectByExample
(
@Param
(
"example"
)
SolidityVersionExample
example
);
}
src/main/java/com/wuban/tron/explore/dao/config/DataSourceConfigE
X
.java
→
src/main/java/com/wuban/tron/explore/dao/config/DataSourceConfigE
x
.java
View file @
46768dc1
...
...
@@ -22,22 +22,22 @@ import javax.sql.DataSource;
*/
@Configuration
@MapperScan
(
basePackages
=
"com.wuban.tron.explore.dao"
,
sqlSessionTemplateRef
=
"sqlSessionTemplateE
X
"
)
public
class
DataSourceConfigE
X
{
@MapperScan
(
basePackages
=
"com.wuban.tron.explore.dao"
,
sqlSessionTemplateRef
=
"sqlSessionTemplateE
x
"
)
public
class
DataSourceConfigE
x
{
@Value
(
"${spring.datasource.type}"
)
private
Class
<?
extends
DataSource
>
dataSourceType
;
@Bean
(
name
=
"dataSourceE
X
"
)
@Bean
(
name
=
"dataSourceE
x
"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource"
)
@Primary
public
DataSource
buildDataSource
()
{
return
DataSourceBuilder
.
create
().
type
(
this
.
dataSourceType
).
build
();
}
@Bean
(
name
=
"sqlSessionFactoryE
X
"
)
@Bean
(
name
=
"sqlSessionFactoryE
x
"
)
@Primary
public
SqlSessionFactory
buildSqlSessionFactory
(
@Qualifier
(
"dataSourceE
X
"
)
final
DataSource
dataSource
)
public
SqlSessionFactory
buildSqlSessionFactory
(
@Qualifier
(
"dataSourceE
x
"
)
final
DataSource
dataSource
)
throws
Exception
{
final
SqlSessionFactoryBean
bean
=
new
SqlSessionFactoryBean
();
bean
.
setDataSource
(
dataSource
);
...
...
@@ -48,17 +48,17 @@ public class DataSourceConfigEX {
return
bean
.
getObject
();
}
@Bean
(
name
=
"transactionManagerE
X
"
)
@Bean
(
name
=
"transactionManagerE
x
"
)
@Primary
public
DataSourceTransactionManager
buildTransactionManager
(
@Qualifier
(
"dataSourceE
X
"
)
final
DataSource
dataSource
)
{
@Qualifier
(
"dataSourceE
x
"
)
final
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
(
name
=
"sqlSessionTemplateE
X
"
)
@Bean
(
name
=
"sqlSessionTemplateE
x
"
)
@Primary
public
SqlSessionTemplate
buildSqlSessionTemplate
(
@Qualifier
(
"sqlSessionFactoryE
X
"
)
final
SqlSessionFactory
sqlSessionFactory
)
{
@Qualifier
(
"sqlSessionFactoryE
x
"
)
final
SqlSessionFactory
sqlSessionFactory
)
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
...
...
src/main/java/com/wuban/tron/explore/entity/Contract.java
View file @
46768dc1
...
...
@@ -19,39 +19,75 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
public
class
Contract
{
/**
*
*/
private
Long
id
;
/**
*
*/
private
String
bytecode
;
/**
* 名称
*/
private
String
name
;
/**
*
*/
private
String
originAddress
;
/**
*
*/
private
String
abi
;
/**
*
*/
private
Long
originEnergyLimit
;
/**
* 合约地址
*/
private
String
contractAddress
;
/**
*
*/
private
String
codeHash
;
/**
*
*/
private
Long
id
;
/**
* 合约code
*/
private
String
bytecode
;
/**
* 合约名称
*/
private
String
name
;
/**
*
*/
private
String
originAddress
;
/**
* 合约ABI
*/
private
String
abi
;
/**
*
*/
private
Long
originEnergyLimit
;
/**
* 合约地址
*/
private
String
contractAddress
;
/**
*
*/
private
String
codeHash
;
/**
* solidity版本号
*/
private
String
version
;
/**
* 合约代码
*/
private
String
source
;
/**
*
*/
private
String
enabled
;
/**
*
*/
private
String
other
;
/**
*
*/
private
String
runs
;
/**
*
*/
private
String
evmVersion
;
/**
*
*/
private
String
licenseType
;
/**
*
*/
private
String
parameters
;
/**
*
*/
private
String
optimization
;
public
static
Contract
getInstance
()
{
return
Contract
.
builder
()
.
id
(
0L
)
...
...
@@ -61,7 +97,17 @@ public class Contract {
.
abi
(
""
)
.
originEnergyLimit
(
0L
)
.
contractAddress
(
""
)
.
codeHash
(
""
)
.
build
();
.
codeHash
(
""
)
.
version
(
""
)
.
source
(
""
)
.
enabled
(
""
)
.
other
(
""
)
.
runs
(
""
)
.
evmVersion
(
""
)
.
licenseType
(
""
)
.
parameters
(
""
)
.
optimization
(
""
)
.
build
();
}
}
\ No newline at end of file
src/main/java/com/wuban/tron/explore/entity/SolidityVersion.java
0 → 100644
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
entity
;
import
lombok.AccessLevel
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* solidity版本号
* @author sky
* @date 2020-12-01
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
public
class
SolidityVersion
{
/**
*
*/
private
Long
id
;
/**
*
*/
private
String
version
;
public
static
SolidityVersion
getInstance
()
{
return
SolidityVersion
.
builder
()
.
id
(
0L
)
.
version
(
""
)
.
build
();
}
}
\ No newline at end of file
src/main/java/com/wuban/tron/explore/entity/example/ContractExample.java
View file @
46768dc1
This diff is collapsed.
Click to expand it.
src/main/java/com/wuban/tron/explore/entity/example/SolidityVersionExample.java
0 → 100644
View file @
46768dc1
This diff is collapsed.
Click to expand it.
src/main/java/com/wuban/tron/explore/fetch/Executor.java
View file @
46768dc1
...
...
@@ -43,7 +43,7 @@ public class Executor {
}
public
void
rebuild
()
{
this
.
pool
=
new
ThreadPoolExecutor
(
SIZE
,
SIZE
,
0L
,
TimeUnit
.
SECONDS
,
this
.
pool
=
new
ThreadPoolExecutor
(
SIZE
,
SIZE
*
2
,
1
0L
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ExecutorThreadFactory
());
}
...
...
src/main/java/com/wuban/tron/explore/param/request/ContractCompilerRequest.java
0 → 100644
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
param
.
request
;
import
lombok.Data
;
/**
* <core>编译合约请求参数</core>
*
* @author sky
* @date 2020/11/02
*/
@Data
public
class
ContractCompilerRequest
{
private
String
name
;
private
String
value
;
private
String
compiler
;
}
src/main/java/com/wuban/tron/explore/param/response/CensusModel.java
View file @
46768dc1
...
...
@@ -24,7 +24,9 @@ public class CensusModel {
@JsonProperty
(
value
=
"block_number"
)
private
String
blockNumber
;
private
String
tps
;
//private String difficulty;
/*
private String difficulty;
*/
@JsonProperty
(
value
=
"address_number"
)
private
String
addressNumber
;
...
...
src/main/java/com/wuban/tron/explore/param/response/ContractModel.java
0 → 100644
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
param
.
response
;
import
lombok.Data
;
/**
* <core>合约详情MODEL</core>
*
* @author sky
* @date 2020/11/02
*/
@Data
public
class
ContractModel
{
/**
* 合约地址
*/
private
String
id
;
/**
* 合约名称
*/
private
String
name
;
/**
* solidity版本号
*/
private
String
version
;
/**
* 合约代码
*/
private
String
source
;
/**
* 合约ABI
*/
private
String
abi
;
/**
* 合约code
*/
private
String
code
;
/**
*
*/
private
String
enabled
;
/**
*
*/
private
String
other
;
/**
*
*/
private
String
runs
;
/**
*
*/
private
String
evmVersion
;
/**
*
*/
private
String
licenseType
;
/**
*
*/
private
String
parameters
;
/**
*
*/
private
String
optimization
;
}
src/main/java/com/wuban/tron/explore/service/ContractComp
li
erService.java
→
src/main/java/com/wuban/tron/explore/service/ContractComp
il
erService.java
View file @
46768dc1
...
...
@@ -6,16 +6,16 @@ package com.wuban.tron.explore.service;
* @author sky
* @date 2020/11/30
*/
public
interface
ContractComp
li
erService
{
public
interface
ContractComp
il
erService
{
/**
* 编译合约
*
* @param name 名称
* @param value 合约内容
* @param comp
li
er solidity版本号
* @param comp
il
er solidity版本号
* @return
*/
String
comp
lier
(
String
name
,
String
value
,
String
compli
er
);
String
comp
iler
(
String
name
,
String
value
,
String
compil
er
);
}
src/main/java/com/wuban/tron/explore/service/SolidityVersionService.java
0 → 100644
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
service
;
import
com.wuban.tron.explore.entity.SolidityVersion
;
import
com.wuban.tron.explore.entity.example.SolidityVersionExample
;
import
java.util.List
;
/**
* <core>solidity版本号服务接口</core>
*
* @author sky
* @date 2020/12/1
*/
public
interface
SolidityVersionService
{
/**
* 版本号列表
*
* @param example
* @return
*/
List
<
SolidityVersion
>
selectByExample
(
SolidityVersionExample
example
);
}
src/main/java/com/wuban/tron/explore/service/impl/ContractComp
li
erServiceImpl.java
→
src/main/java/com/wuban/tron/explore/service/impl/ContractComp
il
erServiceImpl.java
View file @
46768dc1
...
...
@@ -2,7 +2,7 @@ package com.wuban.tron.explore.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.wuban.tron.explore.service.BaseCommonService
;
import
com.wuban.tron.explore.service.ContractComp
li
erService
;
import
com.wuban.tron.explore.service.ContractComp
il
erService
;
import
com.wuban.tron.explore.util.ApiResponse
;
import
okhttp3.Request
;
import
org.springframework.stereotype.Service
;
...
...
@@ -18,14 +18,14 @@ import java.util.Map;
* @date 2020/11/30
*/
@Service
public
class
ContractComp
lierServiceImpl
extends
BaseCommonService
implements
ContractCompli
erService
{
public
class
ContractComp
ilerServiceImpl
extends
BaseCommonService
implements
ContractCompil
erService
{
@Override
public
String
comp
lier
(
String
name
,
String
value
,
String
compli
er
)
{
public
String
comp
iler
(
String
name
,
String
value
,
String
compil
er
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
3
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"value"
,
value
);
map
.
put
(
"comp
lier"
,
compli
er
);
map
.
put
(
"comp
iler"
,
compil
er
);
Request
request
=
this
.
builderPost
(
map
);
String
str
=
this
.
execute
(
request
);
if
(
StringUtils
.
isEmpty
(
str
))
{
...
...
src/main/java/com/wuban/tron/explore/service/impl/SolidityVersionServiceImpl.java
0 → 100644
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
service
.
impl
;
import
com.wuban.tron.explore.dao.SolidityVersionRepository
;
import
com.wuban.tron.explore.entity.SolidityVersion
;
import
com.wuban.tron.explore.entity.example.SolidityVersionExample
;
import
com.wuban.tron.explore.service.SolidityVersionService
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* <core>solidity版本号服务接口实现类</core>
*
* @author sky
* @date 2020/12/1
*/
@Service
@RequiredArgsConstructor
(
onConstructor_
=
@Autowired
)
public
class
SolidityVersionServiceImpl
implements
SolidityVersionService
{
private
final
SolidityVersionRepository
solidityVersionRepository
;
@Override
public
List
<
SolidityVersion
>
selectByExample
(
SolidityVersionExample
example
)
{
return
this
.
solidityVersionRepository
.
selectByExample
(
example
);
}
}
src/main/resources/mapper/ContractMapper.xml
View file @
46768dc1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.wuban.tron.explore.dao.ContractRepository"
>
<!-- CodeBuilder Generated-->
<!-- CodeBuilder Generated-->
<resultMap
id=
"ContractMap"
type=
"com.wuban.tron.explore.entity.Contract"
>
<result
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"bytecode"
property=
"bytecode"
jdbcType=
"VARCHAR"
/>
...
...
@@ -11,6 +11,15 @@
<result
column=
"origin_energy_limit"
property=
"originEnergyLimit"
jdbcType=
"BIGINT"
/>
<result
column=
"contract_address"
property=
"contractAddress"
jdbcType=
"VARCHAR"
/>
<result
column=
"code_hash"
property=
"codeHash"
jdbcType=
"VARCHAR"
/>
<result
column=
"version"
property=
"version"
jdbcType=
"VARCHAR"
/>
<result
column=
"source"
property=
"source"
jdbcType=
"LONGVARCHAR"
/>
<result
column=
"enabled"
property=
"enabled"
jdbcType=
"VARCHAR"
/>
<result
column=
"other"
property=
"other"
jdbcType=
"VARCHAR"
/>
<result
column=
"runs"
property=
"runs"
jdbcType=
"VARCHAR"
/>
<result
column=
"evm_version"
property=
"evmVersion"
jdbcType=
"VARCHAR"
/>
<result
column=
"license_type"
property=
"licenseType"
jdbcType=
"VARCHAR"
/>
<result
column=
"parameters"
property=
"parameters"
jdbcType=
"VARCHAR"
/>
<result
column=
"optimization"
property=
"optimization"
jdbcType=
"VARCHAR"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
...
...
@@ -44,9 +53,9 @@
</sql>
<sql
id=
"Table_Name"
>
tron_contract
</sql>
<sql
id=
"Base_Column_List_Without_Id"
>
id , bytecode , name , origin_address , abi , origin_energy_limit , contract_address , code_hash
</sql>
id , bytecode , name , origin_address , abi , origin_energy_limit , contract_address , code_hash
, version , source , enabled , other , runs , evm_version , license_type , parameters , optimization
</sql>
<sql
id=
"Base_Column_List"
>
<include
refid=
"Base_Column_List_Without_Id"
/>
<include
refid=
"Base_Column_List_Without_Id"
/>
</sql>
<sql
id=
"Insert_Columns"
>
<if
test=
"record.id != null"
>
id,
</if>
...
...
@@ -57,6 +66,15 @@
<if
test=
"record.originEnergyLimit != null"
>
origin_energy_limit,
</if>
<if
test=
"record.contractAddress != null"
>
contract_address,
</if>
<if
test=
"record.codeHash != null"
>
code_hash,
</if>
<if
test=
"record.version != null"
>
version,
</if>
<if
test=
"record.source != null"
>
source,
</if>
<if
test=
"record.enabled != null"
>
enabled,
</if>
<if
test=
"record.other != null"
>
other,
</if>
<if
test=
"record.runs != null"
>
runs,
</if>
<if
test=
"record.evmVersion != null"
>
evm_version,
</if>
<if
test=
"record.licenseType != null"
>
license_type,
</if>
<if
test=
"record.parameters != null"
>
parameters,
</if>
<if
test=
"record.optimization != null"
>
optimization,
</if>
</sql>
<sql
id=
"Insert_Values"
>
<if
test=
"record.id != null"
>
#{record.id,jdbcType=BIGINT},
</if>
...
...
@@ -67,6 +85,15 @@
<if
test=
"record.originEnergyLimit != null"
>
#{record.originEnergyLimit,jdbcType=BIGINT},
</if>
<if
test=
"record.contractAddress != null"
>
#{record.contractAddress,jdbcType=VARCHAR},
</if>
<if
test=
"record.codeHash != null"
>
#{record.codeHash,jdbcType=VARCHAR},
</if>
<if
test=
"record.version != null"
>
#{record.version,jdbcType=VARCHAR},
</if>
<if
test=
"record.source != null"
>
#{record.source,jdbcType=LONGVARCHAR},
</if>
<if
test=
"record.enabled != null"
>
#{record.enabled,jdbcType=VARCHAR},
</if>
<if
test=
"record.other != null"
>
#{record.other,jdbcType=VARCHAR},
</if>
<if
test=
"record.runs != null"
>
#{record.runs,jdbcType=VARCHAR},
</if>
<if
test=
"record.evmVersion != null"
>
#{record.evmVersion,jdbcType=VARCHAR},
</if>
<if
test=
"record.licenseType != null"
>
#{record.licenseType,jdbcType=VARCHAR},
</if>
<if
test=
"record.parameters != null"
>
#{record.parameters,jdbcType=VARCHAR},
</if>
<if
test=
"record.optimization != null"
>
#{record.optimization,jdbcType=VARCHAR},
</if>
</sql>
<sql
id=
"Batch_Insert_Values"
>
#{record.id,jdbcType=BIGINT},
...
...
@@ -77,9 +104,18 @@
#{record.originEnergyLimit,jdbcType=BIGINT},
#{record.contractAddress,jdbcType=VARCHAR},
#{record.codeHash,jdbcType=VARCHAR},
#{record.version,jdbcType=VARCHAR},
#{record.source,jdbcType=LONGVARCHAR},
#{record.enabled,jdbcType=VARCHAR},
#{record.other,jdbcType=VARCHAR},
#{record.runs,jdbcType=VARCHAR},
#{record.evmVersion,jdbcType=VARCHAR},
#{record.licenseType,jdbcType=VARCHAR},
#{record.parameters,jdbcType=VARCHAR},
#{record.optimization,jdbcType=VARCHAR},
</sql>
<sql
id=
"Batch_Insert_Values_On_DuplicateKey"
>
<include
refid=
"Batch_Insert_Values"
/>
<include
refid=
"Batch_Insert_Values"
/>
</sql>
<sql
id=
"Update_Set_From_Bean"
>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=BIGINT} ,
</if>
...
...
@@ -90,6 +126,15 @@
<if
test=
"record.originEnergyLimit != null"
>
origin_energy_limit = #{record.originEnergyLimit,jdbcType=BIGINT} ,
</if>
<if
test=
"record.contractAddress != null"
>
contract_address = #{record.contractAddress,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.codeHash != null"
>
code_hash = #{record.codeHash,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.version != null"
>
version = #{record.version,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.source != null"
>
source = #{record.source,jdbcType=LONGVARCHAR} ,
</if>
<if
test=
"record.enabled != null"
>
enabled = #{record.enabled,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.other != null"
>
other = #{record.other,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.runs != null"
>
runs = #{record.runs,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.evmVersion != null"
>
evm_version = #{record.evmVersion,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.licenseType != null"
>
license_type = #{record.licenseType,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.parameters != null"
>
parameters = #{record.parameters,jdbcType=VARCHAR} ,
</if>
<if
test=
"record.optimization != null"
>
optimization = #{record.optimization,jdbcType=VARCHAR} ,
</if>
</sql>
<!-- insert -->
<insert
id=
"insert"
parameterType=
"java.util.Map"
>
...
...
@@ -125,7 +170,7 @@
</trim>
</foreach>
ON DUPLICATE KEY UPDATE
id = VALUES(id) , bytecode = VALUES(bytecode) , name = VALUES(name) , origin_address = VALUES(origin_address) , abi = VALUES(abi) , origin_energy_limit = VALUES(origin_energy_limit) , contract_address = VALUES(contract_address) , code_hash = VALUES(code_hash)
</insert>
id = VALUES(id) , bytecode = VALUES(bytecode) , name = VALUES(name) , origin_address = VALUES(origin_address) , abi = VALUES(abi) , origin_energy_limit = VALUES(origin_energy_limit) , contract_address = VALUES(contract_address) , code_hash = VALUES(code_hash)
, version = VALUES(version) , source = VALUES(source) , enabled = VALUES(enabled) , other = VALUES(other) , runs = VALUES(runs) , evm_version = VALUES(evm_version) , license_type = VALUES(license_type) , parameters = VALUES(parameters) , optimization = VALUES(optimization)
</insert>
<!-- end insert -->
<!-- delete -->
<delete
id=
"deleteById"
parameterType=
"java.util.Map"
>
...
...
src/main/resources/mapper/SolidityVersionMapper.xml
0 → 100644
View file @
46768dc1
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.wuban.tron.explore.dao.SolidityVersionRepository"
>
<!-- CodeBuilder Generated-->
<resultMap
id=
"SolidityVersionMap"
type=
"com.wuban.tron.explore.entity.SolidityVersion"
>
<result
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"version"
property=
"version"
jdbcType=
"VARCHAR"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
<foreach
collection=
"example.oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
suffix=
")"
prefixOverrides=
"and"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
collection=
"criterion.value"
item=
"listItem"
open=
"("
close=
")"
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Table_Name"
>
tron_solidity_version
</sql>
<sql
id=
"Base_Column_List_Without_Id"
>
id , version
</sql>
<sql
id=
"Base_Column_List"
>
<include
refid=
"Base_Column_List_Without_Id"
/>
</sql>
<sql
id=
"Insert_Columns"
>
<if
test=
"record.id != null"
>
id,
</if>
<if
test=
"record.version != null"
>
version,
</if>
</sql>
<sql
id=
"Insert_Values"
>
<if
test=
"record.id != null"
>
#{record.id,jdbcType=BIGINT},
</if>
<if
test=
"record.version != null"
>
#{record.version,jdbcType=VARCHAR},
</if>
</sql>
<sql
id=
"Batch_Insert_Values"
>
#{record.id,jdbcType=BIGINT},
#{record.version,jdbcType=VARCHAR},
</sql>
<sql
id=
"Batch_Insert_Values_On_DuplicateKey"
>
<include
refid=
"Batch_Insert_Values"
/>
</sql>
<sql
id=
"Update_Set_From_Bean"
>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=BIGINT} ,
</if>
<if
test=
"record.version != null"
>
version = #{record.version,jdbcType=VARCHAR} ,
</if>
</sql>
<!-- insert -->
<insert
id=
"insert"
parameterType=
"java.util.Map"
>
insert into
<include
refid=
"Table_Name"
/>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<include
refid=
"Insert_Columns"
/>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<include
refid=
"Insert_Values"
/>
</trim>
</insert>
<insert
id=
"batchInsert"
parameterType=
"java.util.Map"
>
insert into
<include
refid=
"Table_Name"
/>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<include
refid=
"Base_Column_List_Without_Id"
/>
</trim>
values
<foreach
collection=
"records"
item=
"record"
index=
"index"
separator=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<include
refid=
"Batch_Insert_Values"
/>
</trim>
</foreach>
</insert>
<insert
id=
"batchInsertOnDuplicateKey"
parameterType=
"java.util.Map"
>
insert into
<include
refid=
"Table_Name"
/>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<include
refid=
"Base_Column_List"
/>
</trim>
values
<foreach
collection=
"records"
item=
"record"
index=
"index"
separator=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<include
refid=
"Batch_Insert_Values_On_DuplicateKey"
/>
</trim>
</foreach>
ON DUPLICATE KEY UPDATE
id = VALUES(id) , version = VALUES(version)
</insert>
<!-- end insert -->
<!-- delete -->
<delete
id=
"deleteById"
parameterType=
"java.util.Map"
>
delete from
<include
refid=
"Table_Name"
/>
where id = #{id,jdbcType=BIGINT}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"java.util.Map"
>
delete from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<delete
id=
"deleteIn"
parameterType=
"java.util.Map"
>
delete from
<include
refid=
"Table_Name"
/>
where id in
<foreach
collection=
"records"
item=
"record"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{record.id,jdbcType=BIGINT}
</foreach>
</delete>
<!-- end delete -->
<!-- update -->
<update
id=
"updateById"
parameterType=
"java.util.Map"
>
update
<include
refid=
"Table_Name"
/>
<set>
<include
refid=
"Update_Set_From_Bean"
/>
</set>
where id = #{record.id,jdbcType=BIGINT}
</update>
<update
id=
"updateByExample"
parameterType=
"java.util.Map"
>
update
<include
refid=
"Table_Name"
/>
<set>
<include
refid=
"Update_Set_From_Bean"
/>
</set>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</update>
<update
id=
"batchUpdate"
parameterType=
"java.util.Map"
>
<foreach
collection=
"records"
item=
"record"
index=
"index"
open=
""
close=
""
separator=
";"
>
update
<include
refid=
"Table_Name"
/>
<set>
<include
refid=
"Update_Set_From_Bean"
/>
</set>
where id=#{record.id,jdbcType=BIGINT}
</foreach>
</update>
<!-- end update -->
<!-- select -->
<select
id=
"selectById"
resultMap=
"SolidityVersionMap"
parameterType=
"java.util.Map"
>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"Table_Name"
/>
where id = #{id,jdbcType=BIGINT}
</select>
<select
id=
"selectByExample"
resultMap=
"SolidityVersionMap"
parameterType=
"java.util.Map"
>
select
<if
test=
"example != null and example.distinct"
>
distinct
</if>
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"example != null and example.orderByClause != null"
>
order by ${example.orderByClause}
</if>
</select>
<select
id=
"selectOneByExample"
resultMap=
"SolidityVersionMap"
parameterType=
"java.util.Map"
>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
limit 1
</select>
<select
id=
"selectIn"
resultMap=
"SolidityVersionMap"
parameterType=
"java.util.Map"
>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"Table_Name"
/>
where id IN
<foreach
collection=
"records"
item=
"record"
index=
"index"
open=
"("
separator=
","
close=
")"
>
#{record.id,jdbcType=BIGINT}
</foreach>
</select>
<select
id=
"countByExample"
resultType=
"java.lang.Integer"
parameterType=
"java.util.Map"
>
select count(*) as total from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<select
id=
"countByPager"
resultType=
"java.lang.Integer"
parameterType=
"java.util.Map"
>
select count(*) as total from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<select
id=
"selectByPager"
resultMap=
"SolidityVersionMap"
parameterType=
"java.util.Map"
>
select
<include
refid=
"Base_Column_List"
/>
from
<include
refid=
"Table_Name"
/>
<if
test=
"example != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"pager.sortItem != null and pager.sortItem != '' "
>
order by ${pager.sortItem} ${pager.sortType}
</if>
limit #{pager.startIndex} , #{pager.pageSize}
</select>
<!-- end select -->
<!-- My Custom Interfaces -->
</mapper>
src/test/java/com/wuban/tron/explore/service/impl/ContractComp
li
erServiceImplTest.java
→
src/test/java/com/wuban/tron/explore/service/impl/ContractComp
il
erServiceImplTest.java
View file @
46768dc1
package
com
.
wuban
.
tron
.
explore
.
service
.
impl
;
import
com.wuban.tron.explore.BaseTest
;
import
com.wuban.tron.explore.service.ContractComp
li
erService
;
import
com.wuban.tron.explore.service.ContractComp
il
erService
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
class
ContractComp
li
erServiceImplTest
extends
BaseTest
{
class
ContractComp
il
erServiceImplTest
extends
BaseTest
{
@Autowired
private
ContractComp
li
erService
contractComplierService
;
private
ContractComp
il
erService
contractComplierService
;
@BeforeEach
void
setUp
()
{
}
@Test
void
comp
li
er
()
{
void
comp
il
er
()
{
String
name
=
"Storage2"
;
String
comp
li
er
=
"solidity0.4.25+commit"
;
String
comp
il
er
=
"solidity0.4.25+commit"
;
String
value
=
"pragma solidity ^0.4.25;\n"
+
"\n"
+
"contract Storage2 {\n"
+
...
...
@@ -42,8 +42,8 @@ class ContractComplierServiceImplTest extends BaseTest {
" pos0 = val;\n"
+
" }\n"
+
"}"
;
String
str
=
this
.
contractComplierService
.
comp
lier
(
name
,
value
,
compli
er
);
System
.
out
.
println
(
"*************"
+
str
);
String
str
=
this
.
contractComplierService
.
comp
iler
(
name
,
value
,
compil
er
);
System
.
out
.
println
(
str
);
}
}
\ No newline at end of file
tron-explore.sql
View file @
46768dc1
...
...
@@ -4,7 +4,7 @@ Navicat MySQL Data Transfer
Source Server : 123.56.5.114.master
Source Server Version : 50731
Source Host : 123.56.5.114:13306
Source Database : t
est_tron
Source Database : t
ron-explore
Target Server Type : MYSQL
Target Server Version : 50731
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment