Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.getcode.utils.TraceType
import com.getcode.utils.trace
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.isActive
import kotlin.time.Duration

/**
Expand Down Expand Up @@ -112,6 +113,10 @@ internal class GiveBillTransactor(
* @return the confirmed [TransactionMetadata.SendPublicPayment] on success.
*/
suspend fun start(): Result<TransactionMetadata.SendPublicPayment> {
if (!scope.isActive) {
return logAndFail(GiveTransactorError.Other(message = "Transactor was disposed"))
}

val ownerKey = owner
?: return logAndFail(GiveTransactorError.Other(message = "No owner key. Did you call with() first?"))
val desiredToken = token
Expand Down Expand Up @@ -212,13 +217,13 @@ internal class GiveBillTransactor(

/** Cancels the coroutine scope and clears all held state. */
fun dispose() {
scope.cancel()
owner = null
presentationData = BillPresentationData(emptyList(), emptyList())
rendezvousKey = null
receivingAccount = null
token = null
providedVerifiedState = null
scope.cancel()
}

sealed class GiveTransactorError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.getcode.opencode.controllers.AccountController
import com.getcode.opencode.controllers.MessagingController
import com.getcode.opencode.controllers.TransactionController
import com.getcode.opencode.exchange.VerifiedFiatCalculator
import com.getcode.opencode.internal.domain.mapping.MintMapper
import com.getcode.opencode.internal.manager.VerifiedState
import com.getcode.opencode.internal.transactors.AccountClusterFactory
import com.getcode.opencode.internal.transactors.BillPresentationData
Expand Down
Loading