diff --git a/templates/nostrmarket/market.html b/templates/nostrmarket/market.html
index eb18f39..33af581 100644
--- a/templates/nostrmarket/market.html
+++ b/templates/nostrmarket/market.html
@@ -14,10 +14,44 @@
>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem,
- eius reprehenderit eos corrupti commodi magni quaerat ex numquam,
- dolorum officiis modi facere maiores architecto suscipit iste
- eveniet doloribus ullam aliquid.
+
+
+
+
+
+
+
+
+
+
+ {%raw%}
+
+ {{ `${pub.slice(0, 5)}...${pub.slice(-5)}` }}{{ pub }}
+
+
+
+
+ {%endraw%}
+
+
@@ -29,10 +63,35 @@
>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem,
- eius reprehenderit eos corrupti commodi magni quaerat ex numquam,
- dolorum officiis modi facere maiores architecto suscipit iste
- eveniet doloribus ullam aliquid.
+
+
+
+
+
+ {%raw%}
+
+ {{ url }}
+
+
+
+
+ {%endraw%}
+
+
@@ -190,11 +249,14 @@
return {
drawer: true,
pubkeys: new Set(),
+ relays: new Set(defaultRelays),
stalls: [],
products: [],
events: [],
searchText: null,
- exchangeRates: null
+ exchangeRates: null,
+ inputPubkey: null,
+ inputRelay: null
}
},
computed: {
@@ -220,7 +282,7 @@
async initNostr() {
this.pool = new nostr.SimplePool()
this.relays = new Set(defaultRelays)
- await this.pool
+ let sub = await this.pool
.list(Array.from(this.relays), [
{
kinds: [30005],
@@ -236,11 +298,12 @@
} else {
// it's a stall
this.stalls.push(e.content)
+ return
}
})
- console.log(this.stalls)
- console.log(this.products)
})
+ await Promise.resolve(sub)
+ this.pool.close()
},
async getRates() {
let noFiat = this.stalls.map(s => s.currency).every(c => c == 'sat')
@@ -260,8 +323,41 @@
},
getAmountFormated(amount, unit = 'USD') {
return LNbits.utils.formatCurrency(amount, unit)
+ },
+ addPubkey() {
+ let pubkey = String(this.inputPubkey).trim()
+ let regExp = /^#([0-9a-f]{3}){1,2}$/i
+ if (regExp.test(pubkey)) {
+ return this.pubkeys.add(pubkey)
+ }
+ try {
+ let {type, data} = nostr.nip19.decode(pubkey)
+ if (type === 'npub') pubkey = data
+ else if (type === 'nprofile') {
+ pubkey = data.pubkey
+ givenRelays = data.relays
+ }
+ this.pubkeys.add(pubkey)
+ this.inputPubkey = null
+ } catch (err) {
+ console.error(err)
+ }
+ },
+ addRelay() {
+ let relay = String(this.inputRelay).trim()
+ if (!relay.startsWith('ws')) {
+ console.debug('invalid url')
+ return
+ }
+ this.relays.add(relay)
+ this.inputRelay = null
}
}
})
+
{% endblock %}