import React, { useState, useEffect } from 'react'; import { withRouter } from "react-router-dom"; import ReactTooltip from "react-tooltip"; import { AccountType, Environment, Network, Role, ContractState } from '../util/enum'; import DisclaimerModal from './disclaimer'; import SsnTable from './ssn-table'; import Footer from './footer'; import WalletKeystore from './wallet-keystore'; import WalletLedger from './wallet-ledger'; import WalletZilPay from './wallet-zilpay'; import IconKeystoreLine from './icons/keystore-line'; import IconLedgerLine from './icons/ledger-line'; import IconZilPayLine from './icons/zil-pay-line'; import IconSun from './icons/sun'; import IconMoon from './icons/moon'; import ZillionLogo from '../static/zillion.svg'; import ZillionLightLogo from '../static/light/zillion.svg'; import LandingStatsTable from './landing-stats-table'; import AvelyLogo from '../static/avely.svg' import IgniteLogo from '../static/ignite_dao.png' import useDarkMode from '../util/use-dark-mode'; import { ToastContainer } from 'react-toastify'; import IconSearch from './icons/search'; import WarningBanner from './warning-banner'; import RewardCountdownTable from './reward-countdown-table'; import { useAppDispatch, useAppSelector } from '../store/hooks'; import { getEnvironment } from '../util/config-json-helper'; import { QUERY_AND_UPDATE_STAKING_STATS } from '../store/stakingSlice'; import { logger } from '../util/logger'; import { INIT_USER, QUERY_AND_UPDATE_USER_STATS, UPDATE_LEDGER_INDEX } from '../store/userSlice'; import { ZilSigner } from '../zilliqa-signer'; function Home(props: any) { const dispatch = useAppDispatch(); const chainInfo = useAppSelector(state => state.blockchain); // config.js from public folder const env = getEnvironment(); const [isDirectDashboard, setIsDirectDashboard] = useState(false); const [isShowAccessMethod, setShowAccessMethod] = useState(false); const [explorerSearchAddress, setExplorerSearchAddress] = useState(''); const [role, setRole] = useState(''); const [accessMethod, setAccessMethod] = useState(''); const [selectedNetwork, setSelectedNetwork] = useState(() => { if (env === Environment.PROD) { return Network.MAINNET; } else { // default to testnet return Network.TESTNET; } }); const darkMode = useDarkMode(true); // trigger show wallets to choose const resetWalletsClicked = () => { setAccessMethod(''); setIsDirectDashboard(false); } const timeout = (delay: number) => { return new Promise(res => setTimeout(res, delay)); } const redirectToDashboard = async (addressBase16: string, addressBech32: string, accountType: AccountType, ledgerIndex?: number) => { // login success // update store and signer network dispatch(INIT_USER({ address_base16: addressBase16, address_bech32: addressBech32, account_type: accountType, authenticated: true, selected_role: role })); dispatch(QUERY_AND_UPDATE_USER_STATS()); await ZilSigner.changeNetwork(chainInfo.blockchain); if (accountType === AccountType.LEDGER && typeof (ledgerIndex) !== 'undefined') { // update ledger index to store if using ledger dispatch(UPDATE_LEDGER_INDEX({ ledger_index: ledgerIndex })); } // add some delay await timeout(1000); logger("directing to dashboard"); props.history.push("/dashboard"); } const handleAccessMethod = (access: string) => { setAccessMethod(access); } const handleShowAccessMethod = (selectedRole: string) => { setRole(selectedRole); setShowAccessMethod(true); } const toggleDirectToDashboard = () => { setIsDirectDashboard(true); } const resetView = () => { setRole(''); setShowAccessMethod(false); setAccessMethod(''); } const DisplayAccessMethod = () => { switch (accessMethod) { case AccountType.KEYSTORE: return ; case AccountType.ZILPAY: return ; case AccountType.LEDGER: return ; default: return null; } } const DisplayLoader = () => { logger("retrieving wallet info..."); return (

Retrieving wallet info...

Connecting...
); } const toggleTheme = () => { if (darkMode.value === true) { darkMode.disable(); } else { darkMode.enable(); } } const toggleZillionLogo = () => { if (darkMode.value === true) { return zillion; } else { return zillion; } } const handleExplorerSearchAddress = (e: any) => { setExplorerSearchAddress(e.target.value); } const handleExplorerKeyPress = (e: any) => { if (e.keyCode === 13) { // Enter key // proceed to search explorerCheckRewards(); } } const explorerCheckRewards = () => { const zillionExplorerUrl = "/address/" + explorerSearchAddress props.history.push(zillionExplorerUrl); }; useEffect(() => { if (env === Environment.PROD) { setSelectedNetwork(Network.MAINNET); } else { setSelectedNetwork(Network.TESTNET); } dispatch(QUERY_AND_UPDATE_STAKING_STATS()); }, [env, selectedNetwork, dispatch]); useEffect(() => { window.onbeforeunload = null; }, []); return (
{/*
*/} { (env === Environment.STAGE || env === Environment.PROD) && {selectedNetwork} }
<>{toggleZillionLogo()}

Staking with Zilliqa. Simplified!

window.location.href = 'https://dapp.avely.fi/'} > Avely
window.location.href = 'https://instantunstaking.ignitedao.io/'} > Ignite DAO
{ !isShowAccessMethod ?
{ /* sign in and seed node table */}
handleShowAccessMethod(Role.DELEGATOR.toString())}>Sign in for Delegators
handleShowAccessMethod(Role.OPERATOR.toString())}>Sign in for Operators
{/*
window.location.href = 'https://dapp.avely.fi/'} style={{ width: '250px', textAlign: 'center', backgroundColor: '#FF6FAC', color: 'white' }} > Liquid Staking
*/}

Staked Seed Nodes

Please refer to our  Staking Viewer  for more information on the nodes' statuses.

: !accessMethod ? <> { /* no wallets selected - show wallets to connect */}

Connect your wallet to start

handleAccessMethod(AccountType.KEYSTORE)}> Keystore
handleAccessMethod(AccountType.LEDGER)}> Ledger
handleAccessMethod(AccountType.ZILPAY)} data-tip={env === Environment.PROD ? "Ensure your ZilPay is on Mainnet network" : "Ensure your ZilPay is on Testnet network"}> ZilPay
: <> {/* wallet selected - show chosen wallet component */} {isDirectDashboard ? <>{DisplayLoader()} : <>{DisplayAccessMethod()}} }
); } export default withRouter(Home);