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
-15
View File
@@ -4,7 +4,6 @@ import { createRuntime } from "./runtime.js";
/**
* @typedef {import("./storage.js").StoredWallet} StoredWallet
* @typedef {import("./storage.js").AddWalletInput} AddWalletInput
* @typedef {import("../derive/address.js").AddressScript} AddressScript
* @typedef {ReturnType<typeof createRuntime>} WalletRuntime
*/
@@ -116,19 +115,6 @@ export function createVault() {
runtimes.set(added.wallet.id, createRuntime(added.wallet.source));
}
/**
* @param {StoredWallet} wallet
* @param {AddressScript} script
*/
async function updateWalletScript(wallet, script) {
wallets = await vaultStorage.updateWalletScript(wallets, {
walletId: wallet.id,
script,
}, password);
runtimes.set(wallet.id, createRuntime(wallet.source));
syncSelected();
}
return {
get wallets() {
return wallets;
@@ -153,6 +139,5 @@ export function createVault() {
setup,
unlock,
addWallet,
updateWalletScript,
};
}
-3
View File
@@ -4,11 +4,9 @@ import { scanWalletAddresses } from "../scan/index.js";
* @typedef {import("../scan/index.js").WalletScan} WalletScan
* @typedef {import("../scan/index.js").WalletScanClient} WalletScanClient
* @typedef {import("../scan/index.js").WalletScanProgress} WalletScanProgress
* @typedef {import("../derive/address.js").AddressScript} AddressScript
*
* @typedef {Object} LoadOptions
* @property {WalletScanClient} client
* @property {AddressScript} script
* @property {(progress: WalletScanProgress) => void} [onProgress]
*/
@@ -31,7 +29,6 @@ export function createRuntime(source) {
pending = scanWalletAddresses({
client: options.client,
source,
script: options.script,
onProgress: options.onProgress,
}).then((nextScan) => {
scan = nextScan;
-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,
});