Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
fix(client): provide fallback bff url
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 committed Sep 21, 2023
1 parent 3ad12c3 commit 61bf767
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
12 changes: 7 additions & 5 deletions client/src/services/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GetRewardsDto | undefined> {
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;
}
Expand All @@ -20,7 +22,7 @@ export async function getCustomRewards(
unlock: boolean
): Promise<GetCustomRewards | undefined> {
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"
}`
);
Expand All @@ -34,7 +36,7 @@ export async function getDeliveredRewards(
stakingAddress: string
): Promise<GetDeliveredRewardsDto> {
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;
}
Expand All @@ -43,7 +45,7 @@ export async function getTransactionStatus(
txHash: string
): Promise<TransactionStatus[] | undefined> {
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;
Expand All @@ -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;
}
30 changes: 16 additions & 14 deletions client/src/services/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dto.GetVmSettings["response"]> {
const response = await axios.get<Dto.GetVmSettings["response"]>(
`${process.env.REACT_APP_CLAIM_API}/api/getsettings`
`${API_URL}/api/getsettings`
);
return response.data;
}
Expand All @@ -20,25 +22,25 @@ 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;
}
return { block_no: 0 };
}

export async function getEpochParams(): Promise<EpochParams> {
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<CardanoTypes.NetworkId> {
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;
Expand All @@ -49,25 +51,25 @@ export async function getNetworkId(): Promise<CardanoTypes.NetworkId> {
}

export async function getPopUpInfo(): Promise<PopUpInfo> {
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<Tip> {
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<GetQueueDto> {
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;
}

export async function createStakeTx(
params: Dto.CreateDelegationTx["body"]
): Promise<Dto.CreateDelegationTx["response"]> {
const response = await axios.post<Dto.CreateDelegationTx["response"]>(
`${process.env.REACT_APP_CLAIM_API}/api/tx/delegate`,
`${API_URL}/api/tx/delegate`,
params
);
return response.data;
Expand All @@ -77,7 +79,7 @@ export async function createTransferTx(
params: Dto.CreateTransferTx["body"]
): Promise<Dto.CreateTransferTx["response"]> {
const response = await axios.post<Dto.CreateTransferTx["response"]>(
`${process.env.REACT_APP_CLAIM_API}/api/tx/transfer`,
`${API_URL}/api/tx/transfer`,
params
);
return response.data;
Expand All @@ -87,7 +89,7 @@ export async function submitStakeTx(
params: Dto.SubmitTx["body"]
): Promise<Dto.SubmitTx["response"]> {
const response = await axios.post<Dto.SubmitTx["response"]>(
`${process.env.REACT_APP_CLAIM_API}/api/tx/submit`,
`${API_URL}/api/tx/submit`,
params
);
return response.data;
Expand All @@ -99,7 +101,7 @@ export async function getBech32Address({
Dto.GetBech32Address["response"]["addressInBech32"]
> {
const response = await axios.get<Dto.GetBech32Address["response"]>(
`${process.env.REACT_APP_CLAIM_API}/api/util/bech32-address?addressInHex=${addressInHex}`
`${API_URL}/api/util/bech32-address?addressInHex=${addressInHex}`
);
return response.data.addressInBech32;
}
Expand All @@ -108,7 +110,7 @@ export async function getBannerText(): Promise<
Dto.GetBannerText["response"]["text"]
> {
const response = await axios.get<Dto.GetBannerText["response"]>(
`${process.env.REACT_APP_CLAIM_API}/api/admin/banner`
`${API_URL}/api/admin/banner`
);
return response.data.text;
}

0 comments on commit 61bf767

Please sign in to comment.