transaction progressor
This commit is contained in:
@@ -38,6 +38,14 @@
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-dialog v-model="placementError" max-width="300">
|
||||
<v-card prepend-icon="mdi-alert" title="Order Error" text="There was an error placing your order. Please try again or contact support.">
|
||||
<v-card-actions>
|
||||
<v-spacer/>
|
||||
<v-btn @click="()=>{placementError=false;ws.transaction=null}">OK</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</needs-chart>
|
||||
</div>
|
||||
</toolbar-pane>
|
||||
@@ -56,6 +64,7 @@ import {useWalletStore} from "@/blockchain/wallet.js";
|
||||
import ToolbarPane from "@/components/chart/ToolbarPane.vue";
|
||||
import NeedsChart from "@/components/NeedsChart.vue";
|
||||
import {PlaceOrderTransaction} from "@/blockchain/transaction.js";
|
||||
import {errorSuggestsMissingVault} from "@/misc.js";
|
||||
|
||||
const s = useStore()
|
||||
const co = useChartOrderStore()
|
||||
@@ -96,6 +105,8 @@ const orderChanged = computed(()=>!(co.orders.length===1 && co.orders[0].builder
|
||||
const showWarnings = ref(false)
|
||||
const orderWarnings = ref([])
|
||||
|
||||
const placementError = ref(false)
|
||||
|
||||
function resetOrder() {
|
||||
showResetDialog.value = true
|
||||
}
|
||||
@@ -103,7 +114,9 @@ function resetOrder() {
|
||||
function doResetOrder() {
|
||||
co.resetOrders();
|
||||
orderWarnings.value = []
|
||||
showWarnings.value = false
|
||||
showResetDialog.value = false
|
||||
placementError.value = false
|
||||
}
|
||||
|
||||
watchEffect(()=>{
|
||||
@@ -157,12 +170,27 @@ async function placeOrder() {
|
||||
|
||||
async function doPlaceOrder() {
|
||||
console.log('place orders')
|
||||
placementError.value = false
|
||||
showWarnings.value = false
|
||||
if (ws.transaction!==null) {
|
||||
console.error('Transaction already in progress')
|
||||
}
|
||||
else {
|
||||
new PlaceOrderTransaction(s.chainId, toRaw(built[0])).submit()
|
||||
const tx = new PlaceOrderTransaction(s.chainId, toRaw(built[0]));
|
||||
tx.retries = 60
|
||||
const oldFailed = tx.failed
|
||||
tx.failed = function(e) {
|
||||
console.error('place order failed', errorSuggestsMissingVault(e), e.code, e)
|
||||
if (errorSuggestsMissingVault(e) && e.action === 'feeManager' && this.retries-- >= 0) {
|
||||
s.creatingVault = true
|
||||
}
|
||||
else {
|
||||
s.creatingVault = false
|
||||
oldFailed.bind(this)(e)
|
||||
placementError.value = true
|
||||
}
|
||||
}
|
||||
tx.submit() // this assigns the tx to walletStore.transaction
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user