Skip to content

Commit

Permalink
Merge pull request #2187 from stakwork/fix/get-balance
Browse files Browse the repository at this point in the history
Fix/get balance
  • Loading branch information
Rassl authored Oct 17, 2024
2 parents 75b81df + 445afa5 commit 8b1d62a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/components/AddContentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const handleSubmitForm = async (
Authorization: lsatToken,
})

await updateBudget(setBudget)

if (res.data.project_id) {
setRunningProjectId(res.data.project_id)
}
Expand All @@ -127,7 +129,7 @@ const handleSubmitForm = async (
} catch (err: any) {
if (err.status === 402) {
await payLsat(setBudget)
await updateBudget(setBudget)

await handleSubmitForm(data, sourceType, setBudget, setRunningProjectId)
} else {
let errorMessage = NODE_ADD_ERROR
Expand Down
8 changes: 4 additions & 4 deletions src/components/Auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ export const AuthGuard = ({ children }: PropsWithChildren) => {
setPubKey('')
}

await updateBudget(setBudget)

if (isE2E || isDevelopment) {
setIsAuthenticated(true)
}
}, [setBudget, setPubKey, setIsAuthenticated])
}, [setPubKey, setIsAuthenticated])

const handleIsAdmin = useCallback(async () => {
try {
Expand Down Expand Up @@ -113,11 +111,13 @@ export const AuthGuard = ({ children }: PropsWithChildren) => {
}
}

await updateBudget(setBudget)

await handleIsAdmin()
}

init()
}, [handleAuth, handleIsAdmin])
}, [handleAuth, handleIsAdmin, setBudget])

const message = 'This is a private Graph, Contact Admin'

Expand Down
4 changes: 3 additions & 1 deletion src/network/fetchGraphData/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isDevelopment, isE2E } from '~/constants'
import { api } from '~/network/api'
import { FetchDataResponse } from '~/types'
import { payLsat } from '~/utils'
import { payLsat, updateBudget } from '~/utils'
import { getLSat } from '~/utils/getLSat'

// Main function to fetch graph data
Expand Down Expand Up @@ -30,6 +30,8 @@ const fetchNodes = async (
try {
const response = await api.get<FetchDataResponse>(url, { Authorization: lsatToken }, signal)

updateBudget(setBudget)

return response
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
Expand Down

0 comments on commit 8b1d62a

Please sign in to comment.