fix going back to public node

This commit is contained in:
PhilReact 2025-04-01 02:54:52 +03:00
parent 69f33733df
commit 12dc1a91fd
2 changed files with 7 additions and 5 deletions

View File

@ -290,7 +290,7 @@ export const getBaseApiReact = (customApi?: string) => {
return customApi;
}
if (globalApiKey) {
if (globalApiKey?.url) {
return globalApiKey?.url;
} else {
return groupApi;
@ -316,7 +316,7 @@ export const getBaseApiReactSocket = (customApi?: string) => {
return customApi;
}
if (globalApiKey) {
if (globalApiKey?.url) {
return `${
getProtocol(globalApiKey?.url) === "http" ? "ws://" : "wss://"
}${cleanUrl(globalApiKey?.url)}`;

View File

@ -291,7 +291,8 @@ export const getBaseApi = async (customApi?: string) => {
}
const apiKey = await getApiKeyFromStorage(); // Retrieve apiKey asynchronously
if (apiKey) {
if (apiKey?.url) {
return apiKey?.url;
} else {
return groupApi;
@ -299,7 +300,7 @@ export const getBaseApi = async (customApi?: string) => {
};
export const isUsingLocal = async () => {
const apiKey = await getApiKeyFromStorage(); // Retrieve apiKey asynchronously
if (apiKey) {
if (apiKey?.url) {
return true;
} else {
return false;
@ -313,7 +314,7 @@ export const createEndpoint = async (endpoint, customApi?: string) => {
const apiKey = await getApiKeyFromStorage(); // Retrieve apiKey asynchronously
if (apiKey) {
if (apiKey?.url) {
// Check if the endpoint already contains a query string
const separator = endpoint.includes("?") ? "&" : "?";
return `${apiKey?.url}${endpoint}${separator}apiKey=${apiKey?.apikey}`;
@ -944,6 +945,7 @@ export async function getBalanceInfo() {
const wallet = await getSaveWallet();
const address = wallet.address0;
const validApi = await getBaseApi();
const response = await fetch(validApi + "/addresses/balance/" + address);
if (!response?.ok) throw new Error("0 QORT in your balance");