@@ -45,7 +45,7 @@ public class ProxyApiProvider extends BasicProvider implements IProxyApi {
45
45
private static final String ACT_ESTIMATEGAS_PARAM = ACT_PREFIX + "eth_estimateGas" ;
46
46
47
47
private static final String BOOLEAN_PARAM = "&boolean=true" ;
48
- private static final String TAG_LAST_PARAM = "&tag=lastest " ;
48
+ private static final String TAG_LAST_PARAM = "&tag=latest " ;
49
49
private static final String POSITION_PARAM = "&position=" ;
50
50
private static final String ADDRESS_PARAM = "&address=" ;
51
51
private static final String TXHASH_PARAM = "&txhash=" ;
@@ -67,7 +67,7 @@ public long blockNoLast() throws ApiException {
67
67
final StringProxyTO response = getRequest (ACT_BLOCKNO_PARAM , StringProxyTO .class );
68
68
return (BasicUtils .isEmpty (response .getResult ()))
69
69
? -1
70
- : BasicUtils .parseHex (response .getResult ());
70
+ : BasicUtils .parseHex (response .getResult ()). longValue () ;
71
71
}
72
72
73
73
@ NotNull
@@ -105,19 +105,19 @@ public Optional<TxProxy> tx(final String txhash) throws ApiException {
105
105
@ Override
106
106
public Optional <TxProxy > tx (final long blockNo , final long index ) throws ApiException {
107
107
final long compBlockNo = BasicUtils .compensateMinBlock (blockNo );
108
- final long compIndex = BasicUtils . compensateMinBlock (index ) ;
108
+ final long compIndex = (index < 1 ) ? 1 : index ;
109
109
110
- final String urlParams = ACT_TX_BY_BLOCKNOINDEX_PARAM + TAG_PARAM + compBlockNo + INDEX_PARAM + compIndex ;
110
+ final String urlParams = ACT_TX_BY_BLOCKNOINDEX_PARAM + TAG_PARAM + compBlockNo + INDEX_PARAM + "0x" + Long . toHexString ( compIndex ) ;
111
111
final TxProxyTO response = getRequest (urlParams , TxProxyTO .class );
112
112
return Optional .ofNullable (response .getResult ());
113
113
}
114
114
115
115
@ Override
116
116
public int txCount (final long blockNo ) throws ApiException {
117
117
final long compensatedBlockNo = BasicUtils .compensateMinBlock (blockNo );
118
- final String urlParams = ACT_BLOCKTX_COUNT_PARAM + TAG_PARAM + compensatedBlockNo ;
118
+ final String urlParams = ACT_BLOCKTX_COUNT_PARAM + TAG_PARAM + "0x" + Long . toHexString ( compensatedBlockNo ) ;
119
119
final StringProxyTO response = getRequest (urlParams , StringProxyTO .class );
120
- return Integer . valueOf (response .getResult ());
120
+ return BasicUtils . parseHex (response .getResult ()). intValue ( );
121
121
}
122
122
123
123
@ Override
@@ -126,7 +126,7 @@ public int txSendCount(final String address) throws ApiException {
126
126
127
127
final String urlParams = ACT_TX_COUNT_PARAM + ADDRESS_PARAM + address + TAG_LAST_PARAM ;
128
128
final StringProxyTO response = getRequest (urlParams , StringProxyTO .class );
129
- return ( int ) BasicUtils .parseHex (response .getResult ());
129
+ return BasicUtils .parseHex (response .getResult ()). intValue ( );
130
130
}
131
131
132
132
@ Override
@@ -160,6 +160,8 @@ public Optional<TxInfoProxy> txReceipt(final String txhash) throws ApiException
160
160
@ Override
161
161
public Optional <String > call (final String address , final String data ) throws ApiException {
162
162
BasicUtils .validateAddress (address );
163
+ if (BasicUtils .isNotHex (data ))
164
+ throw new InvalidDataHexException ("Data is not hex encoded." );
163
165
164
166
final String urlParams = ACT_CALL_PARAM + TO_PARAM + address + DATA_PARAM + data + TAG_LAST_PARAM ;
165
167
final StringProxyTO response = getRequest (urlParams , StringProxyTO .class );
@@ -199,7 +201,7 @@ public BigInteger gasPrice() throws ApiException {
199
201
final StringProxyTO response = getRequest (ACT_GASPRICE_PARAM , StringProxyTO .class );
200
202
return (BasicUtils .isEmpty (response .getResult ()))
201
203
? BigInteger .valueOf (-1 )
202
- : BigInteger . valueOf ( BasicUtils .parseHex (response .getResult () ));
204
+ : BasicUtils .parseHex (response .getResult ());
203
205
}
204
206
205
207
@ NotNull
@@ -211,13 +213,13 @@ public BigInteger gasEstimated() throws ApiException {
211
213
@ NotNull
212
214
@ Override
213
215
public BigInteger gasEstimated (final String hexData ) throws ApiException {
214
- if (BasicUtils .isNotHex (hexData ))
216
+ if (! BasicUtils . isEmpty ( hexData ) && BasicUtils .isNotHex (hexData ))
215
217
throw new InvalidDataHexException ("Data is not in hex format." );
216
218
217
219
final String urlParams = ACT_ESTIMATEGAS_PARAM + DATA_PARAM + hexData + GAS_PARAM + "2000000000000000" ;
218
220
final StringProxyTO response = getRequest (urlParams , StringProxyTO .class );
219
221
return (BasicUtils .isEmpty (response .getResult ()))
220
222
? BigInteger .valueOf (-1 )
221
- : BigInteger . valueOf ( BasicUtils .parseHex (response .getResult () ));
223
+ : BasicUtils .parseHex (response .getResult ());
222
224
}
223
225
}
0 commit comments