Improve code quality by fixing lint issues
Co-authored-by: brunoedcf <brest.dallacosta@outlook.com>
This commit is contained in:
parent
8338064dcd
commit
c8a3fd12b2
@ -8,7 +8,6 @@ import p2pix from "../utils/smart_contract_files/P2PIX.json";
|
|||||||
import { BigNumber, ethers, type Event } from "ethers";
|
import { BigNumber, ethers, type Event } from "ethers";
|
||||||
import { formatEther, parseEther } from "ethers/lib/utils";
|
import { formatEther, parseEther } from "ethers/lib/utils";
|
||||||
|
|
||||||
|
|
||||||
// Buyer Flow methods //
|
// Buyer Flow methods //
|
||||||
|
|
||||||
// Make lock
|
// Make lock
|
||||||
@ -43,7 +42,6 @@ const releaseLock = async (
|
|||||||
e2eId: string,
|
e2eId: string,
|
||||||
lockId: string
|
lockId: string
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
const mockBacenSigner = new ethers.Wallet(
|
const mockBacenSigner = new ethers.Wallet(
|
||||||
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
||||||
);
|
);
|
||||||
@ -105,9 +103,6 @@ const withdrawDeposit = async (depositId: BigNumber): Promise<Boolean> => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Releases lock by specific ID and other additional data
|
// Releases lock by specific ID and other additional data
|
||||||
|
|
||||||
|
|
||||||
export { cancelDeposit, withdrawDeposit, addLock, releaseLock };
|
export { cancelDeposit, withdrawDeposit, addLock, releaseLock };
|
||||||
|
@ -46,8 +46,7 @@ const getValidDeposits = async ( contract?: Contract ): Promise<any[]> => {
|
|||||||
|
|
||||||
if (contract) {
|
if (contract) {
|
||||||
p2pContract = contract;
|
p2pContract = contract;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
const provider = getProvider();
|
const provider = getProvider();
|
||||||
const signer = provider.getSigner();
|
const signer = provider.getSigner();
|
||||||
|
|
||||||
@ -60,7 +59,9 @@ const getValidDeposits = async ( contract?: Contract ): Promise<any[]> => {
|
|||||||
const depositList: any[] = await Promise.all(
|
const depositList: any[] = await Promise.all(
|
||||||
eventsDeposits
|
eventsDeposits
|
||||||
.map(async (deposit) => {
|
.map(async (deposit) => {
|
||||||
const mappedDeposit = await p2pContract.mapDeposits(deposit.args?.depositID);
|
const mappedDeposit = await p2pContract.mapDeposits(
|
||||||
|
deposit.args?.depositID
|
||||||
|
);
|
||||||
let validDeposit = {};
|
let validDeposit = {};
|
||||||
|
|
||||||
if (mappedDeposit.valid) {
|
if (mappedDeposit.valid) {
|
||||||
@ -69,7 +70,7 @@ const getValidDeposits = async ( contract?: Contract ): Promise<any[]> => {
|
|||||||
depositID: deposit.args?.depositID,
|
depositID: deposit.args?.depositID,
|
||||||
remaining: formatEther(mappedDeposit.remaining),
|
remaining: formatEther(mappedDeposit.remaining),
|
||||||
seller: mappedDeposit.seller,
|
seller: mappedDeposit.seller,
|
||||||
pixKey: mappedDeposit.pixTarget
|
pixKey: mappedDeposit.pixTarget,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ const listValidDepositTransactionsByWalletAddress = async (
|
|||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const listAllTransactionByWalletAddress = async (
|
const listAllTransactionByWalletAddress = async (
|
||||||
walletAddress: string
|
walletAddress: string
|
||||||
): Promise<any[] | undefined> => {
|
): Promise<any[] | undefined> => {
|
||||||
@ -94,10 +93,9 @@ const listReleaseTransactionByWalletAddress = async (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
updateWalletStatus,
|
updateWalletStatus,
|
||||||
listValidDepositTransactionsByWalletAddress,
|
listValidDepositTransactionsByWalletAddress,
|
||||||
listAllTransactionByWalletAddress,
|
listAllTransactionByWalletAddress,
|
||||||
listReleaseTransactionByWalletAddress
|
listReleaseTransactionByWalletAddress,
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,12 @@ import { NetworkEnum } from "@/model/NetworkEnum";
|
|||||||
// Store reference
|
// Store reference
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
const { walletAddress, networkName, depositsValidListGoerli, depositsValidListMumbai } = storeToRefs(etherStore);
|
const {
|
||||||
|
walletAddress,
|
||||||
|
networkName,
|
||||||
|
depositsValidListGoerli,
|
||||||
|
depositsValidListMumbai,
|
||||||
|
} = storeToRefs(etherStore);
|
||||||
|
|
||||||
// Reactive state
|
// Reactive state
|
||||||
const tokenValue = ref(0);
|
const tokenValue = ref(0);
|
||||||
@ -33,9 +38,12 @@ const connectAccount = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const emitConfirmButton = () => {
|
const emitConfirmButton = () => {
|
||||||
const selectedDeposit = networkName.value == NetworkEnum.ethereum ? selectedGoerliDeposit.value : selectedMumbaiDeposit.value;
|
const selectedDeposit =
|
||||||
emit('tokenBuy', selectedDeposit, tokenValue.value)
|
networkName.value == NetworkEnum.ethereum
|
||||||
}
|
? selectedGoerliDeposit.value
|
||||||
|
: selectedMumbaiDeposit.value;
|
||||||
|
emit("tokenBuy", selectedDeposit, tokenValue.value);
|
||||||
|
};
|
||||||
|
|
||||||
// Debounce methods
|
// Debounce methods
|
||||||
const handleInputEvent = (event: any) => {
|
const handleInputEvent = (event: any) => {
|
||||||
@ -74,15 +82,22 @@ const verifyLiquidity = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedGoerliDeposit.value = verifyNetworkLiquidity(tokenValue.value, walletAddress.value, depositsValidListGoerli.value);
|
selectedGoerliDeposit.value = verifyNetworkLiquidity(
|
||||||
selectedMumbaiDeposit.value = verifyNetworkLiquidity(tokenValue.value, walletAddress.value, depositsValidListMumbai.value);
|
tokenValue.value,
|
||||||
|
walletAddress.value,
|
||||||
|
depositsValidListGoerli.value
|
||||||
|
);
|
||||||
|
selectedMumbaiDeposit.value = verifyNetworkLiquidity(
|
||||||
|
tokenValue.value,
|
||||||
|
walletAddress.value,
|
||||||
|
depositsValidListMumbai.value
|
||||||
|
);
|
||||||
|
|
||||||
enableOrDisableConfirmButton()
|
enableOrDisableConfirmButton();
|
||||||
if (selectedGoerliDeposit.value || selectedMumbaiDeposit.value) {
|
if (selectedGoerliDeposit.value || selectedMumbaiDeposit.value) {
|
||||||
hasLiquidity.value = true;
|
hasLiquidity.value = true;
|
||||||
enableWalletButton.value = true;
|
enableWalletButton.value = true;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
hasLiquidity.value = false;
|
hasLiquidity.value = false;
|
||||||
enableWalletButton.value = true;
|
enableWalletButton.value = true;
|
||||||
}
|
}
|
||||||
@ -93,12 +108,11 @@ const enableOrDisableConfirmButton = (): void => {
|
|||||||
enableConfirmButton.value = true;
|
enableConfirmButton.value = true;
|
||||||
if (selectedMumbaiDeposit.value && networkName.value == NetworkEnum.polygon)
|
if (selectedMumbaiDeposit.value && networkName.value == NetworkEnum.polygon)
|
||||||
enableConfirmButton.value = true;
|
enableConfirmButton.value = true;
|
||||||
else
|
else enableConfirmButton.value = false;
|
||||||
enableConfirmButton.value = false;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
watch(networkName, async () => {
|
watch(networkName, async () => {
|
||||||
enableOrDisableConfirmButton()
|
enableOrDisableConfirmButton();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
const verifyNetworkLiquidity = (tokenValue: number, walletAddress: string, validDepositList: any[]) => {
|
const verifyNetworkLiquidity = (
|
||||||
|
tokenValue: number,
|
||||||
|
walletAddress: string,
|
||||||
|
validDepositList: any[]
|
||||||
|
) => {
|
||||||
const element = validDepositList.find((element) => {
|
const element = validDepositList.find((element) => {
|
||||||
const remaining = element.remaining;
|
const remaining = element.remaining;
|
||||||
if (
|
if (
|
||||||
@ -11,7 +15,7 @@ const verifyNetworkLiquidity = (tokenValue: number, walletAddress: string, valid
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
return element
|
return element;
|
||||||
}
|
};
|
||||||
|
|
||||||
export { verifyNetworkLiquidity }
|
export { verifyNetworkLiquidity };
|
||||||
|
@ -10,7 +10,7 @@ import { storeToRefs } from "pinia";
|
|||||||
import { addLock, releaseLock } from "@/blockchain/buyerMethods";
|
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";
|
||||||
|
|
||||||
enum Step {
|
enum Step {
|
||||||
Search,
|
Search,
|
||||||
@ -46,7 +46,7 @@ const confirmBuyClick = async (selectedDeposit: any, tokenValue: number) => {
|
|||||||
lockTransactionHash.value = lock.transactionHash;
|
lockTransactionHash.value = lock.transactionHash;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err)
|
console.log(err);
|
||||||
flowStep.value = Step.Search;
|
flowStep.value = Step.Search;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -75,8 +75,9 @@ const releaseTransaction = async ({ e2eId }: any) => {
|
|||||||
);
|
);
|
||||||
release.wait();
|
release.wait();
|
||||||
|
|
||||||
await listReleaseTransactionByWalletAddress(walletAddress.value.toLowerCase())
|
await listReleaseTransactionByWalletAddress(
|
||||||
.then((releaseTransactions) => {
|
walletAddress.value.toLowerCase()
|
||||||
|
).then((releaseTransactions) => {
|
||||||
if (releaseTransactions)
|
if (releaseTransactions)
|
||||||
lastWalletReleaseTransactions.value = releaseTransactions;
|
lastWalletReleaseTransactions.value = releaseTransactions;
|
||||||
});
|
});
|
||||||
@ -86,10 +87,9 @@ const releaseTransaction = async ({ e2eId }: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getNetworksLiquidity();
|
await getNetworksLiquidity();
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -5,7 +5,7 @@ import ListingComponent from "@/components/ListingComponent.vue";
|
|||||||
import type { BigNumber } from "ethers";
|
import type { BigNumber } 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";
|
||||||
|
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
@ -13,8 +13,7 @@ const { walletAddress } = storeToRefs(etherStore);
|
|||||||
const depositList = ref<any[]>([]);
|
const depositList = ref<any[]>([]);
|
||||||
|
|
||||||
if (walletAddress.value) {
|
if (walletAddress.value) {
|
||||||
const walletDeposits =
|
const walletDeposits = await listValidDepositTransactionsByWalletAddress(
|
||||||
await listValidDepositTransactionsByWalletAddress(
|
|
||||||
walletAddress.value
|
walletAddress.value
|
||||||
);
|
);
|
||||||
if (walletDeposits) {
|
if (walletDeposits) {
|
||||||
@ -39,8 +38,7 @@ const handleWithDrawDeposit = async (depositID: BigNumber, index: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
watch(walletAddress, async () => {
|
watch(walletAddress, async () => {
|
||||||
const walletDeposits =
|
const walletDeposits = await listValidDepositTransactionsByWalletAddress(
|
||||||
await listValidDepositTransactionsByWalletAddress(
|
|
||||||
walletAddress.value
|
walletAddress.value
|
||||||
);
|
);
|
||||||
if (walletDeposits) {
|
if (walletDeposits) {
|
||||||
|
@ -10,8 +10,7 @@ const { walletAddress } = storeToRefs(etherStore);
|
|||||||
const allUserTransactions = ref<any[]>([]);
|
const allUserTransactions = ref<any[]>([]);
|
||||||
|
|
||||||
if (walletAddress.value) {
|
if (walletAddress.value) {
|
||||||
await listAllTransactionByWalletAddress(walletAddress.value)
|
await listAllTransactionByWalletAddress(walletAddress.value).then((res) => {
|
||||||
.then((res) => {
|
|
||||||
if (res) allUserTransactions.value = res;
|
if (res) allUserTransactions.value = res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user