Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use packageName in Relay header #18

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import org.koin.android.ext.koin.androidContext
import org.koin.core.qualifier.named
import org.koin.dsl.module

fun coreStorageModule(storagePrefix: String = String.Empty, bundleId: String) = module {
fun coreStorageModule(storagePrefix: String = String.Empty, packageName: String) = module {

includes(baseStorageModule(storagePrefix, bundleId))
includes(baseStorageModule(storagePrefix, packageName))

single<SqlDriver>(named(AndroidBuildVariantDITags.ANDROID_CORE_DATABASE_DRIVER)) {
AndroidSqliteDriver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ class CoreProtocol(private val koinApp: KoinApplication = wcKoinApp) : CoreInter
metaData: Core.Model.AppMetaData,
keyServerUrl: String?
) {
val bundleId: String = application.packageName
val packageName: String = application.packageName
val relayServerUrl = if (serverUrl.isNullOrEmpty()) "wss://relay.walletconnect.org?projectId=$projectId" else serverUrl

with(koinApp) {
androidContext(application)
modules(
module { single { ProjectId(projectId) } },
module { single(named(AndroidCommonDITags.TELEMETRY_ENABLED)) { TelemetryEnabled(telemetryEnabled) } },
coreAndroidNetworkModule(relayServerUrl, connectionType, BuildConfig.SDK_VERSION, networkClientTimeout, bundleId),
coreAndroidNetworkModule(relayServerUrl, connectionType, BuildConfig.SDK_VERSION, networkClientTimeout, packageName),
coreCommonModule(),
coreCryptoModule(),
)
Expand All @@ -156,7 +156,7 @@ class CoreProtocol(private val koinApp: KoinApplication = wcKoinApp) : CoreInter
}

modules(
coreStorageModule(bundleId = bundleId),
coreStorageModule(packageName = packageName),
module { single(named(AndroidCommonDITags.CLIENT_ID)) { requireNotNull(get<SharedPreferences>().getString(KEY_CLIENT_ID, null)) } },
pushModule(),
module { single { relay ?: Relay } },
Expand All @@ -181,7 +181,7 @@ class CoreProtocol(private val koinApp: KoinApplication = wcKoinApp) : CoreInter
keyServerModule(keyServerUrl),
explorerModule(),
appKitModule(),
pulseModule(bundleId)
pulseModule(packageName)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.koin.core.scope.Scope
import org.koin.dsl.module
import com.reown.android.internal.common.scope as wcScope

fun baseStorageModule(storagePrefix: String = String.Empty, bundleId: String) = module {
fun baseStorageModule(storagePrefix: String = String.Empty, packageName: String) = module {
single<ColumnAdapter<List<String>, String>>(named(AndroidCommonDITags.COLUMN_ADAPTER_LIST)) {
object : ColumnAdapter<List<String>, String> {
override fun decode(databaseValue: String): List<String> =
Expand Down Expand Up @@ -128,7 +128,7 @@ fun baseStorageModule(storagePrefix: String = String.Empty, bundleId: String) =

single { PushMessagesRepository(pushMessageQueries = get()) }

single { EventsRepository(eventQueries = get(), bundleId = bundleId, telemetryEnabled = get(named(AndroidCommonDITags.TELEMETRY_ENABLED))) }
single { EventsRepository(eventQueries = get(), bundleId = packageName, telemetryEnabled = get(named(AndroidCommonDITags.TELEMETRY_ENABLED))) }

single { DatabaseConfig(storagePrefix = storagePrefix) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal const val KEY_CLIENT_ID = "clientId"

@Suppress("LocalVariableName")
@JvmSynthetic
fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType, sdkVersion: String, timeout: NetworkClientTimeout? = null, bundleId: String) = module {
fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType, sdkVersion: String, timeout: NetworkClientTimeout? = null, packageName: String) = module {
val networkClientTimeout = timeout ?: NetworkClientTimeout.getDefaultTimeout()
factory(named(AndroidCommonDITags.RELAY_URL)) {
val jwt = get<GenerateJwtStoreClientIdUseCase>().invoke(serverUrl)
Expand All @@ -58,7 +58,7 @@ fun coreAndroidNetworkModule(serverUrl: String, connectionType: ConnectionType,
Interceptor { chain ->
val updatedRequest = chain.request().newBuilder()
.addHeader("User-Agent", get(named(AndroidCommonDITags.USER_AGENT)))
.addHeader("Origin", bundleId)
.addHeader("packageName", packageName)
.build()

chain.proceed(updatedRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ internal fun overrideModule(
corePairingModule(pairing, pairingController),
coreCryptoModule(sharedPrefsFile, keyStoreAlias),
coreJsonRpcModule(),
coreAndroidNetworkModule(relayUrl, connectionType, "test_version", bundleId = bundleId)
coreAndroidNetworkModule(relayUrl, connectionType, "test_version", packageName = bundleId)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal fun overrideModule(
coreStorageModule(storagePrefix, bundleId),
corePairingModule(pairing, pairingController),
coreCryptoModule(sharedPrefsFile, keyStoreAlias),
coreAndroidNetworkModule(relayUrl, connectionType, "test_version", bundleId = bundleId),
coreAndroidNetworkModule(relayUrl, connectionType, "test_version", packageName = bundleId),
coreJsonRpcModule()
)
}
Loading