From: Chris Duncan <chris@zoso.dev> Date: Sun, 13 Oct 2024 09:20:13 +0000 (-0700) Subject: Get rid of IndexedDB since libnemo will just use sessionStorage. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d7261ee1ab0f76cec7347f0b1b2dadcf2f720736;p=nemo-wallet.git Get rid of IndexedDB since libnemo will just use sessionStorage. --- diff --git a/app/pages/nemo-wallet.html b/app/pages/nemo-wallet.html index 4130fc1..a3ad906 100644 --- a/app/pages/nemo-wallet.html +++ b/app/pages/nemo-wallet.html @@ -5,28 +5,42 @@ <script> let Bip44Wallet let Xel - async function load () { - console.log('loading') - const libnemo = await import('https://unpkg.com/libnemo@latest') - Bip44Wallet = libnemo.Bip44Wallet - console.log('libnemo loaded') + function load () { + loadUi().then(loadNemo) + } + async function loadUi () { + console.log('loading xel') Xel = await import('https://unpkg.com/xel@latest') - // await Xel.whenThemeReady + await Xel.whenThemeReady setTimeout(() => { document.getElementById('main').style.visibility = 'visible' - console.log('xel loaded') - }, 100) + }, 0) + console.log('loaded xel') + } + async function loadNemo () { + console.log('loading libnemo') + const libnemo = await import('https://unpkg.com/libnemo@latest') + Bip44Wallet = libnemo.Bip44Wallet + console.log('loaded libnemo') } async function wallet () { const wallet = await Bip44Wallet.create('password') await wallet.unlock('password') return wallet } - function showWallet (wallet) { + async function showWallets () { const card = document.getElementById('wallet') - const walletElement = document.createElement('x-label') - walletElement.innerText = wallet.mnemonic - card.appendChild(walletElement) + for (let i = 0; i < sessionStorage.length; i++) { + const name = sessionStorage.key(i) + const item = sessionStorage.getItem(name) + console.log(item) + const walletElement = document.createElement('x-label') + walletElement.innerText = item + card.appendChild(walletElement) + } + } + function clear () { + sessionStorage.clear() } </script> <script src="" type="module"></script> @@ -35,12 +49,15 @@ <meta name="xel-icons" content="https://unpkg.com/xel@latest/icons/fluent-outlined.svg"> </head> -<body onload="load().then(() => {console.log('loaded')})"> +<body onload="load()"> <x-box id="main" style="visibility:hidden;"> - <x-button onclick="wallet().then(w => {console.log(w);showWallet(w)})"> + <x-button onclick="wallet().then(w => {console.log(w);showWallets()})"> <x-label>Create</x-label> </x-button> <x-card id="wallet"> </x-card> + <x-button onclick="clear()"> + <x-label>Clear</x-label> + </x-button> </x-box> </body>