Updated on 2026-08-14
This commit is contained in:
parent
21ab0100a1
commit
349596635d
3 changed files with 11 additions and 12 deletions
|
|
@ -27,7 +27,7 @@ sealed class WalletConnectAction : Action {
|
|||
) : WalletConnectAction()
|
||||
|
||||
data class SetNewSessionData(
|
||||
val newSession: DataForNewSession,
|
||||
val newSession: NewWcSessionData,
|
||||
) : WalletConnectAction()
|
||||
|
||||
object RefuseOpeningSession : WalletConnectAction()
|
||||
|
|
|
|||
|
|
@ -213,14 +213,15 @@ class WalletConnectMiddleware {
|
|||
|
||||
private fun scanCard(session: WalletConnectSession, chainId: Int?) {
|
||||
val blockchain = WalletConnectNetworkUtils.parseBlockchain(
|
||||
chainId = chainId, peer = session.peerMeta,
|
||||
chainId = chainId,
|
||||
peer = session.peerMeta,
|
||||
) ?: Blockchain.Ethereum
|
||||
|
||||
store.dispatch(
|
||||
GlobalAction.ScanCard(
|
||||
additionalBlockchainsToDerive = listOf(blockchain),
|
||||
onSuccess = { scanResponse ->
|
||||
handleScanResponse(scanResponse, session, blockchain)
|
||||
handleScanResponse(scanResponse = scanResponse, session = session, blockchain = blockchain)
|
||||
},
|
||||
onFailure = {
|
||||
store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null))
|
||||
|
|
@ -290,7 +291,9 @@ class WalletConnectMiddleware {
|
|||
}
|
||||
|
||||
private fun handleScanResponse(
|
||||
scanResponse: ScanResponse, session: WalletConnectSession, blockchain: Blockchain,
|
||||
scanResponse: ScanResponse,
|
||||
session: WalletConnectSession,
|
||||
blockchain: Blockchain,
|
||||
) {
|
||||
val card = scanResponse.card
|
||||
if (!card.isMultiwalletAllowed) {
|
||||
|
|
@ -301,9 +304,7 @@ class WalletConnectMiddleware {
|
|||
val updatedSession = session.copy(wallet = session.wallet.copy(blockchain = blockchain))
|
||||
store.dispatch(
|
||||
WalletConnectAction.SetNewSessionData(
|
||||
DataForNewSession(
|
||||
updatedSession, scanResponse, blockchain,
|
||||
),
|
||||
NewWcSessionData(session = updatedSession, scanResponse = scanResponse, blockchain = blockchain),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -313,9 +314,7 @@ class WalletConnectMiddleware {
|
|||
withMainContext {
|
||||
store.dispatch(
|
||||
GlobalAction.ShowDialog(
|
||||
WalletConnectDialog.ApproveWcSession(
|
||||
updatedSession, blockchains,
|
||||
),
|
||||
WalletConnectDialog.ApproveWcSession(session = updatedSession, networks = blockchains),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import com.trustwallet.walletconnect.models.session.WCSession
|
|||
data class WalletConnectState(
|
||||
val loading: Boolean = false,
|
||||
val sessions: List<WalletConnectSession> = listOf(),
|
||||
val newSessionData: DataForNewSession? = null,
|
||||
val newSessionData: NewWcSessionData? = null,
|
||||
)
|
||||
|
||||
data class DataForNewSession(
|
||||
data class NewWcSessionData(
|
||||
val session: WalletConnectSession,
|
||||
val scanResponse: ScanResponse,
|
||||
val blockchain: Blockchain?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue