partial commit (will be removed)

This commit is contained in:
RcleydsonR
2022-12-28 20:24:41 -03:00
parent c6067fb4eb
commit 59c9eabd30
5 changed files with 92 additions and 58 deletions

View File

@@ -12,7 +12,7 @@ const allUserTransactions = ref<any[]>([]);
watch(walletAddress, async (newValue) => {
await blockchain
.listAllTransactionByWalletAddress(newValue)
.then((res) => (allUserTransactions.value = res));
.then((res) => {if(res) (allUserTransactions.value = res)});
});
watch(walletAddress, async (newValue) => {

View File

@@ -7,30 +7,47 @@ import type { BigNumber } from "ethers";
import { ref } from "vue";
const etherStore = useEtherStore();
const { walletAddress, depositsValidList } = storeToRefs(etherStore);
const { walletAddress } = storeToRefs(etherStore);
const depositList = ref<any[]>([]);
const listValidDepositTransactionsByWalletAddress = (walletAddress: string, deposits: any[]) => {
depositList.value = deposits.filter((deposit) => deposit.seller === walletAddress)
}
const handleCancelDeposit = async (depositID: BigNumber) => {
const response = await blockchain.cancelDeposit(depositID);
if (response == true) console.log("Depósito cancelado com sucesso.");
if (response == true) {
console.log("Depósito cancelado com sucesso.");
await blockchain
.listValidDepositTransactionsByWalletAddress(walletAddress.value)
.then((deposits) => {
if (deposits) depositList.value = deposits;
});
}
};
const handleWithDrawDeposit = async (depositID: BigNumber) => {
const response = await blockchain.withdrawDeposit(depositID);
if (response == true) console.log("Token retirado com sucesso.");
if (response == true) {
console.log("Token retirado com sucesso.");
await blockchain
.listValidDepositTransactionsByWalletAddress(walletAddress.value)
.then((deposits) => {
if (deposits) depositList.value = deposits;
});
}
};
if (walletAddress.value) {
listValidDepositTransactionsByWalletAddress(walletAddress.value, depositsValidList.value)
depositList.value = etherStore.getValidDepositByWalletAddress(
walletAddress.value
);
}
etherStore.$subscribe((_mutation, state) => {
if(state.walletAddress != "")
listValidDepositTransactionsByWalletAddress(state.walletAddress, state.depositsValidList)
etherStore.$subscribe(async (_mutation, state) => {
if (state.walletAddress != "" && state.depositsValidList.length > 0) {
await blockchain
.listValidDepositTransactionsByWalletAddress(walletAddress.value)
.then((deposits) => {
if (deposits) depositList.value = deposits;
});
}
});
</script>