Add typing on views layer
Co-authored-by: geovanne97 <geovannessaraiva97@gmail.com>
This commit is contained in:
parent
f87434debe
commit
846fa82f04
@ -11,10 +11,7 @@ import { formatEther, parseEther } from "ethers/lib/utils";
|
||||
// Buyer Flow methods //
|
||||
|
||||
// Make lock
|
||||
const addLock = async (
|
||||
depositId: BigNumber,
|
||||
amount: number
|
||||
): Promise<any> => {
|
||||
const addLock = async (depositId: BigNumber, amount: number): Promise<any> => {
|
||||
const etherStore = useEtherStore();
|
||||
|
||||
const provider = getProvider();
|
||||
|
@ -42,7 +42,9 @@ const getNetworksLiquidity = async (): Promise<void> => {
|
||||
console.log(depositListMumbai);
|
||||
};
|
||||
|
||||
const getValidDeposits = async (contract?: Contract): Promise<ValidDeposit[]> => {
|
||||
const getValidDeposits = async (
|
||||
contract?: Contract
|
||||
): Promise<ValidDeposit[]> => {
|
||||
let p2pContract: Contract;
|
||||
|
||||
if (contract) {
|
||||
|
@ -146,7 +146,7 @@ const validatePix = async () => {
|
||||
<CustomButton
|
||||
:is-disabled="isPixValid == false"
|
||||
:text="'Enviar para a rede'"
|
||||
@button-clicked="emit('pixValidated', { e2eId })"
|
||||
@button-clicked="emit('pixValidated', e2eId)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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;
|
||||
};
|
||||
depositID: BigNumber;
|
||||
blockNumber: number;
|
||||
remaining: string;
|
||||
seller: string;
|
||||
pixKey: string;
|
||||
pixTarget?: string;
|
||||
};
|
||||
|
@ -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;
|
||||
},
|
||||
},
|
||||
|
@ -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<string>("");
|
||||
const tokenAmount = ref<number>();
|
||||
const lockTransactionHash = ref<string>("");
|
||||
const lockId = ref<string>("");
|
||||
const loadingRelease = ref<Boolean>(false);
|
||||
const lastWalletReleaseTransactions = ref<any[]>([]);
|
||||
const loadingRelease = ref<boolean>(false);
|
||||
const lastWalletReleaseTransactions = ref<Event[]>([]);
|
||||
|
||||
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;
|
||||
|
@ -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<any[]>([]);
|
||||
const depositList = ref<ValidDeposit[]>([]);
|
||||
|
||||
if (walletAddress.value) {
|
||||
const walletDeposits = await listValidDepositTransactionsByWalletAddress(
|
||||
|
@ -23,11 +23,11 @@ const offerValue = ref<number>();
|
||||
const pixKeyBuyer = ref<string>("");
|
||||
|
||||
// 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;
|
||||
|
@ -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<any[]>([]);
|
||||
const allUserTransactions = ref<(Event | ValidDeposit)[]>([]);
|
||||
|
||||
if (walletAddress.value) {
|
||||
await listAllTransactionByWalletAddress(walletAddress.value).then((res) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user