+ activeChain?: string
+ isTransfer?: boolean
+ selectTransferChain: (str: CrosschainChain) => void
+}
+const ModalContainer = styled.div`
+ padding: 1.5rem;
+ width: 100%;
+ h5 {
+ font-weight: bold;
+ margin-bottom: 1rem;
+ }
+ p {
+ font-size: 0.85rem;
+ margin-top: 1rem;
+ line-height: 20px;
+ color: #ced0d9;
+ a {
+ font-weight: bold;
+ color: ${({ theme }) => theme.primary1};
+ cursor: pointer;
+ outline: none;
+ text-decoration: none;
+ margin-left: 4px;
+ margin-right: 4px;
+ }
+ }
+ ul {
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ padding-left: 0;
+ padding-right: 0;
+ li {
+ display: flex;
+ flex-direction: row;
+ margin-bottom: .5rem;
+ position: relative;
+ padding: 12px;
+ transition: all 0.2s ease-in-out;
+ border-radius: 12px;
+ align-items: center;
+ &.active {
+ background: rgba(255, 255, 255, 0.1);
+ &:before {
+ position: absolute;
+ content: '';
+ width: 8px;
+ height: 8px;
+ border-radius: 100%;
+ background: ${({ theme }) => theme.primary1};
+ top: 8px;
+ right: 8px;
+ }
+ }
+ &.disabled {
+ opacity: 0.35;
+ pointer-events: none;
+ user-select: none;
+ }
+ &.selectable {
+ cursor: pointer;
+ &:hover {
+ border-radius: 12px;
+ background: rgba(255, 255, 255, 0.1);
+ }
+ }
+ &:hover {
+ background-color: blue;
+ }
+ img {
+ margin-right: 0.5rem;
+ }
+ span {
+ }
+ }
+ }
+`
+
+function StyledCrossChainModal({
+ isOpen,
+ onDismiss,
+ supportedChains,
+ activeChain,
+ isTransfer,
+ selectTransferChain
+}: StyledCrossChainModalProps) {
+ return (
+
+
+ {Supported Blockchains:
}
+
+ -
+
+ {activeChain}
+
+ {supportedChains.map((chain: CrosschainChain) => (
+ - {
+ selectTransferChain(chain)
+ onDismiss()
+
+ }}
+ className={`
+ ${activeChain === chain.name && !isTransfer ? 'active' : ''}
+ ${(activeChain === chain.name && isTransfer) || chain.name === 'Polkadot' ? 'disabled' : ''}
+ ${isTransfer && activeChain !== chain.name ? 'selectable' : ''}
+ `}
+ >
+
+ {chain.name}
+
+ ))}
+
+
+
+ )
+}
+
+
+function NetworkSwitcher() {
+ const { chainId } = useActiveWeb3React()
+ const {
+ availableChains: allChains,
+ } = useCrosschainState()
+ const availableChains = useMemo(() => {
+ return allChains.filter(i => i.name !== (chainId ? CHAIN_LABELS[chainId] : 'Ethereum'))
+ }, [allChains])
+
+ const [crossChainModalOpen, setShowCrossChainModal] = useState(false)
+ const hideCrossChainModal = () => {
+ setShowCrossChainModal(false)
+ // startNewSwap()
+ }
+ const showCrossChainModal = () => {
+ setShowCrossChainModal(true)
+ }
+
+ const onSelectTransferChain = async (chain: CrosschainChain) => {
+ let { ethereum } = window;
+ if (ethereum) {
+ let chainsConfig = null;
+ for (const item of crosschainConfig.chains) {
+ if (item.chainId === +chain.chainID) {
+ chainsConfig = item
+ }
+ }
+ if (chainsConfig) {
+ const hexChainId = "0x" + Number(chainsConfig.networkId).toString(16);
+ const data = [{
+ chainId: hexChainId,
+ chainName: chainsConfig.name,
+ nativeCurrency:
+ {
+ name: chainsConfig.nativeTokenSymbol,
+ symbol: chainsConfig.nativeTokenSymbol,
+ decimals: 18
+ },
+ rpcUrls: [chainsConfig.rpcUrl],
+ blockExplorerUrls: [chainsConfig.blockExplorer],
+ }]
+ /* eslint-disable */
+ const tx = (ethereum && ethereum.request) ? await ethereum['request']({ method: 'wallet_addEthereumChain', params: data }).catch() : ''
+
+ if (tx) {
+ console.log(tx)
+ }
+ }
+ }
+
+ }
+ return (
+ <>
+
+
+ {chainId && NETWORK_LABELS[chainId] && (
+ {NETWORK_LABELS[chainId]}
+ )}
+
+
+
+ >
+ )
}
export default function Header() {
@@ -312,23 +513,9 @@ export default function Header() {
- {/*
- Current Blockchain:
- { chainId === 1 &&
-
- }
- { chainId === 43113 &&
-
- }
- */}
-
-
- {chainId && NETWORK_LABELS[chainId] && (
- {NETWORK_LABELS[chainId]}
- )}
-
+
{account && userEthBalance ? (
diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts
index e03b385aba5..6362b7b9796 100644
--- a/src/react-app-env.d.ts
+++ b/src/react-app-env.d.ts
@@ -11,6 +11,7 @@ interface Window {
isMetaMask?: true
on?: (...args: any[]) => void
removeListener?: (...args: any[]) => void
+ request?: (...args: any[]) => Promise
}
web3?: {}
}