<meta lang="en" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="module" src="https://cdn.jsdelivr.net/npm/barcode-detector@2.2.11/dist/es/side-effects.min.js"></script>
+ <script type="module">
+ import { Buffer } from 'https://esm.run/buffer-browser@6.0.4/index.js'
+ globalThis.Buffer = Buffer
+ </script>
<script type="module" src="https://cdn.jsdelivr.net/npm/libnemo@0.0.17/dist/global.min.js"></script>
<script>
// const barcodeDetector = new BarcodeDetector({
} catch (err) {
location.hash = '#transact'
}
- await loadDependencies()
await loadData()
await loadUi()
console.log('done')
})
- async function loadDependencies () {
- console.log('loading dependencies')
- globalThis.Buffer ??= (await import('https://cdn.jsdelivr.net/npm/buffer-esm@1.2.0/esm/index.js')).Buffer
- console.log('loaded dependencies')
- }
-
async function loadData () {
console.log('loading data')
const walletSelect = document.querySelector('#wallet')
const themeCheckbox = document.getElementById('theme-checkbox')
themeCheckbox.addEventListener('change', selectTheme)
selectTheme()
- const forms = document.querySelectorAll('form')
+ const forms = document.querySelectorAll('.form')
for (const form of forms) {
const cancelButtons = form.querySelectorAll('button.cancel')
for (const cancelButton of cancelButtons) {
cancelButton.addEventListener('click', (event) => {
- cancelForm(form.parentElement.id)
+ cancelForm(form.id)
})
}
}
function getWalletClass (algorithm) {
switch (algorithm) {
+ case 'ledger': {
+ return libnemo.LedgerWallet
+ }
case 'blake2b': {
return libnemo.Blake2bWallet
}
}
case '_ledger': {
try {
- await libnemo.LedgerWallet.create()
+ const walletId = await libnemo.LedgerWallet.create()
+ const walletData = {
+ id: wallet.id,
+ name: 'Ledger',
+ algorithm: 'ledger'
+ }
+ await addToStorage(`wallets`, JSON.stringify(walletData))
+ updateAccountForm('account-new')
+ await reloadAccountSelect()
} catch (err) {
walletSelect.value = ''
console.error(err)
async function loadWallet () {
const walletSelect = document.getElementById('wallet')
- if (walletSelect?.value) {
+ if (walletSelect?.value?.substring(0, 1) !== '_') {
const wallets = await loadWallets()
const { id, algorithm } = wallets.find(w => w.id === walletSelect.value)
const walletClass = getWalletClass(algorithm)
await resetSelectOptions('account', accountOptions)
}
+ function updateAccountForm (id) {
+ const form = document.getElementById(id)
+ if (!form) {
+ notify.error(`Form ID not found, contact developer`)
+ return
+ }
+ const walletSelect = document.getElementById('wallet')
+ const passwordContainer = document.getElementById(`${id}-password`)
+ const password = document.getElementById(`${id}-password-input`)
+ if (walletSelect?.value === '_ledger') {
+ password.value = ''
+ passwordContainer.classList.add('hide')
+ } else {
+ passwordContainer.classList.remove('hide')
+ }
+ }
+
async function resetSelectOptions (id, options) {
try {
if (!Array.isArray(options)) {
text-align: center;
}
hr {
- margin: revert !important;
+ border: 10px solid var(--theme-content) !important;
+ height: 10px !important;
}
label {
margin-right: 0.5em;
position: fixed;
top: 0.5rem;
width: 100%;
+ z-index: 100;
}
#notifications > dialog[open] {
background-color: var(--theme-highlight);
position: relative;
padding: 0.5rem;
width: fit-content;
- z-index: 100;
}
.page {
display: none;
select:focus {
background-color: var(--theme-primary);
border: 1px solid var(--theme-content);
- color: var(--theme-text);
+ color: var(--theme-content);
font-size: calc(16px + 0.1dvh); /* prevents input focus zoom on mobile */
}
input:disabled,
<option value="_new">New</option>
<option value="_import">Import</option>
<hr />
- <option disabled value="_ledger">Ledger</option>
+ <option value="_ledger">Ledger</option>
<hr />
</select>
</div>
<!-- New Wallet Form -->
- <div id="wallet-new" class="page">
+ <div id="wallet-new" class="form page">
<h1>New Wallet</h1>
<div class="flex-y stretch">
<div id="wallet-new-name" class="flex-x left mid">
<!-- Import Wallet Form -->
- <div id="wallet-import" class="page">
+ <div id="wallet-import" class="form page">
<h1>Import Wallet</h1>
<div class="flex-y stretch">
<div id="wallet-import-name" class="flex-x left mid">
<!-- New Account Form -->
- <div id="account-new" class="page">
+ <div id="account-new" class="form page">
<h1>New Account</h1>
<div class="flex-y stretch">
<div id="account-new-name" class="flex-x left mid">