blob: 9114364b6c5d2f8f5cfea9862a5d3a73e22cc01d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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.')
}
}
get() {
return new Promise((resolve) => {
extension.storage.local.get(STORAGE_KEY, resolve)
})
}
set(state) {
return new Promise((resolve) => {
extension.storage.local.set(state, resolve)
})
}
}
|