Skip to content

Commit f119492

Browse files
Update ContractStore.walletConnected in AccountListener when the user disconnects the wallet (#1119)
* check if response is null before checking response.ok * Update ContractStore in AccountListener when the user disconnects the wallet
1 parent c4958f4 commit f119492

File tree

9 files changed

+17
-7
lines changed

9 files changed

+17
-7
lines changed

contracts/test/vault/rebase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("Vault rebase pausing", async () => {
5151
);
5252
});
5353

54-
it("Should allow governor tonpause rebasing", async () => {
54+
it("Should allow governor to pause rebasing", async () => {
5555
let { vault, governor } = await loadFixture(defaultFixture);
5656
await vault.connect(governor).pauseRebase();
5757
});

dapp/src/components/AccountListener.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ const AccountListener = (props) => {
9090
s.allowances = {}
9191
s.balances = {}
9292
})
93+
ContractStore.update((s) => {
94+
s.walletConnected = false
95+
})
9396
PoolStore.update((s) => {
9497
s.claimable_ogn = null
9598
s.lp_tokens = null

dapp/src/components/buySell/BalanceHeader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ const BalanceHeader = ({
243243
<Statistic
244244
title={fbt('Balance', 'OUSD Balance')}
245245
value={
246-
!isNaN(parseFloat(displayedBalance)) && ousdBalanceLoaded
246+
walletConnected &&
247+
!isNaN(parseFloat(displayedBalance)) &&
248+
ousdBalanceLoaded
247249
? displayedBalance
248250
: '--.--'
249251
}

dapp/src/components/wrap/BalanceHeaderWrapped.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ const BalanceHeaderWrapped = ({
257257
<Statistic
258258
title={fbt('wOUSD Balance', 'wOUSD Balance')}
259259
value={
260-
!isNaN(parseFloat(displayedWousdBalance)) && wousdBalanceLoaded
260+
walletConnected &&
261+
!isNaN(parseFloat(displayedWousdBalance)) &&
262+
wousdBalanceLoaded
261263
? displayedWousdBalance
262264
: '--.--'
263265
}

dapp/src/services/apy.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class ApyService {
1212
throw new Error(`Unexpected days param: ${days}`)
1313
}
1414
const response = await fetch(endpoint)
15-
if (!response.ok) {
15+
if (!response || !response.ok) {
1616
throw new Error(`Failed to fetch ${days} day APY`, err)
1717
}
1818
const json = await response.json()

dapp/src/services/balances.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class BalancesService {
4444
body: JSON.stringify(data),
4545
})
4646

47-
if (!response.ok) {
47+
if (!response || !response.ok) {
4848
throw new Error(
4949
`Could not fetch balances from Alchemy http status: ${response.status}`
5050
)

dapp/src/services/transaction-history-page.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class TransactionHistoryPageService {
1919
}/${account.toLowerCase()}/history?per_page=${transactionHistoryItemsPerPage}&page=${page}${filter_param}`
2020
)
2121

22-
if (!response.ok) {
22+
if (!response || !response.ok) {
2323
throw new Error('Failed fetching history from analytics')
2424
}
2525

dapp/src/services/transaction-history.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class TransactionHistoryService {
1313
this.baseURL
1414
}/${account.toLowerCase()}/history?per_page=1000000${filter_param}`
1515
)
16-
if (!response.ok) {
16+
if (!response || !response.ok) {
1717
throw new Error('Failed fetching history from analytics')
1818
}
1919

dapp/src/utils/contracts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ export async function setupContracts(account, library, chainId, fetchId) {
389389

390390
const fetchCreditsPerToken = async () => {
391391
try {
392+
if (!walletConnected) {
393+
return
394+
}
392395
const response = await fetch(process.env.CREDITS_ANALYTICS_ENDPOINT)
393396
if (response.ok) {
394397
const json = await response.json()

0 commit comments

Comments
 (0)