Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Feb 27, 2024
1 parent 59d98a1 commit 612cceb
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions trade.renegade.fi/contexts/Renegade/renegade-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,29 @@ function RenegadeProvider({ children }: React.PropsWithChildren) {
attemptedAutoSignin.current = accountId
setAccountId(accountId)
refreshAccount(accountId)

const funded = safeLocalStorageGetItem(`funded_${accountId}`)
if (funded) {
fetch(`/api/fund?address=${address}`, {
method: "GET",
}).then((response) => {
if (response.ok) {
return response.text().then(() => {
toast.success("Your account has been funded with test funds.", {
description: "Try depositing some funds to start trading.",
duration: 10000,
})
safeLocalStorageSetItem(`funded_${accountId}`, "true")
return
if (funded) return

// If the account has not been funded, fund it
fetch(`/api/fund?address=${address}`, {
method: "GET",
}).then((response) => {
if (response.ok) {
return response.text().then(() => {
toast.success("Your account has been funded with test funds.", {
description: "Try depositing some funds to start trading.",
duration: 10000,
})
} else {
toast.error(
"Funding failed: An unexpected error occurred. Please try again."
)
}
})
}
safeLocalStorageSetItem(`funded_${accountId}`, "true")
return
})
} else {
toast.error(
"Funding failed: An unexpected error occurred. Please try again."
)
}
})
})
}

Expand Down

0 comments on commit 612cceb

Please sign in to comment.