diff --git a/src/store/__tests__/addressBookSlice.test.ts b/src/store/__tests__/addressBookSlice.test.ts index 435927eafd..d72cc69d2b 100644 --- a/src/store/__tests__/addressBookSlice.test.ts +++ b/src/store/__tests__/addressBookSlice.test.ts @@ -32,6 +32,18 @@ describe('addressBookSlice', () => { }) }) + it('should ignore empty names in the address book', () => { + const state = addressBookSlice.reducer( + initialState, + upsertAddressBookEntry({ + chainId: '1', + address: '0x2', + name: '', + }), + ) + expect(state).toEqual(initialState) + }) + it('should edit an entry in the address book', () => { const state = addressBookSlice.reducer( initialState, diff --git a/src/store/addressBookSlice.ts b/src/store/addressBookSlice.ts index 62bf1f6449..9a24c03637 100644 --- a/src/store/addressBookSlice.ts +++ b/src/store/addressBookSlice.ts @@ -26,6 +26,9 @@ export const addressBookSlice = createSlice({ upsertAddressBookEntry: (state, action: PayloadAction<{ chainId: string; address: string; name: string }>) => { const { chainId, address, name } = action.payload + if (name.trim() === '') { + return + } if (!state[chainId]) state[chainId] = {} state[chainId][address] = name },