Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64f9db3

Browse files
authored
Merge pull request#14 from GoodforGod/dev
[1.2.0]
2 parents2969dc1 +6f359b5 commit64f9db3

File tree

7 files changed

+132
-5
lines changed

7 files changed

+132
-5
lines changed

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ sonarqube {
3636

3737
dependencies {
3838
implementation"org.jetbrains:annotations:22.0.0"
39-
implementation"com.google.code.gson:gson:2.8.8"
39+
implementation"com.google.code.gson:gson:2.8.9"
4040

4141
testImplementation"junit:junit:4.13.1"
4242
}

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
groupId=com.github.goodforgod
22
artifactId=java-etherscan-api
3-
artifactVersion=1.1.1
3+
artifactVersion=1.2.0
44
buildNumber=1
55

66

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public interface IAccountApi {
9393
List<TxInternal>txsInternalByHash(Stringtxhash)throwsApiException;
9494

9595
/**
96-
* All token txs for given address
96+
* AllERC-20token txs for given address
9797
*
9898
* @param address get txs for
9999
* @param startBlock tx from this blockNumber
@@ -110,6 +110,24 @@ public interface IAccountApi {
110110
@NotNull
111111
List<TxToken>txsToken(Stringaddress)throwsApiException;
112112

113+
/**
114+
* All ERC-721 (NFT) token txs for given address
115+
*
116+
* @param address get txs for
117+
* @param startBlock tx from this blockNumber
118+
* @param endBlock tx to this blockNumber
119+
* @return txs for address
120+
* @throws ApiException parent exception class
121+
*/
122+
@NotNull
123+
List<TxToken>txsNftToken(Stringaddress,longstartBlock,longendBlock)throwsApiException;
124+
125+
@NotNull
126+
List<TxToken>txsNftToken(Stringaddress,longstartBlock)throwsApiException;
127+
128+
@NotNull
129+
List<TxToken>txsNftToken(Stringaddress)throwsApiException;
130+
113131
/**
114132
* All blocks mined by address
115133
*

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class AccountApiProvider extends BasicProvider implements IAccountApi {
3434
privatestaticfinalStringACT_TX_ACTION =ACT_PREFIX +"txlist";
3535
privatestaticfinalStringACT_TX_INTERNAL_ACTION =ACT_PREFIX +"txlistinternal";
3636
privatestaticfinalStringACT_TX_TOKEN_ACTION =ACT_PREFIX +"tokentx";
37+
privatestaticfinalStringACT_TX_NFT_TOKEN_ACTION =ACT_PREFIX +"tokennfttx";
3738
privatestaticfinalStringACT_MINED_ACTION =ACT_PREFIX +"getminedblocks";
3839

3940
privatestaticfinalStringBLOCK_TYPE_PARAM ="&blocktype=blocks";
@@ -229,6 +230,31 @@ public List<TxToken> txsToken(final String address, final long startBlock, final
229230
returngetRequestUsingOffset(urlParams,TxTokenResponseTO.class);
230231
}
231232

233+
@NotNull
234+
@Override
235+
publicList<TxToken>txsNftToken(Stringaddress)throwsApiException {
236+
returntxsNftToken(address,MIN_START_BLOCK);
237+
}
238+
239+
@NotNull
240+
@Override
241+
publicList<TxToken>txsNftToken(Stringaddress,longstartBlock)throwsApiException {
242+
returntxsNftToken(address,startBlock,MAX_END_BLOCK);
243+
}
244+
245+
@NotNull
246+
@Override
247+
publicList<TxToken>txsNftToken(Stringaddress,longstartBlock,longendBlock)throwsApiException {
248+
BasicUtils.validateAddress(address);
249+
finalBlockParamblocks =BasicUtils.compensateBlocks(startBlock,endBlock);
250+
251+
finalStringoffsetParam =PAGE_PARAM +"%s" +OFFSET_PARAM +OFFSET_MAX;
252+
finalStringblockParam =START_BLOCK_PARAM +blocks.start() +END_BLOCK_PARAM +blocks.end();
253+
finalStringurlParams =ACT_TX_NFT_TOKEN_ACTION +offsetParam +ADDRESS_PARAM +address +blockParam +SORT_ASC_PARAM;
254+
255+
returngetRequestUsingOffset(urlParams,TxTokenResponseTO.class);
256+
}
257+
232258
@NotNull
233259
@Override
234260
publicList<Block>minedBlocks(finalStringaddress)throwsApiException {

‎src/main/java/io/api/etherscan/manager/impl/QueueManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
publicclassQueueManagerimplementsIQueueManager,AutoCloseable {
1616

17-
publicstaticfinalQueueManagerDEFAULT_KEY_QUEUE =newQueueManager(1,7);
17+
publicstaticfinalQueueManagerDEFAULT_KEY_QUEUE =newQueueManager(1,5200L,5200L,0);
1818
publicstaticfinalQueueManagerPERSONAL_KEY_QUEUE =newQueueManager(5,1100L,1100L,5);
1919

2020
privatefinalScheduledExecutorServiceexecutorService =Executors.newSingleThreadScheduledExecutor();

‎src/test/java/io/api/ApiRunner.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public class ApiRunner extends Assert {
2020
?EtherScanApi.DEFAULT_KEY
2121
:key;
2222

23-
finalQueueManagerqueueManager =newQueueManager(1,1200L,1200L,0);
23+
finalQueueManagerqueueManager = (EtherScanApi.DEFAULT_KEY.equals(apiKey))
24+
?QueueManager.DEFAULT_KEY_QUEUE
25+
:newQueueManager(1,1200L,1200L,0);
26+
2427
api =newEtherScanApi(ApiRunner.apiKey,EthNetwork.MAINNET,queueManager);
2528
apiKovan =newEtherScanApi(ApiRunner.apiKey,EthNetwork.KOVAN,queueManager);
2629
apiRopsten =newEtherScanApi(ApiRunner.apiKey,EthNetwork.ROPSTEN,queueManager);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
packageio.api.etherscan.account;
2+
3+
importio.api.ApiRunner;
4+
importio.api.etherscan.error.InvalidAddressException;
5+
importio.api.etherscan.model.TxToken;
6+
importorg.junit.Test;
7+
8+
importjava.util.List;
9+
10+
/**
11+
* @author NGuggs
12+
* @since 11.28.2021
13+
*/
14+
publicclassAccountTxRc721TokenTestextendsApiRunner {
15+
16+
@Test
17+
publicvoidcorrect() {
18+
List<TxToken>txs =getApi().account().txsNftToken("0x1a1ebe0d86f72884c3fd484ae1e796e08f8ffa67");
19+
assertNotNull(txs);
20+
assertEquals(16,txs.size());
21+
assertTxs(txs);
22+
assertNotEquals(0,txs.get(0).getGasPrice());
23+
assertNotEquals(-1,txs.get(0).getNonce());
24+
25+
assertNotNull(txs.get(0).toString());
26+
assertNotEquals(txs.get(0).toString(),txs.get(1).toString());
27+
28+
assertNotEquals(txs.get(0),txs.get(1));
29+
assertNotEquals(txs.get(0).hashCode(),txs.get(1).hashCode());
30+
31+
assertEquals(txs.get(1),txs.get(1));
32+
assertEquals(txs.get(1).hashCode(),txs.get(1).hashCode());
33+
}
34+
35+
@Test
36+
publicvoidcorrectStartBlock() {
37+
List<TxToken>txs =getApi().account().txsNftToken("0x1a1ebe0d86f72884c3fd484ae1e796e08f8ffa67",4762071);
38+
System.out.println(txs);
39+
assertNotNull(txs);
40+
assertEquals(5,txs.size());
41+
assertTxs(txs);
42+
}
43+
44+
@Test
45+
publicvoidcorrectStartBlockEndBlock() {
46+
List<TxToken>txs =getApi().account().txsNftToken("0x1a1ebe0d86f72884c3fd484ae1e796e08f8ffa67",4761862,4761934);
47+
System.out.println(txs);
48+
assertNotNull(txs);
49+
assertEquals(11,txs.size());
50+
assertTxs(txs);
51+
}
52+
53+
@Test(expected =InvalidAddressException.class)
54+
publicvoidinvalidParamWithError() {
55+
getApi().account().txsNftToken("0x6ec53A8fBa6358d59B3C4476D82cc60A2B0FaD7");
56+
}
57+
58+
@Test
59+
publicvoidcorrectParamWithEmptyExpectedResult() {
60+
List<TxToken>txs =getApi().account().txsNftToken("0x31ec53A8fBa6358d59B3C4476D82cc60A2B0FaD7");
61+
assertNotNull(txs);
62+
assertTrue(txs.isEmpty());
63+
}
64+
65+
privatevoidassertTxs(List<TxToken>txs) {
66+
for (TxTokentx :txs) {
67+
assertNotNull(tx.getBlockHash());
68+
assertNotNull(tx.getTokenName());
69+
assertNotNull(tx.getTokenSymbol());
70+
assertNotNull(tx.getFrom());
71+
assertNotNull(tx.getTo());
72+
assertNotNull(tx.getTimeStamp());
73+
assertNotNull(tx.getTokenDecimal());
74+
assertNotEquals(-1, (tx.getConfirmations()));
75+
assertNotNull(tx.getGasUsed());
76+
assertNotEquals(-1,tx.getCumulativeGasUsed());
77+
assertNotEquals(-1,tx.getTransactionIndex());
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp