diff --git a/.env.example b/.env.example index fff208c3..87e12c50 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,6 @@ REACT_APP_CHAIN_ENDPOINT=wss://peregrine.kilt.io REACT_APP_UNIRESOLVER_ENDPOINT=https://dev-uniresolver.kilt.io +REACT_APP_CHECKOUT_URL=https://dev-checkout.kilt.io +REACT_APP_TXD_URL=https://txd-dev.trusted-entity.io REACT_APP_MAINTENANCE=false REACT_APP_IS_TEST_ENV=false diff --git a/src/Utils/useTXDTransmitter.ts b/src/Utils/useTXDTransmitter.ts index 99f567e1..e5a3925a 100644 --- a/src/Utils/useTXDTransmitter.ts +++ b/src/Utils/useTXDTransmitter.ts @@ -3,24 +3,15 @@ import ky from 'ky'; import { type KiltAddress } from '@kiltprotocol/sdk-js'; -import { endpoint } from './claimWeb3name-helpers'; - -const txdUrls: Record = { - 'wss://kilt-rpc.dwellir.com': 'https://txd.trusted-entity.io', - 'wss://spiritnet.kilt.io': 'https://txd.trusted-entity.io', - 'wss://spiritnet.api.onfinality.io/public-ws': - 'https://txd.trusted-entity.io', - 'wss://peregrine.kilt.io': 'https://dev.txd.trusted-entity.io', - 'wss://peregrine-stg.kilt.io/para': 'https://smoke.txd.trusted-entity.io', -}; +export const checkoutServiceURL = process.env.REACT_APP_CHECKOUT_URL as string; +if (!checkoutServiceURL) { + throw new Error('No URL for the Checkout Service provided.'); +} -const checkoutUrls: Record = { - 'wss://kilt-rpc.dwellir.com': 'https://checkout.kilt.io', - 'wss://spiritnet.kilt.io': 'https://checkout.kilt.io', - 'wss://spiritnet.api.onfinality.io/public-ws': 'https://checkout.kilt.io', - 'wss://peregrine.kilt.io': 'https://dev.checkout.kilt.io', - 'wss://peregrine-stg.kilt.io/para': 'https://smoke.checkout.kilt.io', -}; +const txdUrl = process.env.REACT_APP_TXD_URL as string; +if (!txdUrl) { + throw new Error('No URL for the Transaction Daemon provided.'); +} function useApi(key: Key) { return useSWR( @@ -29,15 +20,12 @@ function useApi(key: Key) { ); } -export const checkoutServiceURL = checkoutUrls[endpoint]; - -export function useApiTXDAddress() { - const txdUrl = txdUrls[endpoint]; - return useApi<{ paymentAddress: KiltAddress }>(`${txdUrl}/meta`); -} - export function useApiTXDCosts() { return useApi<{ did: string; w3n: string }>( `${checkoutServiceURL}/api/costs`, ); } + +export function useApiTXDAddress() { + return useApi<{ paymentAddress: KiltAddress }>(`${txdUrl}/meta`); +}