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

PWN-8341 - refreshDeviceShare no longer contains metadata to update - we do it by ourselves #1889

Merged
1 commit merged into from
Jun 28, 2023
Merged
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
2 changes: 1 addition & 1 deletion app/src/main/assets/index.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.p2p.wallet.auth.interactor.restore

import org.p2p.wallet.auth.analytics.RestoreWalletAnalytics
import org.p2p.wallet.auth.analytics.RestoreWalletAnalytics.UsernameRestoreMethod
import org.p2p.wallet.auth.gateway.repository.model.GatewayOnboardingMetadata
import org.p2p.wallet.auth.model.OnboardingFlow
import org.p2p.wallet.auth.model.PhoneNumber
import org.p2p.wallet.auth.model.RestoreUserResult
Expand Down Expand Up @@ -42,9 +41,8 @@ class RestoreWalletInteractor(
suspend fun tryRestoreUser(restoreFlow: OnboardingFlow.RestoreWallet): RestoreUserResult =
userRestoreInteractor.tryRestoreUser(restoreFlow)

suspend fun refreshDeviceShare(
metadata: GatewayOnboardingMetadata
): Web3AuthSignUpResponse.ShareDetailsWithMeta = userRestoreInteractor.refreshDeviceShare(metadata)
suspend fun refreshDeviceShare(): Web3AuthSignUpResponse.ShareDetailsWithMeta =
userRestoreInteractor.refreshDeviceShare()

suspend fun finishAuthFlow() {
restoreWalletAnalytics.setUserRestoreMethod(UsernameRestoreMethod.WEB3AUTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.p2p.wallet.auth.interactor.restore
import com.google.gson.JsonObject
import timber.log.Timber
import org.p2p.core.crashlytics.CrashLogger
import org.p2p.wallet.auth.gateway.repository.model.GatewayOnboardingMetadata
import org.p2p.wallet.auth.interactor.UsernameInteractor
import org.p2p.wallet.auth.model.OnboardingFlow.RestoreWallet
import org.p2p.wallet.auth.model.RestoreError
Expand Down Expand Up @@ -262,12 +261,10 @@ class UserRestoreInteractor(
usernameInteractor.tryRestoreUsername(tokenKeyProvider.publicKey.toBase58Instance())
}

suspend fun refreshDeviceShare(
metadata: GatewayOnboardingMetadata
): Web3AuthSignUpResponse.ShareDetailsWithMeta {
suspend fun refreshDeviceShare(): Web3AuthSignUpResponse.ShareDetailsWithMeta {
val socialShareUserId = restoreFlowDataLocalRepository.socialShareUserId
?: error("Device+Social restore way failed. Social share ID is null")
val deviceShare = web3AuthApi.refreshDeviceShare(metadata)
val deviceShare = web3AuthApi.refreshDeviceShare()
val data = signUpDetailsStorage.getLastSignUpUserDetails()!!.signUpDetails.copy(deviceShare = deviceShare)
signUpDetailsStorage.save(
data = data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.p2p.wallet.auth.web3authsdk

import com.google.gson.JsonObject
import org.p2p.wallet.auth.gateway.repository.model.GatewayOnboardingMetadata
import org.p2p.wallet.auth.web3authsdk.response.Web3AuthSignInResponse
import org.p2p.wallet.auth.web3authsdk.response.Web3AuthSignUpResponse

Expand Down Expand Up @@ -29,9 +28,7 @@ interface Web3AuthApi {
encryptedMnemonic: JsonObject
): Web3AuthSignInResponse

suspend fun refreshDeviceShare(
metadata: GatewayOnboardingMetadata
): Web3AuthSignUpResponse.ShareDetailsWithMeta
suspend fun refreshDeviceShare(): Web3AuthSignUpResponse.ShareDetailsWithMeta

/**
* @param googleIdJwtToken used to auth user on Web3Auth server-side using google web client id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import kotlin.coroutines.resumeWithException
import kotlinx.coroutines.CancellableContinuation
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.suspendCancellableCoroutine
import org.p2p.core.network.environment.TorusEnvironment
import org.p2p.wallet.BuildConfig
import org.p2p.wallet.auth.gateway.repository.model.GatewayOnboardingMetadata
import org.p2p.wallet.auth.repository.AuthRepository
import org.p2p.wallet.auth.web3authsdk.mapper.Web3AuthClientMapper
import org.p2p.wallet.auth.web3authsdk.response.Web3AuthSignInResponse
import org.p2p.wallet.auth.web3authsdk.response.Web3AuthSignUpResponse
import org.p2p.core.network.environment.TorusEnvironment

private const val JS_COMMUNICATION_CHANNEL_NAME = "AndroidCommunicationChannel"
private const val INDEX_HTML_URI = "file:///android_asset/index.html"
Expand Down Expand Up @@ -155,19 +154,16 @@ class Web3AuthApiClient(
}
}

override suspend fun refreshDeviceShare(
metadata: GatewayOnboardingMetadata
): Web3AuthSignUpResponse.ShareDetailsWithMeta {
override suspend fun refreshDeviceShare(): Web3AuthSignUpResponse.ShareDetailsWithMeta {
return suspendCancellableCoroutine {
this.continuation = it

Timber.tag(TAG).i("refreshDeviceShare triggered")

val metadataAsJsObject = gson.toJson(metadata)
onboardingWebView.evaluateJavascript("console.log(lastFacade)", null)
onboardingWebView.evaluateJavascript(
callToLastFacade(
jsMethodCall = "refreshDeviceShare($metadataAsJsObject)"
jsMethodCall = "refreshDeviceShare()"
),
null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DevicesPresenter(

private suspend fun refreshDeviceShare(newMetadata: GatewayOnboardingMetadata) {
try {
restoreWalletInteractor.refreshDeviceShare(newMetadata)
restoreWalletInteractor.refreshDeviceShare()
metadataInteractor.updateMetadata(newMetadata)
} catch (error: Throwable) {
view?.showFailDeviceChange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SettingsEmailConfirmPresenter(

private suspend fun refreshDeviceShare(newMetadata: GatewayOnboardingMetadata) {
try {
restoreWalletInteractor.refreshDeviceShare(newMetadata)
restoreWalletInteractor.refreshDeviceShare()
metadataInteractor.updateMetadata(newMetadata)
} catch (error: Throwable) {
view?.showFailDeviceChange()
Expand Down
Loading