diff --git a/client/src/services/claim.ts b/client/src/services/claim.ts index fdff8c5..f16d839 100644 --- a/client/src/services/claim.ts +++ b/client/src/services/claim.ts @@ -3,10 +3,12 @@ import { GetDeliveredRewardsDto } from "src/entities/dto"; import { TransactionStatus } from "src/entities/koios.entities"; import { GetCustomRewards, GetRewardsDto } from "../entities/vm.entities"; +const API_URL = process.env.REACT_APP_CLAIM_API || "http://localhost:3000" + export async function getRewards( address: string ): Promise { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/getrewards?address=${address}`); + const response = await axios.get(`${API_URL}/api/getrewards?address=${address}`); if (response && response.data) { return response.data; } @@ -20,7 +22,7 @@ export async function getCustomRewards( unlock: boolean ): Promise { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/getcustomrewards?staking_address=${staking_address}&session_id=${session_id}&selected=${selected}&unlock=${ + `${API_URL}/api/getcustomrewards?staking_address=${staking_address}&session_id=${session_id}&selected=${selected}&unlock=${ unlock ? "true" : "false" }` ); @@ -34,7 +36,7 @@ export async function getDeliveredRewards( stakingAddress: string ): Promise { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/getdeliveredrewards?staking_address=${stakingAddress}` + `${API_URL}/api/getdeliveredrewards?staking_address=${stakingAddress}` ); return response.data; } @@ -43,7 +45,7 @@ export async function getTransactionStatus( txHash: string ): Promise { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/gettransactionstatus?txHash=${txHash}` + `${API_URL}/api/gettransactionstatus?txHash=${txHash}` ); if (response && response.data) { return response.data; @@ -53,7 +55,7 @@ export async function getTransactionStatus( export async function getTxStatus(request_id: string, session_id: string) { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/txstatus?request_id=${request_id}&session_id=${session_id}` + `${API_URL}/api/txstatus?request_id=${request_id}&session_id=${session_id}` ); return response.data; } diff --git a/client/src/services/common.ts b/client/src/services/common.ts index 6696757..8ae1f1e 100644 --- a/client/src/services/common.ts +++ b/client/src/services/common.ts @@ -4,14 +4,16 @@ import { PopUpInfo } from "src/entities/common.entities"; import { Dto, GetQueueDto } from "src/entities/dto"; import { EpochParams, Tip } from "src/entities/koios.entities"; +const API_URL = process.env.REACT_APP_CLAIM_API || "http://localhost:3000" + export async function getFeatures() { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/features`); + const response = await axios.get(`${API_URL}/features`); return response.data; } export async function getSettings(): Promise { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/getsettings` + `${API_URL}/api/getsettings` ); return response.data; } @@ -20,12 +22,12 @@ export async function getStakeKey(addr: string) { if (addr.slice(0, 5) === "stake") { return { staking_address: addr }; } - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/getstakekey?address=${addr}`); + const response = await axios.get(`${API_URL}/api/getstakekey?address=${addr}`); return response.data; } export async function getBlock(): Promise<{ block_no: number }> { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/getblock`); + const response = await axios.get(`${API_URL}/api/getblock`); if (response && response.data) { return response.data; } @@ -33,12 +35,12 @@ export async function getBlock(): Promise<{ block_no: number }> { } export async function getEpochParams(): Promise { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/getepochparams`); + const response = await axios.get(`${API_URL}/api/getepochparams`); return response.data[0]; } export async function getNetworkId(): Promise { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/features`); + const response = await axios.get(`${API_URL}/features`); if (response && response.data) { if (response.data.network === "preview") { return CardanoTypes.NetworkId.preview; @@ -49,17 +51,17 @@ export async function getNetworkId(): Promise { } export async function getPopUpInfo(): Promise { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/getpopupinfo`); + const response = await axios.get(`${API_URL}/api/getpopupinfo`); return response.data; } export async function getTip(): Promise { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/gettip`); + const response = await axios.get(`${API_URL}/api/gettip`); return response.data; } export async function getQueue(): Promise { - const response = await axios.get(`${process.env.REACT_APP_CLAIM_API}/api/getqueue`); + const response = await axios.get(`${API_URL}/api/getqueue`); return response.data; } @@ -67,7 +69,7 @@ export async function createStakeTx( params: Dto.CreateDelegationTx["body"] ): Promise { const response = await axios.post( - `${process.env.REACT_APP_CLAIM_API}/api/tx/delegate`, + `${API_URL}/api/tx/delegate`, params ); return response.data; @@ -77,7 +79,7 @@ export async function createTransferTx( params: Dto.CreateTransferTx["body"] ): Promise { const response = await axios.post( - `${process.env.REACT_APP_CLAIM_API}/api/tx/transfer`, + `${API_URL}/api/tx/transfer`, params ); return response.data; @@ -87,7 +89,7 @@ export async function submitStakeTx( params: Dto.SubmitTx["body"] ): Promise { const response = await axios.post( - `${process.env.REACT_APP_CLAIM_API}/api/tx/submit`, + `${API_URL}/api/tx/submit`, params ); return response.data; @@ -99,7 +101,7 @@ export async function getBech32Address({ Dto.GetBech32Address["response"]["addressInBech32"] > { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/util/bech32-address?addressInHex=${addressInHex}` + `${API_URL}/api/util/bech32-address?addressInHex=${addressInHex}` ); return response.data.addressInBech32; } @@ -108,7 +110,7 @@ export async function getBannerText(): Promise< Dto.GetBannerText["response"]["text"] > { const response = await axios.get( - `${process.env.REACT_APP_CLAIM_API}/api/admin/banner` + `${API_URL}/api/admin/banner` ); return response.data.text; }