1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 14:15:06 +01:00
metamask-extension/app/scripts/lib/local-store.js
2018-01-24 15:03:16 -08:00

25 lines
635 B
JavaScript

// 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')
module.exports = class ExtensionStore {
constructor() {
this.isSupported = !!(extension.storage.local)
if (!this.isSupported) {
log.error('Storage local API not available.')
}
}
get() {
return new Promise((resolve) => {
extension.storage.local.get(null, resolve)
})
}
set(state) {
return new Promise((resolve) => {
extension.storage.local.set(state, resolve)
})
}
}