Skip to content

Commit

Permalink
Remove callback for link mode authenticate
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubuid committed Jul 15, 2024
1 parent 52957df commit 82415bd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ object Web3Modal {
fun authenticate(
authenticate: Modal.Params.Authenticate,
walletAppLink: String? = null,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onError: (Modal.Model.Error) -> Unit,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ internal class Web3ModalEngine(
name: String, method: String,
authenticate: Modal.Params.Authenticate,
walletAppLink: String? = null,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onError: (Throwable) -> Unit
) {
connectionEventRepository.saveEvent(name, method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ internal class ConnectViewModel : ViewModel(), Navigator by NavigatorImpl(), Par
name, method,
walletAppLink = linkMode,
authParams = if (Web3Modal.selectedChain != null) Web3Modal.authPayloadParams!!.copy(chains = listOf(Web3Modal.selectedChain!!.id)) else Web3Modal.authPayloadParams!!,
onSuccess = { if (!it.isNullOrBlank()) onSuccess(it) },
onSuccess = { onSuccess(it) },
onError = {
sendEventUseCase.send(Props(EventType.TRACK, EventType.Track.CONNECT_ERROR, Properties(message = it.message ?: "Relay error while connecting")))
showError(it.localizedMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal interface ParingController {
name: String, method: String,
authParams: Modal.Model.AuthPayloadParams,
walletAppLink: String? = null,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onError: (Throwable) -> Unit
)

Expand Down Expand Up @@ -66,7 +66,7 @@ internal class PairingControllerImpl : ParingController {
method: String,
authParams: Modal.Model.AuthPayloadParams,
walletAppLink: String?,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onError: (Throwable) -> Unit
) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fun dappClientAuthenticateLinkMode(onPairing: (String) -> Unit) {
"https://web3modal-laboratory-git-chore-kotlin-assetlinks-walletconnect1.vercel.app/wallet",
onSuccess = { pairingUrl ->
Timber.d("DappClient: on sent authenticate success: $pairingUrl")
onPairing(pairingUrl ?: "")
onPairing(pairingUrl)
},
onError = ::globalOnError
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ interface SignInterface {
onError: (Sign.Model.Error) -> Unit,
)

fun authenticate(authenticate: Sign.Params.Authenticate, walletAppLink: String?, onSuccess: (String?) -> Unit, onError: (Sign.Model.Error) -> Unit)

@Deprecated(
"The onSuccess callback has been replaced with a new callback that returns optional Pairing URL",
replaceWith = ReplaceWith("fun authenticate(authenticate: Sign.Params.Authenticate, val walletAppLink: String?, onSuccess: (String?) -> Unit, onError: (Sign.Model.Error) -> Unit)")
)
fun authenticate(authenticate: Sign.Params.Authenticate, onSuccess: (String) -> Unit, onError: (Sign.Model.Error) -> Unit)

fun authenticate(authenticate: Sign.Params.Authenticate, walletAppLink: String? = null, onSuccess: (String) -> Unit, onError: (Sign.Model.Error) -> Unit)
fun dispatchEnvelope(urlWithEnvelope: String, onError: (Sign.Model.Error) -> Unit)

@Deprecated(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.walletconnect.sign.di.signJsonRpcModule
import com.walletconnect.sign.di.storageModule
import com.walletconnect.sign.engine.domain.SignEngine
import com.walletconnect.sign.engine.model.EngineDO
import com.walletconnect.util.Empty
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -137,7 +136,7 @@ class SignProtocol(private val koinApp: KoinApplication = wcKoinApp) : SignInter
override fun authenticate(
authenticate: Sign.Params.Authenticate,
walletAppLink: String?,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onError: (Sign.Model.Error) -> Unit,
) {
checkEngineInitialization()
Expand Down Expand Up @@ -499,31 +498,6 @@ class SignProtocol(private val koinApp: KoinApplication = wcKoinApp) : SignInter
}
}

@Deprecated(
"The onSuccess callback has been replaced with a new callback that returns optional Pairing URL",
replaceWith = ReplaceWith("fun authenticate(authenticate: Sign.Params.Authenticate, val walletAppLink: String?, onSuccess: (String?) -> Unit, onError: (Sign.Model.Error) -> Unit)")
)
@Throws(IllegalStateException::class)
override fun authenticate(
authenticate: Sign.Params.Authenticate,
onSuccess: (String) -> Unit,
onError: (Sign.Model.Error) -> Unit,
) {
checkEngineInitialization()
scope.launch {
try {
signEngine.authenticate(authenticate.toAuthenticate(),
authenticate.methods, authenticate.pairingTopic,
if (authenticate.expiry == null) null else Expiry(authenticate.expiry),
null,
onSuccess = { url -> onSuccess(url ?: String.Empty) },
onFailure = { throwable -> onError(Sign.Model.Error(throwable)) })
} catch (error: Exception) {
onError(Sign.Model.Error(error))
}
}
}

@Deprecated(
"The onSuccess callback has been replaced with a new callback that returns Sign.Model.SentRequest",
replaceWith = ReplaceWith("this.request(request, onSuccessWithSentRequest, onError)", "com.walletconnect.sign.client")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class SessionAuthenticateUseCase(
pairingTopic: String?,
expiry: Expiry?,
walletAppLink: String?,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onFailure: (Throwable) -> Unit
) {
if (authenticate.chains.isEmpty()) {
Expand Down Expand Up @@ -101,7 +101,6 @@ internal class SessionAuthenticateUseCase(
if (isLinkModeEnabled(walletAppLink)) {
try {
linkModeJsonRpcInteractor.triggerRequest(authRequest, appLink = walletAppLink!!, topic = Topic(generateUUID()), envelopeType = EnvelopeType.TWO)
onSuccess(null)
} catch (e: Error) {
onFailure(e)
}
Expand Down Expand Up @@ -230,7 +229,7 @@ internal interface SessionAuthenticateUseCaseInterface {
pairingTopic: String?,
expiry: Expiry?,
walletAppLink: String? = null,
onSuccess: (String?) -> Unit,
onSuccess: (String) -> Unit,
onFailure: (Throwable) -> Unit
)
}

0 comments on commit 82415bd

Please sign in to comment.