1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 02:58:09 +01:00
metamask-extension/app/scripts/lib/local-store.js

25 lines
635 B
JavaScript
Raw Normal View History

// 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.')
}
}
2018-01-24 22:05:13 +01:00
get() {
return new Promise((resolve) => {
2018-01-25 00:03:16 +01:00
extension.storage.local.get(null, resolve)
})
}
2018-01-24 22:05:13 +01:00
set(state) {
return new Promise((resolve) => {
extension.storage.local.set(state, resolve)
})
}
}