Skip to content

Commit

Permalink
Fix a race condition on launch that causes mobile wallet issue (#154)
Browse files Browse the repository at this point in the history
On release build, abacusStateManager.environment might not be yet set
when the worker starts.

There is still an issue where the first attempt triggers a WalletConnect
NoRelayConnection error. We will need to look into that in next couple
of weeks.
  • Loading branch information
ruixhuang authored Jun 12, 2024
1 parent 73fc704 commit ca681df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion v4/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
minSdkVersion parent.minSdkVersion
targetSdkVersion parent.targetSdkVersion
versionCode 11
versionName "1.4.0"
versionName "1.4.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ object DydxOnboardConnectView : DydxComponent {
closeAction = { state.closeButtonHandler?.invoke() },
)
Text(
text = state.localizer.localize("ONBOARDING.TWO_SIGNATURE_REQUESTS"),
text = state.localizer.localize("APP.ONBOARDING.TWO_SIGNATURE_REQUESTS"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import exchange.dydx.utilities.utils.Logging
import exchange.dydx.utilities.utils.WorkerProtocol
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach

private const val TAG = "DydxCarteraConfigWorker"

Expand All @@ -38,11 +40,16 @@ class DydxCarteraConfigWorker(
}
}

abacusStateManager.environment?.let {
configureCartera(it)
} ?: run {
logger.e(TAG, "Environment is null")
}
abacusStateManager.currentEnvironmentId
.filterNotNull()
.onEach {
abacusStateManager.environment?.let {
configureCartera(it)
} ?: run {
logger.e(TAG, "Environment is null")
}
}
.launchIn(scope)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DydxV4WalletSetup @Inject constructor(
val map = json.jsonObject.toMap()
val mnemonic = parser.asString(map["mnemonic"])
val cosmosAddress = parser.asString(map["address"])
if (mnemonic != null && address != null) {
if (mnemonic != null) {
_status.value = Status.Signed(
SetupResult(
ethereumAddress = address,
Expand Down

0 comments on commit ca681df

Please sign in to comment.