fix(amm): end submits when backend disconnects

This commit is contained in:
Ricardo Guilherme Schmidt 2026-07-17 20:52:20 -03:00
parent 07325ccf48
commit d9852f2715
No known key found for this signature in database
GPG Key ID: 1396EA17DE132FFE
3 changed files with 48 additions and 1 deletions

View File

@ -1300,6 +1300,7 @@ AmmActionCard {
"wallet_unavailable": qsTr("Wallet is unavailable."),
"wallet_syncing": qsTr("Wallet is still syncing. Review the quote while it finishes."),
"wallet_submission_failed": qsTr("Wallet submission failed. Review and retry manually."),
"submission_status_unknown": qsTr("Connection was lost before submission status was known. Check wallet activity before retrying."),
"signature_rejected": qsTr("Wallet approval was rejected."),
"quote_changed": qsTr("Pool or wallet state changed. Review the refreshed quote."),
"quote_not_submittable": qsTr("Current quote cannot be submitted."),

View File

@ -106,6 +106,16 @@ QtObject {
Qt.callLater(function() { root.quoteRefreshRequested(true) })
}
onBackendReadyChanged: {
if (root.backendReady || !root.submitting)
return
root.submitRequestId = 0
root.submitting = false
root.pendingSubmitSnapshot = ({})
root.flowErrorCode = "submission_status_unknown"
root.submitFailed()
}
function contextHints(refreshPublicData) {
const request = root.pendingQuoteRequest.request || {}
const recent = []

View File

@ -28,6 +28,7 @@ TestCase {
})
property var newPositionQuoteResult: ({})
property var newPositionSubmitResult: ({})
property bool deferSubmitResult: false
property var newPositionContext: ({
"schema": "new-position.v2",
"status": "ready",
@ -43,7 +44,8 @@ TestCase {
++submitCalls
var result = JSON.parse(JSON.stringify(submitResult || ({})))
result.requestId = requestId
newPositionSubmitResult = result
if (!deferSubmitResult)
newPositionSubmitResult = result
}
function requestNewPositionQuote(request, requestId, forceRefresh) {
@ -244,6 +246,40 @@ TestCase {
verify(!page.flow.submitting)
}
function test_backendLossEndsSubmissionWithUnknownStatus() {
var backend = createTemporaryObject(backendComponent, testCase, {
"deferSubmitResult": true,
"submitResult": {
"schema": "new-position.v2",
"status": "submitted",
"transactionId": submittedTransactionId
}
})
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })
verify(page)
page.flow.confirm({ "request": ({}), "quoteHash": "sha256:expected" })
const staleRequestId = page.flow.submitRequestId
verify(page.flow.submitting)
verify(staleRequestId > 0)
page.backend = null
tryCompare(page.flow, "submitting", false)
compare(page.flow.submitRequestId, 0)
compare(page.flow.flowErrorCode, "submission_status_unknown")
page.backend = backend
backend.newPositionSubmitResult = {
"schema": "new-position.v2",
"status": "submitted",
"transactionId": submittedTransactionId,
"requestId": staleRequestId
}
wait(0)
compare(page.flow.transactionId, "")
compare(page.flow.flowErrorCode, "submission_status_unknown")
}
function test_poolProbeDoesNotPublishProbeAsCurrentQuote() {
var backend = createTemporaryObject(backendComponent, testCase)
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })