Add logic to check for unreleased locks on homeview
This commit is contained in:
parent
a5d72650ee
commit
2ea9f18cc1
@ -154,11 +154,6 @@ const validatePix = async (): Promise<void> => {
|
|||||||
@button-clicked="emit('pixValidated', e2eId)"
|
@button-clicked="emit('pixValidated', e2eId)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CustomModal
|
|
||||||
v-if="showModal"
|
|
||||||
@close-modal="showModal = false"
|
|
||||||
:isRedirectModal="false"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import SearchComponent from "@/components/SearchComponent.vue";
|
import SearchComponent from "@/components/SearchComponent.vue";
|
||||||
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
|
import LoadingComponent from "@/components/LoadingComponent/LoadingComponent.vue";
|
||||||
import BuyConfirmedComponent from "@/components/BuyConfirmedComponent/BuyConfirmedComponent.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 { useEtherStore } from "@/store/ether";
|
||||||
import QrCodeComponent from "@/components/QrCodeComponent.vue";
|
import QrCodeComponent from "@/components/QrCodeComponent.vue";
|
||||||
import CustomModal from "@/components/CustomModal.vue";
|
import CustomModal from "@/components/CustomModal.vue";
|
||||||
@ -11,6 +11,7 @@ import { addLock, releaseLock } from "@/blockchain/buyerMethods";
|
|||||||
import {
|
import {
|
||||||
updateWalletStatus,
|
updateWalletStatus,
|
||||||
listReleaseTransactionByWalletAddress,
|
listReleaseTransactionByWalletAddress,
|
||||||
|
checkUnreleasedLocks,
|
||||||
} from "@/blockchain/wallet";
|
} from "@/blockchain/wallet";
|
||||||
import { getNetworksLiquidity } from "@/blockchain/events";
|
import { getNetworksLiquidity } from "@/blockchain/events";
|
||||||
import type { Event } from "ethers";
|
import type { Event } from "ethers";
|
||||||
@ -26,13 +27,13 @@ const etherStore = useEtherStore();
|
|||||||
etherStore.setSellerView(false);
|
etherStore.setSellerView(false);
|
||||||
|
|
||||||
// States
|
// States
|
||||||
const { loadingLock, walletAddress } = storeToRefs(etherStore);
|
const { loadingLock, walletAddress, networkName} = storeToRefs(etherStore);
|
||||||
const flowStep = ref<Step>(Step.Search);
|
const flowStep = ref<Step>(Step.Search);
|
||||||
const pixTarget = ref<number>();
|
const pixTarget = ref<number>();
|
||||||
const tokenAmount = ref<number>();
|
const tokenAmount = ref<number>();
|
||||||
const _lockID = ref<string>("");
|
const lockID = ref<string>("");
|
||||||
const loadingRelease = ref<boolean>(false);
|
const loadingRelease = ref<boolean>(false);
|
||||||
const showModal = ref<boolean>(true);
|
const showModal = ref<boolean>(false);
|
||||||
const lastWalletReleaseTransactions = ref<Event[]>([]);
|
const lastWalletReleaseTransactions = ref<Event[]>([]);
|
||||||
|
|
||||||
const confirmBuyClick = async (
|
const confirmBuyClick = async (
|
||||||
@ -49,8 +50,8 @@ const confirmBuyClick = async (
|
|||||||
etherStore.setLoadingLock(true);
|
etherStore.setLoadingLock(true);
|
||||||
|
|
||||||
await addLock(selectedDeposit.seller, selectedDeposit.token, tokenValue)
|
await addLock(selectedDeposit.seller, selectedDeposit.token, tokenValue)
|
||||||
.then((lockID) => {
|
.then((_lockID) => {
|
||||||
_lockID.value = lockID;
|
lockID.value = _lockID;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -65,12 +66,12 @@ const releaseTransaction = async (e2eId: string) => {
|
|||||||
flowStep.value = Step.List;
|
flowStep.value = Step.List;
|
||||||
loadingRelease.value = true;
|
loadingRelease.value = true;
|
||||||
|
|
||||||
if (_lockID.value && tokenAmount.value && pixTarget.value) {
|
if (lockID.value && tokenAmount.value && pixTarget.value) {
|
||||||
const release = await releaseLock(
|
const release = await releaseLock(
|
||||||
pixTarget.value,
|
pixTarget.value,
|
||||||
tokenAmount.value,
|
tokenAmount.value,
|
||||||
e2eId,
|
e2eId,
|
||||||
_lockID.value
|
lockID.value
|
||||||
);
|
);
|
||||||
release.wait();
|
release.wait();
|
||||||
|
|
||||||
@ -86,6 +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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (walletAddress){
|
||||||
|
await checkForUnreleasedLocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(walletAddress, async () => {
|
||||||
|
await checkForUnreleasedLocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(networkName, async () => {
|
||||||
|
await checkForUnreleasedLocks();
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getNetworksLiquidity();
|
await getNetworksLiquidity();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user