From f8d1716507eb4631420d8ceb12165c5514023db7 Mon Sep 17 00:00:00 2001
From: 7400 <>
Date: Thu, 30 Nov 2023 11:44:52 -0800
Subject: [PATCH] CancelAll button
---
src/blockchain/abi.js | 1 +
src/blockchain/wallet.js | 10 ++++++++++
src/views/OrdersView.vue | 7 +++++++
3 files changed, 18 insertions(+)
diff --git a/src/blockchain/abi.js b/src/blockchain/abi.js
index 54a9379..7ebb9ff 100644
--- a/src/blockchain/abi.js
+++ b/src/blockchain/abi.js
@@ -60,4 +60,5 @@ export const vaultAbi = [
'function placeOrder((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint16,(uint8,bytes)[])[]))',
'function placeOrders((address,address,(uint8,uint24),uint256,bool,bool,uint64,(uint16,(uint8,bytes)[])[])[],uint8)',
'function cancelOrder(uint64)',
+ 'function cancelAll()',
]
diff --git a/src/blockchain/wallet.js b/src/blockchain/wallet.js
index bffe88d..9bae4aa 100644
--- a/src/blockchain/wallet.js
+++ b/src/blockchain/wallet.js
@@ -184,6 +184,16 @@ export async function cancelOrder(vault, orderIndex) {
})
}
+export async function cancelAll(vault) {
+ pendTransaction(async (signer)=> {
+ const contract = contractOrNull(vault, vaultAbi, signer)
+ if( contract === null ) {
+ console.error('vault contract was null while canceling order', vault)
+ return null
+ }
+ return await contract.cancelAll()
+ })
+}
export function flushOrders(vault) {
for( const order of pendingOrders )
diff --git a/src/views/OrdersView.vue b/src/views/OrdersView.vue
index a443ea9..fabcd9f 100644
--- a/src/views/OrdersView.vue
+++ b/src/views/OrdersView.vue
@@ -4,6 +4,7 @@
New Dexorder
+ Cancel All Orders
@@ -17,6 +18,12 @@ import NeedsSigner from "@/components/NeedsSigner.vue";
import NeedsProvider from "@/components/NeedsProvider.vue";
import Btn from "@/components/Btn.vue";
import PhoneCard from "@/components/PhoneCard.vue";
+import {cancelAll} from "@/blockchain/wallet.js";
+import {useStore} from "@/store/store";
+import {computed} from "vue";
+const s = useStore()
+const props = defineProps(['vault'])
+const vaultAddr = computed(()=>props.vault?props.vault:s.vault)