Updated on 2026-08-14
This commit is contained in:
parent
07369a80f0
commit
dcb83d1a51
3 changed files with 5 additions and 64 deletions
|
|
@ -163,7 +163,9 @@ internal class WcSessionRequestConverter(
|
|||
return sessionsRepository.loadSessions(userWalletId)
|
||||
.firstOrNull { it.topic == sessionRequest.topic }
|
||||
?.accounts?.firstOrNull {
|
||||
it.chainId == sessionRequest.chainId && it.walletAddress.lowercase() == walletAddress?.lowercase()
|
||||
// if walletAddress == null take first account
|
||||
it.chainId == sessionRequest.chainId &&
|
||||
(walletAddress == null || it.walletAddress.lowercase() == walletAddress.lowercase())
|
||||
}?.derivationPath
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
package com.tangem.tap.domain.walletconnect2.domain.mapper
|
||||
|
||||
import com.tangem.blockchain.blockchains.solana.solanaj.core.SolanaTransaction
|
||||
import com.tangem.tap.domain.walletconnect2.domain.models.solana.SolanaTransactionRequest
|
||||
import org.p2p.solanaj.core.AccountMeta
|
||||
import org.p2p.solanaj.core.PublicKey
|
||||
import org.p2p.solanaj.core.TransactionInstruction
|
||||
|
||||
internal fun SolanaTransactionRequest.mapToTransaction(): SolanaTransaction {
|
||||
val from = PublicKey(feePayer)
|
||||
val instructions = instructions.map(SolanaTransactionRequest.Instruction::mapToInstruction)
|
||||
|
||||
return SolanaTransaction(from)
|
||||
.apply {
|
||||
instructions.forEach(::addInstruction)
|
||||
setRecentBlockHash(recentBlockhash)
|
||||
}
|
||||
}
|
||||
|
||||
private fun SolanaTransactionRequest.Instruction.mapToInstruction() = TransactionInstruction(
|
||||
/* programId = */ PublicKey(programId),
|
||||
/* keys = */ keys.map(SolanaTransactionRequest.Key::mapToAccountMeta),
|
||||
/* data = */ data.toByteArray(),
|
||||
)
|
||||
|
||||
private fun SolanaTransactionRequest.Key.mapToAccountMeta() = AccountMeta(
|
||||
/* publicKey = */ PublicKey(publicKey),
|
||||
/* isSigner = */ isSigner,
|
||||
/* isWritable = */ isWritable,
|
||||
)
|
||||
|
|
@ -7,39 +7,8 @@ import com.tangem.tap.domain.walletconnect2.domain.WcRequestData
|
|||
@JsonClass(generateAdapter = true)
|
||||
data class SolanaTransactionRequest(
|
||||
@Json(name = "feePayer")
|
||||
val feePayer: String,
|
||||
|
||||
@Json(name = "recentBlockhash")
|
||||
val recentBlockhash: String,
|
||||
|
||||
@Json(name = "instructions")
|
||||
val instructions: List<Instruction>,
|
||||
val feePayer: String?,
|
||||
|
||||
@Json(name = "transaction")
|
||||
val transaction: String,
|
||||
) : WcRequestData {
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class Instruction(
|
||||
@Json(name = "programId")
|
||||
val programId: String,
|
||||
|
||||
@Json(name = "data")
|
||||
val data: String,
|
||||
|
||||
@Json(name = "keys")
|
||||
val keys: List<Key>,
|
||||
)
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class Key(
|
||||
@Json(name = "isSigner")
|
||||
val isSigner: Boolean,
|
||||
|
||||
@Json(name = "isWritable")
|
||||
val isWritable: Boolean,
|
||||
|
||||
@Json(name = "pubkey")
|
||||
val publicKey: String,
|
||||
)
|
||||
}
|
||||
) : WcRequestData
|
||||
Loading…
Add table
Add a link
Reference in a new issue