Skip to content

Commit 1559a3f

Browse files
added support for txsToken with contract address too
1 parent cafcdff commit 1559a3f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/main/java/io/api/etherscan/core/IAccountApi.java

+19
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ public interface IAccountApi {
110110
@NotNull
111111
List<TxToken> txsToken(String address) throws ApiException;
112112

113+
/**
114+
* All ERC-20 token txs for given address and contract address
115+
*
116+
* @param address get txs for
117+
* @param contractAddress contract address to get txs for
118+
* @param startBlock tx from this blockNumber
119+
* @param endBlock tx to this blockNumber
120+
* @return txs for address
121+
* @throws ApiException parent exception class
122+
*/
123+
@NotNull
124+
List<TxToken> txsToken(String address, String contractAddress, long startBlock, long endBlock) throws ApiException;
125+
126+
@NotNull
127+
List<TxToken> txsToken(String address, String contractAddress, long startBlock) throws ApiException;
128+
129+
@NotNull
130+
List<TxToken> txsToken(String address, String contractAddress) throws ApiException;
131+
113132
/**
114133
* All ERC-721 (NFT) token txs for given address
115134
*

src/main/java/io/api/etherscan/core/impl/AccountApiProvider.java

+26
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,32 @@ public List<TxToken> txsToken(final String address, final long startBlock, final
230230
return getRequestUsingOffset(urlParams, TxTokenResponseTO.class);
231231
}
232232

233+
@NotNull
234+
@Override
235+
public List<TxToken> txsToken(final String address, final String contractAddress) throws ApiException {
236+
return txsToken(address, contractAddress, MIN_START_BLOCK);
237+
}
238+
239+
@NotNull
240+
@Override
241+
public List<TxToken> txsToken(final String address, final String contractAddress, final long startBlock) throws ApiException {
242+
return txsToken(address, contractAddress, startBlock, MAX_END_BLOCK);
243+
}
244+
245+
@NotNull
246+
@Override
247+
public List<TxToken> txsToken(final String address, final String contractAddress, final long startBlock, final long endBlock) throws ApiException {
248+
BasicUtils.validateAddress(address);
249+
final BlockParam blocks = BasicUtils.compensateBlocks(startBlock, endBlock);
250+
251+
final String offsetParam = PAGE_PARAM + "%s" + OFFSET_PARAM + OFFSET_MAX;
252+
final String blockParam = START_BLOCK_PARAM + blocks.start() + END_BLOCK_PARAM + blocks.end();
253+
final String urlParams = ACT_TX_TOKEN_ACTION + offsetParam + ADDRESS_PARAM + address
254+
+ CONTRACT_PARAM + contractAddress + blockParam + SORT_ASC_PARAM;
255+
256+
return getRequestUsingOffset(urlParams, TxTokenResponseTO.class);
257+
}
258+
233259
@NotNull
234260
@Override
235261
public List<TxToken> txsNftToken(String address) throws ApiException {

0 commit comments

Comments
 (0)