-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Include LocalTerra in the chain list - Preconfigured accounts for added network with checked option - Display error message if the connection is disconnected - Show the networks menu on the sandbox mode
- Loading branch information
sim
committed
Jan 20, 2022
1 parent
1697337
commit 06cd3bb
Showing
32 changed files
with
387 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { FC, useEffect, useState } from "react" | ||
import { fromPairs } from "ramda" | ||
import axios from "axios" | ||
import { ASSETS } from "config/constants" | ||
import createContext from "utils/createContext" | ||
import { useCustomNetworks } from "data/settings/CustomNetworks" | ||
|
||
export const [useNetworks, NetworksProvider] = | ||
createContext<CustomNetworks>("useNetworks") | ||
|
||
const InitNetworks: FC = ({ children }) => { | ||
const [networks, setNetworks] = useState<CustomNetworks>() | ||
const { list } = useCustomNetworks() | ||
|
||
useEffect(() => { | ||
const fetchChains = async () => { | ||
const { data: chains } = await axios.get<TerraNetworks>("/chains.json", { | ||
baseURL: ASSETS, | ||
}) | ||
|
||
const networks = { | ||
...chains, | ||
localterra: { ...chains.localterra, preconfigure: true }, | ||
} | ||
|
||
setNetworks({ | ||
...networks, | ||
...fromPairs(list.map((item) => [item.name, item])), | ||
}) | ||
} | ||
|
||
fetchChains() | ||
}, [list]) | ||
|
||
if (!networks) return null | ||
return <NetworksProvider value={networks}>{children}</NetworksProvider> | ||
} | ||
|
||
export default InitNetworks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.title { | ||
font-size: 24px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useTranslation } from "react-i18next" | ||
import Logo from "styles/images/LocalTerra.png" | ||
import { useNetworkState } from "data/wallet" | ||
import { Button, ExternalLink } from "components/general" | ||
import { FlexColumn } from "components/layout" | ||
import styles from "./NetworkError.module.scss" | ||
|
||
const NetworkError = () => { | ||
const { t } = useTranslation() | ||
const [network, setNetwork] = useNetworkState() | ||
|
||
const isLocalTerra = network === "localterra" | ||
|
||
return ( | ||
<FlexColumn gap={20}> | ||
<img src={Logo} alt={t("Logo")} width={60} height={60} /> | ||
|
||
<article> | ||
<h1 className={styles.title}> | ||
{isLocalTerra | ||
? t("LocalTerra is not running") | ||
: t(`${network} is not running`)} | ||
</h1> | ||
|
||
{isLocalTerra && ( | ||
<ExternalLink href="https://github.com/terra-money/localterra"> | ||
{t("Learn more")} | ||
</ExternalLink> | ||
)} | ||
</article> | ||
|
||
<Button onClick={() => setNetwork("mainnet")} size="small" outline> | ||
{t("Back to mainnet")} | ||
</Button> | ||
</FlexColumn> | ||
) | ||
} | ||
|
||
export default NetworkError |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { FC } from "react" | ||
import { useNodeInfo } from "data/queries/tendermint" | ||
import Overlay from "./components/Overlay" | ||
import NetworkError from "./NetworkError" | ||
|
||
const WithNodeInfo: FC = ({ children }) => { | ||
const { isLoading, isError } = useNodeInfo() | ||
|
||
if (isError) { | ||
return ( | ||
<Overlay> | ||
<NetworkError /> | ||
</Overlay> | ||
) | ||
} | ||
|
||
if (isLoading) return null | ||
return <>{children}</> | ||
} | ||
|
||
export default WithNodeInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { readDenom } from "@terra.kitchen/utils" | ||
import { useActiveDenoms } from "data/queries/oracle" | ||
import { useCurrencyState } from "data/settings/Currency" | ||
import { RadioGroup } from "components/form" | ||
|
||
const CurrencySetting = () => { | ||
const { data: activeDenoms = [] } = useActiveDenoms() | ||
const [currency, setCurrency] = useCurrencyState() | ||
|
||
return ( | ||
<RadioGroup | ||
options={activeDenoms.map((denom) => { | ||
return { value: denom, label: readDenom(denom) } | ||
})} | ||
value={currency} | ||
onChange={setCurrency} | ||
/> | ||
) | ||
} | ||
|
||
export default CurrencySetting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useTranslation } from "react-i18next" | ||
import { Languages } from "config/lang" | ||
import { RadioGroup } from "components/form" | ||
|
||
const LanguageSetting = () => { | ||
const { i18n } = useTranslation() | ||
|
||
return ( | ||
<RadioGroup | ||
options={Object.values(Languages)} | ||
value={i18n.language} | ||
onChange={(language) => i18n.changeLanguage(language)} | ||
/> | ||
) | ||
} | ||
|
||
export default LanguageSetting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useTranslation } from "react-i18next" | ||
import { useNetworkOptions, useNetworkState } from "data/wallet" | ||
import { useCustomNetworks } from "data/settings/CustomNetworks" | ||
import { InternalLink } from "components/general" | ||
import { RadioGroup } from "components/form" | ||
|
||
const NetworkSetting = () => { | ||
const { t } = useTranslation() | ||
const [network, setNetwork] = useNetworkState() | ||
const networkOptions = useNetworkOptions() | ||
const { list } = useCustomNetworks() | ||
|
||
if (!networkOptions) return null | ||
|
||
return ( | ||
<> | ||
<RadioGroup | ||
options={networkOptions} | ||
value={network} | ||
onChange={setNetwork} | ||
/> | ||
|
||
{list.length ? ( | ||
<InternalLink to="/networks" chevron> | ||
{t("Manage networks")} | ||
</InternalLink> | ||
) : ( | ||
<InternalLink to="/network/new" chevron> | ||
{t("Add a network")} | ||
</InternalLink> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default NetworkSetting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.