Skip to content
Draft
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
60 changes: 60 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -987,13 +987,19 @@ workflows:
build_type: "debug"
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- test:
name: test_defaults_bc7_release
flavor: "defaults"
bc_version: "bc7"
build_type: "release"
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- test:
name: test_cec_<< matrix.build_type >>
flavor: "customEntitlementComputation"
Expand All @@ -1003,6 +1009,9 @@ workflows:
matrix:
parameters:
build_type: ["debug", "release"]
# FIXME We only need read access here.
context:
- github-packages-publishing
# Special case for defaults BC8 release with kover
- test:
name: test_defaults_bc8_release
Expand All @@ -1012,54 +1021,105 @@ workflows:
run_kover: true
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- verify-compatibility:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- lint:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- detekt:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- metalava:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- assemble-purchase-tester:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- assemble-paywall-tester-release:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- assemble-rct-tester-release:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- assemble-admob-integration-sample-app:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- test_dokka_hide_internal:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- test-galaxy:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- run-backend-integration-tests:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- record-and-upload-paparazzi-revenuecatui-snapshots:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- run-revenuecatui-ui-tests:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- emerge_purchases_ui_snapshot_tests:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- emerge_size_analysis_tests:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- run-maestro-e2e-tests:
requires:
- prepare-tests
# FIXME We only need read access here.
context:
- github-packages-publishing
- run-integration-tests:
requires:
- prepare-tests
Expand Down
1 change: 1 addition & 0 deletions purchases/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ dependencies {
implementation(libs.tink)
implementation(libs.playServices.ads.identifier)
implementation(libs.coroutines.core)
implementation("com.revenuecat.purchases:purchases-core:0.0.0-rust-SNAPSHOT")
"bc8Api"(libs.billing.bc8)
"bc7Api"(libs.billing.bc7)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.revenuecat.purchases

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import uniffi.purchases_core.HttpClient
import uniffi.purchases_core.HttpException
import java.net.URL

/**
* PoC: Kotlin implementation of the Rust `HttpClient` foreign trait.
* Rust calls `fetch(url)` on this object and awaits the result.
*/
internal class NativeHttpClient : HttpClient {

override suspend fun fetch(url: String): String {
return withContext(Dispatchers.IO) {
try {
URL(url).readText()
} catch (e: Exception) {
throw HttpException.RequestFailed("${e.javaClass.simpleName}: ${e.message}")
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import com.revenuecat.purchases.common.errorLog
import com.revenuecat.purchases.common.events.FeatureEvent
import com.revenuecat.purchases.common.infoLog
import com.revenuecat.purchases.common.log
import uniffi.purchases_core.add
import uniffi.purchases_core.fetchWithNative
import uniffi.purchases_core.performOperation
import com.revenuecat.purchases.customercenter.CustomerCenterListener
import com.revenuecat.purchases.deeplinks.DeepLinkParser
import com.revenuecat.purchases.interfaces.Callback
Expand Down Expand Up @@ -43,6 +46,10 @@ import com.revenuecat.purchases.strings.BillingStrings
import com.revenuecat.purchases.strings.ConfigureStrings
import com.revenuecat.purchases.utils.DefaultIsDebugBuildProvider
import com.revenuecat.purchases.virtualcurrencies.VirtualCurrencies
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import uniffi.purchases_core.HttpException
import uniffi.purchases_core.OperationMode
import java.net.URL
import java.util.Locale

Expand Down Expand Up @@ -1283,6 +1290,32 @@ public class Purchases internal constructor(
public fun configure(
configuration: PurchasesConfiguration,
): Purchases {
// Call Rust add() function to verify integration
val rustResult = add(2uL, 3uL)
infoLog { "Rust add(2, 3) = $rustResult" }
GlobalScope.launch {
val successResult = performOperation(OperationMode.SUCCESS)
errorLog { "Operation result in Rust: $successResult" }
try {
val failureResult = performOperation(OperationMode.ERROR)
} catch (e: Exception) {
errorLog(e) { "Error performing operation in Rust" }
}
try {
val timeoutResult = performOperation(OperationMode.TIMEOUT)
} catch (e: Exception) {
errorLog(e) { "Timeout performing operation in Rust" }
}

// PoC: 2-way communication — Rust calls back into Kotlin via HttpClient
try {
val result = fetchWithNative(NativeHttpClient(), "https://httpbin.org/get")
infoLog { "[Android] Rust round-trip result: $result" }
} catch (e: Exception) {
errorLog(e) { "[Android] Rust round-trip error" }
}
}

if (isConfigured) {
if (backingFieldSharedInstance?.purchasesOrchestrator?.currentConfiguration == configuration) {
infoLog { ConfigureStrings.INSTANCE_ALREADY_EXISTS_WITH_SAME_CONFIG }
Expand Down
10 changes: 10 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ dependencyResolutionManagement {
// fallback for the rest of the dependencies
mavenCentral()

// GitHub Packages for purchases-core Rust library
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/RevenueCat/purchases-core")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: ""
password = System.getenv("GITHUB_TOKEN") ?: ""
}
}

// Local Samsung IAP SDK AAR
flatDir {
dirs(samsungIapSdkDir)
Expand Down
15 changes: 15 additions & 0 deletions test-apps/sdksizetesting/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenLocal()
// GitHub Packages for purchases-core Rust library (transitive dependency)
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/RevenueCat/purchases-core")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: ""
password = System.getenv("GITHUB_TOKEN") ?: ""
}
content {
// Only fetch purchases-core from GitHub Packages
includeModule("com.revenuecat.purchases", "purchases-core")
includeModule("com.revenuecat.purchases", "purchases-core-android")
includeModule("com.revenuecat.purchases", "purchases-core-jvm")
}
}
google {
content {
// Exclude to make sure we use dependency from mavenLocal
Expand Down