Add initial alchemy structure code

This commit is contained in:
RcleydsonR
2023-01-12 00:32:52 -03:00
parent 6a4884aec9
commit aedd4bc532
9 changed files with 12886 additions and 2334 deletions
+2
View File
@@ -1 +1,3 @@
VITE_API_URL=http://localhost:8000/
VITE_GOERLI_API_KEY={GOERLI_API_KEY_ALCHEMY}
VITE_MUMBAI_API_KEY={MUMBAI_API_KEY_ALCHEMY}
+10468
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -14,6 +14,7 @@
"dependencies": {
"@headlessui/vue": "^1.7.3",
"@heroicons/vue": "^2.0.12",
"alchemy-sdk": "^2.3.0",
"axios": "^1.2.1",
"crc": "^3.8.0",
"pinia": "^2.0.23",
+13 -14
View File
@@ -4,8 +4,8 @@ import { useEtherStore } from "../store/ether";
import { ref } from "vue";
import { NetworkEnum } from "@/model/NetworkEnum";
import blockchain from "../utils/blockchain";
import ethereumImage from "../assets/ethereum.svg"
import polygonImage from "../assets/polygon.svg"
import ethereumImage from "../assets/ethereum.svg";
import polygonImage from "../assets/polygon.svg";
// Store reference
const etherStore = useEtherStore();
@@ -50,12 +50,12 @@ const closeMenu = () => {
const getNetworkImage = (networkName: NetworkEnum) => {
let validImages = {
"Ethereum": ethereumImage,
"Polygon": polygonImage,
}
Ethereum: ethereumImage,
Polygon: polygonImage,
};
return validImages[networkName];
}
};
</script>
<template>
@@ -81,7 +81,7 @@ const getNetworkImage = (networkName: NetworkEnum) => {
]
"
@mouseover="currencyMenuHoverToggle = true"
@mouseout="currencyMenuHoverToggle = false;"
@mouseout="currencyMenuHoverToggle = false"
:style="{
backgroundColor: currencyMenuOpenToggle
? '#F9F9F9'
@@ -90,7 +90,10 @@ const getNetworkImage = (networkName: NetworkEnum) => {
: 'transparent',
}"
>
<img alt="Choosed network image" :src="getNetworkImage(etherStore.networkName)" />
<img
alt="Choosed network image"
:src="getNetworkImage(etherStore.networkName)"
/>
<span
class="default-text group-hover:text-gray-900"
:style="{
@@ -136,9 +139,7 @@ const getNetworkImage = (networkName: NetworkEnum) => {
height="20"
src="@/assets/ethereum.svg"
/>
<span
class="text-gray-900 py-4 text-end font-semibold text-sm"
>
<span class="text-gray-900 py-4 text-end font-semibold text-sm">
Ethereum
</span>
</div>
@@ -155,9 +156,7 @@ const getNetworkImage = (networkName: NetworkEnum) => {
height="20"
src="@/assets/polygon.svg"
/>
<span
class="text-gray-900 py-4 text-end font-semibold text-sm"
>
<span class="text-gray-900 py-4 text-end font-semibold text-sm">
Polygon
</span>
<hr />
+2 -2
View File
@@ -1,4 +1,4 @@
export enum NetworkEnum {
ethereum = "Ethereum",
polygon = "Polygon"
};
polygon = "Polygon",
}
+32
View File
@@ -0,0 +1,32 @@
import { Network, Alchemy } from "alchemy-sdk";
import { useEtherStore } from "@/store/ether";
const getAlchemy = () => {
const possibleSettings = {
Ethereum: {
apiKey: import.meta.env.VITE_GOERLI_API_KEY,
network: Network.ETH_GOERLI,
},
Polygon: {
apiKey: import.meta.env.VITE_MUMBAI_API_KEY,
network: Network.MATIC_MUMBAI,
},
};
const etherStore = useEtherStore();
const settings = possibleSettings[etherStore.networkName];
const alchemy = new Alchemy(settings);
return alchemy;
};
const showLatestBlockNumber = async () => {
const alchemy = getAlchemy();
const latestBlock = await alchemy.core.getBlockNumber();
if (latestBlock) console.log(latestBlock);
};
export default {
getAlchemy,
showLatestBlockNumber,
};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2360 -2310
View File
File diff suppressed because it is too large Load Diff