Skip to content

Commit

Permalink
Merge pull request #1460 from WalletConnect/develop
Browse files Browse the repository at this point in the history
BOM_1.33.1
  • Loading branch information
jakubuid committed Jul 29, 2024
2 parents ed01485 + cb6e6a1 commit a028335
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 85 deletions.
1 change: 1 addition & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
commitish: master
template: |
## What's Changed
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci_github_release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Release
name: Create GitHub Release

on:
push:
Expand All @@ -19,15 +19,16 @@ jobs:
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.drafter.outputs.changelog }}
draft: false
prerelease: false
prerelease: false
target_commitish: master
7 changes: 6 additions & 1 deletion .github/workflows/ci_release_articacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ jobs:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: |
./gradlew closeAndReleaseMultipleRepositories
./gradlew closeAndReleaseMultipleRepositories
- name: Push Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew pushTagToMain
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name: 'Slack Release Notifications'
on:
release:
types: [ published, edited ]
types: [ published ]
jobs:
push-notifications:
runs-on: 'ubuntu-latest'
Expand Down
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {

| BOM | [Core SDK](core/android) | [Sign SDK](protocol/sign) | [Auth SDK](protocol/auth) | [Chat SDK](protocol/chat) | [Notify SDK](protocol/notify) | [web3wallet](product/web3wallet) | [web3modal](product/web3modal) | [WalletConnectModal](product/walletconnectmodal) |
|-----------------------------------------------------------------------------------------|--------------------------|---------------------------|---------------------------|---------------------------|:------------------------------|----------------------------------|--------------------------------|--------------------------------------------------|
| 1.33.1 | 1.33.1 | 2.33.1 | 1.28.5 | 1.0.0.beta32 | 1.3.6 | 1.33.1 | 1.6.1 | 1.5.6 |
| 1.33.0 | 1.33.0 | 2.33.0 | 1.28.4 | 1.0.0.beta31 | 1.3.5 | 1.33.0 | 1.6.0 | 1.5.5 |
| 1.32.1 | 1.32.0 | 2.32.0 | 1.28.3 | 1.0.0.beta30 | 1.3.4 | 1.32.1 | 1.5.4 | 1.5.4 |
| 1.31.3 | 1.31.2 | 2.31.2 | 1.28.2 | 1.0.0.beta30 | 1.3.2 | 1.31.2 | 1.5.2 | 1.5.2 |
Expand Down
122 changes: 88 additions & 34 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import com.android.build.gradle.BaseExtension
import org.apache.http.client.methods.HttpGet
import org.apache.http.client.methods.HttpPost
Expand Down Expand Up @@ -131,20 +130,21 @@ tasks.register("closeAndReleaseMultipleRepositories") {
description = "Release all Sonatype staging repositories"

doLast {
val repos = fetchRepositoryIds()
val repos = fetchOpenRepositoryIds()
if (repos.isEmpty()) {
println("No open repositories found")
return@doLast
}
closeRepositories(repos)
waitForAllRepositoriesToClose(repos)
waitForAllRepositoriesToDesireState(repos, "closed")
releaseRepositories(repos)
waitForAllRepositoriesToDesireState(repos, "released")
dropRepositories(repos)
waitForArtifactsToBeAvailable()
//todo task for pushing a tag
}
}

fun fetchRepositoryIds(): List<String> {
fun fetchOpenRepositoryIds(): List<String> {
val client = HttpClients.createDefault()
val httpGet = HttpGet("$nexusUrl/profile_repositories").apply {
setHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString("$nexusUsername:$nexusPassword".toByteArray()))
Expand Down Expand Up @@ -189,9 +189,36 @@ fun closeRepositories(repoIds: List<String>) {
}
""".trimIndent()
executePostRequest(closeUrl, json)
println("Closed repositories: ${repoIds.joinToString(", ")}")
}

fun waitForAllRepositoriesToClose(repoIds: List<String>) {
fun releaseRepositories(repoIds: List<String>) {
val releaseUrl = "$nexusUrl/bulk/promote"
val json = """
{
"data": {
"stagedRepositoryIds": ${repoIds.joinToString(prefix = "[\"", separator = "\",\"", postfix = "\"]")}
}
}
""".trimIndent()
println("Released repositories: ${repoIds.joinToString(", ")}")
executePostRequest(releaseUrl, json)
}

fun dropRepositories(repoIds: List<String>) {
val dropUrl = "$nexusUrl/bulk/drop"
val json = """
{
"data": {
"stagedRepositoryIds": ${repoIds.joinToString(prefix = "[\"", separator = "\",\"", postfix = "\"]")}
}
}
""".trimIndent()
executePostRequest(dropUrl, json)
println("Dropped repositories: ${repoIds.joinToString(", ")}")
}

fun waitForAllRepositoriesToDesireState(repoIds: List<String>, desireState: String) {
val client = HttpClients.createDefault()
val statusUrl = "$nexusUrl/repository/"
val closedRepos = mutableSetOf<String>()
Expand All @@ -207,11 +234,11 @@ fun waitForAllRepositoriesToClose(repoIds: List<String>) {
val responseBody = EntityUtils.toString(response.entity)

val state = parseRepositoryState(responseBody, repoId)
if (state == "closed") {
if (state == desireState) {
println("Repository $repoId is now in state: $state")
closedRepos.add(repoId)
} else {
println("Waiting for repository $repoId to be closed, current state: $state")
println("Waiting for repository $repoId to be $desireState, current state: $state")
}
}
}
Expand All @@ -221,37 +248,50 @@ fun waitForAllRepositoriesToClose(repoIds: List<String>) {
}
}

fun releaseRepositories(repoIds: List<String>) {
val releaseUrl = "$nexusUrl/bulk/promote"
val json = """
{
"data": {
"stagedRepositoryIds": ${repoIds.joinToString(prefix = "[\"", separator = "\",\"", postfix = "\"]")}
}
}
""".trimIndent()
executePostRequest(releaseUrl, json)
}

fun waitForArtifactsToBeAvailable() {
val repoIds: List<String> = repoIdWithVersion.map { it.first }
val client = HttpClients.createDefault()
var artifactsAvailable = false

while (!artifactsAvailable) {
artifactsAvailable = repoIdWithVersion.all { (repoId, version) ->
val artifactUrl = "https://repo1.maven.org/maven2/com/walletconnect/$repoId/$version/"
val httpGet = HttpGet(artifactUrl)
val response = client.execute(httpGet)
response.statusLine.statusCode == 200
val artifactUrls = repoIdWithVersion.map { (repoId, version) ->
println("Checking: https://repo1.maven.org/maven2/com/walletconnect/$repoId/$version/")
"https://repo1.maven.org/maven2/com/walletconnect/$repoId/$version/"
}
val maxRetries = 20
var attempt = 0
val availableRepos = mutableSetOf<String>()

while (availableRepos.size < repoIds.size && attempt < maxRetries) {
artifactUrls.forEachIndexed { index, artifactUrl ->
if (!availableRepos.contains(repoIds[index])) {
val httpGet = HttpGet(artifactUrl)
try {
val response = client.execute(httpGet)
val statusCode = response.statusLine.statusCode
EntityUtils.consume(response.entity) // Ensure the response is fully consumed
if (statusCode == 200 || statusCode == 201) {
println("Artifact for repository ${repoIds[index]} is now available.")
availableRepos.add(repoIds[index])
} else {
println("Artifact for repository ${repoIds[index]} not yet available. Status code: $statusCode")
}
} catch (e: Exception) {
println("Error checking artifact for repository ${repoIds[index]}: ${e.message}")
} finally {
httpGet.releaseConnection() // Ensure the connection is released
}
}
}

if (!artifactsAvailable) {
println("Artifacts not yet available. Waiting...")
Thread.sleep(30000) // Wait for 30 seconds before retrying
} else {
println("All artifacts are now available.")
if (availableRepos.size < repoIds.size) {
println("Waiting for artifacts to be available... Attempt: ${attempt + 1}")
attempt++
Thread.sleep(10000) // Wait for 10 seconds before retrying
}
}

if (availableRepos.size < repoIds.size) {
throw RuntimeException("Artifacts were not available after ${maxRetries * 10} seconds.")
} else {
println("All artifacts are now available.")
}
}

fun executePostRequest(url: String, json: String) {
Expand Down Expand Up @@ -287,6 +327,20 @@ fun parseRepositoryState(xmlResponse: String, repositoryId: String): String? {
return null
}

tasks.register<Exec>("createTag") {
val tagName = "BOM_$BOM_VERSION"
commandLine("git", "tag", tagName)
}

tasks.register<Exec>("pushTagToMain") {
val tagName = "BOM_$BOM_VERSION"
val repoUrl = "https://github.com/WalletConnect/WalletConnectKotlinV2.git"
val token = System.getenv("GITHUB_TOKEN") ?: throw GradleException("GITHUB_TOKEN environment variable is not set")
dependsOn("createTag")
val authenticatedRepoUrl = repoUrl.replace("https://", "https://$token:@")
commandLine("git", "push", authenticatedRepoUrl, tagName, "refs/heads/main")
}

private val repoIdWithVersion = listOf(
Pair(ANDROID_BOM, BOM_VERSION),
Pair(FOUNDATION, FOUNDATION_VERSION),
Expand Down
22 changes: 11 additions & 11 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID"
const val KEY_SDK_NAME = "SDK_NAME"

//Latest versions
const val BOM_VERSION = "1.33.0"
const val FOUNDATION_VERSION = "1.17.3"
const val CORE_VERSION = "1.33.0"
const val SIGN_VERSION = "2.33.0"
const val AUTH_VERSION = "1.28.4"
const val CHAT_VERSION = "1.0.0-beta31"
const val NOTIFY_VERSION = "1.3.5"
const val WEB_3_WALLET_VERSION = "1.33.0"
const val WEB_3_MODAL_VERSION = "1.6.0"
const val WC_MODAL_VERSION = "1.5.5"
const val MODAL_CORE_VERSION = "1.6.0"
const val BOM_VERSION = "1.33.1"
const val FOUNDATION_VERSION = "1.17.4"
const val CORE_VERSION = "1.33.1"
const val SIGN_VERSION = "2.33.1"
const val AUTH_VERSION = "1.28.5"
const val CHAT_VERSION = "1.0.0-beta32"
const val NOTIFY_VERSION = "1.3.6"
const val WEB_3_WALLET_VERSION = "1.33.1"
const val WEB_3_MODAL_VERSION = "1.6.1"
const val WC_MODAL_VERSION = "1.5.6"
const val MODAL_CORE_VERSION = "1.6.1"

//Artifact ids
const val ANDROID_BOM = "android-bom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.walletconnect.android.internal.common.di
enum class AndroidCommonDITags {
MOSHI,
SHARED_INTERCEPTOR,
FAIL_OVER_INTERCEPTOR,
LOGGING_INTERCEPTOR,
AUTHENTICATOR,
OK_HTTP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,6 @@ import org.koin.dsl.module
import com.walletconnect.android.internal.common.scope as wcScope

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

fun Scope.createCoreDB(): AndroidCoreDatabase = AndroidCoreDatabase(
driver = get(named(AndroidBuildVariantDITags.ANDROID_CORE_DATABASE_DRIVER)),
MetaDataAdapter = MetaData.Adapter(
iconsAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_LIST)),
typeAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_APPMETADATATYPE))
),
VerifyContextAdapter = VerifyContext.Adapter(
validationAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_VALIDATION))
),
EventDaoAdapter = EventDao.Adapter(
traceAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_LIST))
),
JsonRpcHistoryDaoAdapter = JsonRpcHistoryDao.Adapter(
transport_typeAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_TRANSPORT_TYPE))
)
)

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 @@ -82,6 +64,23 @@ fun baseStorageModule(storagePrefix: String = String.Empty, bundleId: String) =

single<ColumnAdapter<Validation, String>>(named(AndroidCommonDITags.COLUMN_ADAPTER_VALIDATION)) { EnumColumnAdapter() }

fun Scope.createCoreDB(): AndroidCoreDatabase = AndroidCoreDatabase(
driver = get(named(AndroidBuildVariantDITags.ANDROID_CORE_DATABASE_DRIVER)),
MetaDataAdapter = MetaData.Adapter(
iconsAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_LIST)),
typeAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_APPMETADATATYPE))
),
VerifyContextAdapter = VerifyContext.Adapter(
validationAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_VALIDATION))
),
EventDaoAdapter = EventDao.Adapter(
traceAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_LIST))
),
JsonRpcHistoryDaoAdapter = JsonRpcHistoryDao.Adapter(
transport_typeAdapter = get(named(AndroidCommonDITags.COLUMN_ADAPTER_TRANSPORT_TYPE))
)
)

single<AndroidCoreDatabase>(named(AndroidBuildVariantDITags.ANDROID_CORE_DATABASE)) {
try {
createCoreDB().also { database ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sealed class TestState {
@ExperimentalCoroutinesApi
class RelayTest {
private val testProjectId: String = requireNotNull(System.getProperty("TEST_PROJECT_ID"))
private val testRelayUrl: String = "https://staging.relay.walletconnect.org"
private val testRelayUrl: String = requireNotNull(System.getProperty("TEST_RELAY_URL"))
private val serverUrl = "$testRelayUrl?projectId=$testProjectId"
private val sdkVersion: String = System.getProperty("SDK_VERSION") + "-relayTest"
private val testJob: CompletableJob = SupervisorJob()
Expand Down Expand Up @@ -97,7 +97,7 @@ class RelayTest {
runBlocking {
val start = System.currentTimeMillis()
// Await test finish or check if timeout occurred
while (testState.value is TestState.Idle && !didTimeout(start, 20000L)) {
while (testState.value is TestState.Idle && !didTimeout(start, 60000L)) {
delay(10)
}

Expand Down Expand Up @@ -138,7 +138,7 @@ class RelayTest {
runBlocking {
val start = System.currentTimeMillis()
// Await test finish or check if timeout occurred
while (testState.value is TestState.Idle && !didTimeout(start, 10000L)) {
while (testState.value is TestState.Idle && !didTimeout(start, 60000L)) {
delay(10)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal class Web3ModalEngine(
internal var recommendedWalletsIds: MutableList<String> = mutableListOf()
internal var siweRequestIdWithMessage: Pair<Long, String>? = null
private lateinit var coinbaseClient: CoinbaseClient
internal var shouldDisconnect: Boolean = true

fun setup(
init: Modal.Params.Init,
Expand Down Expand Up @@ -165,15 +166,15 @@ internal class Web3ModalEngine(
}
}

private fun openWalletApp(topic: String, onError: (Throwable) -> Unit) {
private fun openWalletApp(topic: String, onError: (RedirectMissingThrowable) -> Unit) {
val redirect = SignClient.getActiveSessionByTopic(topic)?.redirect ?: String.Empty
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(redirect))
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
wcKoinApp.koin.get<Context>().startActivity(intent)
} catch (e: Throwable) {
onError(e)
onError(RedirectMissingThrowable("Please redirect to a wallet manually"))
}
}

Expand Down Expand Up @@ -205,6 +206,7 @@ internal class Web3ModalEngine(
onSuccess = {
sendEventUseCase.send(Props(EventType.TRACK, EventType.Track.DISCONNECT_SUCCESS))
scope.launch { deleteSessionDataUseCase() }
shouldDisconnect = true
onSuccess()
},
onError = {
Expand Down Expand Up @@ -346,4 +348,6 @@ internal class Web3ModalEngine(
"Coinbase Client needs to be initialized first using the initialize function"
}
}

internal class RedirectMissingThrowable(message: String) : Throwable(message)
}
Loading

0 comments on commit a028335

Please sign in to comment.