Skip to content

Commit

Permalink
fix(app): handle undefined selectedUserMigrationInfo (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeifuChen authored Oct 9, 2023
1 parent 4345e46 commit c73ab06
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/app/src/state/stakingMigration/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchRegisteredVestingEntryIDs.fulfilled, (state, { payload }) => {
state.fetchRegisteredVestingEntryIDsStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].registeredVestingEntryIDs =
payload.registeredVestingEntryIDs
})
Expand All @@ -69,6 +72,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchUnregisteredVestingEntryIDs.fulfilled, (state, { payload }) => {
state.fetchUnregisteredVestingEntryIDsStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].unregisteredVestingEntryIDs =
payload.unregisteredVestingEntryIDs
})
Expand All @@ -83,6 +89,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchUnvestedRegisteredEntryIDs.fulfilled, (state, { payload }) => {
state.fetchUnvestedRegisteredEntryIDsStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].unvestedRegisteredEntryIDs =
payload.unvestedRegisteredEntryIDs
})
Expand All @@ -97,6 +106,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchUnmigratedRegisteredEntryIDs.fulfilled, (state, { payload }) => {
state.fetchUnmigratedRegisteredEntryIDsStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].unmigratedRegisteredEntryIDs =
payload.unmigratedRegisteredEntryIDs
})
Expand All @@ -111,6 +123,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchToPay.fulfilled, (state, { payload }) => {
state.fetchToPayStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].toPay = payload.toPay
})
builder.addCase(fetchToPay.rejected, (state) => {
Expand All @@ -124,6 +139,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchEscrowMigratorAllowance.fulfilled, (state, { payload }) => {
state.fetchEscrowMigratorAllowanceStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].escrowMigratorAllowance =
payload.escrowMigratorAllowance
})
Expand All @@ -138,6 +156,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchMigrationDeadline.fulfilled, (state, { payload }) => {
state.fetchMigrationDeadlineStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].migrationPeriod = payload.migrationPeriod
})
builder.addCase(fetchMigrationDeadline.rejected, (state) => {
Expand All @@ -151,6 +172,9 @@ export const stakingMigrationSlice = createSlice({
})
builder.addCase(fetchTotalEscrowUnmigrated.fulfilled, (state, { payload }) => {
state.fetchTotalEscrowUnmigratedStatus = SUCCESS_STATUS
if (!state.selectedUserMigrationInfo[payload.wallet]) {
state.selectedUserMigrationInfo[payload.wallet] = DEFAULT_MIGRATION_INFO
}
state.selectedUserMigrationInfo[payload.wallet].totalEscrowUnmigrated =
payload.totalEscrowUnmigrated
})
Expand Down

0 comments on commit c73ab06

Please sign in to comment.