55import lombok .extern .slf4j .Slf4j ;
66import org .springframework .beans .factory .annotation .Autowired ;
77import org .springframework .stereotype .Component ;
8- import org .springframework .util .CollectionUtils ;
98import org .tron .api .GrpcAPI .AssetIssueList ;
10- import org .tron .api .GrpcAPI .NumberMessage ;
119import org .tron .api .GrpcAPI .TransactionList ;
1210import org .tron .api .GrpcAPI .WitnessList ;
1311import org .tron .common .utils .ByteArray ;
1412import org .tron .core .db .api .StoreAPI ;
15- import org .tron .core .exception .NonUniqueObjectException ;
1613import org .tron .protos .Contract .AssetIssueContract ;
17- import org .tron .protos .Protocol .Account ;
18- import org .tron .protos .Protocol .Block ;
1914import org .tron .protos .Protocol .Transaction ;
2015import org .tron .protos .Protocol .Witness ;
2116
@@ -26,17 +21,6 @@ public class WalletSolidity {
2621 @ Autowired
2722 private StoreAPI storeAPI ;
2823
29- public Account getAccount (ByteString addressBs ) {
30- Account accountByAddress = null ;
31- try {
32- accountByAddress = storeAPI
33- .getAccountByAddress (ByteArray .toHexString (addressBs .toByteArray ()));
34- } catch (NonUniqueObjectException e ) {
35- e .printStackTrace ();
36- }
37- return accountByAddress ;
38- }
39-
4024 public WitnessList getWitnessList () {
4125 List <Witness > witnessAll = storeAPI .getWitnessAll ();
4226 WitnessList witnessList = WitnessList .newBuilder ().addAllWitnesses (witnessAll ).build ();
@@ -50,81 +34,9 @@ public AssetIssueList getAssetIssueList() {
5034 return assetIssueList ;
5135 }
5236
53- public AssetIssueList getAssetIssueListByTimestamp (long timestamp ) {
54- List <AssetIssueContract > assetIssueAll = storeAPI .getAssetIssueByTime (timestamp );
55- AssetIssueList assetIssueList =
56- AssetIssueList .newBuilder ().addAllAssetIssue (assetIssueAll ).build ();
57- return assetIssueList ;
58- }
59-
60- public AssetIssueList getAssetIssueByAccount (ByteString address ) {
61- List <AssetIssueContract > assetIssueByOwnerAddress = storeAPI
62- .getAssetIssueByOwnerAddress (ByteArray .toHexString (address .toByteArray ()));
63- AssetIssueList assetIssueList =
64- AssetIssueList .newBuilder ().addAllAssetIssue (assetIssueByOwnerAddress ).build ();
65- return assetIssueList ;
66- }
67-
68- public AssetIssueContract getAssetIssueByName (ByteString name ) {
69- AssetIssueContract assetIssueByName = null ;
70- try {
71- assetIssueByName = storeAPI .getAssetIssueByName (name .toStringUtf8 ());
72- } catch (NonUniqueObjectException e ) {
73- e .printStackTrace ();
74- }
75- return assetIssueByName ;
76- }
77-
78- public Block getNowBlock () {
79- List <Block > latestBlocks = storeAPI .getLatestBlocks (1 );
80- if (CollectionUtils .isEmpty (latestBlocks )) {
81- return null ;
82- }
83- return latestBlocks .get (0 );
84- }
85-
86- public Block getBlockByNum (long num ) {
87- Block blockByNumber = null ;
88- try {
89- blockByNumber = storeAPI .getBlockByNumber (num );
90- } catch (NonUniqueObjectException e ) {
91- e .printStackTrace ();
92- }
93- return blockByNumber ;
94- }
95-
96- public NumberMessage totalTransaction () {
97- long transactionCount = storeAPI .getTransactionCount ();
98- return NumberMessage .newBuilder ().setNum (transactionCount ).build ();
99- }
100-
101- public Transaction getTransactionById (ByteString id ) {
102- try {
103- Transaction transactionById = storeAPI
104- .getTransactionById (ByteArray .toHexString (id .toByteArray ()));
105- return transactionById ;
106- } catch (NonUniqueObjectException e ) {
107- e .printStackTrace ();
108- }
109- return null ;
110- }
111-
112- public TransactionList getTransactionsByTimestamp (long beginTime , long endTime , long offset , long limit ) {
113- List <Transaction > transactionsByTimestamp = storeAPI
114- .getTransactionsByTimestamp (beginTime , endTime , offset , limit );
115- TransactionList transactionList = TransactionList .newBuilder ()
116- .addAllTransaction (transactionsByTimestamp ).build ();
117- return transactionList ;
118- }
119-
120- public NumberMessage getTransactionsByTimestampCount (long beginTime , long endTime ) {
121- return NumberMessage .newBuilder ().setNum (storeAPI
122- .getTransactionsByTimestampCount (beginTime , endTime )).build ();
123- }
124-
125- public TransactionList getTransactionsFromThis (ByteString thisAddress , long offset , long limit ) {
37+ public TransactionList getTransactionsFromThis (ByteString thisAddress , long offset , long limit ) {
12638 List <Transaction > transactionsFromThis = storeAPI
127- .getTransactionsFromThis (ByteArray .toHexString (thisAddress .toByteArray ()),offset , limit );
39+ .getTransactionsFromThis (ByteArray .toHexString (thisAddress .toByteArray ()), offset , limit );
12840 TransactionList transactionList = TransactionList .newBuilder ()
12941 .addAllTransaction (transactionsFromThis ).build ();
13042 return transactionList ;
@@ -137,11 +49,4 @@ public TransactionList getTransactionsToThis(ByteString toAddress, long offset,
13749 .addAllTransaction (transactionsToThis ).build ();
13850 return transactionList ;
13951 }
140- public NumberMessage getTransactionFromThisCount (ByteString toAddress ) {
141- return NumberMessage .newBuilder ().setNum (storeAPI .getTransactionsFromThisCount (ByteArray .toHexString (toAddress .toByteArray ()))).build ();
142- }
143-
144- public NumberMessage getTransactionToThisCount (ByteString toAddress ) {
145- return NumberMessage .newBuilder ().setNum (storeAPI .getTransactionsToThisCount (ByteArray .toHexString (toAddress .toByteArray ()))).build ();
146- }
14752}
0 commit comments