Skip to content

Commit

Permalink
Merge pull request #1015 from dashevo/feature-coinbase-integration
Browse files Browse the repository at this point in the history
add Coinbase integration
  • Loading branch information
HashEngineering committed Aug 15, 2022
2 parents 703197a + 1539667 commit cdb4044
Show file tree
Hide file tree
Showing 335 changed files with 16,629 additions and 1,570 deletions.
Binary file modified .deploy/service.properties.gpg
Binary file not shown.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ fastlane/report.xml
google-services.json
output-metadata.json
service.properties
wallet/assets/explore/*.db
wallet/assets/explore/*.db
7 changes: 7 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ file_filter = integrations/crowdnode/src/main/res/values-<lang>/strings-crowdnod
lang_map = sl_SI:sl, zh_TW:zh-rTW
source_file = integrations/crowdnode/src/main/res/values/strings-crowdnode.xml
source_lang = en
type = ANDROID

[dash-mobile-wallets.strings-coinbase]
file_filter = integrations/coinbase-integration/src/main/res/values-<lang>/strings.xml
lang_map = sl_SI:sl, zh_TW:zh-rTW
source_file = integrations/coinbase-integration/src/main/res/values/strings.xml
source_lang = en
type = ANDROID
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unf_ext (0.0.8.2-x64-mingw32)
unicode-display_width (1.8.0)
webrick (1.7.0)
word_wrap (1.0.0)
Expand All @@ -210,6 +211,7 @@ GEM
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
universal-darwin-20
x64-mingw-ucrt
x64-mingw32

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ buildscript {
junitVersion = '4.13.2'
mockitoVersion = '4.0.0'
espressoVersion = '3.4.0'
coilVersion = '1.4.0'
junitExtVersion = '1.1.3'
coreTestingVersion = '2.1.0'
}
Expand Down
17 changes: 15 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'dagger.hilt.android.plugin'

android {
Expand Down Expand Up @@ -56,6 +56,11 @@ dependencies {
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'

//UI
implementation "com.github.bumptech.glide:glide:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"
implementation "io.coil-kt:coil:$coilVersion"

//Retrofit + OkHttp
api "com.squareup.okhttp3:okhttp:$ok_http_version"
api "com.squareup.okhttp3:logging-interceptor:$ok_http_version"
Expand All @@ -73,6 +78,14 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
implementation "androidx.datastore:datastore-preferences:1.0.0"

// UI
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.browser:browser:$browserVersion"
implementation "androidx.constraintlayout:constraintlayout:$constrainLayoutVersion"
//noinspection GradleDependency
implementation 'com.google.zxing:core:3.3.3' // Don't update. 3.3.3 is the maximum to support Android 6.x

// UI
implementation 'com.google.android.material:material:1.4.0'
Expand All @@ -88,7 +101,7 @@ dependencies {
// Database
api "androidx.room:room-runtime:$roomVersion"
api "androidx.room:room-ktx:$roomVersion"
annotationProcessor "androidx.room:room-compiler:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion"

testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoVersion"
Expand Down
83 changes: 81 additions & 2 deletions common/src/main/java/org/dash/wallet/common/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.MonetaryFormat;
import org.dash.wallet.common.data.CurrencyInfo;
import org.dash.wallet.common.util.GenericUtils;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -90,6 +91,18 @@ public class Configuration {
public static final String PREFS_KEY_LAST_LIQUID_BALANCE = "last_liquid_balance";
public static final String PREFS_KEY_LAST_UPHOLD_BALANCE = "last_uphold_balance";

// Coinbase

public static final String PREFS_KEY_LAST_COINBASE_ACCESS_TOKEN = "last_coinbase_access_token";
public static final String PREFS_KEY_LAST_COINBASE_REFRESH_TOKEN = "last_coinbase_refresh_token";
public static final String PREFS_KEY_LAST_COINBASE_BALANCE = "last_coinbase_balance";
public static final String PREFS_KEY_COINBASE_USER_ACCOUNT_ID = "coinbase_account_id";
public static final String PREFS_KEY_COINBASE_AUTH_INFO_SHOWN = "coinbase_auth_info_shown";
public static final String PREFS_KEY_COINBASE_USER_WITHDRAWAL_LIMIT = "withdrawal_limit";
public static final String PREFS_KEY_COINBASE_SEND_LIMIT_CURRENCY = "send_limit_currency";



private static final int PREFS_DEFAULT_BTC_SHIFT = 0;
private static final int PREFS_DEFAULT_BTC_PRECISION = 8;
public static final String PREFS_KEY_IS_DASH_TO_FIAT_DIRECTION = "is_dash_to_fiat_direction";
Expand Down Expand Up @@ -487,9 +500,16 @@ public void setLastUpholdBalance(String balance) {
prefs.edit().putString(PREFS_KEY_LAST_UPHOLD_BALANCE, balance).apply();
}

@NonNull
public String getLastUpholdBalance() {
return prefs.getString(PREFS_KEY_LAST_UPHOLD_BALANCE, "0.00");
return prefs.getString(PREFS_KEY_LAST_UPHOLD_BALANCE, null);
}

public void setLastLiquidBalance(String balance) {
prefs.edit().putString(PREFS_KEY_LAST_LIQUID_BALANCE, balance).apply();
}

public String getLastLiquidBalance() {
return prefs.getString(PREFS_KEY_LAST_LIQUID_BALANCE, null);
}

public Boolean isDashToFiatDirection() {
Expand Down Expand Up @@ -555,6 +575,65 @@ public String getExploreDatabaseName() {
return prefs.getString(PREFS_KEY_EXPLORE_DATABASE_NAME, "explore-database");
}

// Coinbase

public void setLastCoinBaseAccessToken(String token) {
prefs.edit().putString(PREFS_KEY_LAST_COINBASE_ACCESS_TOKEN, token).apply();
}

public String getLastCoinbaseAccessToken() {
return prefs.getString(PREFS_KEY_LAST_COINBASE_ACCESS_TOKEN, null);
}

public void setLastCoinBaseRefreshToken(String token) {
prefs.edit().putString(PREFS_KEY_LAST_COINBASE_REFRESH_TOKEN, token).apply();
}

public String getLastCoinbaseRefreshToken() {
return prefs.getString(PREFS_KEY_LAST_COINBASE_REFRESH_TOKEN, null);
}

public void setLastCoinBaseBalance(String balance) {
prefs.edit().putString(PREFS_KEY_LAST_COINBASE_BALANCE, balance).apply();
}

@Nullable
public String getLastCoinbaseBalance() {
return prefs.getString(PREFS_KEY_LAST_COINBASE_BALANCE, null);
}

public Boolean getHasCoinbaseAuthInfoBeenShown() {
return prefs.getBoolean(PREFS_KEY_COINBASE_AUTH_INFO_SHOWN, false);
}

public void setHasCoinbaseAuthInfoBeenShown(boolean isShown) {
prefs.edit().putBoolean(PREFS_KEY_COINBASE_AUTH_INFO_SHOWN, isShown).apply();
}

public void setCoinBaseUserAccountId(String accountId) {
prefs.edit().putString(PREFS_KEY_COINBASE_USER_ACCOUNT_ID, accountId).apply();
}

public String getCoinbaseUserAccountId(){
return prefs.getString(PREFS_KEY_COINBASE_USER_ACCOUNT_ID, null);
}

public void setCoinbaseUserWithdrawalLimitAmount(String amount){
prefs.edit().putString(PREFS_KEY_COINBASE_USER_WITHDRAWAL_LIMIT, amount).apply();
}

public String getCoinbaseUserWithdrawalLimitAmount() {
return prefs.getString(PREFS_KEY_COINBASE_USER_WITHDRAWAL_LIMIT, null);
}

public void setCoinbaseSendLimitCurrency(String currency){
prefs.edit().putString(PREFS_KEY_COINBASE_SEND_LIMIT_CURRENCY, currency).apply();
}

public String getCoinbaseSendLimitCurrency() {
return prefs.getString(PREFS_KEY_COINBASE_SEND_LIMIT_CURRENCY, GenericUtils.getLocaleCurrencyCode());
}

// CrowdNode

@NonNull
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/org/dash/wallet/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Constants {
public static final int REQUEST_CODE_BUY_SELL = 100;
public static final int USER_BUY_SELL_DASH = 101;
public static final int RESULT_CODE_GO_HOME = 100;
public static final int COIN_BASE_AUTH = 102;

public static Coin MAX_MONEY = MainNetParams.get().getMaxMoney();
public static final Coin ECONOMIC_FEE = Coin.valueOf(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ interface WalletDataProvider {
@Deprecated("Inject Configuration instead")
fun defaultCurrencyCode(): String

fun getWalletBalance(): Coin

fun observeBalance(balanceType: Wallet.BalanceType = Wallet.BalanceType.ESTIMATED): Flow<Coin>

fun observeTransactions(vararg filters: TransactionFilter): Flow<Transaction>
Expand All @@ -60,7 +62,7 @@ interface WalletDataProvider {
fun processDirectTransaction(tx: Transaction)

@Throws(LeftoverBalanceException::class)
fun checkSendingConditions(address: Address, amount: Coin)
fun checkSendingConditions(address: Address?, amount: Coin)

fun observeMostRecentTransaction(): Flow<Transaction>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ object ServiceName {
const val CrowdNode = "crowdnode"
const val Liquid = "liquid"
const val Uphold = "uphold"
const val Coinbase = "Coinbase"
const val Unknown = "unknown"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2021 Dash Core Group.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.dash.wallet.common.di

import android.content.Context
import android.net.ConnectivityManager
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.dash.wallet.common.livedata.NetworkState
import org.dash.wallet.common.livedata.NetworkStateInt

@Module
@InstallIn(SingletonComponent::class)
object ConnectivityProviderModule {
@Provides
fun provideConnectivityManager(@ApplicationContext context: Context): ConnectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}

@Module
@InstallIn(SingletonComponent::class)
@ExperimentalCoroutinesApi
abstract class NetworkStateProviderModule {
@Binds
abstract fun bindNetworkState(networkState: NetworkState) : NetworkStateInt
}
Empty file.
54 changes: 54 additions & 0 deletions common/src/main/java/org/dash/wallet/common/livedata/Event.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2021 Dash Core Group.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.dash.wallet.common.livedata

import androidx.lifecycle.Observer

/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
@Deprecated(message = "Use SingleLiveEvent")
open class Event<out T>(private val content: T) {

var hasBeenHandled = false
private set // Allow external read but not write

/**
* Returns the content and prevents its use again.
*/
fun getContentIfNotHandled(): T? {
return if (hasBeenHandled) {
null
} else {
hasBeenHandled = true
content
}
}

/**
* Returns the content, even if it's already been handled.
*/
fun peekContent(): T = content
}

class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
onEventUnhandledContent(value)
}
}
}

0 comments on commit cdb4044

Please sign in to comment.