Skip to content

Commit b123e74

Browse files
committed
more tests, more endpoints
1 parent 7670e88 commit b123e74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1313
-50
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ project build.gradle
2424
```groovy
2525
2626
ext {
27-
minterBlockchainSDK = "0.4.0"
27+
minterBlockchainSDK = "0.5.0"
2828
}
2929
3030
dependencies {

RELEASE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
- Create multisig address (transaction for creating multisignature address)
99
- Multisend (single transaction for sending coins to multiple addresses)
1010
- Edit candidate (transaction for editing existing candidate)
11-
- Added network "status" endpoint to repositories
11+
- Added missing endpoints and repositories
12+
- More tests (still without mocks. Soon...)
1213

1314

1415
## 0.4.0

scripts

src/androidTest/java/network/minter/blockchain/models/BaseApiTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.junit.Before;
3333

3434
import network.minter.core.MinterSDK;
35+
import network.minter.core.internal.exceptions.NativeLoadException;
3536
import network.minter.core.internal.log.Mint;
3637
import network.minter.core.internal.log.StdLogger;
3738

@@ -42,7 +43,11 @@
4243
public class BaseApiTest {
4344

4445
static {
45-
MinterSDK.initialize();
46+
try {
47+
MinterSDK.initialize();
48+
} catch (NativeLoadException e) {
49+
e.printStackTrace();
50+
}
4651
//noinspection ConstantConditions
4752
Mint.brew(new StdLogger());
4853
}

src/main/java/network/minter/blockchain/MinterBlockChainApi.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,22 @@
3333
import javax.annotation.Nonnull;
3434

3535
import network.minter.blockchain.repo.BlockChainAccountRepository;
36+
import network.minter.blockchain.repo.BlockChainBlockRepository;
37+
import network.minter.blockchain.repo.BlockChainCandidateRepository;
3638
import network.minter.blockchain.repo.BlockChainCoinRepository;
39+
import network.minter.blockchain.repo.BlockChainEventRepository;
40+
import network.minter.blockchain.repo.BlockChainStatusRepository;
3741
import network.minter.blockchain.repo.BlockChainTransactionRepository;
3842
import network.minter.core.crypto.BytesData;
3943
import network.minter.core.crypto.MinterAddress;
4044
import network.minter.core.crypto.MinterHash;
45+
import network.minter.core.crypto.MinterPublicKey;
4146
import network.minter.core.internal.api.ApiService;
4247
import network.minter.core.internal.api.converters.BigIntegerDeserializer;
4348
import network.minter.core.internal.api.converters.BytesDataDeserializer;
4449
import network.minter.core.internal.api.converters.MinterAddressDeserializer;
4550
import network.minter.core.internal.api.converters.MinterHashDeserializer;
51+
import network.minter.core.internal.api.converters.MinterPublicKeyDeserializer;
4652
import network.minter.core.internal.log.Mint;
4753
import network.minter.core.internal.log.TimberLogger;
4854
import okhttp3.logging.HttpLoggingInterceptor;
@@ -58,6 +64,10 @@ public class MinterBlockChainApi {
5864
private BlockChainAccountRepository mAccountRepository;
5965
private BlockChainCoinRepository mCoinRepository;
6066
private BlockChainTransactionRepository mTransactionRepository;
67+
private BlockChainBlockRepository mBlockRepository;
68+
private BlockChainCandidateRepository mBlockChainCandidateRepository;
69+
private BlockChainStatusRepository mStatusRepository;
70+
private BlockChainEventRepository mEventRepository;
6171

6272
private MinterBlockChainApi() {
6373
this(BASE_NODE_URL);
@@ -93,6 +103,10 @@ public static void initialize(boolean debug) {
93103
initialize(BASE_NODE_URL, debug, new TimberLogger());
94104
}
95105

106+
public static void initialize(String baseNodeApiUrl) {
107+
initialize(baseNodeApiUrl, false, new TimberLogger());
108+
}
109+
96110
public static MinterBlockChainApi getInstance() {
97111
return INSTANCE;
98112
}
@@ -103,10 +117,43 @@ public GsonBuilder getGsonBuilder() {
103117
out.registerTypeAdapter(MinterHash.class, new MinterHashDeserializer());
104118
out.registerTypeAdapter(BigInteger.class, new BigIntegerDeserializer());
105119
out.registerTypeAdapter(BytesData.class, new BytesDataDeserializer());
120+
out.registerTypeAdapter(MinterPublicKey.class, new MinterPublicKeyDeserializer());
106121

107122
return out;
108123
}
109124

125+
public BlockChainEventRepository event() {
126+
if (mEventRepository == null) {
127+
mEventRepository = new BlockChainEventRepository(mApiService);
128+
}
129+
130+
return mEventRepository;
131+
}
132+
133+
public BlockChainStatusRepository status() {
134+
if (mStatusRepository == null) {
135+
mStatusRepository = new BlockChainStatusRepository(mApiService);
136+
}
137+
138+
return mStatusRepository;
139+
}
140+
141+
public BlockChainCandidateRepository candidate() {
142+
if (mBlockChainCandidateRepository == null) {
143+
mBlockChainCandidateRepository = new BlockChainCandidateRepository(mApiService);
144+
}
145+
146+
return mBlockChainCandidateRepository;
147+
}
148+
149+
public BlockChainBlockRepository block() {
150+
if (mBlockRepository == null) {
151+
mBlockRepository = new BlockChainBlockRepository(mApiService);
152+
}
153+
154+
return mBlockRepository;
155+
}
156+
110157
public BlockChainAccountRepository account() {
111158
if (mAccountRepository == null) {
112159
mAccountRepository = new BlockChainAccountRepository(mApiService);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package network.minter.blockchain.api;
2+
3+
import network.minter.blockchain.models.BCResult;
4+
import network.minter.blockchain.models.BlockInfo;
5+
import retrofit2.Call;
6+
import retrofit2.http.GET;
7+
import retrofit2.http.Query;
8+
9+
/**
10+
* minter-android-blockchain. 2019
11+
* @author Eduard Maximovich [edward.vstock@gmail.com]
12+
*/
13+
public interface BlockChainBlockEndpoint {
14+
15+
@GET("/block")
16+
Call<BCResult<BlockInfo>> getByHeight(@Query("height") long height);
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package network.minter.blockchain.api;
2+
3+
import java.util.List;
4+
5+
import network.minter.blockchain.models.BCResult;
6+
import network.minter.blockchain.models.CandidateItem;
7+
import network.minter.blockchain.models.CandidateStatus;
8+
import retrofit2.Call;
9+
import retrofit2.http.GET;
10+
import retrofit2.http.Query;
11+
12+
/**
13+
* minter-android-blockchain. 2019
14+
* @author Eduard Maximovich [edward.vstock@gmail.com]
15+
*/
16+
public interface BlockChainCandidateEndpoint {
17+
18+
@GET("/candidate")
19+
Call<BCResult<CandidateItem>> getCandidate(@Query("pubkey") String pubKey);
20+
21+
@GET("/candidate")
22+
Call<BCResult<CandidateItem>> getCandidate(@Query("pubkey") String pubKey, long blockHeight);
23+
24+
@GET("/candidates")
25+
Call<BCResult<List<CandidateStatus>>> getCandidates(@Query("height") long blockHeight);
26+
}

src/main/java/network/minter/blockchain/api/BlockChainCoinEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public interface BlockChainCoinEndpoint {
5858
* @param coinToBuy coin to convert to
5959
* @return
6060
*/
61-
@GET("/api/estimate_coin_sell")
61+
@GET("/estimate_coin_sell")
6262
Call<BCResult<ExchangeSellValue>> getCoinExchangeCurrencyToSell(
6363
@Query("coin_to_sell") String coinToSell,
6464
@Query("value_to_sell") String valueToSell,
@@ -73,7 +73,7 @@ Call<BCResult<ExchangeSellValue>> getCoinExchangeCurrencyToSell(
7373
* @param coinToBuy coin to convert to
7474
* @return
7575
*/
76-
@GET("/api/estimate_coin_buy")
76+
@GET("/estimate_coin_buy")
7777
Call<BCResult<ExchangeBuyValue>> getCoinExchangeCurrencyToBuy(
7878
@Query("coin_to_sell") String coinToSell,
7979
@Query("value_to_buy") String valueToBuy,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package network.minter.blockchain.api;
2+
3+
import network.minter.blockchain.models.BCResult;
4+
import network.minter.blockchain.models.EventList;
5+
import retrofit2.Call;
6+
import retrofit2.http.GET;
7+
import retrofit2.http.Query;
8+
9+
/**
10+
* minter-android-blockchain. 2019
11+
* @author Eduard Maximovich [edward.vstock@gmail.com]
12+
*/
13+
public interface BlockChainEventEndpoint {
14+
15+
@GET("/events")
16+
Call<BCResult<EventList>> getByHeight(@Query("height") long height);
17+
}

src/main/java/network/minter/blockchain/api/BlockChainStatusEndpoint.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
package network.minter.blockchain.api;
2828

29+
import java.util.List;
30+
2931
import network.minter.blockchain.models.BCResult;
3032
import network.minter.blockchain.models.NetworkStatus;
3133
import retrofit2.Call;
@@ -37,6 +39,9 @@
3739
*/
3840
public interface BlockChainStatusEndpoint {
3941

40-
@GET("status")
42+
@GET("/status")
4143
Call<BCResult<NetworkStatus>> status();
44+
45+
@GET("/validators")
46+
Call<BCResult<List<NetworkStatus.Validator>>> validators();
4247
}

0 commit comments

Comments
 (0)