Skip to content

Commit 9caffdc

Browse files
committed
Fix error: stakingEvents parsing when not array
Sometimes the stakingEvents was null and we were still trying to access it as an array. This is fixing this issue, which was causing the staking button to be gone as well as the staking modal to be completely white.
1 parent 1a46a8d commit 9caffdc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/stores/Staking.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ export const useStakingStore = createStore({
202202
const { activeAddress } = useAddressStore();
203203
if (!activeAddress.value) return null;
204204

205-
return state.stakingEventsByAddress[activeAddress.value] || null;
205+
const events = state.stakingEventsByAddress[activeAddress.value] || null;
206+
if (!events || !Array.isArray(events)) return null;
207+
return events;
206208
},
207209
restakingRewards: (state, { stakingEvents, activeValidator }): Readonly<number | null> => {
208210
// Only show rewards for restaking validators
@@ -212,7 +214,7 @@ export const useStakingStore = createStore({
212214
) return null;
213215

214216
const events = stakingEvents.value as StakingEvent[] | null;
215-
if (!events) return null;
217+
if (!events || !Array.isArray(events)) return null;
216218

217219
const addStakeEvents: AddStakeEvent[] = events.filter((event) => {
218220
if (event.type !== 6) return false;

0 commit comments

Comments
 (0)