<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>