Skip to content

Commit

Permalink
Merge pull request #3 from reown-com/migration_clean_ups
Browse files Browse the repository at this point in the history
Migration clean ups
  • Loading branch information
jakubuid authored Sep 11, 2024
2 parents b82f8a5 + bfcd177 commit 96f85b1
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 250 deletions.
6 changes: 0 additions & 6 deletions product/appkit/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

# Installation

:::caution
**The AppKit SDK is currently in Alpha and is not production-ready**.

It's public API and associated documentation may still see significant and breaking changes.
:::

Kotlin implementation of AppKit for Android applications.

Android Core ![Maven Central](https://img.shields.io/maven-central/v/com.walletconnect/android-core)
Expand Down
53 changes: 0 additions & 53 deletions product/appkit/src/main/kotlin/com/reown/appkit/client/AppKit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,6 @@ object AppKit {
}.launchIn(scope)
}

@Deprecated(
message = "Replaced with the same name method but onSuccess callback returns a Pairing URL",
replaceWith = ReplaceWith(expression = "fun connect(connect: Modal.Params.Connect, onSuccess: (String) -> Unit, onError: (Modal.Model.Error) -> Unit)")
)
internal fun connect(
connect: Modal.Params.Connect,
onSuccess: () -> Unit,
onError: (Modal.Model.Error) -> Unit
) {
SignClient.connect(
connect.toSign(),
onSuccess
) { onError(it.toModal()) }
}

fun connect(
connect: Modal.Params.Connect,
onSuccess: (String) -> Unit,
Expand Down Expand Up @@ -219,23 +204,6 @@ object AppKit {
}
}

@Deprecated(
message = "Modal.Params.Request is deprecated",
replaceWith = ReplaceWith("com.reown.appkit.client.models.Request")
)
fun request(
request: Modal.Params.Request,
onSuccess: (Modal.Model.SentRequest) -> Unit = {},
onError: (Modal.Model.Error) -> Unit,
) {
checkEngineInitialization()
appKitEngine.request(
request = Request(request.method, request.params, request.expiry),
onSuccess = { onSuccess(it.sentRequestToModal()) },
onError = { onError(it.toModalError()) }
)
}

