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 //
 | 
					// Buyer Flow methods //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Make lock
 | 
					// Make lock
 | 
				
			||||||
const addLock = async (
 | 
					const addLock = async (depositId: BigNumber, amount: number): Promise<any> => {
 | 
				
			||||||
  depositId: BigNumber,
 | 
					 | 
				
			||||||
  amount: number
 | 
					 | 
				
			||||||
): Promise<any> => {
 | 
					 | 
				
			||||||
  const etherStore = useEtherStore();
 | 
					  const etherStore = useEtherStore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const provider = getProvider();
 | 
					  const provider = getProvider();
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,9 @@ const getNetworksLiquidity = async (): Promise<void> => {
 | 
				
			|||||||
  console.log(depositListMumbai);
 | 
					  console.log(depositListMumbai);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getValidDeposits = async (contract?: Contract): Promise<ValidDeposit[]> => {
 | 
					const getValidDeposits = async (
 | 
				
			||||||
 | 
					  contract?: Contract
 | 
				
			||||||
 | 
					): Promise<ValidDeposit[]> => {
 | 
				
			||||||
  let p2pContract: Contract;
 | 
					  let p2pContract: Contract;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (contract) {
 | 
					  if (contract) {
 | 
				
			||||||
 | 
				
			|||||||
@ -146,7 +146,7 @@ const validatePix = async () => {
 | 
				
			|||||||
      <CustomButton
 | 
					      <CustomButton
 | 
				
			||||||
        :is-disabled="isPixValid == false"
 | 
					        :is-disabled="isPixValid == false"
 | 
				
			||||||
        :text="'Enviar para a rede'"
 | 
					        :text="'Enviar para a rede'"
 | 
				
			||||||
        @button-clicked="emit('pixValidated', { e2eId })"
 | 
					        @button-clicked="emit('pixValidated', e2eId)"
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -5,6 +5,6 @@ export type ValidDeposit = {
 | 
				
			|||||||
  blockNumber: number;
 | 
					  blockNumber: number;
 | 
				
			||||||
  remaining: string;
 | 
					  remaining: string;
 | 
				
			||||||
  seller: string;
 | 
					  seller: string;
 | 
				
			||||||
    pixKey: (string | undefined);
 | 
					  pixKey: string;
 | 
				
			||||||
  pixTarget?: string;
 | 
					  pixTarget?: string;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -1,4 +1,6 @@
 | 
				
			|||||||
import { NetworkEnum } from "@/model/NetworkEnum";
 | 
					import { NetworkEnum } from "@/model/NetworkEnum";
 | 
				
			||||||
 | 
					import type { ValidDeposit } from "@/model/ValidDeposit";
 | 
				
			||||||
 | 
					import type { Event } from "ethers";
 | 
				
			||||||
import { defineStore } from "pinia";
 | 
					import { defineStore } from "pinia";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const useEtherStore = defineStore("ether", {
 | 
					export const useEtherStore = defineStore("ether", {
 | 
				
			||||||
@ -9,19 +11,19 @@ export const useEtherStore = defineStore("ether", {
 | 
				
			|||||||
    loadingLock: false,
 | 
					    loadingLock: false,
 | 
				
			||||||
    sellerView: false,
 | 
					    sellerView: false,
 | 
				
			||||||
    // Depósitos válidos para compra GOERLI
 | 
					    // Depósitos válidos para compra GOERLI
 | 
				
			||||||
    depositsValidListGoerli: [] as any[],
 | 
					    depositsValidListGoerli: [] as ValidDeposit[],
 | 
				
			||||||
    // Depósitos válidos para compra MUMBAI
 | 
					    // Depósitos válidos para compra MUMBAI
 | 
				
			||||||
    depositsValidListMumbai: [] as any[],
 | 
					    depositsValidListMumbai: [] as ValidDeposit[],
 | 
				
			||||||
    // Depósitos adicionados na blockchain
 | 
					    // Depósitos adicionados na blockchain
 | 
				
			||||||
    depositsAddedList: [] as any[],
 | 
					    depositsAddedList: [] as Event[],
 | 
				
			||||||
    // Depósitos expirados na blockchain
 | 
					    // Depósitos expirados na blockchain
 | 
				
			||||||
    depositsExpiredList: [] as any[],
 | 
					    depositsExpiredList: [] as Event[],
 | 
				
			||||||
    // Locks adicionados na blockchain
 | 
					    // Locks adicionados na blockchain
 | 
				
			||||||
    locksAddedList: [] as any[],
 | 
					    locksAddedList: [] as Event[],
 | 
				
			||||||
    // Locks 'released' na blockchain
 | 
					    // Locks 'released' na blockchain
 | 
				
			||||||
    locksReleasedList: [] as any[],
 | 
					    locksReleasedList: [] as Event[],
 | 
				
			||||||
    // Locks expirados na blockchain
 | 
					    // Locks expirados na blockchain
 | 
				
			||||||
    locksExpiredList: [] as any[],
 | 
					    locksExpiredList: [] as Event[],
 | 
				
			||||||
  }),
 | 
					  }),
 | 
				
			||||||
  actions: {
 | 
					  actions: {
 | 
				
			||||||
    setWalletAddress(walletAddress: string) {
 | 
					    setWalletAddress(walletAddress: string) {
 | 
				
			||||||
@ -39,25 +41,25 @@ export const useEtherStore = defineStore("ether", {
 | 
				
			|||||||
    setSellerView(sellerView: boolean) {
 | 
					    setSellerView(sellerView: boolean) {
 | 
				
			||||||
      this.sellerView = sellerView;
 | 
					      this.sellerView = sellerView;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setDepositsValidListGoerli(depositsValidList: any[]) {
 | 
					    setDepositsValidListGoerli(depositsValidList: ValidDeposit[]) {
 | 
				
			||||||
      this.depositsValidListGoerli = depositsValidList;
 | 
					      this.depositsValidListGoerli = depositsValidList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setDepositsValidListMumbai(depositsValidList: any[]) {
 | 
					    setDepositsValidListMumbai(depositsValidList: ValidDeposit[]) {
 | 
				
			||||||
      this.depositsValidListMumbai = depositsValidList;
 | 
					      this.depositsValidListMumbai = depositsValidList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setDepositsAddedList(depositsAddedList: any[]) {
 | 
					    setDepositsAddedList(depositsAddedList: Event[]) {
 | 
				
			||||||
      this.depositsAddedList = depositsAddedList;
 | 
					      this.depositsAddedList = depositsAddedList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setDepositsExpiredList(depositsExpiredList: any[]) {
 | 
					    setDepositsExpiredList(depositsExpiredList: Event[]) {
 | 
				
			||||||
      this.depositsExpiredList = depositsExpiredList;
 | 
					      this.depositsExpiredList = depositsExpiredList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setLocksAddedList(locksAddedList: any[]) {
 | 
					    setLocksAddedList(locksAddedList: Event[]) {
 | 
				
			||||||
      this.locksAddedList = locksAddedList;
 | 
					      this.locksAddedList = locksAddedList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setLocksReleasedList(locksReleasedList: any[]) {
 | 
					    setLocksReleasedList(locksReleasedList: Event[]) {
 | 
				
			||||||
      this.locksReleasedList = locksReleasedList;
 | 
					      this.locksReleasedList = locksReleasedList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setLocksExpiredList(locksExpiredList: any[]) {
 | 
					    setLocksExpiredList(locksExpiredList: Event[]) {
 | 
				
			||||||
      this.locksExpiredList = locksExpiredList;
 | 
					      this.locksExpiredList = locksExpiredList;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,8 @@ import { addLock, releaseLock } from "@/blockchain/buyerMethods";
 | 
				
			|||||||
import { updateWalletStatus } from "@/blockchain/wallet";
 | 
					import { updateWalletStatus } from "@/blockchain/wallet";
 | 
				
			||||||
import { getNetworksLiquidity } from "@/blockchain/events";
 | 
					import { getNetworksLiquidity } from "@/blockchain/events";
 | 
				
			||||||
import { listReleaseTransactionByWalletAddress } from "@/blockchain/wallet";
 | 
					import { listReleaseTransactionByWalletAddress } from "@/blockchain/wallet";
 | 
				
			||||||
 | 
					import type { Event } from "ethers";
 | 
				
			||||||
 | 
					import type { ValidDeposit } from "@/model/ValidDeposit";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum Step {
 | 
					enum Step {
 | 
				
			||||||
  Search,
 | 
					  Search,
 | 
				
			||||||
@ -28,10 +30,13 @@ const pixTarget = ref<string>("");
 | 
				
			|||||||
const tokenAmount = ref<number>();
 | 
					const tokenAmount = ref<number>();
 | 
				
			||||||
const lockTransactionHash = ref<string>("");
 | 
					const lockTransactionHash = ref<string>("");
 | 
				
			||||||
const lockId = ref<string>("");
 | 
					const lockId = ref<string>("");
 | 
				
			||||||
const loadingRelease = ref<Boolean>(false);
 | 
					const loadingRelease = ref<boolean>(false);
 | 
				
			||||||
const lastWalletReleaseTransactions = ref<any[]>([]);
 | 
					const lastWalletReleaseTransactions = ref<Event[]>([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const confirmBuyClick = async (selectedDeposit: any, tokenValue: number) => {
 | 
					const confirmBuyClick = async (
 | 
				
			||||||
 | 
					  selectedDeposit: ValidDeposit,
 | 
				
			||||||
 | 
					  tokenValue: number
 | 
				
			||||||
 | 
					) => {
 | 
				
			||||||
  // finish buy screen
 | 
					  // finish buy screen
 | 
				
			||||||
  pixTarget.value = selectedDeposit.pixKey;
 | 
					  pixTarget.value = selectedDeposit.pixKey;
 | 
				
			||||||
  tokenAmount.value = tokenValue;
 | 
					  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;
 | 
					  flowStep.value = Step.List;
 | 
				
			||||||
  loadingRelease.value = true;
 | 
					  loadingRelease.value = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const findLock = locksAddedList.value.find((element) => {
 | 
					  const findLock = locksAddedList.value.find((element) => {
 | 
				
			||||||
    if (element.transactionHash === lockTransactionHash.value) {
 | 
					    if (element.transactionHash === lockTransactionHash.value) {
 | 
				
			||||||
      lockId.value = element.args.lockID;
 | 
					      lockId.value = element.args?.lockID;
 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
 | 
				
			|||||||
@ -2,15 +2,16 @@
 | 
				
			|||||||
import { useEtherStore } from "@/store/ether";
 | 
					import { useEtherStore } from "@/store/ether";
 | 
				
			||||||
import { storeToRefs } from "pinia";
 | 
					import { storeToRefs } from "pinia";
 | 
				
			||||||
import ListingComponent from "@/components/ListingComponent.vue";
 | 
					import ListingComponent from "@/components/ListingComponent.vue";
 | 
				
			||||||
import type { BigNumber } from "ethers";
 | 
					import type { BigNumber, Event } from "ethers";
 | 
				
			||||||
import { ref, watch } from "vue";
 | 
					import { ref, watch } from "vue";
 | 
				
			||||||
import { cancelDeposit, withdrawDeposit } from "@/blockchain/buyerMethods";
 | 
					import { cancelDeposit, withdrawDeposit } from "@/blockchain/buyerMethods";
 | 
				
			||||||
import { listValidDepositTransactionsByWalletAddress } from "@/blockchain/wallet";
 | 
					import { listValidDepositTransactionsByWalletAddress } from "@/blockchain/wallet";
 | 
				
			||||||
 | 
					import type { ValidDeposit } from "@/model/ValidDeposit";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const etherStore = useEtherStore();
 | 
					const etherStore = useEtherStore();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const { walletAddress } = storeToRefs(etherStore);
 | 
					const { walletAddress } = storeToRefs(etherStore);
 | 
				
			||||||
const depositList = ref<any[]>([]);
 | 
					const depositList = ref<ValidDeposit[]>([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (walletAddress.value) {
 | 
					if (walletAddress.value) {
 | 
				
			||||||
  const walletDeposits = await listValidDepositTransactionsByWalletAddress(
 | 
					  const walletDeposits = await listValidDepositTransactionsByWalletAddress(
 | 
				
			||||||
 | 
				
			|||||||
@ -23,11 +23,11 @@ const offerValue = ref<number>();
 | 
				
			|||||||
const pixKeyBuyer = ref<string>("");
 | 
					const pixKeyBuyer = ref<string>("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Verificar tipagem
 | 
					// Verificar tipagem
 | 
				
			||||||
const approveOffer = async ({ offer, pixKey }: any) => {
 | 
					const approveOffer = async (args: { offer: number; pixKey: string }) => {
 | 
				
			||||||
  loading.value = true;
 | 
					  loading.value = true;
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    offerValue.value = offer;
 | 
					    offerValue.value = args.offer;
 | 
				
			||||||
    pixKeyBuyer.value = pixKey;
 | 
					    pixKeyBuyer.value = args.pixKey;
 | 
				
			||||||
    await approveTokens(String(offerValue.value));
 | 
					    await approveTokens(String(offerValue.value));
 | 
				
			||||||
    flowStep.value = Step.Network;
 | 
					    flowStep.value = Step.Network;
 | 
				
			||||||
    loading.value = false;
 | 
					    loading.value = false;
 | 
				
			||||||
 | 
				
			|||||||
@ -4,10 +4,12 @@ import { storeToRefs } from "pinia";
 | 
				
			|||||||
import { ref, watch } from "vue";
 | 
					import { ref, watch } from "vue";
 | 
				
			||||||
import ListingComponent from "@/components/ListingComponent.vue";
 | 
					import ListingComponent from "@/components/ListingComponent.vue";
 | 
				
			||||||
import { listAllTransactionByWalletAddress } from "@/blockchain/wallet";
 | 
					import { listAllTransactionByWalletAddress } from "@/blockchain/wallet";
 | 
				
			||||||
 | 
					import type { Event } from "ethers";
 | 
				
			||||||
 | 
					import type { ValidDeposit } from "@/model/ValidDeposit";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const etherStore = useEtherStore();
 | 
					const etherStore = useEtherStore();
 | 
				
			||||||
const { walletAddress } = storeToRefs(etherStore);
 | 
					const { walletAddress } = storeToRefs(etherStore);
 | 
				
			||||||
const allUserTransactions = ref<any[]>([]);
 | 
					const allUserTransactions = ref<(Event | ValidDeposit)[]>([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (walletAddress.value) {
 | 
					if (walletAddress.value) {
 | 
				
			||||||
  await listAllTransactionByWalletAddress(walletAddress.value).then((res) => {
 | 
					  await listAllTransactionByWalletAddress(walletAddress.value).then((res) => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user