Skip to content

Commit

Permalink
Improve link schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubuid committed Aug 20, 2024
1 parent d569de5 commit 01191db
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,58 @@ internal class GetSampleWalletsUseCase(
private val context: Context
) : GetSampleWalletsUseCaseInterface {
override suspend fun invoke(): List<Wallet> {
val samples = listOf(SampleWallet, RNSampleWallet)
samples.forEach { wallet ->
val samples = mapOf(
"com.walletconnect.sample.wallet.debug" to SampleWalletDebug,
"com.walletconnect.sample.wallet.internal" to SampleWalletInternal,
"com.walletconnect.sample.wallet" to SampleWalletRelease,
"com.walletconnect.web3wallet.rnsample.internal" to RNSampleWallet
)
samples.forEach { (walletPackage, wallet) ->
wallet.apply {
isWalletInstalled = androidSamplePackages.any { samplePackage -> context.packageManager.isWalletInstalled(samplePackage) }
isWalletInstalled = context.packageManager.isWalletInstalled(walletPackage)
}
}
return samples.filter { it.isWalletInstalled }
return samples.map { it.value }.filter { it.isWalletInstalled }
}
}


private val SampleWallet = Wallet(
id = "AndroidSampleWallet",
name = "Android Sample",
private val SampleWalletDebug = Wallet(
id = "SampleWalletDebug",
name = "Android Sample Debug",
homePage = "https://walletconnect.com",
imageUrl = "https://raw.githubusercontent.com/WalletConnect/WalletConnectKotlinV2/develop/sample/wallet/src/main/res/drawable-xxxhdpi/wc_icon.png",
order = "1",
mobileLink = "kotlin-web3wallet://",
playStore = null,
webAppLink = null,
linkMode = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet",
linkMode = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet_debug",
true
)

private val SampleWalletInternal = Wallet(
id = "SampleWalletInternal",
name = "Android Sample Internal",
homePage = "https://walletconnect.com",
imageUrl = "https://raw.githubusercontent.com/WalletConnect/WalletConnectKotlinV2/develop/sample/wallet/src/main/res/drawable-xxxhdpi/wc_icon.png",
order = "2",
mobileLink = "kotlin-web3wallet://",
playStore = null,
webAppLink = null,
linkMode = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet_internal",
true
)

private val SampleWalletRelease = Wallet(
id = "SampleWalletRelease",
name = "Android Sample Release",
homePage = "https://walletconnect.com",
imageUrl = "https://raw.githubusercontent.com/WalletConnect/WalletConnectKotlinV2/develop/sample/wallet/src/main/res/drawable-xxxhdpi/wc_icon.png",
order = "3",
mobileLink = "kotlin-web3wallet://",
playStore = null,
webAppLink = null,
linkMode = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet_release",
true
)

Expand All @@ -41,17 +72,10 @@ private val RNSampleWallet = Wallet(
name = "RN Sample",
homePage = "https://walletconnect.com",
imageUrl = "https://raw.githubusercontent.com/WalletConnect/WalletConnectKotlinV2/develop/sample/wallet/src/main/res/drawable-xxxhdpi/wc_icon.png",
order = "2",
order = "4",
mobileLink = "rn-web3wallet://",
playStore = null,
webAppLink = null,
linkMode = "https://lab.web3modal.com/walletkit_rn",
true
)

private val androidSamplePackages = listOf(
"com.walletconnect.sample.wallet",
"com.walletconnect.sample.wallet.debug",
"com.walletconnect.sample.wallet.internal",
"com.walletconnect.web3wallet.rnsample.internal"
)
)
18 changes: 18 additions & 0 deletions sample/dapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ android {
buildConfigField("String", "BOM_VERSION", "\"${BOM_VERSION ?: ""}\"")
}

buildTypes {
getByName("release") {
manifestPlaceholders["pathPrefix"] = "/dapp_release"
buildConfigField("String", "DAPP_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/dapp_release\"")
}

getByName("internal") {
manifestPlaceholders["pathPrefix"] = "/dapp_internal"
buildConfigField("String", "DAPP_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/dapp_internal\"")

}

getByName("debug") {
manifestPlaceholders["pathPrefix"] = "/dapp_debug"
buildConfigField("String", "DAPP_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/dapp_debug\"")
}
}

lint {
abortOnError = true
ignoreWarnings = true
Expand Down
2 changes: 1 addition & 1 deletion sample/dapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<data
android:host="web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app"
android:scheme="https"
android:pathPrefix="/dapp"/>
android:pathPrefix="${pathPrefix}"/>
</intent-filter>

<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.walletconnect.android.Core
import com.walletconnect.android.CoreClient
import com.walletconnect.sample.common.BuildConfig
import com.walletconnect.sample.common.tag
import com.walletconnect.wcmodal.client.Modal
import com.walletconnect.wcmodal.client.WalletConnectModal
import timber.log.Timber
import com.walletconnect.sample.common.BuildConfig as CommonBuildConfig

class DappSampleApp : Application() {

Expand All @@ -23,13 +23,13 @@ class DappSampleApp : Application() {
url = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app",
icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media"),
redirect = "kotlin-dapp-wc://request",
appLink = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/dapp",
appLink = BuildConfig.DAPP_APP_LINK,
linkMode = true
)

CoreClient.initialize(
application = this,
projectId = BuildConfig.PROJECT_ID,
projectId = CommonBuildConfig.PROJECT_ID,
metaData = appMetaData,
) {
Firebase.crashlytics.recordException(it.throwable)
Expand Down
18 changes: 18 additions & 0 deletions sample/modal/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ android {
buildConfigField("String", "BOM_VERSION", "\"${BOM_VERSION}\"")
}

buildTypes {
getByName("release") {
manifestPlaceholders["pathPrefix"] = "/lab_release"
buildConfigField("String", "LAB_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/lab_release\"")
}

getByName("internal") {
manifestPlaceholders["pathPrefix"] = "/lab_internal"
buildConfigField("String", "LAB_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/lab_internal\"")

}

getByName("debug") {
manifestPlaceholders["pathPrefix"] = "/lab_debug"
buildConfigField("String", "LAB_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/lab_debug\"")
}
}

lint {
abortOnError = true
ignoreWarnings = true
Expand Down
2 changes: 1 addition & 1 deletion sample/modal/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<data
android:host="web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app"
android:scheme="https"
android:pathPrefix="/lab"/>
android:pathPrefix="${pathPrefix}"/>
</intent-filter>

<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.google.firebase.ktx.Firebase
import com.walletconnect.android.Core
import com.walletconnect.android.CoreClient
import com.walletconnect.android.relay.ConnectionType
import com.walletconnect.sample.common.BuildConfig
import com.walletconnect.sample.common.tag
import com.walletconnect.util.bytesToHex
import com.walletconnect.util.randomBytes
Expand All @@ -16,6 +15,7 @@ import com.walletconnect.web3.modal.client.Web3Modal
import com.walletconnect.web3.modal.presets.Web3ModalChainsPresets
import com.walletconnect.web3.modal.utils.EthUtils
import timber.log.Timber
import com.walletconnect.sample.common.BuildConfig as CommonBuildConfig

class ModalSampleApp : Application() {
override fun onCreate() {
Expand All @@ -28,11 +28,11 @@ class ModalSampleApp : Application() {
icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media"),
redirect = "kotlin-modal-wc://request",
linkMode = true,
appLink = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/lab"
appLink = BuildConfig.LAB_APP_LINK
)

CoreClient.initialize(
projectId = BuildConfig.PROJECT_ID,
projectId = CommonBuildConfig.PROJECT_ID,
connectionType = ConnectionType.AUTOMATIC,
application = this,
metaData = appMetaData,
Expand Down
18 changes: 18 additions & 0 deletions sample/wallet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ android {
buildConfigField("String", "BOM_VERSION", "\"${BOM_VERSION}\"")
}

buildTypes {
getByName("release") {
manifestPlaceholders["pathPrefix"] = "/wallet_release"
buildConfigField("String", "WALLET_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet_release\"")
}

getByName("internal") {
manifestPlaceholders["pathPrefix"] = "/wallet_internal"
buildConfigField("String", "WALLET_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet_internal\"")

}

getByName("debug") {
manifestPlaceholders["pathPrefix"] = "/wallet_debug"
buildConfigField("String", "WALLET_APP_LINK", "\"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet_debug\"")
}
}

lint {
abortOnError = true
ignoreWarnings = true
Expand Down
2 changes: 1 addition & 1 deletion sample/wallet/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<data
android:host="web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app"
android:scheme="https"
android:pathPrefix="/wallet"/>
android:pathPrefix="${pathPrefix}"/>
</intent-filter>

<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Web3WalletApplication : Application() {
url = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app",
icons = listOf("https://raw.githubusercontent.com/WalletConnect/walletconnect-assets/master/Icon/Gradient/Icon.png"),
redirect = "kotlin-web3wallet://request",
appLink = "https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet",
appLink = BuildConfig.WALLET_APP_LINK,
linkMode = true
)

Expand Down

0 comments on commit 01191db

Please sign in to comment.