Add correct implementation to check unreleased lock using getLocksStatus abi function
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import SearchComponent from "@/components/SearchComponent.vue";
|
||||
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
|
||||
import BuyConfirmedComponent from "@/components/BuyConfirmedComponent/BuyConfirmedComponent.vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { useEtherStore } from "@/store/ether";
|
||||
import QrCodeComponent from "@/components/QrCodeComponent.vue";
|
||||
import CustomModal from "@/components/CustomModal/CustomModal.vue";
|
||||
@@ -11,6 +11,7 @@ import { addLock, releaseLock } from "@/blockchain/buyerMethods";
|
||||
import {
|
||||
updateWalletStatus,
|
||||
listReleaseTransactionByWalletAddress,
|
||||
checkUnreleasedLock,
|
||||
} from "@/blockchain/wallet";
|
||||
import { getNetworksLiquidity } from "@/blockchain/events";
|
||||
import type { Event } from "ethers";
|
||||
@@ -26,7 +27,7 @@ const etherStore = useEtherStore();
|
||||
etherStore.setSellerView(false);
|
||||
|
||||
// States
|
||||
const { loadingLock, walletAddress } = storeToRefs(etherStore);
|
||||
const { loadingLock, walletAddress, networkName } = storeToRefs(etherStore);
|
||||
const flowStep = ref<Step>(Step.Search);
|
||||
const pixTarget = ref<number>();
|
||||
const tokenAmount = ref<number>();
|
||||
@@ -86,30 +87,31 @@ const releaseTransaction = async (e2eId: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
// const checkForUnreleasedLocks = async () => {
|
||||
// const walletLocks = await checkUnreleasedLocks(walletAddress.value);
|
||||
// if (walletLocks) {
|
||||
// lockID.value = walletLocks.lockID;
|
||||
// tokenAmount.value = walletLocks.pix.value;
|
||||
// pixTarget.value = Number(walletLocks.pix.pixKey);
|
||||
// showModal.value = true;
|
||||
// } else {
|
||||
// flowStep.value = Step.Search;
|
||||
// showModal.value = false;
|
||||
// }
|
||||
// };
|
||||
const checkForUnreleasedLocks = async (): Promise<void> => {
|
||||
const walletLocks = await checkUnreleasedLock(walletAddress.value);
|
||||
console.log(walletLocks);
|
||||
if (walletLocks) {
|
||||
lockID.value = walletLocks.lockID;
|
||||
tokenAmount.value = walletLocks.pix.value;
|
||||
pixTarget.value = Number(walletLocks.pix.pixKey);
|
||||
showModal.value = true;
|
||||
} else {
|
||||
flowStep.value = Step.Search;
|
||||
showModal.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// if (walletAddress) {
|
||||
// await checkForUnreleasedLocks();
|
||||
// }
|
||||
if (walletAddress.value) {
|
||||
await checkForUnreleasedLocks();
|
||||
}
|
||||
|
||||
// watch(walletAddress, async () => {
|
||||
// await checkForUnreleasedLocks();
|
||||
// });
|
||||
watch(walletAddress, async () => {
|
||||
await checkForUnreleasedLocks();
|
||||
});
|
||||
|
||||
// watch(networkName, async () => {
|
||||
// await checkForUnreleasedLocks();
|
||||
// });
|
||||
watch(networkName, async () => {
|
||||
if (walletAddress.value) await checkForUnreleasedLocks();
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await getNetworksLiquidity();
|
||||
|
||||
Reference in New Issue
Block a user