diff --git a/.env.example b/.env.example index fe4c9d0f..33c72925 100644 --- a/.env.example +++ b/.env.example @@ -3,12 +3,12 @@ NEXT_PUBLIC_NETWORK=mainnet NEXT_PUBLIC_WALLET_CONNECT_ID=0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x ### 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_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 ### Enable the following environment variables if you have access to the charting library CHARTING_LIBRARY_USERNAME=git_username diff --git a/README.md b/README.md index 812ad56f..def79ad5 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ We allow the use of environment variables to be passed to the Docker container t | Variable | Description | Default | | ----------------- | ------------------------------------- | ---------------------------------------- | -| URL_OSMOSIS_REST | The Osmosis node REST endpoint to use | https://lcd-osmosis.blockapsis.com/ | -| URL_OSMOSIS_RPC | The Osmosis node RPC endpoint to use | https://rpc-osmosis.blockapsis.com/ | +| URL_OSMOSIS_REST | The Osmosis node REST endpoint to use | https://lcd-osmosis.blockapsis.com | +| URL_OSMOSIS_RPC | The Osmosis node RPC endpoint to use | https://rpc-osmosis.blockapsis.com | | WALLET_CONNECT_ID | Your projects WalletConnect v2 ID | 0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x | **Sample Docker run command** @@ -36,8 +36,8 @@ This command will start the container in interactive mode with port 3000 bound t ```sh docker run -it -p 3000:3000 \ - -e URL_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com/ \ - -e URL_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com/ \ + -e URL_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com \ + -e URL_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com \ -e WALLET_CONNECT_ID=0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x marsprotocol/interface:latest ``` diff --git a/src/configs/chains/neutron/pion-1.ts b/src/configs/chains/neutron/pion-1.ts index a3c125ba..c44541ee 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', - 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/', + 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 281058ac..84ee35d7 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: 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/', + 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 96656936..8277fee5 100644 --- a/src/configs/chains/osmosis/osmosis-1.ts +++ b/src/configs/chains/osmosis/osmosis-1.ts @@ -25,6 +25,7 @@ import WETHaxl from 'configs/assets/WETH.xal' import { VAULTS_META_DATA } from 'constants/vaults' import { NETWORK } from 'types/enums/network' import { ChainInfoID } from 'types/enums/wallet' +import { getUrl } from 'utils/url' const ASSETS = [ { ...OSMO, denom: 'uosmo' }, @@ -137,15 +138,15 @@ const Osmosis1: ChainConfig = { }, }, endpoints: { - rpc: process.env.NEXT_PUBLIC_OSMOSIS_RPC ?? 'https://rpc-osmosis.blockapsis.com/', - rest: process.env.NEXT_PUBLIC_OSMOSIS_REST ?? 'https://lcd-osmosis.blockapsis.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', - pools: - (process.env.NEXT_PUBLIC_OSMOSIS_REST || - 'https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-lcd-front/') + + pools: getUrl( + process.env.NEXT_PUBLIC_OSMOSIS_REST ?? 'https://lcd-osmosis.blockapsis.com', 'osmosis/gamm/v1beta1/pools/POOL_ID', + ), aprs: { vaults: 'https://api.marsprotocol.io/v1/vaults/osmosis', stride: 'https://edge.stride.zone/api/stake-stats', diff --git a/src/hooks/useWalletBalances.tsx b/src/hooks/useWalletBalances.tsx index a2377bc0..2d7f96fd 100644 --- a/src/hooks/useWalletBalances.tsx +++ b/src/hooks/useWalletBalances.tsx @@ -1,6 +1,7 @@ import useSWR from 'swr' import useChainConfig from 'hooks/useChainConfig' +import { getUrl } from 'utils/url' export default function useWalletBalances(address?: string) { const chainConfig = useChainConfig() @@ -16,13 +17,9 @@ export default function useWalletBalances(address?: string) { } async function getWalletBalances(chainConfig: ChainConfig, address: string): Promise { - const uri = '/cosmos/bank/v1beta1/balances/' + const uri = getUrl(chainConfig.endpoints.rest, `cosmos/bank/v1beta1/balances/${address}`) - const response = await fetch( - process.env.NEXT_PUBLIC_API_KEY - ? `${chainConfig.endpoints.rest}${uri}${address}?x-apikey=${process.env.NEXT_PUBLIC_API_KEY}` - : `${chainConfig.endpoints.rest}${uri}${address}`, - ) + const response = await fetch(uri) if (response.ok) { const data = await response.json() diff --git a/src/utils/url.ts b/src/utils/url.ts new file mode 100644 index 00000000..807c2ed0 --- /dev/null +++ b/src/utils/url.ts @@ -0,0 +1,8 @@ +export const getUrl = (baseUrl: string, path: string): string => { + const url = new URL(baseUrl) + + if (process.env.NEXT_PUBLIC_API_KEY) + return `${url.href}${path}?x-apikey=${process.env.NEXT_PUBLIC_API_KEY}` + + return url.href + path +}