diff --git a/product/walletkit/src/main/kotlin/com/reown/walletkit/client/Wallet.kt b/product/walletkit/src/main/kotlin/com/reown/walletkit/client/Wallet.kt index 71a9fefd9..89779cacd 100644 --- a/product/walletkit/src/main/kotlin/com/reown/walletkit/client/Wallet.kt +++ b/product/walletkit/src/main/kotlin/com/reown/walletkit/client/Wallet.kt @@ -28,6 +28,7 @@ object Wallet { val properties: Map? = null, val scopedProperties: Map? = null, val relayProtocol: String? = null, + val sessionTopic: String? = null ) : Params() data class ApproveSessionAuthenticate(val id: Long, val auths: List) : Params() diff --git a/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt b/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt index 8c1f411a4..b470751a0 100644 --- a/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt +++ b/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt @@ -114,7 +114,12 @@ object WalletKit { } @Throws(IllegalStateException::class) - fun registerDeviceToken(firebaseAccessToken: String, enableEncrypted: Boolean = false, onSuccess: () -> Unit, onError: (Wallet.Model.Error) -> Unit) { + fun registerDeviceToken( + firebaseAccessToken: String, + enableEncrypted: Boolean = false, + onSuccess: () -> Unit, + onError: (Wallet.Model.Error) -> Unit + ) { coreClient.Echo.register(firebaseAccessToken, enableEncrypted, onSuccess) { error -> onError(Wallet.Model.Error(error)) } } @@ -157,12 +162,24 @@ object WalletKit { onSuccess: (Wallet.Params.SessionApprove) -> Unit = {}, onError: (Wallet.Model.Error) -> Unit, ) { - val signParams = Sign.Params.Approve(params.proposerPublicKey, params.namespaces.toSign(), params.properties, params.scopedProperties, params.relayProtocol) - SignClient.approveSession(signParams, { onSuccess(params) }, { error -> onError(Wallet.Model.Error(error.throwable)) }) + val signParams = Sign.Params.Approve( + params.proposerPublicKey, + params.namespaces.toSign(), + params.properties, + params.scopedProperties, + params.relayProtocol, + ) + SignClient.approveSession( + signParams, + { approve -> onSuccess(params.copy(sessionTopic = approve.sessionTopic)) }, + { error -> onError(Wallet.Model.Error(error.throwable)) }) } @Throws(Exception::class) - fun generateApprovedNamespaces(sessionProposal: Wallet.Model.SessionProposal, supportedNamespaces: Map): Map { + fun generateApprovedNamespaces( + sessionProposal: Wallet.Model.SessionProposal, + supportedNamespaces: Map + ): Map { return com.reown.sign.client.utils.generateApprovedNamespaces(sessionProposal.toSign(), supportedNamespaces.toSign()).toWallet() } @@ -197,12 +214,20 @@ object WalletKit { } @Throws(Exception::class) - fun generateAuthObject(payloadParams: Wallet.Model.PayloadAuthRequestParams, issuer: String, signature: Wallet.Model.Cacao.Signature): Wallet.Model.Cacao { + fun generateAuthObject( + payloadParams: Wallet.Model.PayloadAuthRequestParams, + issuer: String, + signature: Wallet.Model.Cacao.Signature + ): Wallet.Model.Cacao { return com.reown.sign.client.utils.generateAuthObject(payloadParams.toSign(), issuer, signature.toSign()).toWallet() } @Throws(Exception::class) - fun generateAuthPayloadParams(payloadParams: Wallet.Model.PayloadAuthRequestParams, supportedChains: List, supportedMethods: List): Wallet.Model.PayloadAuthRequestParams { + fun generateAuthPayloadParams( + payloadParams: Wallet.Model.PayloadAuthRequestParams, + supportedChains: List, + supportedMethods: List + ): Wallet.Model.PayloadAuthRequestParams { return com.reown.sign.client.utils.generateAuthPayloadParams(payloadParams.toSign(), supportedChains, supportedMethods).toWallet() } diff --git a/protocol/sign/src/main/kotlin/com/reown/sign/client/Sign.kt b/protocol/sign/src/main/kotlin/com/reown/sign/client/Sign.kt index 11d106dbf..7dcba3f9a 100644 --- a/protocol/sign/src/main/kotlin/com/reown/sign/client/Sign.kt +++ b/protocol/sign/src/main/kotlin/com/reown/sign/client/Sign.kt @@ -355,6 +355,7 @@ object Sign { val properties: Map? = null, val scopedProperties: Map? = null, val relayProtocol: String? = null, + val sessionTopic: String? = null ) : Params() data class Reject(val proposerPublicKey: String, val reason: String) : Params() diff --git a/protocol/sign/src/main/kotlin/com/reown/sign/client/SignProtocol.kt b/protocol/sign/src/main/kotlin/com/reown/sign/client/SignProtocol.kt index 42dc4abe4..9b262e931 100644 --- a/protocol/sign/src/main/kotlin/com/reown/sign/client/SignProtocol.kt +++ b/protocol/sign/src/main/kotlin/com/reown/sign/client/SignProtocol.kt @@ -221,7 +221,7 @@ class SignProtocol(private val koinApp: KoinApplication = wcKoinApp) : SignInter sessionNamespaces = approve.namespaces.toMapOfEngineNamespacesSession(), sessionProperties = approve.properties, scopedProperties = approve.scopedProperties, - onSuccess = { onSuccess(approve) }, + onSuccess = { topic -> onSuccess(approve.copy(sessionTopic = topic)) }, onFailure = { error -> onError(Sign.Model.Error(error)) } ) diff --git a/protocol/sign/src/main/kotlin/com/reown/sign/engine/use_case/calls/ApproveSessionUseCase.kt b/protocol/sign/src/main/kotlin/com/reown/sign/engine/use_case/calls/ApproveSessionUseCase.kt index 98bd004ca..9740367cf 100644 --- a/protocol/sign/src/main/kotlin/com/reown/sign/engine/use_case/calls/ApproveSessionUseCase.kt +++ b/protocol/sign/src/main/kotlin/com/reown/sign/engine/use_case/calls/ApproveSessionUseCase.kt @@ -51,7 +51,7 @@ internal class ApproveSessionUseCase( sessionNamespaces: Map, sessionProperties: Map?, scopedProperties: Map?, - onSuccess: () -> Unit, + onSuccess: (String) -> Unit, onFailure: (Throwable) -> Unit ) = supervisorScope { val trace: MutableList = mutableListOf() @@ -114,7 +114,7 @@ internal class ApproveSessionUseCase( settleRequest = sessionSettle, correlationId = proposal.requestId, onSuccess = { - onSuccess() + onSuccess(sessionTopic.value) scope.launch { supervisorScope { trace.add(Trace.Session.SESSION_APPROVE_SUCCESS) @@ -155,7 +155,7 @@ internal interface ApproveSessionUseCaseInterface { sessionNamespaces: Map, sessionProperties: Map? = null, scopedProperties: Map? = null, - onSuccess: () -> Unit = {}, + onSuccess: (String) -> Unit = {}, onFailure: (Throwable) -> Unit = {}, ) } \ No newline at end of file