diff --git a/src/blockchain/buyerMethods.ts b/src/blockchain/buyerMethods.ts index 431445f..8ffc520 100644 --- a/src/blockchain/buyerMethods.ts +++ b/src/blockchain/buyerMethods.ts @@ -11,10 +11,7 @@ import { formatEther, parseEther } from "ethers/lib/utils"; // Buyer Flow methods // // Make lock -const addLock = async ( - depositId: BigNumber, - amount: number -): Promise => { +const addLock = async (depositId: BigNumber, amount: number): Promise => { const etherStore = useEtherStore(); const provider = getProvider(); diff --git a/src/blockchain/events.ts b/src/blockchain/events.ts index cfa2048..b9d6327 100644 --- a/src/blockchain/events.ts +++ b/src/blockchain/events.ts @@ -42,7 +42,9 @@ const getNetworksLiquidity = async (): Promise => { console.log(depositListMumbai); }; -const getValidDeposits = async (contract?: Contract): Promise => { +const getValidDeposits = async ( + contract?: Contract +): Promise => { let p2pContract: Contract; if (contract) { diff --git a/src/components/QrCodeComponent.vue b/src/components/QrCodeComponent.vue index 47a1386..0c4aaf2 100644 --- a/src/components/QrCodeComponent.vue +++ b/src/components/QrCodeComponent.vue @@ -146,7 +146,7 @@ const validatePix = async () => { diff --git a/src/model/ValidDeposit.ts b/src/model/ValidDeposit.ts index 2aa19ab..d68ad65 100644 --- a/src/model/ValidDeposit.ts +++ b/src/model/ValidDeposit.ts @@ -1,10 +1,10 @@ import type { BigNumber } from "ethers"; export type ValidDeposit = { - depositID: BigNumber; - blockNumber: number; - remaining: string; - seller: string; - pixKey: (string | undefined); - pixTarget?: string; -}; \ No newline at end of file + depositID: BigNumber; + blockNumber: number; + remaining: string; + seller: string; + pixKey: string; + pixTarget?: string; +}; diff --git a/src/store/ether.ts b/src/store/ether.ts index 4ae39da..37ab210 100644 --- a/src/store/ether.ts +++ b/src/store/ether.ts @@ -1,4 +1,6 @@ import { NetworkEnum } from "@/model/NetworkEnum"; +import type { ValidDeposit } from "@/model/ValidDeposit"; +import type { Event } from "ethers"; import { defineStore } from "pinia"; export const useEtherStore = defineStore("ether", { @@ -9,19 +11,19 @@ export const useEtherStore = defineStore("ether", { loadingLock: false, sellerView: false, // Depósitos válidos para compra GOERLI - depositsValidListGoerli: [] as any[], + depositsValidListGoerli: [] as ValidDeposit[], // Depósitos válidos para compra MUMBAI - depositsValidListMumbai: [] as any[], + depositsValidListMumbai: [] as ValidDeposit[], // Depósitos adicionados na blockchain - depositsAddedList: [] as any[], + depositsAddedList: [] as Event[], // Depósitos expirados na blockchain - depositsExpiredList: [] as any[], + depositsExpiredList: [] as Event[], // Locks adicionados na blockchain - locksAddedList: [] as any[], + locksAddedList: [] as Event[], // Locks 'released' na blockchain - locksReleasedList: [] as any[], + locksReleasedList: [] as Event[], // Locks expirados na blockchain - locksExpiredList: [] as any[], + locksExpiredList: [] as Event[], }), actions: { setWalletAddress(walletAddress: string) { @@ -39,25 +41,25 @@ export const useEtherStore = defineStore("ether", { setSellerView(sellerView: boolean) { this.sellerView = sellerView; }, - setDepositsValidListGoerli(depositsValidList: any[]) { + setDepositsValidListGoerli(depositsValidList: ValidDeposit[]) { this.depositsValidListGoerli = depositsValidList; }, - setDepositsValidListMumbai(depositsValidList: any[]) { + setDepositsValidListMumbai(depositsValidList: ValidDeposit[]) { this.depositsValidListMumbai = depositsValidList; }, - setDepositsAddedList(depositsAddedList: any[]) { + setDepositsAddedList(depositsAddedList: Event[]) { this.depositsAddedList = depositsAddedList; }, - setDepositsExpiredList(depositsExpiredList: any[]) { + setDepositsExpiredList(depositsExpiredList: Event[]) { this.depositsExpiredList = depositsExpiredList; }, - setLocksAddedList(locksAddedList: any[]) { + setLocksAddedList(locksAddedList: Event[]) { this.locksAddedList = locksAddedList; }, - setLocksReleasedList(locksReleasedList: any[]) { + setLocksReleasedList(locksReleasedList: Event[]) { this.locksReleasedList = locksReleasedList; }, - setLocksExpiredList(locksExpiredList: any[]) { + setLocksExpiredList(locksExpiredList: Event[]) { this.locksExpiredList = locksExpiredList; }, }, diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 4a369ef..bf17508 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -11,6 +11,8 @@ import { addLock, releaseLock } from "@/blockchain/buyerMethods"; import { updateWalletStatus } from "@/blockchain/wallet"; import { getNetworksLiquidity } from "@/blockchain/events"; import { listReleaseTransactionByWalletAddress } from "@/blockchain/wallet"; +import type { Event } from "ethers"; +import type { ValidDeposit } from "@/model/ValidDeposit"; enum Step { Search, @@ -28,10 +30,13 @@ const pixTarget = ref(""); const tokenAmount = ref(); const lockTransactionHash = ref(""); const lockId = ref(""); -const loadingRelease = ref(false); -const lastWalletReleaseTransactions = ref([]); +const loadingRelease = ref(false); +const lastWalletReleaseTransactions = ref([]); -const confirmBuyClick = async (selectedDeposit: any, tokenValue: number) => { +const confirmBuyClick = async ( + selectedDeposit: ValidDeposit, + tokenValue: number +) => { // finish buy screen pixTarget.value = selectedDeposit.pixKey; tokenAmount.value = tokenValue; @@ -54,13 +59,13 @@ const confirmBuyClick = async (selectedDeposit: any, tokenValue: number) => { } }; -const releaseTransaction = async ({ e2eId }: any) => { +const releaseTransaction = async (e2eId: string) => { flowStep.value = Step.List; loadingRelease.value = true; const findLock = locksAddedList.value.find((element) => { if (element.transactionHash === lockTransactionHash.value) { - lockId.value = element.args.lockID; + lockId.value = element.args?.lockID; return true; } return false; diff --git a/src/views/ManageBidsView.vue b/src/views/ManageBidsView.vue index 7f5ae75..69d226b 100644 --- a/src/views/ManageBidsView.vue +++ b/src/views/ManageBidsView.vue @@ -2,15 +2,16 @@ import { useEtherStore } from "@/store/ether"; import { storeToRefs } from "pinia"; import ListingComponent from "@/components/ListingComponent.vue"; -import type { BigNumber } from "ethers"; +import type { BigNumber, Event } from "ethers"; import { ref, watch } from "vue"; import { cancelDeposit, withdrawDeposit } from "@/blockchain/buyerMethods"; import { listValidDepositTransactionsByWalletAddress } from "@/blockchain/wallet"; +import type { ValidDeposit } from "@/model/ValidDeposit"; const etherStore = useEtherStore(); const { walletAddress } = storeToRefs(etherStore); -const depositList = ref([]); +const depositList = ref([]); if (walletAddress.value) { const walletDeposits = await listValidDepositTransactionsByWalletAddress( diff --git a/src/views/SellerView.vue b/src/views/SellerView.vue index f7e5743..2c2e2c9 100644 --- a/src/views/SellerView.vue +++ b/src/views/SellerView.vue @@ -23,11 +23,11 @@ const offerValue = ref(); const pixKeyBuyer = ref(""); // Verificar tipagem -const approveOffer = async ({ offer, pixKey }: any) => { +const approveOffer = async (args: { offer: number; pixKey: string }) => { loading.value = true; try { - offerValue.value = offer; - pixKeyBuyer.value = pixKey; + offerValue.value = args.offer; + pixKeyBuyer.value = args.pixKey; await approveTokens(String(offerValue.value)); flowStep.value = Step.Network; loading.value = false; diff --git a/src/views/TransactionHistoryView.vue b/src/views/TransactionHistoryView.vue index b9eec00..f1339f4 100644 --- a/src/views/TransactionHistoryView.vue +++ b/src/views/TransactionHistoryView.vue @@ -4,10 +4,12 @@ import { storeToRefs } from "pinia"; import { ref, watch } from "vue"; import ListingComponent from "@/components/ListingComponent.vue"; import { listAllTransactionByWalletAddress } from "@/blockchain/wallet"; +import type { Event } from "ethers"; +import type { ValidDeposit } from "@/model/ValidDeposit"; const etherStore = useEtherStore(); const { walletAddress } = storeToRefs(etherStore); -const allUserTransactions = ref([]); +const allUserTransactions = ref<(Event | ValidDeposit)[]>([]); if (walletAddress.value) { await listAllTransactionByWalletAddress(walletAddress.value).then((res) => {