Skip to content

Commit

Permalink
network switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
hathbanger committed Nov 13, 2024
1 parent 909019b commit d14dcae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
10 changes: 9 additions & 1 deletion apps/demo.lasereyes.build/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ export default function Home() {

const [mounted, setMounted] = useState(false)

const switchNet = (net: NetworkType) => {
const switchNet = () => {
if (network === MAINNET) {
setNetwork(TESTNET4)
} else if (network === TESTNET4) {
setNetwork(TESTNET)
} else if (network === TESTNET) {
setNetwork(SIGNET)
} else if (network === SIGNET) {
setNetwork(FRACTAL_MAINNET)
} else if (network === FRACTAL_MAINNET) {
setNetwork(FRACTAL_TESTNET)
} else {
setNetwork(MAINNET)
}
Expand Down
25 changes: 16 additions & 9 deletions apps/demo.lasereyes.build/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import WalletCard from '@/components/WalletCard'
import { useEffect, useState } from 'react'
import { clsx } from 'clsx'
import {
FRACTAL_MAINNET,
FRACTAL_TESTNET,
MAINNET,
NetworkType,
ProviderType,
SIGNET,
SUPPORTED_WALLETS,
TESTNET,
TESTNET4,
useLaserEyes,
WalletIcon,
Expand Down Expand Up @@ -55,6 +59,18 @@ const App = ({ setNetwork }: { setNetwork: (n: NetworkType) => void }) => {
if (network === MAINNET) {
switchNetwork(TESTNET4)
setNetwork(TESTNET4)
} else if (network === TESTNET4) {
switchNetwork(TESTNET)
setNetwork(TESTNET)
} else if (network === TESTNET) {
switchNetwork(SIGNET)
setNetwork(SIGNET)
} else if (network === SIGNET) {
switchNetwork(FRACTAL_MAINNET)
setNetwork(FRACTAL_MAINNET)
} else if (network === FRACTAL_MAINNET) {
switchNetwork(FRACTAL_TESTNET)
setNetwork(FRACTAL_TESTNET)
} else {
switchNetwork(MAINNET)
setNetwork(MAINNET)
Expand All @@ -79,15 +95,6 @@ const App = ({ setNetwork }: { setNetwork: (n: NetworkType) => void }) => {
// @ts-ignore
const total = satoshisToBTC(balance)

// const NETWORKS = [
// MAINNET,
// TESTNET,
// TESTNET4,
// SIGNET,
// FRACTAL_TESTNET,
// FRACTAL_MAINNET,
// ]

return (
<div
className={
Expand Down

0 comments on commit d14dcae

Please sign in to comment.