fun request(
request: Request,
onSuccess: (SentRequestResult) -> Unit = {},
Expand All @@ -261,26 +229,6 @@ object AppKit {

fun ping(sessionPing: Modal.Listeners.SessionPing? = null) = appKitEngine.ping(sessionPing)

@Deprecated(
message = "This has become deprecate in favor of the parameterless disconnect function",
level = DeprecationLevel.WARNING
)
fun disconnect(
onSuccess: (Modal.Params.Disconnect) -> Unit = {},
onError: (Modal.Model.Error) -> Unit,
) {
checkEngineInitialization()
val topic = when (val session = appKitEngine.getActiveSession()) {
is WalletConnect -> session.topic
else -> String.Empty
}

appKitEngine.disconnect(
onSuccess = { onSuccess(Modal.Params.Disconnect(topic)) },
onError = { onError(it.toModalError()) }
)
}

fun disconnect(
onSuccess: () -> Unit,
onError: (Throwable) -> Unit,
Expand All @@ -294,7 +242,6 @@ object AppKit {
* It is advised that this function be called from background operation
*/
fun getSelectedChain() = selectedChain
// fun getSelectedChain() = getSelectedChainUseCase()?.toChain()

/**
* Caution: This function is blocking and runs on the current thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,6 @@ object WalletKit {
return SignClient.getActiveSessionByTopic(topic)?.toWallet()
}

/**
* Caution: This function is blocking and runs on the current thread.
* It is advised that this function be called from background operation
*/

@Deprecated(
"The return type of getPendingRequests methods has been replaced with SessionRequest list",
replaceWith = ReplaceWith("getPendingSessionRequests(topic: String): List<Sign.Model.SessionRequest>")
)
@Throws(IllegalStateException::class)
fun getPendingSessionRequests(topic: String): List<Wallet.Model.PendingSessionRequest> {
return SignClient.getPendingRequests(topic).mapToPendingRequests()
}

/**
* Caution: This function is blocking and runs on the current thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,19 @@ interface SignInterface {
fun initialize(init: Sign.Params.Init, onSuccess: () -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
fun setWalletDelegate(delegate: WalletDelegate)
fun setDappDelegate(delegate: DappDelegate)

@Deprecated(
message = "Replaced with the same name method but onSuccess callback returns a Pairing URL",
replaceWith = ReplaceWith(expression = "fun connect(connect: Sign.Params.Connect, onSuccess: (String) -> Unit, onError: (Sign.Model.Error) -> Unit)")
)
fun connect(
connect: Sign.Params.Connect, onSuccess: () -> Unit,
onError: (Sign.Model.Error) -> Unit,
)

fun connect(
connect: Sign.Params.Connect, 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(
message = "Creating a pairing will be moved to CoreClient to make pairing SDK agnostic",
replaceWith = ReplaceWith(expression = "CoreClient.Pairing.pair()", imports = ["com.reown.android.CoreClient"])
)
fun pair(pair: Sign.Params.Pair, onSuccess: (Sign.Params.Pair) -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
fun approveSession(approve: Sign.Params.Approve, onSuccess: (Sign.Params.Approve) -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
fun rejectSession(reject: Sign.Params.Reject, onSuccess: (Sign.Params.Reject) -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
fun approveAuthenticate(approve: Sign.Params.ApproveAuthenticate, onSuccess: (Sign.Params.ApproveAuthenticate) -> Unit, onError: (Sign.Model.Error) -> Unit)
fun rejectAuthenticate(reject: Sign.Params.RejectAuthenticate, onSuccess: (Sign.Params.RejectAuthenticate) -> Unit, onError: (Sign.Model.Error) -> Unit)
fun formatAuthMessage(formatMessage: Sign.Params.FormatMessage): String

@Deprecated(
message = "The onSuccess callback has been replaced with a new callback that returns Sign.Model.SentRequest",
replaceWith = ReplaceWith(expression = "this.request(request, onSuccessWithSentRequest, onError)", imports = ["com.reown.sign.client"])
)
fun request(
request: Sign.Params.Request,
onSuccess: (Sign.Params.Request) -> Unit = {},
onSuccessWithSentRequest: (Sign.Model.SentRequest) -> Unit = { it: Sign.Model.SentRequest -> Unit },
onError: (Sign.Model.Error) -> Unit,
)

fun request(request: Sign.Params.Request, onSuccess: (Sign.Model.SentRequest) -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
fun respond(response: Sign.Params.Response, onSuccess: (Sign.Params.Response) -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
fun update(update: Sign.Params.Update, onSuccess: (Sign.Params.Update) -> Unit = {}, onError: (Sign.Model.Error) -> Unit)
Expand All @@ -115,46 +88,6 @@ interface SignInterface {
*/
fun getActiveSessionByTopic(topic: String): Sign.Model.Session?

/**
* Caution: This function is blocking and runs on the current thread.
* It is advised that this function be called from background operation
*/
@Deprecated(
message = "Getting a list of settled sessions is replaced with getListOfActiveSessions()",
replaceWith = ReplaceWith(expression = "SignClient.getListOfActiveSessions()")
)
fun getListOfSettledSessions(): List<Sign.Model.Session>

/**
* Caution: This function is blocking and runs on the current thread.
* It is advised that this function be called from background operation
*/
@Deprecated(
message = "Getting a list of settled sessions by topic is replaced with getSettledSessionByTopic()",
replaceWith = ReplaceWith(expression = "SignClient.getSettledSessionByTopic()")
)
fun getSettledSessionByTopic(topic: String): Sign.Model.Session?

/**
* Caution: This function is blocking and runs on the current thread.
* It is advised that this function be called from background operation
*/
@Deprecated(
message = "Getting a list of Pairings will be moved to CoreClient to make pairing SDK agnostic",
replaceWith = ReplaceWith(expression = "CoreClient.Pairing.getPairings()")
)
fun getListOfSettledPairings(): List<Sign.Model.Pairing>

/**
* Caution: This function is blocking and runs on the current thread.
* It is advised that this function be called from background operation
*/
@Deprecated(
"The return type of getPendingRequests methods has been replaced with SessionRequest list",
replaceWith = ReplaceWith("getPendingSessionRequests(topic: String): List<Sign.Model.SessionRequest>")
)
fun getPendingRequests(topic: String): List<Sign.Model.PendingRequest>

/**
* Caution: This function is blocking and runs on the current thread.
* It is advised that this function be called from background operation
Expand Down
111 changes: 0 additions & 111 deletions protocol/sign/src/main/kotlin/com/reown/sign/client/SignProtocol.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,6 @@ class SignProtocol(private val koinApp: KoinApplication = wcKoinApp) : SignInter
return runBlocking { signEngine.formatMessage(formatMessage.payloadParams.toEngine(), formatMessage.iss) }
}

@Throws(IllegalStateException::class)
override fun pair(
pair: Sign.Params.Pair,
onSuccess: (Sign.Params.Pair) -> Unit,
onError: (Sign.Model.Error) -> Unit,
) {
checkEngineInitialization()

scope.launch {
try {
signEngine.pair(
uri = pair.uri,
onSuccess = { onSuccess(pair) },
onFailure = { throwable -> onError(Sign.Model.Error(throwable)) }
)
} catch (error: Exception) {
onError(Sign.Model.Error(error))
}
}
}

@Throws(IllegalStateException::class)
override fun approveSession(approve: Sign.Params.Approve, onSuccess: (Sign.Params.Approve) -> Unit, onError: (Sign.Model.Error) -> Unit) {
checkEngineInitialization()
Expand Down Expand Up @@ -424,23 +403,6 @@ class SignProtocol(private val koinApp: KoinApplication = wcKoinApp) : SignInter
}
}

@Throws(IllegalStateException::class)
override fun getListOfSettledSessions(): List<Sign.Model.Session> {
checkEngineInitialization()
return runBlocking {
signEngine.getListOfSettledSessions().map(EngineDO.Session::toClientActiveSession)
}
}

@Throws(IllegalStateException::class)
override fun getSettledSessionByTopic(topic: String): Sign.Model.Session? {
checkEngineInitialization()
return runBlocking {
signEngine.getListOfSettledSessions().map(EngineDO.Session::toClientActiveSession)
.find { session -> session.topic == topic }
}
}

@Throws(IllegalStateException::class)
override fun getPendingSessionRequests(topic: String): List<Sign.Model.SessionRequest> {
checkEngineInitialization()
Expand Down Expand Up @@ -471,79 +433,6 @@ class SignProtocol(private val koinApp: KoinApplication = wcKoinApp) : SignInter
return runBlocking { signEngine.getListOfVerifyContexts().map { verifyContext -> verifyContext.toCore() } }
}

@Deprecated(
message = "Replaced with the same name method but onSuccess callback returns a Pairing URL",
replaceWith = ReplaceWith(expression = "fun connect(connect: Sign.Params.Connect, onSuccess: (String) -> Unit, onError: (Sign.Model.Error) -> Unit)")
)
@Throws(IllegalStateException::class)
override fun connect(
connect: Sign.Params.Connect,
onSuccess: () -> Unit,
onError: (Sign.Model.Error) -> Unit,
) {
checkEngineInitialization()
scope.launch {
try {
signEngine.proposeSession(
connect.namespaces?.toMapOfEngineNamespacesRequired(),
connect.optionalNamespaces?.toMapOfEngineNamespacesOptional(),
connect.properties,
connect.pairing.toPairing(),
onSuccess = { onSuccess() },
onFailure = { error -> onError(Sign.Model.Error(error)) }
)
} 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.reown.sign.client")
)
@Throws(IllegalStateException::class)
override fun request(
request: Sign.Params.Request,
onSuccess: (Sign.Params.Request) -> Unit,
onSuccessWithSentRequest: (Sign.Model.SentRequest) -> Unit,
onError: (Sign.Model.Error) -> Unit,
) {
checkEngineInitialization()

scope.launch {
try {
signEngine.sessionRequest(
request = request.toEngineDORequest(),
onSuccess = { onSuccess(request) },
onFailure = { error -> onError(Sign.Model.Error(error)) }
)
} catch (error: Exception) {
onError(Sign.Model.Error(error))
}
}
}

@Deprecated(
"Getting a list of Pairings will be moved to CoreClient to make pairing SDK agnostic",
replaceWith = ReplaceWith("CoreClient.Pairing.getPairings()", "com.reown.android.CoreClient")
)
@Throws(IllegalStateException::class)
override fun getListOfSettledPairings(): List<Sign.Model.Pairing> {
checkEngineInitialization()
return runBlocking { signEngine.getListOfSettledPairings().map(EngineDO.PairingSettle::toClientSettledPairing) }
}

@Deprecated(
"The return type of getPendingRequests methods has been replaced with SessionRequest list",
replaceWith = ReplaceWith("getPendingSessionRequests(topic: String): List<Sign.Model.SessionRequest>")
)
@Throws(IllegalStateException::class)
override fun getPendingRequests(topic: String): List<Sign.Model.PendingRequest> {
checkEngineInitialization()
return runBlocking { signEngine.getPendingRequests(Topic(topic)).mapToPendingRequests() }
}

// TODO: Uncomment once reinit scope logic is added
// fun shutdown() {
// scope.cancel()
Expand Down

0 comments on commit 96f85b1

Please sign in to comment.