Skip to content

Commit

Permalink
Move api resources to central location
Browse files Browse the repository at this point in the history
- version code bump
  • Loading branch information
kcw-grunt committed Jan 15, 2023
1 parent 9c70b68 commit 6cd5b4f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ android {
applicationId = 'com.loafwallet'
minSdkVersion 27
targetSdkVersion 32
versionCode 695
versionCode 705
versionName "v2.7.1"
multiDexEnabled true
archivesBaseName = "${versionName}(${versionCode})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class PlatformTests {
// proto is the transport protocol to use for talking to the API (either http or https)
private static final String PROTO = "https";
// host is the server(s) on which the API is hosted
// private static final String HOST = "api.breadwallet.com";
// convenience getter for the API endpoint
private static final String BASE_URL = PROTO + "://" + BreadApp.HOST;
//feePerKb url
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.breadwallet.presenter.fragments;

import static com.breadwallet.tools.util.BRConstants.LW_API_HOST;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ClipData;
Expand Down Expand Up @@ -45,7 +47,6 @@ public class FragmentBuy extends Fragment {
private ProgressBar progress;
private WebView webView;
private String onCloseUrl;
private static final String URL_BUY_LTC = "https://api-prod.lite-wallet.org";
private static final String CURRENCY_KEY = "currency_code_key";
private static final String PARTNER_KEY = "partner_key";
private ValueCallback<Uri> uploadMessage;
Expand Down Expand Up @@ -122,13 +123,12 @@ public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrig
return rootView;
}


public static String url(Context context, Partner partner, String currency) {
String walletAddress = BRSharedPrefs.getReceiveAddress(context);
Long timestamp = new Date().getTime();
String uuid = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
String prefix = partner == Partner.MOONPAY ? "/moonpay/buy" : "";
return String.format(URL_BUY_LTC + prefix + "?address=%s&code=%s&idate=%s&uid=%s", walletAddress, currency, timestamp, uuid);
return String.format(LW_API_HOST + prefix + "?address=%s&code=%s&idate=%s&uid=%s", walletAddress, currency, timestamp, uuid);
}

private void closePayment() {
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/breadwallet/tools/manager/BRApiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.breadwallet.presenter.entities.CurrencyEntity;
import com.breadwallet.tools.sqlite.CurrencyDataSource;
import com.breadwallet.tools.threads.BRExecutor;

import com.breadwallet.tools.util.BRConstants;
import com.breadwallet.tools.util.Utils;
import com.platform.APIClient;

Expand All @@ -32,6 +34,10 @@
import okhttp3.Response;
import timber.log.Timber;

import static com.breadwallet.tools.util.BRConstants.*;
import static com.breadwallet.tools.util.BRConstants.LW_API_HOST;
import static com.breadwallet.tools.util.BRConstants.LW_BACKUP_API_HOST;

public class BRApiManager {
private static BRApiManager instance;
private Timer timer;
Expand Down Expand Up @@ -131,7 +137,7 @@ public void stopTimerTask() {
}

public static JSONArray fetchRates(Activity activity) {
String jsonString = createGETRequestURL(activity, "https://api.loafwallet.org/api/v1/rates");
String jsonString = createGETRequestURL(activity, LW_API_HOST + "/api/v1/rates");
JSONArray jsonArray = null;
if (jsonString == null) return null;
try {
Expand All @@ -143,7 +149,9 @@ public static JSONArray fetchRates(Activity activity) {
}

public static JSONArray backupFetchRates(Activity activity) {
String jsonString = createGETRequestURL(activity, "https://api-prod.lite-wallet.org/api/v1/rates");
String jsonString = createGETRequestURL(activity, LW_BACKUP_API_HOST + "/api/v1/rates");

AnalyticsManager.logCustomEvent(_20230113_BAC);

JSONArray jsonArray = null;
if (jsonString == null) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ public class BRConstants {
public static final String REDDIT_LINK = "https://www.reddit.com/r/Litewallet";
public static final String WEB_LINK = "https://litewalle.io";
public static final String TOS_LINK = "https://litewallet.io/privacy/policy.html";
public static String CUSTOMER_SUPPORT_LINK = "https://litecoinfoundation.zendesk.com";
public static String CUSTOMER_SUPPORT_LINK = "https://support.litewallet.io";
public static String BITREFILL_AFFILIATE_LINK = "https://www.bitrefill.com/";

/**
* API Hosts
*/
public static final String LW_API_HOST = "https://api-prod.lite-wallet.org";
public static final String LW_BACKUP_API_HOST = "https://api-dev.lite-wallet.org";

public static final String BLOCK_EXPLORER_BASE_URL = BuildConfig.LITECOIN_TESTNET ? "https://testnet.litecore.io/tx/" : "https://insight.litecore.io/tx/";

Expand Down Expand Up @@ -131,6 +136,7 @@ private BRConstants() {
public static final String _20201121_SIL = "started_IFPS_lookup";
public static final String _20201121_DRIA = "did_resolve_IPFS_address";
public static final String _20201121_FRIA = "failed_resolve_IPFS_address";
public static final String _20230113_BAC = "backup_apiserver_called";

///Dev: These events not yet used
public static final String _20200207_DTHB = "did_tap_header_balance";
Expand Down Expand Up @@ -168,6 +174,7 @@ private BRConstants() {
_20201121_SIL,
_20201121_DRIA,
_20201121_FRIA,
_20230113_BAC,
_20200207_DTHB,
_20210405_TAWDF,
_20210804_TAA2FAC,
Expand Down

0 comments on commit 6cd5b4f

Please sign in to comment.