diff --git a/apps/taquito-test-dapp/src/App.svelte b/apps/taquito-test-dapp/src/App.svelte index cc7f65b418..0d8ff2808d 100644 --- a/apps/taquito-test-dapp/src/App.svelte +++ b/apps/taquito-test-dapp/src/App.svelte @@ -3,7 +3,7 @@ import { TezosToolkit } from "@taquito/taquito"; import { NetworkType } from "@airgap/beacon-sdk"; import Select from "svelte-select"; - import { rpcUrl } from "./config"; + import { getRpcUrl } from "./config"; import store from "./store"; import Layout from "./Layout.svelte"; import TestContainer from "./lib/TestContainer.svelte"; @@ -35,12 +35,11 @@ let networkError = false; let showCustomNetworkInput = false; let customNetworkInput = "https://"; - const groupBy = (item) => item.group; + const groupBy = (item: { group: any }) => item.group; - const changeNetwork = (event) => { + const changeNetwork = (event: { detail: { value: string } }) => { networkError = false; showCustomNetworkInput = false; - const walletComponent = layout.getSideBar().getWallet(); switch (event.detail.value.toLocaleLowerCase()) { case "mainnet": store.updateNetworkType(NetworkType.MAINNET); @@ -48,9 +47,6 @@ case "ghostnet": store.updateNetworkType(NetworkType.GHOSTNET); break; - case "mumbainet": - store.updateNetworkType(NetworkType.MUMBAINET); - break; case "nairobinet": store.updateNetworkType(NetworkType.NAIROBINET); break; @@ -58,7 +54,7 @@ //TODO: input custom RPC URL showCustomNetworkInput = true; setTimeout(() => { - document.getElementById("custom-network-input").focus(); + document.getElementById("custom-network-input")?.focus(); }, 100); break; default: @@ -67,7 +63,7 @@ } }; - const changeMatrixNode = (event) => { + const changeMatrixNode = (event: { detail: { value: string } }) => { switch (event.detail.value.toLocaleLowerCase()) { case "default": store.updateMatrixNode("beacon-node-1.sky.papers.tech"); @@ -77,9 +73,10 @@ break; case "custom": store.updateMatrixNode("beacon-node-1.sky.papers.tech"); - if (!rpcUrl.custom) { + if (!getRpcUrl(NetworkType.CUSTOM)) { + // TODO: This logic does not seem right // in case the user did not provide any custom network URL - store.updateTezos(new TezosToolkit(rpcUrl.ghostnet)); + store.updateTezos(new TezosToolkit(getRpcUrl(NetworkType.GHOSTNET))); } break; } @@ -116,7 +113,7 @@
@@ -35,6 +53,15 @@ +
+ Events ({$store.eventLogs.length}): +
    + {#each $store.eventLogs as event} +
  • + event_note + {event} +
  • + {/each} +
+
- - diff --git a/apps/taquito-test-dapp/src/config.ts b/apps/taquito-test-dapp/src/config.ts index 9d12294df6..c56aa13253 100644 --- a/apps/taquito-test-dapp/src/config.ts +++ b/apps/taquito-test-dapp/src/config.ts @@ -1,14 +1,31 @@ import { NetworkType } from "@airgap/beacon-sdk"; -export const rpcUrl = { - mumbainet: "https://mumbainet.ecadinfra.com/", - nairobinet: "https://nairobinet.ecadinfra.com/", - ghostnet: "https://ghostnet.ecadinfra.com/", - ithacanet: "https://ithacanet.ecadinfra.com/", - mainnet: "https://mainnet.ecadinfra.com", //"https://mainnet-tezos.giganode.io" - custom: "https://ghostnet.ecadinfra.com/" +export type SupportedNetworks = NetworkType.NAIROBINET | NetworkType.GHOSTNET | NetworkType.MAINNET | NetworkType.CUSTOM; + +const rpcUrls: Record = { + [NetworkType.NAIROBINET]: "https://nairobinet.ecadinfra.com/", + [NetworkType.GHOSTNET]: "https://ghostnet.ecadinfra.com/", + [NetworkType.MAINNET]: "https://mainnet.ecadinfra.com", //"https://mainnet-tezos.giganode.io" + [NetworkType.CUSTOM]: "https://ghostnet.ecadinfra.com/", }; +export const getRpcUrl = (networkType: SupportedNetworks): string => { + return rpcUrls[networkType]; +} + +export const getTzKtUrl = (networkType: SupportedNetworks): string | undefined => { + switch (networkType) { + case NetworkType.NAIROBINET: + return "https://nairobinet.tzkt.io"; + case NetworkType.GHOSTNET: + return "https://ghostnet.tzkt.io"; + case NetworkType.MAINNET: + return "https://tzkt.io"; + case NetworkType.CUSTOM: + return undefined; + } +} + export const defaultMatrixNode = "beacon-node-1.sky.papers.tech"; export const defaultNetworkType = NetworkType.GHOSTNET; diff --git a/apps/taquito-test-dapp/src/lib/Sidebar.svelte b/apps/taquito-test-dapp/src/lib/Sidebar.svelte index 7b561e6a6b..705d564b13 100644 --- a/apps/taquito-test-dapp/src/lib/Sidebar.svelte +++ b/apps/taquito-test-dapp/src/lib/Sidebar.svelte @@ -21,7 +21,7 @@