diff --git a/src/blockchain/buyerMethods.ts b/src/blockchain/buyerMethods.ts index b2e3a81..0f8ecac 100644 --- a/src/blockchain/buyerMethods.ts +++ b/src/blockchain/buyerMethods.ts @@ -84,10 +84,13 @@ const cancelDeposit = async (depositId: BigNumber): Promise => { return cancel; }; -const withdrawDeposit = async (depositId: BigNumber): Promise => { +const withdrawDeposit = async ( + depositId: BigNumber, + amount: string +): Promise => { const contract = getContract(); - const withdraw = await contract.withdraw(depositId, []); + const withdraw = await contract.withdraw(depositId, amount, []); await withdraw.wait(); return withdraw; diff --git a/src/blockchain/events.ts b/src/blockchain/events.ts index 72ee93d..2a3b226 100644 --- a/src/blockchain/events.ts +++ b/src/blockchain/events.ts @@ -92,7 +92,8 @@ const getValidDeposits = async ( }; } - if (validDeposit) depositList[deposit.args?.seller + token] = validDeposit; + if (validDeposit) + depositList[deposit.args?.seller + token] = validDeposit; }) ); diff --git a/src/blockchain/wallet.ts b/src/blockchain/wallet.ts index 4f8bf29..9c35282 100644 --- a/src/blockchain/wallet.ts +++ b/src/blockchain/wallet.ts @@ -35,7 +35,7 @@ const updateWalletStatus = async (): Promise => { const listValidDepositTransactionsByWalletAddress = async ( walletAddress: string ): Promise => { - const walletDeposits = await getValidDeposits(); + const walletDeposits = await getValidDeposits(getTokenAddress()); if (walletDeposits) { return walletDeposits diff --git a/src/components/ListingComponent/ListingComponent.vue b/src/components/ListingComponent/ListingComponent.vue index 7bd3bd8..bdf9c68 100644 --- a/src/components/ListingComponent/ListingComponent.vue +++ b/src/components/ListingComponent/ListingComponent.vue @@ -20,7 +20,7 @@ const itemsToShow = ref<(Event | ValidDeposit)[]>([]); const isValidDeposit = ( deposit: Event | ValidDeposit ): deposit is ValidDeposit => { - return (deposit as ValidDeposit).depositID !== undefined; + return (deposit as ValidDeposit).token !== undefined; }; const showInitialItems = (): void => { @@ -72,7 +72,7 @@ watch(props, async (): Promise => { }); //emits -const emit = defineEmits(["cancelDeposit", "withdrawDeposit"]); +const emit = defineEmits(["withdrawDeposit"]); // initial itemsToShow value showInitialItems(); @@ -83,6 +83,7 @@ showInitialItems();
ValorData - {{ - props.isManageMode ? "Cancelar oferta" : "Tipo de transação" - }} + + "Tipo de transação" + {{ props.isManageMode ? "Retirar tokens" : "Checar transação" }}
@@ -129,18 +134,7 @@ showInitialItems();
- Cancelar - Cancel image -
- -
Retirar Withdraw image diff --git a/src/views/ManageBidsView.vue b/src/views/ManageBidsView.vue index c24c5d9..475396c 100644 --- a/src/views/ManageBidsView.vue +++ b/src/views/ManageBidsView.vue @@ -4,7 +4,7 @@ import { storeToRefs } from "pinia"; import ListingComponent from "@/components/ListingComponent/ListingComponent.vue"; import type { BigNumber } from "ethers"; import { ref, watch, onMounted } from "vue"; -import { cancelDeposit, withdrawDeposit } from "@/blockchain/buyerMethods"; +import { withdrawDeposit } from "@/blockchain/buyerMethods"; import { listValidDepositTransactionsByWalletAddress } from "@/blockchain/wallet"; import type { ValidDeposit } from "@/model/ValidDeposit"; @@ -24,16 +24,9 @@ onMounted(async () => { } }); -const handleCancelDeposit = async (depositID: BigNumber, index: number) => { - const response = await cancelDeposit(depositID); - if (response) { - console.log("Depósito cancelado com sucesso."); - depositList.value.splice(index, 1); - } -}; - -const handleWithDrawDeposit = async (depositID: BigNumber, index: number) => { - const response = await withdrawDeposit(depositID); +const handleWithDrawDeposit = async (token: BigNumber, index: number) => { + const fixedAmount = "1"; // Need to ask user for amount + const response = await withdrawDeposit(token, fixedAmount); if (response) { console.log("Token retirado com sucesso."); depositList.value.splice(index, 1); @@ -68,7 +61,6 @@ watch(networkName, async () => {