mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-19 13:29:56 +00:00
fix(amm): end submits when backend disconnects
This commit is contained in:
parent
07325ccf48
commit
d9852f2715
@ -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."),
|
||||
|
||||
@ -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 = []
|
||||
|
||||
@ -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 })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user