Skip to content

Commit

Permalink
Merge pull request #208 from G7DAO/feat/network-toggle
Browse files Browse the repository at this point in the history
Feat/network toggle
  • Loading branch information
elclandestin0 authored Nov 25, 2024
2 parents 6a10317 + def8ab1 commit 27d1102
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const HistoryDesktop: React.FC<HistoryDesktopProps> = () => {
JSON.stringify([...storedTransactions, ...newTransactions])
)
}
setMergedTransactions(selectedNetworkType === "Testnet" ? combinedTransactions : localTransactions)
setMergedTransactions(combinedTransactions)
}, [messages, apiTransactions])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const BenefitsSection: React.FC = () => {
return (
<div className={styles.secondSection}>
<div className={styles.contentContainer}>
<div className={styles.sectionTitle}>Get all benefits of the G7 Network</div>
<div className={styles.sectionTitle}>Get all of the benefits of the G7 Network</div>
<div className={styles.cards}>
{benefits.map((benefit, index) => (
<div className={styles.card} key={index}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const essentials = [
},
{
title: "Docs",
description: "Get more information about building in the G7 Network",
description: "Get more information about building on the G7 Network",
imageClass: styles.networkEssentialDocs,
onClick: () => window.open('https://wiki.game7.io/g7-developer-resource/', '_blank'),
},
Expand Down
10 changes: 7 additions & 3 deletions webapps/world-builder-dashboard/src/hooks/useBridgeAPI.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { useQuery } from 'react-query'
import { ethers } from 'ethers'
import { useBlockchainContext } from '@/contexts/BlockchainContext'

const BASE_URL = 'https://api.game7.build'

export const useBridgeAPI = () => {
const useHistoryTransactions = (address: string | undefined) => {
const isValidAddress = ethers.utils.isAddress(address ?? '')
const { selectedNetworkType } = useBlockchainContext()
const uriSnippet = selectedNetworkType === 'Testnet' ? '-testnet' : ''
return useQuery(
['historyTransactions', address],
['historyTransactions', address, selectedNetworkType],
async () => {
const res = await fetch(`${BASE_URL}/bridge/${address}/transactions?limit=50&offset=0`, {
console.log(selectedNetworkType)
const res = await fetch(`${BASE_URL}/bridge/game7${uriSnippet}/${address}/transactions?limit=50&offset=0`, {
method: 'GET'
})
if (!res.ok) {
Expand All @@ -19,7 +23,7 @@ export const useBridgeAPI = () => {
return data
},
{
enabled: !!address && isValidAddress,
enabled: !!address && isValidAddress && !!selectedNetworkType,
retry: false
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,15 @@ export const useNotifications = (
offset: number,
limit: number
): UseQueryResult<BridgeNotification[]> => {
const { selectedNetworkType } = useBlockchainContext()
return useQuery(
['notifications', connectedAccount, offset, limit],
async () => {
if (!connectedAccount) {
return []
}
// const { selectedNetworkType } = useBlockchainContext()
const transactionsString = localStorage.getItem(`bridge-${connectedAccount}-transactions`)
const transactionsString = localStorage.getItem(`bridge-${connectedAccount}-transactions-${selectedNetworkType}`)
let transactions
if (!transactionsString) {
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import AlliesSection from "@/components/landing/AlliesSection";
import NetworkEssentials from "@/components/landing/NetworksEssentials";
import Navbar from "@/components/landing/Navbar";
import Container from "@/components/landing/Container";
import { useBlockchainContext } from '@/contexts/BlockchainContext';

const LandingPage: React.FC = () => {
const navigate = useNavigate();
const {setSelectedNetworkType} = useBlockchainContext()
const [navbarOpen, setNavBarOpen] = useState<boolean>(false);
const smallView = useMediaQuery('(max-width: 750px)');
const isLargeView = useMediaQuery('(min-width: 1440px)');

const startBuilding = () => {
setSelectedNetworkType('Testnet')
navigate('/faucet');
};

Expand Down

0 comments on commit 27d1102

Please sign in to comment.