Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
coroutinesVersion = '1.6.4'
ok_http_version = '4.12.0'
dashjVersion = '21.1.12'
dppVersion = "2.0.2-SNAPSHOT"
dppVersion = "2.0.2"
hiltVersion = '2.53'
hiltCompilerVersion = '1.2.0'
hiltWorkVersion = '1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ data class GetMerchantResponse(
val id: String,
val denominations: List<String>,
val denominationsType: String,
val savingsPercentage: Int = 0,
val savingsPercentage: Int? = 0,
val userDiscount: Int? = 0,
val redeemType: String = "",
val enabled: Boolean = true,
val productId: String = ""
) {
val discount
get() = userDiscount ?: savingsPercentage ?: 0
val denominationType: DenominationType
get() = DenominationType.fromString(denominationsType)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ abstract class ExploreDashModule {

@Provides fun provideFirebaseStorage() = Firebase.storage

fun provideRemoteDataSource(config: CTXSpendConfig): RemoteDataSource {
return RemoteDataSource(config)
@Provides
fun provideRemoteDataSource(config: CTXSpendConfig, walletDataProvider: WalletDataProvider): RemoteDataSource {
return RemoteDataSource(config, walletDataProvider)
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.dash.wallet.features.exploredash.network
import okhttp3.Authenticator
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.bitcoinj.core.NetworkParameters
import org.dash.wallet.common.WalletDataProvider
import org.dash.wallet.common.data.ServiceName
import org.dash.wallet.features.exploredash.network.authenticator.TokenAuthenticator
import org.dash.wallet.features.exploredash.network.interceptor.ErrorHandlingInterceptor
Expand All @@ -33,14 +35,23 @@ import javax.inject.Inject
import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration

class RemoteDataSource @Inject constructor(private val config: CTXSpendConfig) {
class RemoteDataSource @Inject constructor(
private val config: CTXSpendConfig,
private val walletData: WalletDataProvider
) {
companion object {
private val log = LoggerFactory.getLogger(RemoteDataSource::class.java)
}

fun <Api> buildApi(api: Class<Api>): Api {
return Retrofit.Builder()
.baseUrl(CTXSpendConstants.BASE_URL)
.baseUrl(
if (walletData.networkParameters.id == NetworkParameters.ID_MAINNET) {
CTXSpendConstants.BASE_URL
} else {
CTXSpendConstants.DEV_BASE_URL
}
)
.client(getOkHttpClient(TokenAuthenticator(buildTokenApi(), config)))
.addConverterFactory(GsonConverterFactory.create())
.build()
Expand All @@ -49,7 +60,13 @@ class RemoteDataSource @Inject constructor(private val config: CTXSpendConfig) {

private fun buildTokenApi(): CTXSpendTokenApi {
return Retrofit.Builder()
.baseUrl(CTXSpendConstants.BASE_URL)
.baseUrl(
if (walletData.networkParameters.id == NetworkParameters.ID_MAINNET) {
CTXSpendConstants.BASE_URL
} else {
CTXSpendConstants.DEV_BASE_URL
}
)
.client(getOkHttpClient())
.addConverterFactory(GsonConverterFactory.create())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class CTXSpendRepository @Inject constructor(
giftCardMap[merchantId] = it
UpdatedMerchantDetails(
id = response.id,
savingsPercentage = response.savingsPercentage,
savingsPercentage = response.discount,
denominationsType = response.denominationsType,
denominations = response.denominations.map { denom -> denom.toDouble() },
redeemType = response.redeemType,
Expand Down Expand Up @@ -244,7 +244,7 @@ class CTXSpendRepository @Inject constructor(
}

override fun getGiftCardDiscount(merchantId: String, denomination: Double): Double {
return giftCardMap[merchantId]?.savingsPercentage?.let {
return giftCardMap[merchantId]?.discount?.let {
it.toDouble() / 10000.0
} ?: 0.0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DashSpendRepositoryFactory @Inject constructor(
}

private fun createCTXSpend(): CTXSpendRepository {
val remoteDataSource = RemoteDataSource(ctxSpendConfig)
val remoteDataSource = RemoteDataSource(ctxSpendConfig, walletDataProvider)
val api = remoteDataSource.buildApi(CTXSpendApi::class.java)
val tokenApi = remoteDataSource.buildApi(CTXSpendTokenApi::class.java)
val tokenAuthenticator = TokenAuthenticator(tokenApi, ctxSpendConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ class GiftCardDetailsViewModel @Inject constructor(
metadataProvider.updateGiftCardMetadata(
giftCard.copy(
number = number,
pin = pinCode,
note = null
pin = pinCode
)
)
}
Expand All @@ -519,8 +518,7 @@ class GiftCardDetailsViewModel @Inject constructor(
viewModelScope.launch {
metadataProvider.updateGiftCardMetadata(
giftCard.copy(
merchantUrl = merchantUrl,
note = null
merchantUrl = merchantUrl
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import javax.inject.Inject

@AndroidEntryPoint
class ExploreDashInfoDialog : OffsetDialogFragment(R.layout.explore_dash_main_info) {

override val forceExpand = true
private val binding by viewBinding(ExploreDashMainInfoBinding::bind)
@Inject lateinit var analyticsService: AnalyticsService

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.dash.wallet.features.exploredash.utils

object CTXSpendConstants {
const val BASE_URL = "https://spend.ctx.com/"
const val DEV_BASE_URL = "https://staging.spend.ctx.com/"
const val CLIENT_ID_PARAM_NAME = "X-Client-Id"
@JvmField var CLIENT_ID = "dcg_android"
const val DEFAULT_DISCOUNT: Int = 0 // 0%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">

<ImageButton
android:id="@+id/collapse_button"
Expand Down
4 changes: 2 additions & 2 deletions wallet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ android {
minSdkVersion 24
targetSdkVersion 35
// version code: MMmmppbb; MM = Major Version, mm = minor version, pp == patch version, bb = build
versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 11040106
versionName project.hasProperty('versionName') ? project.property('versionName') : "11.4.1"
versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 11040210
versionName project.hasProperty('versionName') ? project.property('versionName') : "11.4.2-ctx-staging"
multiDexEnabled true
generatedDensities = ['hdpi', 'xhdpi']
vectorDrawables.useSupportLibrary = true
Expand Down