-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
3 changed files
with
87 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
async function getServerUrl() { | ||
const result = await this.$browser.storage.sync.get({ | ||
serverUrl: '' | ||
}) | ||
return result.serverUrl | ||
} | ||
|
||
async function setServerUrl(value) { | ||
return this.$browser.storage.sync.set({ | ||
serverUrl: value | ||
}); | ||
} | ||
|
||
async function getUser() { | ||
const result = await this.$browser.storage.sync.get({ | ||
user: '', | ||
}); | ||
return result.user; | ||
} | ||
|
||
async function setUser(value) { | ||
return this.$browser.storage.sync.set({ | ||
user: value | ||
}); | ||
} | ||
|
||
async function getUserId() { | ||
const result = await this.$browser.storage.sync.get({ | ||
userId: '' | ||
}) | ||
return result.userId | ||
} | ||
|
||
async function setUserId(value) { | ||
return this.$browser.storage.sync.set({ | ||
userId: value | ||
}); | ||
} | ||
|
||
async function getWalletId() { | ||
const result = await this.$browser.storage.sync.get({ | ||
walletId: '' | ||
}) | ||
return result.walletId | ||
} | ||
|
||
async function setWalletId(value) { | ||
return this.$browser.storage.sync.set({ | ||
walletId: value | ||
}); | ||
} | ||
|
||
async function getActiveWallet() { | ||
const user = await getUser() | ||
const walletId = await getWalletId() | ||
const activeWallet = user.wallets.find((w) => w.id === walletId) | ||
return activeWallet || user.wallets[0]; | ||
} | ||
|
||
async function isConfigValid() { | ||
const serverUrl = await getServerUrl() | ||
const user = await getUser() | ||
|
||
return serverUrl && user && user.id && user.wallets && user.wallets.length | ||
} | ||
|
||
export default { | ||
getServerUrl, | ||
setServerUrl, | ||
getUser, | ||
setUser, | ||
getUserId, | ||
setUserId, | ||
getWalletId, | ||
setWalletId, | ||
getActiveWallet, | ||
isConfigValid, | ||
} |
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