Remove alchemy file and add localhost network to possible network to choose
Co-authored-by: brunoedcf <brest.dallacosta@outlook.com>
This commit is contained in:
parent
aedd4bc532
commit
62dd4349b2
@ -52,6 +52,7 @@ const getNetworkImage = (networkName: NetworkEnum) => {
|
|||||||
let validImages = {
|
let validImages = {
|
||||||
Ethereum: ethereumImage,
|
Ethereum: ethereumImage,
|
||||||
Polygon: polygonImage,
|
Polygon: polygonImage,
|
||||||
|
Localhost: ethereumImage
|
||||||
};
|
};
|
||||||
|
|
||||||
return validImages[networkName];
|
return validImages[networkName];
|
||||||
@ -159,7 +160,23 @@ const getNetworkImage = (networkName: NetworkEnum) => {
|
|||||||
<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
|
Polygon
|
||||||
</span>
|
</span>
|
||||||
<hr />
|
</div>
|
||||||
|
<div class="w-full flex justify-center">
|
||||||
|
<hr class="w-4/5" />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="menu-button gap-2 px-4 rounded-md cursor-pointer"
|
||||||
|
@click="etherStore.setNetworkName(NetworkEnum.localhost)"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
alt="Localhost"
|
||||||
|
width="20"
|
||||||
|
height="20"
|
||||||
|
src="@/assets/ethereum.svg"
|
||||||
|
/>
|
||||||
|
<span class="text-gray-900 py-4 text-end font-semibold text-sm">
|
||||||
|
Localhost
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export enum NetworkEnum {
|
export enum NetworkEnum {
|
||||||
ethereum = "Ethereum",
|
ethereum = "Ethereum",
|
||||||
polygon = "Polygon",
|
polygon = "Polygon",
|
||||||
|
localhost = "Localhost",
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
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,
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user