Add correct etherscan url

Co-authored-by: brunoedcf <brest.dallacosta@outlook.com>
This commit is contained in:
RcleydsonR 2023-01-19 18:12:41 -03:00
parent 3c4a629ed7
commit bb6be691af
3 changed files with 17 additions and 19 deletions

View File

@ -6,12 +6,12 @@ import { getP2PixAddress } from "./addresses";
import p2pix from "../utils/smart_contract_files/P2PIX.json";
import { BigNumber, ethers } from "ethers";
import { formatEther, parseEther } from "ethers/lib/utils";
import { 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<string> => {
const etherStore = useEtherStore();
const provider = getProvider();
@ -34,7 +34,6 @@ const addLock = async (depositId: BigNumber, amount: number): Promise<any> => {
return t.args.lockID;
};
// Release lock
const releaseLock = async (
pixKey: string,
amount: number,
@ -83,8 +82,6 @@ const cancelDeposit = async (depositId: BigNumber): Promise<boolean> => {
const contract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
await contract.cancelDeposit(depositId);
// await updateWalletBalance();
// await updateValidDeposits();
return true;
};
@ -97,11 +94,7 @@ const withdrawDeposit = async (depositId: BigNumber): Promise<boolean> => {
const contract = new ethers.Contract(getP2PixAddress(), p2pix.abi, signer);
await contract.withdraw(depositId, []);
// // await updateWalletBalance();
// await updateValidDeposits();
return true;
};
// Releases lock by specific ID and other additional data
export { cancelDeposit, withdrawDeposit, addLock, releaseLock };

View File

@ -1,5 +1,7 @@
<script setup lang="ts">
import { NetworkEnum } from "@/model/NetworkEnum";
import type { ValidDeposit } from "@/model/ValidDeposit";
import { useEtherStore } from "@/store/ether";
import { formatEther } from "@ethersproject/units";
import type { Event } from "ethers";
import { ref, watch } from "vue";
@ -10,6 +12,8 @@ const props = defineProps<{
isManageMode: boolean;
}>();
const etherStore = useEtherStore();
const itemsToShow = ref<(Event | ValidDeposit)[]>([]);
// Methods
@ -23,7 +27,12 @@ const showInitialItems = (): void => {
itemsToShow.value = props.walletTransactions.slice(0, 3);
};
const openEtherscanUrl = (url: string): void => {
const openEtherscanUrl = (transactionHash: string): void => {
const networkUrl =
etherStore.networkName == NetworkEnum.ethereum
? "goerli.etherscan.io"
: "mumbai.polygonscan.com";
const url = `https://${networkUrl}/tx/${transactionHash}`;
window.open(url, "_blank");
};
@ -130,11 +139,7 @@ showInitialItems();
<div
v-if="!props.isManageMode"
class="flex gap-2 cursor-pointer items-center justify-self-center"
@click="
openEtherscanUrl(
`https://etherscan.io/tx/${(item as Event)?.transactionHash}`
)
"
@click="openEtherscanUrl((item as Event)?.transactionHash)"
>
<span class="last-release-info">Etherscan</span>
<img alt="Redirect image" src="@/assets/redirect.svg" />

View File

@ -24,7 +24,7 @@ const etherStore = useEtherStore();
etherStore.setSellerView(false);
// States
const { loadingLock, walletAddress, locksAddedList } = storeToRefs(etherStore);
const { loadingLock, walletAddress } = storeToRefs(etherStore);
const flowStep = ref<Step>(Step.Search);
const pixTarget = ref<string>("");
const tokenAmount = ref<number>();