website: redesign part 31

This commit is contained in:
nym21
2026-06-18 22:39:28 +02:00
parent 408d83c350
commit 00f7d69ea6
37 changed files with 811 additions and 703 deletions
-33
View File
@@ -4,14 +4,12 @@ const STORAGE_KEY = "bitview.wallets.v3";
/**
* @typedef {import("./encryption.js").EncryptedSecret} EncryptedSecret
* @typedef {import("../derive/address.js").AddressScript} AddressScript
*/
/**
* @typedef {Object} StoredWallet
* @property {string} id
* @property {string} name
* @property {AddressScript} script
* @property {string} source
* @property {number} createdAt
* @property {number} updatedAt
@@ -20,16 +18,9 @@ const STORAGE_KEY = "bitview.wallets.v3";
/**
* @typedef {Object} AddWalletInput
* @property {string} name
* @property {AddressScript} script
* @property {string} source
*/
/**
* @typedef {Object} UpdateWalletScriptInput
* @property {string} walletId
* @property {AddressScript} script
*/
/**
* @typedef {Object} WalletVault
* @property {StoredWallet[]} wallets
@@ -120,7 +111,6 @@ async function addWallet(wallets, input, pagePassword) {
const wallet = {
id: createWalletId(),
name: input.name.trim(),
script: input.script,
source: input.source.trim(),
createdAt: time,
updatedAt: time,
@@ -135,33 +125,10 @@ async function addWallet(wallets, input, pagePassword) {
};
}
/**
* @param {StoredWallet[]} wallets
* @param {UpdateWalletScriptInput} input
* @param {string} pagePassword
*/
async function updateWalletScript(wallets, input, pagePassword) {
const time = now();
const nextWallets = wallets.map((wallet) => {
return wallet.id === input.walletId
? {
...wallet,
script: input.script,
updatedAt: time,
}
: wallet;
});
await writeWallets(nextWallets, pagePassword);
return nextWallets;
}
export const vaultStorage = /** @type {const} */ ({
has,
reset,
setup,
load,
addWallet,
updateWalletScript,
});