diff --git a/src/assets/bg.svg b/src/assets/bg.svg index f8ef667..722c762 100644 --- a/src/assets/bg.svg +++ b/src/assets/bg.svg @@ -1,34 +1,34 @@ - + - - - + + + - - - - + + + + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/src/blockchain/buyerMethods.ts b/src/blockchain/buyerMethods.ts index 883cb16..d44b38b 100644 --- a/src/blockchain/buyerMethods.ts +++ b/src/blockchain/buyerMethods.ts @@ -92,10 +92,8 @@ const withdrawDeposit = async (amount: string): Promise => { parseEther(String(amount)), [] ); - const with_rec = await withdraw.wait(); - const [t] = with_rec.events; + await withdraw.wait(); - console.log(t.args); return withdraw; }; diff --git a/src/blockchain/events.ts b/src/blockchain/events.ts index 59608f6..897e087 100644 --- a/src/blockchain/events.ts +++ b/src/blockchain/events.ts @@ -10,7 +10,6 @@ import { NetworkEnum } from "@/model/NetworkEnum"; const getNetworksLiquidity = async (): Promise => { const etherStore = useEtherStore(); - console.log("Loading events"); const goerliProvider = new ethers.providers.JsonRpcProvider( import.meta.env.VITE_GOERLI_API_URL, @@ -32,6 +31,7 @@ const getNetworksLiquidity = async (): Promise => { mumbaiProvider ); + etherStore.setLoadingNetworkLiquidity(true); const depositListGoerli = await getValidDeposits( getTokenAddress(NetworkEnum.ethereum), p2pContractGoerli @@ -43,10 +43,8 @@ const getNetworksLiquidity = async (): Promise => { ); etherStore.setDepositsValidListGoerli(depositListGoerli); - console.log(depositListGoerli); - etherStore.setDepositsValidListMumbai(depositListMumbai); - console.log(depositListMumbai); + etherStore.setLoadingNetworkLiquidity(false); }; const getValidDeposits = async ( diff --git a/src/blockchain/wallet.ts b/src/blockchain/wallet.ts index 828a5eb..15271d8 100644 --- a/src/blockchain/wallet.ts +++ b/src/blockchain/wallet.ts @@ -5,10 +5,12 @@ import { getTokenAddress, possibleChains } from "./addresses"; import mockToken from "@/utils/smart_contract_files/MockToken.json"; -import { ethers, type Event } from "ethers"; +import { ethers, type Event, type BigNumber } from "ethers"; import { formatEther } from "ethers/lib/utils"; import { getValidDeposits } from "./events"; + import type { ValidDeposit } from "@/model/ValidDeposit"; +import type { WalletTransaction } from "@/model/WalletTransaction"; import type { UnreleasedLock } from "@/model/UnreleasedLock"; import type { Pix } from "@/model/Pix"; @@ -50,9 +52,46 @@ const listValidDepositTransactionsByWalletAddress = async ( return []; }; +const getLockStatus = async (id: [BigNumber]): Promise => { + const p2pContract = getContract(); + const res = await p2pContract.getLocksStatus([id]); + + return res[1][0]; +}; + +const filterLockStatus = async ( + transactions: Event[] +): Promise => { + const txs = await Promise.all( + transactions.map(async (transaction) => { + const tx: WalletTransaction = { + token: transaction.args?.token ? transaction.args?.token : "", + blockNumber: transaction.blockNumber ? transaction.blockNumber : -1, + amount: transaction.args?.amount + ? Number(formatEther(transaction.args?.amount)) + : -1, + seller: transaction.args?.seller ? transaction.args?.seller : "", + buyer: transaction.args?.buyer ? transaction.args?.buyer : "", + event: transaction.event ? transaction.event : "", + lockStatus: + transaction.event == "LockAdded" + ? await getLockStatus(transaction.args?.lockID) + : -1, + transactionHash: transaction.transactionHash + ? transaction.transactionHash + : "", + }; + + return tx; + }) + ); + + return txs; +}; + const listAllTransactionByWalletAddress = async ( walletAddress: string -): Promise => { +): Promise => { const p2pContract = getContract(true); const filterDeposits = p2pContract.filters.DepositAdded([walletAddress]); @@ -73,14 +112,18 @@ const listAllTransactionByWalletAddress = async ( filterWithdrawnDeposits ); - return [ - ...eventsDeposits, - ...eventsAddedLocks, - ...eventsReleasedLocks, - ...eventsWithdrawnDeposits, - ].sort((a, b) => { - return b.blockNumber - a.blockNumber; - }); + const lockStatusFiltered = await filterLockStatus( + [ + ...eventsDeposits, + ...eventsAddedLocks, + ...eventsReleasedLocks, + ...eventsWithdrawnDeposits, + ].sort((a, b) => { + return b.blockNumber - a.blockNumber; + }) + ); + + return lockStatusFiltered; }; // get wallet's release transactions diff --git a/src/components/BuyConfirmedComponent/BuyConfirmedComponent.vue b/src/components/BuyConfirmedComponent/BuyConfirmedComponent.vue index 2c23ce3..db63dff 100644 --- a/src/components/BuyConfirmedComponent/BuyConfirmedComponent.vue +++ b/src/components/BuyConfirmedComponent/BuyConfirmedComponent.vue @@ -1,11 +1,8 @@