diff --git a/.env.example b/.env.example index 9c6a39da35..7eaeacc6b2 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,6 @@ VITE_ALCHEMY_API_KEY= VITE_WALLET_CONNECT_PROJECT_ID= VITE_OISY_URL=https://oisy.com VITE_COINGECKO_API_KEY= -VITE_BLOCKCHAIN_API_URL=https://blockchain.info VITE_BLOCKSTREAM_API_URL=https://blockstream.info/api VITE_EXCHANGE_DISABLED=true VITE_JUNO_SATELLITE_ID= diff --git a/.env.test b/.env.test index 100cc7850d..4c63006977 100644 --- a/.env.test +++ b/.env.test @@ -5,7 +5,6 @@ VITE_INFURA_API_KEY= VITE_ALCHEMY_API_KEY= VITE_WALLET_CONNECT_PROJECT_ID= VITE_OISY_URL=https://oisy.com -VITE_BLOCKCHAIN_API_URL=https://blockchain.info VITE_BLOCKSTREAM_API_URL=https://blockstream.info/api VITE_JUNO_SATELLITE_ID= VITE_JUNO_ORBITER_ID= diff --git a/.github/workflows/deploy-to-environment.yml b/.github/workflows/deploy-to-environment.yml index b3fada1875..b400ec2bd7 100644 --- a/.github/workflows/deploy-to-environment.yml +++ b/.github/workflows/deploy-to-environment.yml @@ -79,7 +79,6 @@ jobs: echo "VITE_AUTH_ALTERNATIVE_ORIGINS=${{ secrets.VITE_AUTH_ALTERNATIVE_ORIGINS_STAGING }}" >> $GITHUB_ENV echo "VITE_AUTH_DERIVATION_ORIGIN=${{ secrets.VITE_AUTH_DERIVATION_ORIGIN_STAGING }}" >> $GITHUB_ENV echo "VITE_BTC_TO_CKBTC_EXCHANGE_ENABLED=${{ secrets.VITE_BTC_TO_CKBTC_EXCHANGE_ENABLED_STAGING }}" >> $GITHUB_ENV - echo "VITE_BLOCKCHAIN_API_URL=https://blockchain.info" >> $GITHUB_ENV echo "VITE_BLOCKSTREAM_API_URL=https://blockstream.info/api" >> $GITHUB_ENV echo "VITE_ONRAMPER_API_KEY_DEV=${{ secrets.VITE_ONRAMPER_API_KEY_DEV_STAGING }}" >> $GITHUB_ENV echo "VITE_ONRAMPER_API_KEY_PROD=${{ secrets.VITE_ONRAMPER_API_KEY_PROD_STAGING }}" >> $GITHUB_ENV @@ -103,7 +102,6 @@ jobs: echo "VITE_AUTH_ALTERNATIVE_ORIGINS=${{ secrets.VITE_AUTH_ALTERNATIVE_ORIGINS_BETA }}" >> $GITHUB_ENV echo "VITE_AUTH_DERIVATION_ORIGIN=${{ secrets.VITE_AUTH_DERIVATION_ORIGIN_BETA }}" >> $GITHUB_ENV echo "VITE_BTC_TO_CKBTC_EXCHANGE_ENABLED=${{ secrets.VITE_BTC_TO_CKBTC_EXCHANGE_ENABLED_BETA }}" >> $GITHUB_ENV - echo "VITE_BLOCKCHAIN_API_URL=https://blockchain.info" >> $GITHUB_ENV echo "VITE_BLOCKSTREAM_API_URL=https://blockstream.info/api" >> $GITHUB_ENV echo "VITE_ONRAMPER_API_KEY_DEV=${{ secrets.VITE_ONRAMPER_API_KEY_DEV_BETA }}" >> $GITHUB_ENV echo "VITE_ONRAMPER_API_KEY_PROD=${{ secrets.VITE_ONRAMPER_API_KEY_PROD_BETA }}" >> $GITHUB_ENV diff --git a/src/frontend/src/env/rest/blockchain.env.ts b/src/frontend/src/env/rest/blockchain.env.ts new file mode 100644 index 0000000000..afa82f63a7 --- /dev/null +++ b/src/frontend/src/env/rest/blockchain.env.ts @@ -0,0 +1,7 @@ +import { UrlSchema } from '$lib/validation/url.validation'; +import { safeParse } from '$lib/validation/utils.validation'; + +export const BLOCKCHAIN_API_URL = safeParse({ + schema: UrlSchema, + value: 'https://blockchain.info' +}); diff --git a/src/frontend/src/lib/rest/blockchain.rest.ts b/src/frontend/src/lib/rest/blockchain.rest.ts index a1b39ed705..ec16cde735 100644 --- a/src/frontend/src/lib/rest/blockchain.rest.ts +++ b/src/frontend/src/lib/rest/blockchain.rest.ts @@ -1,7 +1,6 @@ +import { BLOCKCHAIN_API_URL } from '$env/rest/blockchain.env'; import type { BitcoinAddressData, BlockchainBtcAddressDataParams } from '$lib/types/blockchain'; -const API_URL = import.meta.env.VITE_BLOCKCHAIN_API_URL; - /** * Get BTC address data (including transactions). * @@ -17,7 +16,7 @@ export const btcAddressData = ({ }); const fetchBlockchainApi = async ({ endpointPath }: { endpointPath: string }): Promise => { - const response = await fetch(`${API_URL}/${endpointPath}`); + const response = await fetch(`${BLOCKCHAIN_API_URL}/${endpointPath}`); if (!response.ok) { throw new Error('Blockchain API response not ok.');