Clean up ether store
Co-authored-by: brunoedcf <brest.dallacosta@outlook.com>
This commit is contained in:
parent
2b61625e1e
commit
d7723ebf07
@ -60,8 +60,7 @@ const getValidDeposits = async (
|
|||||||
const eventsDeposits = await p2pContract.queryFilter(filterDeposits);
|
const eventsDeposits = await p2pContract.queryFilter(filterDeposits);
|
||||||
|
|
||||||
const depositList = await Promise.all(
|
const depositList = await Promise.all(
|
||||||
eventsDeposits
|
eventsDeposits.map(async (deposit) => {
|
||||||
.map(async (deposit) => {
|
|
||||||
const mappedDeposit = await p2pContract.mapDeposits(
|
const mappedDeposit = await p2pContract.mapDeposits(
|
||||||
deposit.args?.depositID
|
deposit.args?.depositID
|
||||||
);
|
);
|
||||||
|
@ -19,7 +19,7 @@ const handleInputEvent = (event: any): void => {
|
|||||||
|
|
||||||
tokenValue.value = Number(value);
|
tokenValue.value = Number(value);
|
||||||
|
|
||||||
if (decimalCount(tokenValue.value) > 2) {
|
if (decimalCount(String(tokenValue.value)) > 2) {
|
||||||
validDecimals.value = false;
|
validDecimals.value = false;
|
||||||
enableSelectButton.value = false;
|
enableSelectButton.value = false;
|
||||||
return;
|
return;
|
||||||
|
@ -35,7 +35,10 @@ const handleInputEvent = (event: any): void => {
|
|||||||
validDecimals.value = true;
|
validDecimals.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleButtonClick = async (offer: string, pixKey: string): Promise<void> => {
|
const handleButtonClick = async (
|
||||||
|
offer: string,
|
||||||
|
pixKey: string
|
||||||
|
): Promise<void> => {
|
||||||
if (walletAddress.value) emit("approveTokens", { offer, pixKey });
|
if (walletAddress.value) emit("approveTokens", { offer, pixKey });
|
||||||
else await connectProvider();
|
else await connectProvider();
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@ import polygonImage from "../assets/polygon.svg";
|
|||||||
// Store reference
|
// Store reference
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
const { walletAddress, balance, sellerView } = storeToRefs(etherStore);
|
const { walletAddress, sellerView } = storeToRefs(etherStore);
|
||||||
|
|
||||||
const menuOpenToggle = ref<boolean>(false);
|
const menuOpenToggle = ref<boolean>(false);
|
||||||
const menuHoverToggle = ref<boolean>(false);
|
const menuHoverToggle = ref<boolean>(false);
|
||||||
@ -33,11 +33,6 @@ const formatWalletAddress = (): string => {
|
|||||||
return `${initialText}...${finalText}`;
|
return `${initialText}...${finalText}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatWalletBalance = (): string => {
|
|
||||||
const fixed = Number(balance.value);
|
|
||||||
return fixed.toFixed(2);
|
|
||||||
};
|
|
||||||
|
|
||||||
const disconnectUser = (): void => {
|
const disconnectUser = (): void => {
|
||||||
etherStore.setWalletAddress("");
|
etherStore.setWalletAddress("");
|
||||||
closeMenu();
|
closeMenu();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
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,23 +8,11 @@ export const useEtherStore = defineStore("ether", {
|
|||||||
balance: "",
|
balance: "",
|
||||||
networkName: NetworkEnum.ethereum,
|
networkName: NetworkEnum.ethereum,
|
||||||
loadingLock: false,
|
loadingLock: false,
|
||||||
loadingWalletTransactionHistory: false,
|
|
||||||
loadingWalletBids: false,
|
|
||||||
sellerView: false,
|
sellerView: false,
|
||||||
// Depósitos válidos para compra GOERLI
|
// Depósitos válidos para compra GOERLI
|
||||||
depositsValidListGoerli: [] as ValidDeposit[],
|
depositsValidListGoerli: [] as ValidDeposit[],
|
||||||
// Depósitos válidos para compra MUMBAI
|
// Depósitos válidos para compra MUMBAI
|
||||||
depositsValidListMumbai: [] as ValidDeposit[],
|
depositsValidListMumbai: [] as ValidDeposit[],
|
||||||
// Depósitos adicionados na blockchain
|
|
||||||
depositsAddedList: [] as Event[],
|
|
||||||
// Depósitos expirados na blockchain
|
|
||||||
depositsExpiredList: [] as Event[],
|
|
||||||
// Locks adicionados na blockchain
|
|
||||||
locksAddedList: [] as Event[],
|
|
||||||
// Locks 'released' na blockchain
|
|
||||||
locksReleasedList: [] as Event[],
|
|
||||||
// Locks expirados na blockchain
|
|
||||||
locksExpiredList: [] as Event[],
|
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setWalletAddress(walletAddress: string) {
|
setWalletAddress(walletAddress: string) {
|
||||||
@ -43,33 +30,12 @@ export const useEtherStore = defineStore("ether", {
|
|||||||
setSellerView(sellerView: boolean) {
|
setSellerView(sellerView: boolean) {
|
||||||
this.sellerView = sellerView;
|
this.sellerView = sellerView;
|
||||||
},
|
},
|
||||||
setLoadingWalletTransactionHistory(loadingWalletTransactionHistory: boolean) {
|
|
||||||
this.loadingWalletTransactionHistory = loadingWalletTransactionHistory;
|
|
||||||
},
|
|
||||||
setLoadingWalletBids(loadingWalletBids: boolean) {
|
|
||||||
this.loadingWalletBids = loadingWalletBids;
|
|
||||||
},
|
|
||||||
setDepositsValidListGoerli(depositsValidList: ValidDeposit[]) {
|
setDepositsValidListGoerli(depositsValidList: ValidDeposit[]) {
|
||||||
this.depositsValidListGoerli = depositsValidList;
|
this.depositsValidListGoerli = depositsValidList;
|
||||||
},
|
},
|
||||||
setDepositsValidListMumbai(depositsValidList: ValidDeposit[]) {
|
setDepositsValidListMumbai(depositsValidList: ValidDeposit[]) {
|
||||||
this.depositsValidListMumbai = depositsValidList;
|
this.depositsValidListMumbai = depositsValidList;
|
||||||
},
|
},
|
||||||
setDepositsAddedList(depositsAddedList: Event[]) {
|
|
||||||
this.depositsAddedList = depositsAddedList;
|
|
||||||
},
|
|
||||||
setDepositsExpiredList(depositsExpiredList: Event[]) {
|
|
||||||
this.depositsExpiredList = depositsExpiredList;
|
|
||||||
},
|
|
||||||
setLocksAddedList(locksAddedList: Event[]) {
|
|
||||||
this.locksAddedList = locksAddedList;
|
|
||||||
},
|
|
||||||
setLocksReleasedList(locksReleasedList: Event[]) {
|
|
||||||
this.locksReleasedList = locksReleasedList;
|
|
||||||
},
|
|
||||||
setLocksExpiredList(locksExpiredList: Event[]) {
|
|
||||||
this.locksExpiredList = locksExpiredList;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// Alterar para integrar com mumbai
|
// Alterar para integrar com mumbai
|
||||||
getters: {
|
getters: {
|
||||||
|
@ -10,7 +10,7 @@ import type { ValidDeposit } from "@/model/ValidDeposit";
|
|||||||
|
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
const { walletAddress, networkName, loadingWalletBids } = storeToRefs(etherStore);
|
const { walletAddress, networkName } = storeToRefs(etherStore);
|
||||||
const depositList = ref<ValidDeposit[]>([]);
|
const depositList = ref<ValidDeposit[]>([]);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@ -21,7 +21,8 @@ onMounted(async () => {
|
|||||||
if (walletDeposits) {
|
if (walletDeposits) {
|
||||||
depositList.value = walletDeposits;
|
depositList.value = walletDeposits;
|
||||||
}
|
}
|
||||||
}})
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const handleCancelDeposit = async (depositID: BigNumber, index: number) => {
|
const handleCancelDeposit = async (depositID: BigNumber, index: number) => {
|
||||||
const response = await cancelDeposit(depositID);
|
const response = await cancelDeposit(depositID);
|
||||||
@ -49,9 +50,11 @@ watch(walletAddress, async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(networkName, async () => {
|
watch(networkName, async () => {
|
||||||
await listValidDepositTransactionsByWalletAddress(walletAddress.value).then((res) => {
|
await listValidDepositTransactionsByWalletAddress(walletAddress.value).then(
|
||||||
|
(res) => {
|
||||||
if (res) depositList.value = res;
|
if (res) depositList.value = res;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ onMounted(async () => {
|
|||||||
if (res) allUserTransactions.value = res;
|
if (res) allUserTransactions.value = res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
watch(walletAddress, async (newValue) => {
|
watch(walletAddress, async (newValue) => {
|
||||||
await listAllTransactionByWalletAddress(newValue).then((res) => {
|
await listAllTransactionByWalletAddress(newValue).then((res) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user