From d78f7f1fdf1097b545e666fa5e0cd99612169b6b Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Tue, 17 Jan 2023 19:27:00 -0300 Subject: [PATCH] Adjust search component and home view to new approaching using alchemy Co-authored-by: brunoedcf --- src/blockchain/events.ts | 16 +++---- src/components/SearchComponent.vue | 77 ++++++++++++++++++++---------- src/views/HomeView.vue | 20 ++++---- 3 files changed, 69 insertions(+), 44 deletions(-) diff --git a/src/blockchain/events.ts b/src/blockchain/events.ts index bdb9abc..c63cb12 100644 --- a/src/blockchain/events.ts +++ b/src/blockchain/events.ts @@ -1,14 +1,13 @@ import { useEtherStore } from "@/store/ether"; import { Contract, ethers } from "ethers"; -import { mapDeposits } from "./sellerMethods"; - import p2pix from "../utils/smart_contract_files/P2PIX.json"; import { formatEther } from "ethers/lib/utils"; import { getProvider } from "./provider"; import { getP2PixAddress } from "./addresses"; const getNetworksLiquidity = async () => { + const etherStore = useEtherStore(); console.log("Loading events"); const goerliProvider = new ethers.providers.JsonRpcProvider( @@ -31,10 +30,9 @@ const getNetworksLiquidity = async () => { mumbaiProvider ); - const depositListGoerli = await getValidDeposits(p2pContractGoerli) - const depositListMumbai = await getValidDeposits(p2pContractMumbai) + const depositListGoerli = await getValidDeposits(p2pContractGoerli); - const etherStore = useEtherStore(); + const depositListMumbai = await getValidDeposits(p2pContractMumbai); etherStore.setDepositsValidListGoerli(depositListGoerli); console.log(depositListGoerli); @@ -43,9 +41,9 @@ const getNetworksLiquidity = async () => { console.log(depositListMumbai); }; -const getValidDeposits = async (contract?: Contract): Promise => { +const getValidDeposits = async ( contract?: Contract ): Promise => { let p2pContract: Contract; - + if (contract){ p2pContract = contract; } @@ -62,7 +60,7 @@ const getValidDeposits = async (contract?: Contract): Promise => { const depositList: any[] = await Promise.all( eventsDeposits .map(async (deposit) => { - const mappedDeposit = await mapDeposits(deposit.args?.depositID); + const mappedDeposit = await p2pContract.mapDeposits(deposit.args?.depositID); let validDeposit = {}; if (mappedDeposit.valid) { @@ -71,7 +69,7 @@ const getValidDeposits = async (contract?: Contract): Promise => { depositID: deposit.args?.depositID, remaining: formatEther(mappedDeposit.remaining), seller: mappedDeposit.seller, - pixKey: mappedDeposit.pixTarget, + pixKey: mappedDeposit.pixTarget }; } diff --git a/src/components/SearchComponent.vue b/src/components/SearchComponent.vue index 4bba0bf..7b54ef5 100644 --- a/src/components/SearchComponent.vue +++ b/src/components/SearchComponent.vue @@ -1,22 +1,26 @@