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

@@ -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" />