diff options
author | Dan Finlay <dan@danfinlay.com> | 2018-01-24 08:26:50 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2018-01-24 08:26:50 +0800 |
commit | 456dfdb9fdc0b7b0637d50808beb85ae33602f5b (patch) | |
tree | 7aa9b4e54e09b151612929571295d39d7c7297a2 /app/scripts/lib | |
parent | 3c6a5b16ad37c83f548028d5b6fa3d0f75293ca5 (diff) | |
download | tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.gz tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.bz2 tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.lz tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.xz tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.tar.zst tangerine-wallet-browser-456dfdb9fdc0b7b0637d50808beb85ae33602f5b.zip |
Modify @heyellieday's work to use storage.local to replace main storage
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/local-store.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/scripts/lib/local-store.js b/app/scripts/lib/local-store.js new file mode 100644 index 000000000..32faac96b --- /dev/null +++ b/app/scripts/lib/local-store.js @@ -0,0 +1,25 @@ +// We should not rely on local storage in an extension! +// We should use this instead! +// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage/local + +const extension = require('extensionizer') +const STORAGE_KEY = 'metamask-config' + +module.exports = class ExtensionStore { + constructor() { + this.isSupported = !!(extension.storage.local) + if (!this.isSupported) { + log.error('Storage local API not available.') + } + } + async get() { + return new Promise((resolve) => { + extension.storage.local.get(STORAGE_KEY, resolve) + }) + } + async set(state) { + return new Promise((resolve) => { + extension.storage.local.set(state, resolve) + }) + } +} |