From 5a5c15ee23c5a47e73410b69481adb2b0d0a7d75 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 11 Oct 2018 13:26:25 +0300 Subject: [PATCH] Updated on 2026-08-14 --- app/build.gradle | 2 +- .../com/tangem/data/network/TangemApi.java | 7 - .../tangem/data/network/UpdateVersionApi.java | 6 - .../data/network/model/CardVerifyBody.java | 10 - .../data/network/model/CardVerifyResponse.kt | 18 -- .../data/network/request/ExchangeRequest.java | 92 -------- .../data/network/request/FeeRequest.java | 101 --------- .../data/network/request/InfuraRequest.java | 200 ------------------ .../request/VerificationServerProtocol.java | 191 ----------------- 9 files changed, 1 insertion(+), 626 deletions(-) delete mode 100644 app/src/main/java/com/tangem/data/network/model/CardVerifyBody.java delete mode 100644 app/src/main/java/com/tangem/data/network/model/CardVerifyResponse.kt delete mode 100644 app/src/main/java/com/tangem/data/network/request/ExchangeRequest.java delete mode 100644 app/src/main/java/com/tangem/data/network/request/FeeRequest.java delete mode 100644 app/src/main/java/com/tangem/data/network/request/InfuraRequest.java delete mode 100644 app/src/main/java/com/tangem/data/network/request/VerificationServerProtocol.java diff --git a/app/build.gradle b/app/build.gradle index 9827f25411..e16d5c4fa8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { applicationId "com.tangem.wallet" minSdkVersion 21 targetSdkVersion 27 - versionCode 86 + versionCode 87 versionName "0.89.2." + generateVersionName() testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/tangem/data/network/TangemApi.java b/app/src/main/java/com/tangem/data/network/TangemApi.java index 7fd96c51a9..3a17e33874 100644 --- a/app/src/main/java/com/tangem/data/network/TangemApi.java +++ b/app/src/main/java/com/tangem/data/network/TangemApi.java @@ -1,8 +1,6 @@ package com.tangem.data.network; import com.tangem.data.network.model.CardVerifyAndGetInfo; -import com.tangem.data.network.model.CardVerifyBody; -import com.tangem.data.network.model.CardVerifyResponse; import okhttp3.ResponseBody; import retrofit2.Call; @@ -13,10 +11,6 @@ import retrofit2.http.POST; import retrofit2.http.Query; public interface TangemApi { - @Headers("Content-Type: application/json") - @POST(Server.ApiTangem.Method.VERIFY) - Call getCardVerify(@Body CardVerifyBody body); - @Headers("Content-Type: application/json") @POST(Server.ApiTangem.Method.VERIFY_AND_GET_INFO) Call getCardVerifyAndGetInfo(@Body CardVerifyAndGetInfo.Request requestBody); @@ -24,5 +18,4 @@ public interface TangemApi { @GET(Server.ApiTangem.Method.ARTWORK) Call getArtwork(@Query("artworkId") String artworkId, @Query("CID") String CID, @Query("publicKey") String publicKey); - } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/data/network/UpdateVersionApi.java b/app/src/main/java/com/tangem/data/network/UpdateVersionApi.java index 7c6c1d7ff4..ab443b7815 100644 --- a/app/src/main/java/com/tangem/data/network/UpdateVersionApi.java +++ b/app/src/main/java/com/tangem/data/network/UpdateVersionApi.java @@ -1,14 +1,8 @@ package com.tangem.data.network; -import com.tangem.data.network.model.CardVerifyBody; -import com.tangem.data.network.model.CardVerifyResponse; - import okhttp3.ResponseBody; import retrofit2.Call; -import retrofit2.http.Body; import retrofit2.http.GET; -import retrofit2.http.Header; -import retrofit2.http.POST; public interface UpdateVersionApi { @GET(Server.ApiUpdateVersion.Method.LAST_VERSION) diff --git a/app/src/main/java/com/tangem/data/network/model/CardVerifyBody.java b/app/src/main/java/com/tangem/data/network/model/CardVerifyBody.java deleted file mode 100644 index 96f18a8219..0000000000 --- a/app/src/main/java/com/tangem/data/network/model/CardVerifyBody.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.tangem.data.network.model; - -public class CardVerifyBody { - private CardVerify[] requests; - - public CardVerifyBody(CardVerify[] requests) { - this.requests = requests; - } - -} diff --git a/app/src/main/java/com/tangem/data/network/model/CardVerifyResponse.kt b/app/src/main/java/com/tangem/data/network/model/CardVerifyResponse.kt deleted file mode 100644 index bd78877a12..0000000000 --- a/app/src/main/java/com/tangem/data/network/model/CardVerifyResponse.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.tangem.data.network.model - -import com.google.gson.annotations.SerializedName - -data class CardVerifyResponse( - @SerializedName("results") - var results: List? = null -) { - - data class Verify( - @SerializedName("CID") - var CID: String = "", - - @SerializedName("passed") - var passed: Boolean = false - ) - -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/data/network/request/ExchangeRequest.java b/app/src/main/java/com/tangem/data/network/request/ExchangeRequest.java deleted file mode 100644 index ecfd83965c..0000000000 --- a/app/src/main/java/com/tangem/data/network/request/ExchangeRequest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.tangem.data.network.request; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Created by dvol on 16.07.2017. - */ - -public class ExchangeRequest { - public JSONObject jsRequestData; - public String answerData; - public String error; - public String WalletAddress; - public String currency; - public String currencyAlter; - - private ExchangeRequest() { - } - - public ExchangeRequest(JSONObject jsRequest) { - try { - jsRequestData = new JSONObject(jsRequest.toString()); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public JSONObject getAnswer() { - try { - return new JSONObject(answerData); - } catch (Exception e) { - try { - return new JSONObject(String.format("[\"Error\":\"%s\"]", e.getMessage())); - } catch (JSONException e1) { - e1.printStackTrace(); - return null; - } - } - } - - public JSONArray getAnswerList() throws JSONException { - return new JSONArray(answerData); - } - - public String getAsString() { - return jsRequestData.toString(); - } - - public void setID(int value) { - try { - jsRequestData.put("id", String.format("%d", value)); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public int getID() { - try { - return jsRequestData.getInt("id"); - } catch (JSONException e) { - e.printStackTrace(); - return 0; - } - } - - public static ExchangeRequest GetRate(String wallet, String currency, String alterCurrency) { - ExchangeRequest request = new ExchangeRequest(); - request.WalletAddress=wallet; - request.currency = currency; - request.currencyAlter = alterCurrency; - return request; - } - - - public JSONArray getParams() throws JSONException { - return jsRequestData.getJSONArray("params"); - } - - public JSONObject getResult() throws JSONException { - return getAnswer().getJSONObject("result"); - } - - public String getResultString() throws JSONException { - return getAnswer().getString("result"); - } - - public JSONArray getResultArray() throws JSONException { - return getAnswer().getJSONArray("result"); - } -} diff --git a/app/src/main/java/com/tangem/data/network/request/FeeRequest.java b/app/src/main/java/com/tangem/data/network/request/FeeRequest.java deleted file mode 100644 index 3bca0b5c75..0000000000 --- a/app/src/main/java/com/tangem/data/network/request/FeeRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.tangem.data.network.request; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Created by dvol on 16.07.2017. - */ - -public class FeeRequest { - public JSONObject jsRequestData; - public String answerData; - public String error; - public String WalletAddress; - public long txSize = 0; - - private FeeRequest() { - } - - public FeeRequest(JSONObject jsRequest) { - try { - jsRequestData = new JSONObject(jsRequest.toString()); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public JSONObject getAnswer() { - try { - return new JSONObject(answerData); - } catch (Exception e) { - try { - return new JSONObject(String.format("[\"Error\":\"%s\"]", e.getMessage())); - } catch (JSONException e1) { - e1.printStackTrace(); - return null; - } - } - } - - public String getAsString() { - return answerData; - } - - public static final int PRIORITY = 2; - public static final int NORMAL = 3; - public static final int MINIMAL = 6; - private int blockCount = NORMAL; - - public void setBlockCount(int count - ) { - blockCount = count; - } - - public int getBlockCount() { - return blockCount; - } - - public void setID(int value) { - try { - jsRequestData.put("id", String.format("%d", value)); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public int getID() { - try { - return jsRequestData.getInt("id"); - } catch (JSONException e) { - e.printStackTrace(); - return 0; - } - } - - public static FeeRequest GetFee(String wallet, long txSize, int blockCount) { - FeeRequest request = new FeeRequest(); - request.WalletAddress = wallet; - request.txSize = txSize; - request.setBlockCount(blockCount); - return request; - } - - - public JSONArray getParams() throws JSONException { - return jsRequestData.getJSONArray("params"); - } - - public JSONObject getResult() throws JSONException { - return getAnswer().getJSONObject("result"); - } - - public String getResultString() throws JSONException { - return getAnswer().getString("result"); - } - - public JSONArray getResultArray() throws JSONException { - return getAnswer().getJSONArray("result"); - } -} diff --git a/app/src/main/java/com/tangem/data/network/request/InfuraRequest.java b/app/src/main/java/com/tangem/data/network/request/InfuraRequest.java deleted file mode 100644 index 871eee5421..0000000000 --- a/app/src/main/java/com/tangem/data/network/request/InfuraRequest.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.tangem.data.network.request; - -/** - * Created by Ilia on 19.12.2017. - */ - -import android.util.Log; - -import com.tangem.domain.wallet.Blockchain; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -public class InfuraRequest { - public static final String METHOD_ETH_GetBalance = "eth_getBalance"; - public static final String METHOD_ETH_GetOutTransactionCount = "eth_getTransactionCount"; - public static final String METHOD_ETH_GetGasPrice = "eth_gasPrice"; - public static final String METHOD_ETH_SendRawTransaction = "eth_sendRawTransaction"; - public static final String METHOD_ETH_Call = "eth_call"; - - public JSONObject jsRequestData; - public String answerData; - public String error; - public String WalletAddress; - public int Dec; - public String amount; - public Blockchain blockchain; - - public void setBlockchain(Blockchain value) { - blockchain = value; - } - - public Blockchain getBlockchain() { - return blockchain; - } - - private InfuraRequest() { - } - - public InfuraRequest(JSONObject jsRequest) { - try { - jsRequestData = new JSONObject(jsRequest.toString()); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public JSONObject getAnswer() { - try { - return new JSONObject(answerData); - } catch (Exception e) { - try { - return new JSONObject(String.format("[\"Error\":\"%s\"]", e.getMessage())); - } catch (JSONException e1) { - e1.printStackTrace(); - return null; - } - } - } - - public String getAsString() { - return jsRequestData.toString(); - } - - public void setID(int value) { - try { - jsRequestData.put("id", value/*String.format("%d", value)*/); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public int getID() { - try { - return jsRequestData.getInt("id"); - } catch (JSONException e) { - e.printStackTrace(); - return 0; - } - } - - public boolean isMethod(String methodName) throws JSONException { - return jsRequestData.getString("method").equals(methodName); - } - - public static InfuraRequest GetBalance(String wallet) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_GetBalance + "\", \"params\":[\"" + wallet + "\", \"latest\"] }"); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - public static InfuraRequest GetTokenBalance(String wallet, String contract, int dec) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.Dec = dec; - String address = wallet.substring(2); - String dataValue = String.format("{\"data\": \"0x70a08231000000000000000000000000%s\", \"to\": \"%s\"}", address, contract); - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_Call + "\", \"params\":[" + dataValue + ", \"latest\"] }"); - - Log.i("swdwd", request.jsRequestData.toString()); - Log.i("swdwd + address", address); - Log.i("swdwd + contract", contract); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - public static InfuraRequest SendTransaction(String wallet, String tx) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_SendRawTransaction + "\", \"params\":[\"" + tx + "\"] }"); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - - public static InfuraRequest GetOutTransactionCount(String wallet) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_GetOutTransactionCount + "\", \"params\":[\"" + wallet + "\", \"latest\"] }"); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - public static InfuraRequest GetPendingTransactionCount(String wallet) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_GetOutTransactionCount + "\", \"params\":[\"" + wallet + "\", \"pending\"] }"); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - public static InfuraRequest GetGasPrise(String wallet) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_GetGasPrice + "\", \"params\":[] }"); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - - public static InfuraRequest SendTransactionCount(String wallet, String TX) { - InfuraRequest request = new InfuraRequest(); - try { - request.WalletAddress = wallet; - request.jsRequestData = new JSONObject("{ \"method\":\"" + METHOD_ETH_SendRawTransaction + "\", \"params\":[\"" + TX + "\"] }"); - } catch (JSONException e) { - e.printStackTrace(); - request.error = e.toString(); - } - return request; - } - - - //METHOD_ETH_GetOutTransactionCount - - - public JSONArray getParams() throws JSONException { - return jsRequestData.getJSONArray("params"); - } - - public JSONObject getResult() throws JSONException { - return getAnswer().getJSONObject("result"); - } - - public String getResultString() throws JSONException { - return getAnswer().getString("result"); - } - - public JSONArray getResultArray() throws JSONException { - return getAnswer().getJSONArray("result"); - } -} - diff --git a/app/src/main/java/com/tangem/data/network/request/VerificationServerProtocol.java b/app/src/main/java/com/tangem/data/network/request/VerificationServerProtocol.java deleted file mode 100644 index 23822ab69e..0000000000 --- a/app/src/main/java/com/tangem/data/network/request/VerificationServerProtocol.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.tangem.data.network.request; - -import android.util.Log; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.tangem.domain.wallet.TangemCard; -import com.tangem.util.Util; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.lang.reflect.Type; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.nio.charset.StandardCharsets; -import java.sql.Date; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Locale; - -public class VerificationServerProtocol { - - public static class Request { - public Request(CustomCommand command, Class answerClass) { - this.command = command; - this.answerClass = answerClass; - } - - public String error; - public CustomCommand command; - public CustomAnswer answer; - public Type answerClass; - - public void doPost(String hostURL) throws IOException { - URL url = new URL(hostURL + "/" + command.getURL()); - Log.i("isOnlineVerified", hostURL + "/" + command.getURL()); - URLConnection con = url.openConnection(); - HttpURLConnection http = (HttpURLConnection) con; - try { - http.setConnectTimeout(30000); - http.setReadTimeout(30000); - http.setRequestMethod("POST"); // PUT is another valid option - http.setDoOutput(true); - - String sRequestBody = getGson().toJson(this.command); - - byte[] out = sRequestBody.getBytes(StandardCharsets.UTF_8); - int length = out.length; - - http.setFixedLengthStreamingMode(length); - http.setRequestProperty("Content-Type", "application/json"); - http.connect(); - try (OutputStream os = http.getOutputStream()) { - os.write(out); - } - try (InputStream is = http.getInputStream()) { - try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { - answer = getGson().fromJson(br, answerClass); - } - } - } finally { - http.disconnect(); - } - } - } - - static abstract class CustomCommand { - public abstract String getURL(); - - public byte[] toBytes() { - return getGson().toJson(this).getBytes(StandardCharsets.UTF_8); - } - - @Override - public String toString() { - return getGson().toJson(this); - } - - } - - static class CustomAnswer { - public String error; - - @Override - public String toString() { - return getGson().toJson(this); - } - } - - public static class Verify { - - static class RequestItem { - public String CID; - public String publicKey; - } - - static class Command extends CustomCommand { - public RequestItem[] requests; - - @Override - public String getURL() { - return "verify"; - } - } - - public static class ResultItem { - public ResultItem(RequestItem request) { - CID = request.CID; - } - - public String error; - public String CID; - public Boolean passed; - } - - public static class Answer extends CustomAnswer { - public ResultItem[] results; - } - - public static Request prepare(TangemCard card) { - Command c = new Command(); - c.requests = new RequestItem[1]; - c.requests[0] = new RequestItem(); - c.requests[0].CID = Util.bytesToHex(card.getCID()); - c.requests[0].publicKey = Util.bytesToHex(card.getCardPublicKey()); - - return new Request(c, Answer.class); - } - } - - public static class Validate { - - static class RequestItem { - public String CID; - public int counter; - public String signature; - } - - static class Command extends CustomCommand { - public RequestItem[] requests; - - @Override - public String getURL() { - return "validate"; - } - } - - static class ResultItem { - public ResultItem(RequestItem request) { - CID = request.CID; - } - - public String error; - public String CID; - public Integer previousCounter; - public Boolean passed; - } - - static class Answer extends CustomAnswer { - public ResultItem[] results; - } - - public Request prepare(TangemCard card, int ValidationCounter, byte[] ValidationSignature) { - Command c = new Command(); - c.requests = new RequestItem[1]; - c.requests[0].CID = Util.bytesToHex(card.getCID()); - c.requests[0].counter = ValidationCounter; - c.requests[0].signature = Util.bytesToHex(ValidationSignature); - return new Request(new Command(), Answer.class); - } - } - - public static Date strToDate(String date) throws ParseException { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); - return new Date(formatter.parse(date).getTime()); - } - - public static String dateToStr(Date date) { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); - return formatter.format(date); - } - - public static Gson getGson() { - return new GsonBuilder().create(); - } - -} \ No newline at end of file