-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
157aeef
commit c2af918
Showing
4 changed files
with
51 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { LocalStorageKey } from '../constants' | ||
|
||
const WAGMI_PREFIX = 'wagmi' | ||
|
||
// Get a wagmi prefixed and stringified value from storage | ||
export const getStorageItem = (key: LocalStorageKey) => { | ||
try { | ||
const json = localStorage.getItem(`${WAGMI_PREFIX}.${key}`) | ||
|
||
if (!json) { | ||
return undefined | ||
} | ||
|
||
const value = JSON.parse(json) | ||
|
||
return value || undefined | ||
} catch (err) { | ||
return undefined | ||
} | ||
} | ||
|
||
// Set a wagmi prefixed and stringified value to storage | ||
export const setStorageItem = (key: LocalStorageKey, value: any) => { | ||
try { | ||
localStorage.setItem(`${WAGMI_PREFIX}.${key}`, JSON.stringify(value)) | ||
} catch (err) { | ||
// Do nothing | ||
} | ||
} |