Updated on 2026-08-14
This commit is contained in:
parent
ba0b69b263
commit
2d170ae61c
8 changed files with 39 additions and 79 deletions
|
|
@ -14,12 +14,12 @@ import retrofit2.http.Query;
|
|||
|
||||
public interface BlockcypherApi {
|
||||
@GET(Server.ApiBlockcypher.Method.MAIN)
|
||||
Call<BlockcypherFee> blockcypherMain();
|
||||
Call<BlockcypherFee> blockcypherMain(@Path("blockchain") String blockchain);
|
||||
|
||||
@GET(Server.ApiBlockcypher.Method.ADDRESS)
|
||||
Call<BlockcypherResponse> blockcypherAddress(@Path("address") String address);
|
||||
Call<BlockcypherResponse> blockcypherAddress(@Path("blockchain") String blockchain, @Path("address") String address);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST(Server.ApiBlockcypher.Method.PUSH)
|
||||
Call<BlockcypherResponse> blockcypherPush(@Body BlockcypherBody blockcypherBody, @Query("token") String token);
|
||||
Call<BlockcypherResponse> blockcypherPush(@Path("blockchain") String blockchain, @Body BlockcypherBody blockcypherBody, @Query("token") String token);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import retrofit2.http.Headers;
|
|||
import retrofit2.http.Query;
|
||||
|
||||
public interface CoinmarketApi {
|
||||
@Headers("X-CMC_PRO_API_KEY: 7850b957-6943-42eb-af73-8d536dd8f73e")
|
||||
@Headers("X-CMC_PRO_API_KEY: f6622117-c043-47a0-8975-9d673ce484de")
|
||||
@GET(Server.ApiCoinmarket.Method.PRICE_CONVERSION)
|
||||
Call<RateInfoResponse> getRateInfo(@Query("amount") int amount, @Query("symbol") String cryptoId);
|
||||
}
|
||||
|
|
@ -67,6 +67,10 @@ public class Server {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://dex.binance.org/
|
||||
*/
|
||||
|
||||
public static class ApiBinance {
|
||||
public static final String URL_BINANCE = ServerURL.API_BINANCE;
|
||||
|
||||
|
|
@ -75,6 +79,10 @@ public class Server {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://testnet-dex.binance.org/
|
||||
*/
|
||||
|
||||
public static class ApiBinanceTestnet {
|
||||
public static final String URL_BINANCE_TESTNET = ServerURL.API_BINANCE_TESTNET;
|
||||
|
||||
|
|
@ -83,12 +91,16 @@ public class Server {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://api.blockcypher.com/
|
||||
*/
|
||||
|
||||
public static class ApiBlockcypher {
|
||||
public static final String URL_BLOCKCYPHER = ServerURL.API_BLOCKCYPHER;
|
||||
static final String V1_BTC_MAIN = "v1/btc/main";
|
||||
static final String V1_MAIN = "v1/{blockchain}/main";
|
||||
|
||||
public static class Method {
|
||||
static final String MAIN = URL_BLOCKCYPHER + V1_BTC_MAIN;
|
||||
static final String MAIN = URL_BLOCKCYPHER + V1_MAIN;
|
||||
static final String ADDRESS = MAIN + "/addrs/{address}?unspentOnly=true&includeScript=true";
|
||||
static final String PUSH = MAIN + "/txs/push";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,13 +42,14 @@ public class ServerApiBlockcypher {
|
|||
responseListener = listener;
|
||||
}
|
||||
|
||||
public void requestData(String method, String wallet, String tx) {
|
||||
public void requestData(String blockchainID, String method, String wallet, String tx) {
|
||||
requestsCount++;
|
||||
String blockchain = blockchainID.toLowerCase();
|
||||
BlockcypherApi blockcypherApi = App.Companion.getNetworkComponent().getRetrofitBlockcypher().create(BlockcypherApi.class);
|
||||
|
||||
switch (method) {
|
||||
case BLOCKCYPHER_ADDRESS:
|
||||
Call<BlockcypherResponse> addressCall = blockcypherApi.blockcypherAddress(wallet);
|
||||
Call<BlockcypherResponse> addressCall = blockcypherApi.blockcypherAddress(blockchain, wallet);
|
||||
addressCall.enqueue(new Callback<BlockcypherResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BlockcypherResponse> call, @NonNull Response<BlockcypherResponse> response) {
|
||||
|
|
@ -71,7 +72,7 @@ public class ServerApiBlockcypher {
|
|||
break;
|
||||
|
||||
case BLOCKCYPHER_FEE:
|
||||
Call<BlockcypherFee> feeCall = blockcypherApi.blockcypherMain();
|
||||
Call<BlockcypherFee> feeCall = blockcypherApi.blockcypherMain(blockchain);
|
||||
feeCall.enqueue(new Callback<BlockcypherFee>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BlockcypherFee> call, @NonNull Response<BlockcypherFee> response) {
|
||||
|
|
@ -96,7 +97,7 @@ public class ServerApiBlockcypher {
|
|||
case BLOCKCYPHER_SEND:
|
||||
BlockcypherToken blockcypherToken = BlockcypherToken.values()[new Random().nextInt(BlockcypherToken.values().length)];
|
||||
|
||||
Call<BlockcypherResponse> sendCall = blockcypherApi.blockcypherPush(new BlockcypherBody(tx), blockcypherToken.getToken());
|
||||
Call<BlockcypherResponse> sendCall = blockcypherApi.blockcypherPush(blockchain, new BlockcypherBody(tx), blockcypherToken.getToken());
|
||||
sendCall.enqueue(new Callback<BlockcypherResponse>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<BlockcypherResponse> call, @NonNull Response<BlockcypherResponse> response) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tangem.data.network;
|
|||
|
||||
class ServerURL {
|
||||
static final String API_TANGEM = "https://verify.tangem.com/";
|
||||
static final String API_COINMARKETCAP = "https://sandbox-api.coinmarketcap.com/"; //TODO: change to "https://pro-api.coinmarketcap.com/" for production environment
|
||||
static final String API_COINMARKETCAP = "https://pro-api.coinmarketcap.com/"; //TODO: change to "https://pro-api.coinmarketcap.com/" for production environment
|
||||
static final String API_INFURA = "https://mainnet.infura.io/";
|
||||
static final String API_ESTIMATEFEE = "https://estimatefee.com/";
|
||||
static final String API_UPDATE_VERSION = "https://raw.githubusercontent.com/";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue