From 3e86054b32e88d3a16aabce0edaad920b88ab123 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 29 Oct 2024 22:19:52 -0700 Subject: [PATCH] Fix form cancellation function call. Start building history loader, although iframe probably won't work but at least we got a single account loader out of it. Fix account creation and add address to session storage. --- app/pages/nemo-wallet.html | 256 +++++++++++++++++++------------------ 1 file changed, 135 insertions(+), 121 deletions(-) diff --git a/app/pages/nemo-wallet.html b/app/pages/nemo-wallet.html index 2d3b4a1..63c4e0f 100644 --- a/app/pages/nemo-wallet.html +++ b/app/pages/nemo-wallet.html @@ -267,7 +267,7 @@ option?.remove() notify.error(err.msg) } finally { - await form.close() + await cancelForm('wallet-new') return wallet } } @@ -318,13 +318,24 @@ } } default: { - const historyIframe = document.getElementById('history-iframe') - historyIframe.src = `https://spynano.org/account/${account.address}` - return + await loadHistory() } } } + async function loadHistory () { + const historyIframe = document.getElementById('history-iframe') + const account = await loadAccount() + if (account != null) { + historyIframe.classList.remove('hide') + historyIframe.src = `https://spynano.org/account/${account.address}` + } else { + historyIframe.src = '' + historyIframe.classList.add('hide') + } + return + } + async function reloadWalletSelect () { const wallets = await loadWallets() const walletOptions = wallets.map(w => { @@ -375,6 +386,13 @@ return [] } + async function loadAccount () { + const accountSelect = document.getElementById('account') + const accounts = await loadAccounts() + const account = accounts?.find(a => a.index === +accountSelect.value) + return account + } + async function createAccount () { let account, option, wallet const accountSelect = document.getElementById('account') @@ -395,15 +413,17 @@ const password = document.getElementById('account-new-password-input')?.value try { await wallet.unlock(password) - const account = await wallet.accounts(+index) + const accounts = await wallet.accounts(+index) await wallet.lock(password) + const account = accounts[0] const accountData = { + name: `${index}${name ? ': ' : ''}${name}`, walletId: wallet.id, - index: account.index, - name: `${index}${name ? ': ' : ''}${name}` + index: await account.index, + address: await account.address } await addToStorage(`accounts`, JSON.stringify(accountData)) - option = new Option(accountData.name, accountData.id, false, true) + option = new Option(accountData.name, accountData.index, false, true) accountSelect.add(option) await selectAccount() } catch (err) { @@ -412,7 +432,7 @@ console.error(err) notify.error(`Error creating account`) } finally { - await form.close() + await cancelForm('account-new') return account } } @@ -724,128 +744,122 @@
-
-

New Wallet

-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
+

New Wallet

+
+
+ + +
+
+ + +
+
+ +
- +
+ + +
+
+
+
+ + +
+
-
-

Import Wallet

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
+

Import Wallet

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
- +
-
-

New Account

-
-
- - -
-
- - -
-
- - -
-
-
- - -
+

New Account

+
+
+ + +
+
+ + +
+
+ +
- +
+
+ + +
+
@@ -858,7 +872,7 @@

History

- +
-
+

Settings

@@ -895,7 +909,7 @@ - +

Licenses

-- 2.34.1