diff --git a/src/utils/localStorage/tokens.js b/src/utils/localStorage/tokens.js index 59becc80..f37ddfa5 100644 --- a/src/utils/localStorage/tokens.js +++ b/src/utils/localStorage/tokens.js @@ -51,3 +51,17 @@ export const setToken = (safeAddress: string, token: Token) => { console.log('Error adding token in localstorage') } } + +export const removeTokenFromStorage = (safeAddress: string, token: Token) => { + const data: List = getTokens(safeAddress) + + try { + const index = data.indexOf(token) + const serializedState = JSON.stringify(data.remove(index)) + const key = getTokensKey(safeAddress) + localStorage.setItem(key, serializedState) + } catch (err) { + // eslint-disable-next-line + console.log('Error removing token in localstorage') + } +}