Updated on 2026-08-14
This commit is contained in:
parent
9f070d6023
commit
b7c264b448
12 changed files with 408 additions and 13 deletions
|
|
@ -19,7 +19,9 @@ import com.tangem.domain.core.lce.LceFlow
|
|||
import com.tangem.domain.walletconnect.WcTransactionSignerProvider
|
||||
import com.tangem.domain.walletconnect.model.HandleMethodError
|
||||
import com.tangem.domain.walletconnect.model.WcBitcoinMethod
|
||||
import com.tangem.domain.walletconnect.model.WcPsbtOutput
|
||||
import com.tangem.domain.walletconnect.usecase.method.BlockAidTransactionCheck
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcPsbtUseCase
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcSignState
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcTransactionUseCase
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
|
|
@ -51,7 +53,8 @@ internal class WcBitcoinSignPsbtUseCase @AssistedInject constructor(
|
|||
blockAidDelegate: BlockAidVerificationDelegate,
|
||||
@SdkMoshi private val moshi: Moshi,
|
||||
) : BaseWcSignUseCase<Nothing, TransactionData>(),
|
||||
WcTransactionUseCase {
|
||||
WcTransactionUseCase,
|
||||
WcPsbtUseCase {
|
||||
|
||||
override val wallet get() = context.session.wallet
|
||||
|
||||
|
|
@ -120,6 +123,20 @@ internal class WcBitcoinSignPsbtUseCase @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun parsePsbtOutputs(): List<WcPsbtOutput> {
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(wallet.walletId, network)
|
||||
?: return emptyList()
|
||||
return when (val result = walletManager.parsePsbtOutputs(method.psbt)) {
|
||||
is SdkResult.Success -> result.data.map { output ->
|
||||
WcPsbtOutput(
|
||||
address = output.address,
|
||||
amountSatoshi = output.amountSatoshi,
|
||||
)
|
||||
}
|
||||
is SdkResult.Failure -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
override fun invoke(): Flow<WcSignState<TransactionData>> {
|
||||
val transactionData = TransactionData.Compiled(
|
||||
value = TransactionData.Compiled.Data.RawString(method.psbt),
|
||||
|
|
|
|||
|
|
@ -54,13 +54,17 @@ internal class BlockAidVerificationDelegate @Inject constructor(
|
|||
is WcSolanaMethod.SignAllTransaction -> TransactionParams.Solana(method.transaction)
|
||||
is WcSolanaMethod.SignTransaction -> TransactionParams.Solana(listOf(method.transaction))
|
||||
is WcSolanaMethod.SignAndSendTransaction -> TransactionParams.Solana(listOf(method.transaction))
|
||||
is WcSolanaMethod.SignMessage,
|
||||
is WcBitcoinMethod,
|
||||
-> {
|
||||
// BlockAid doesn't support Solana message signing and Bitcoin methods
|
||||
is WcSolanaMethod.SignMessage -> {
|
||||
// BlockAid doesn't support Solana message signing
|
||||
emit(Lce.Content(createSafeResult()))
|
||||
return@flow
|
||||
}
|
||||
is WcBitcoinMethod -> {
|
||||
// BlockAid doesn't support Bitcoin methods: don't synthesize a SAFE result for an unscanned
|
||||
// transaction
|
||||
emit(Lce.Content(failedResult))
|
||||
return@flow
|
||||
}
|
||||
else -> {
|
||||
emit(Lce.Content(failedResult))
|
||||
return@flow
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue