diff --git a/.env.example b/.env.example index 7090bfc3..157c8e96 100644 --- a/.env.example +++ b/.env.example @@ -1,16 +1,16 @@ +## Mandatory Environment Variables NEXT_PUBLIC_NETWORK=mainnet +NEXT_PUBLIC_WALLET_CONNECT_ID=abcdefghijklmnopqrstuvwxyz -NEXT_PUBLIC_OSMOSIS_RPC=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-rpc-front/ -NEXT_PUBLIC_OSMOSIS_REST=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-lcd-front/ +### Optional Environment Variables +NEXT_PUBLIC_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com/ +NEXT_PUBLIC_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com/ NEXT_PUBLIC_OSMOSIS_TEST_RPC=https://rpc.devnet.osmosis.zone/ NEXT_PUBLIC_OSMOSIS_TEST_REST=https://lcd.devnet.osmosis.zone/ NEXT_PUBLIC_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech/ NEXT_PUBLIC_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech/ -NEXT_PUBLIC_WALLET_CONNECT_ID=d93fdffb159bae5ec87d8fee4cdbb045 +### Enable the following environment variables if you have access to the charting library CHARTING_LIBRARY_USERNAME=git_username CHARTING_LIBRARY_ACCESS_TOKEN=access_token -CHARTING_LIBRARY_REPOSITORY=github.com/tradingview/charting_library/ - -NEXT_PUBLIC_PYTH_API=https://mars.rpc.p2p.world/api -NEXT_PUBLIC_API_KEY=api_key +CHARTING_LIBRARY_REPOSITORY=github.com/tradingview/charting_library/ \ No newline at end of file diff --git a/src/components/Wallet/WalletConnectProvider.tsx b/src/components/Wallet/WalletConnectProvider.tsx index 4345a2c4..3769b25d 100644 --- a/src/components/Wallet/WalletConnectProvider.tsx +++ b/src/components/Wallet/WalletConnectProvider.tsx @@ -17,7 +17,7 @@ import { FC } from 'react' import chains from 'configs/chains' import { WALLETS } from 'constants/wallets' -import { ChainInfoID, WalletID } from 'types/enums/wallet' +import { WalletID } from 'types/enums/wallet' type Props = { children?: React.ReactNode @@ -37,23 +37,6 @@ function mapChainConfigToChainInfo(chainConfig: ChainConfig): ChainInfo { features: ['ibc-transfer', 'ibc-go'], } - switch (chainConfig.id) { - case ChainInfoID.Osmosis1: - chainInfo.rpc = process.env.NEXT_PUBLIC_OSMOSIS_RPC ?? chainInfo.rpc - chainInfo.rest = process.env.NEXT_PUBLIC_OSMOSIS_REST ?? chainInfo.rpc - break - - case ChainInfoID.OsmosisDevnet: - chainInfo.rpc = process.env.NEXT_PUBLIC_OSMOSIS_TEST_RPC ?? chainInfo.rpc - chainInfo.rest = process.env.NEXT_PUBLIC_OSMOSIS_TEST_REST ?? chainInfo.rpc - break - - case ChainInfoID.Pion1: - chainInfo.rpc = process.env.NEXT_PUBLIC_NEUTRON_TEST_RPC ?? chainInfo.rpc - chainInfo.rest = process.env.NEXT_PUBLIC_NEUTRON_TEST_REST ?? chainInfo.rpc - break - } - return chainInfo } diff --git a/src/configs/chains/neutron/pion-1.ts b/src/configs/chains/neutron/pion-1.ts index 8e425b96..99e9e506 100644 --- a/src/configs/chains/neutron/pion-1.ts +++ b/src/configs/chains/neutron/pion-1.ts @@ -33,8 +33,8 @@ const Pion1: ChainConfig = { }, endpoints: { routes: 'https://app.astroport.fi/api/routes', - rest: 'https://rest-palvus.pion-1.ntrn.tech/', - rpc: 'https://rpc-palvus.pion-1.ntrn.tech/', + rpc: process.env.NEXT_PUBLIC_NEUTRON_TEST_RPC ?? 'https://rpc-palvus.pion-1.ntrn.tech/', + rest: process.env.NEXT_PUBLIC_NEUTRON_TEST_REST ?? 'https://rest-palvus.pion-1.ntrn.tech/', swap: 'https://testnet-neutron.astroport.fi/swap', pools: '', //TODO: ⛓️ Implement this explorer: 'https://testnet.mintscan.io/neutron-testnet', diff --git a/src/configs/chains/osmosis/devnet.ts b/src/configs/chains/osmosis/devnet.ts index bdf24af0..281058ac 100644 --- a/src/configs/chains/osmosis/devnet.ts +++ b/src/configs/chains/osmosis/devnet.ts @@ -9,8 +9,8 @@ const Devnet: ChainConfig = { name: 'Osmosis Devnet', endpoints: { ...Osmosis1.endpoints, - rpc: 'https://rpc.devnet.osmosis.zone/', - rest: 'https://lcd.devnet.osmosis.zone/', + rpc: process.env.NEXT_PUBLIC_OSMOSIS_TEST_RPC ?? 'https://rpc-osmosis.blockapsis.com/', + rest: process.env.NEXT_PUBLIC_OSMOSIS_TEST_REST ?? 'https://lcd-osmosis.blockapsis.com/', swap: 'https://testnet.osmosis.zone', }, } diff --git a/src/configs/chains/osmosis/osmosis-1.ts b/src/configs/chains/osmosis/osmosis-1.ts index 73324653..18bfe1ed 100644 --- a/src/configs/chains/osmosis/osmosis-1.ts +++ b/src/configs/chains/osmosis/osmosis-1.ts @@ -137,8 +137,8 @@ const Osmosis1: ChainConfig = { }, }, endpoints: { - rpc: 'https://osmosis-rpc.cosmos-apis.com?x-apikey=' + process.env.NEXT_PUBLIC_API_KEY, - rest: 'https://osmosis-rest.cosmos-apis.com/', + rpc: process.env.NEXT_PUBLIC_OSMOSIS_RPC ?? 'https://rpc-osmosis.blockapsis.com/', + rest: process.env.NEXT_PUBLIC_OSMOSIS_REST ?? 'https://lcd-osmosis.blockapsis.com/', swap: 'https://app.osmosis.zone', explorer: 'https://www.mintscan.io/osmosis/transactions/', routes: 'https://sqs.osmosis.zone/router', diff --git a/src/hooks/useWalletBalances.tsx b/src/hooks/useWalletBalances.tsx index a7cb42ec..a2377bc0 100644 --- a/src/hooks/useWalletBalances.tsx +++ b/src/hooks/useWalletBalances.tsx @@ -19,7 +19,9 @@ async function getWalletBalances(chainConfig: ChainConfig, address: string): Pro const uri = '/cosmos/bank/v1beta1/balances/' const response = await fetch( - `${chainConfig.endpoints.rest}${uri}${address}?x-apikey=${process.env.NEXT_PUBLIC_API_KEY}`, + process.env.NEXT_PUBLIC_API_KEY + ? `${chainConfig.endpoints.rest}${uri}${address}?x-apikey=${process.env.NEXT_PUBLIC_API_KEY}` + : `${chainConfig.endpoints.rest}${uri}${address}`, ) if (response.ok) { diff --git a/validate-env.js b/validate-env.js index 67b9136a..49ab4795 100644 --- a/validate-env.js +++ b/validate-env.js @@ -1,16 +1,10 @@ require('dotenv').config({ path: './.env.local' }) -if (!process.env.CHARTING_LIBRARY_USERNAME) { - throw 'CHARTING_LIBRARY_USERNAME is not defined' -} -if (!process.env.CHARTING_LIBRARY_ACCESS_TOKEN) { - throw 'CHARTING_LIBRARY_ACCESS_TOKEN is not defined' -} -if (!process.env.CHARTING_LIBRARY_REPOSITORY) { - throw 'CHARTING_LIBRARY_REPOSITORY is not defined' +if (!process.env.NEXT_PUBLIC_NETWORK) { + throw 'NEXT_PUBLIC_NETWORK is not defined. Set ot to "mainnet" or "testnet".' } if (!process.env.NEXT_PUBLIC_WALLET_CONNECT_ID) { - throw 'NEXT_PUBLIC_WALLET_CONNECT_ID is not defined' + throw 'NEXT_PUBLIC_WALLET_CONNECT_ID is not defined. Get a WalletConnect project ID from https://walletconnect.com/.' } console.log('✅ Required env variables set')