Skip to content

Commit 920a067

Browse files
committed
Fix error: stakingEvents parsing when not array
Sometimes the stakingEvents is null and we’re still trying to access it as an array. Now we’re just initializing it as an empty array if no stakingEvents have been received.
1 parent 1a46a8d commit 920a067

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)