]> zoso.dev Git - nemo-wallet.git/commitdiff
Get rid of IndexedDB since libnemo will just use sessionStorage.
authorChris Duncan <chris@zoso.dev>
Sun, 13 Oct 2024 09:20:13 +0000 (02:20 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 13 Oct 2024 09:20:13 +0000 (02:20 -0700)
app/pages/nemo-wallet.html

index 4130fc18ca65c4d12d26321abc40ab872b95045a..a3ad90662c1a689f7d07cf6bb4b77f4d09e5d1bc 100644 (file)
@@ -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>
   <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>