remove exchange rates
This commit is contained in:
parent
46a9f9c01e
commit
5c852f11eb
8 changed files with 163 additions and 101 deletions
|
|
@ -4,7 +4,7 @@ async function customerMarket(path) {
|
||||||
name: 'customer-market',
|
name: 'customer-market',
|
||||||
template,
|
template,
|
||||||
|
|
||||||
props: ['products', 'exchange-rates', 'change-page'],
|
props: ['products', 'change-page'],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,12 @@
|
||||||
<q-breadcrumbs-el :label="stall.name" icon="widgets"></q-breadcrumbs-el>
|
<q-breadcrumbs-el :label="stall.name" icon="widgets"></q-breadcrumbs-el>
|
||||||
</q-breadcrumbs>
|
</q-breadcrumbs>
|
||||||
<q-toolbar-title></q-toolbar-title>
|
<q-toolbar-title></q-toolbar-title>
|
||||||
|
<chat-dialog
|
||||||
|
v-if="this.customerPrivkey || this.customerUseExtension"
|
||||||
|
:account="account"
|
||||||
|
:merchant="stall.pubkey"
|
||||||
|
:relays="relays"
|
||||||
|
/>
|
||||||
<shopping-cart
|
<shopping-cart
|
||||||
:cart="cart"
|
:cart="cart"
|
||||||
:cart-menu="cartMenu"
|
:cart-menu="cartMenu"
|
||||||
|
|
@ -56,7 +62,8 @@
|
||||||
<q-input
|
<q-input
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
v-model.trim="checkoutDialog.data.pubkey"
|
readonly
|
||||||
|
v-model.trim="customerPubkey"
|
||||||
label="Public key"
|
label="Public key"
|
||||||
>
|
>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
@ -64,12 +71,12 @@
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
readonly
|
readonly
|
||||||
hint="This your key pair! Don't lose it!"
|
type="password"
|
||||||
v-if="checkoutDialog.data.privkey"
|
v-if="customerPrivkey"
|
||||||
v-model="checkoutDialog.data.privkey"
|
v-model="customerPrivkey"
|
||||||
>
|
>
|
||||||
</q-input>
|
</q-input>
|
||||||
<div class="row">
|
<!-- <div class="row">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<q-btn unelevated @click="generateKeyPair" color="primary"
|
<q-btn unelevated @click="generateKeyPair" color="primary"
|
||||||
>Generate key pair</q-btn
|
>Generate key pair</q-btn
|
||||||
|
|
@ -80,7 +87,7 @@
|
||||||
>Get from Extension</q-btn
|
>Get from Extension</q-btn
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
<q-input
|
<q-input
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
|
|
@ -112,14 +119,15 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
Total: {{ stall.currency != 'sat' ? getAmountFormated(finalCost) :
|
Total: {{ stall.currency != 'sat' ? getAmountFormated(finalCost,
|
||||||
finalCost + 'sats' }}
|
stall.currency) : finalCost + 'sats' }}
|
||||||
<span v-if="stall.currency != 'sat'" class="q-ml-sm text-grey-6"
|
<!-- <span v-if="stall.currency != 'sat'" class="q-ml-sm text-grey-6"
|
||||||
>({{ getValueInSats(finalCost) }} sats)</span
|
>({{ getValueInSats(finalCost) }} sats)</span
|
||||||
>
|
> -->
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-mt-lg">
|
<div class="row q-mt-lg">
|
||||||
<q-btn
|
<q-btn
|
||||||
|
:loading="loading"
|
||||||
unelevated
|
unelevated
|
||||||
color="primary"
|
color="primary"
|
||||||
:disable="checkoutDialog.data.address == null
|
:disable="checkoutDialog.data.address == null
|
||||||
|
|
@ -140,4 +148,48 @@
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
<!-- END CHECKOUT DIALOG -->
|
<!-- END CHECKOUT DIALOG -->
|
||||||
|
<!-- INVOICE DIALOG -->
|
||||||
|
<q-dialog
|
||||||
|
v-model="qrCodeDialog.show"
|
||||||
|
position="top"
|
||||||
|
@hide="closeQrCodeDialog"
|
||||||
|
>
|
||||||
|
<q-card
|
||||||
|
v-if="!qrCodeDialog.data.payment_request"
|
||||||
|
class="q-pa-lg q-pt-xl lnbits__dialog-card"
|
||||||
|
>
|
||||||
|
<div class="q-gutter-md row items-center">
|
||||||
|
<q-spinner-cube color="white" size="5.5em" />
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
|
<q-card v-else class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||||
|
<div class="text-center q-mb-lg">
|
||||||
|
<a :href="'lightning:' + qrCodeDialog.data.payment_request">
|
||||||
|
<q-responsive :ratio="1" class="q-mx-xl">
|
||||||
|
<qrcode
|
||||||
|
:value="qrCodeDialog.data.payment_request"
|
||||||
|
:options="{width: 340}"
|
||||||
|
class="rounded-borders"
|
||||||
|
></qrcode>
|
||||||
|
</q-responsive>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="row q-mt-lg">
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
color="grey"
|
||||||
|
@click="copyText(qrCodeDialog.data.payment_request)"
|
||||||
|
>Copy invoice</q-btn
|
||||||
|
>
|
||||||
|
<q-btn
|
||||||
|
@click="closeQrCodeDialog"
|
||||||
|
v-close-popup
|
||||||
|
flat
|
||||||
|
color="grey"
|
||||||
|
class="q-ml-auto"
|
||||||
|
>Close</q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,16 @@ async function customerStall(path) {
|
||||||
template,
|
template,
|
||||||
|
|
||||||
props: [
|
props: [
|
||||||
|
'account',
|
||||||
'stall',
|
'stall',
|
||||||
'products',
|
'products',
|
||||||
'exchange-rates',
|
|
||||||
'product-detail',
|
'product-detail',
|
||||||
'change-page',
|
'change-page',
|
||||||
'relays'
|
'relays'
|
||||||
],
|
],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
loading: false,
|
||||||
cart: {
|
cart: {
|
||||||
total: 0,
|
total: 0,
|
||||||
size: 0,
|
size: 0,
|
||||||
|
|
@ -23,8 +24,9 @@ async function customerStall(path) {
|
||||||
cartMenu: [],
|
cartMenu: [],
|
||||||
hasNip07: false,
|
hasNip07: false,
|
||||||
customerPubkey: null,
|
customerPubkey: null,
|
||||||
customerPrivKey: null,
|
customerPrivkey: null,
|
||||||
nostrMessages: new Map(),
|
customerUseExtension: null,
|
||||||
|
activeOrder: null,
|
||||||
checkoutDialog: {
|
checkoutDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -58,12 +60,6 @@ async function customerStall(path) {
|
||||||
changePageS(page, opts) {
|
changePageS(page, opts) {
|
||||||
this.$emit('change-page', page, opts)
|
this.$emit('change-page', page, opts)
|
||||||
},
|
},
|
||||||
getValueInSats(amount, unit = 'USD') {
|
|
||||||
if (!this.exchangeRates) return 0
|
|
||||||
return Math.ceil(
|
|
||||||
(amount / this.exchangeRates[`BTC${unit}`][unit]) * 1e8
|
|
||||||
)
|
|
||||||
},
|
|
||||||
getAmountFormated(amount, unit = 'USD') {
|
getAmountFormated(amount, unit = 'USD') {
|
||||||
return LNbits.utils.formatCurrency(amount, unit)
|
return LNbits.utils.formatCurrency(amount, unit)
|
||||||
},
|
},
|
||||||
|
|
@ -125,26 +121,12 @@ async function customerStall(path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getPubkey() {
|
closeQrCodeDialog() {
|
||||||
try {
|
this.qrCodeDialog.dismissMsg()
|
||||||
this.customerPubkey = await window.nostr.getPublicKey()
|
this.qrCodeDialog.show = false
|
||||||
this.checkoutDialog.data.pubkey = this.customerPubkey
|
|
||||||
this.checkoutDialog.data.privkey = null
|
|
||||||
} catch (err) {
|
|
||||||
console.error(
|
|
||||||
`Failed to get a public key from a Nostr extension: ${err}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
generateKeyPair() {
|
|
||||||
let sk = NostrTools.generatePrivateKey()
|
|
||||||
let pk = NostrTools.getPublicKey(sk)
|
|
||||||
this.customerPubkey = pk
|
|
||||||
this.customerPrivKey = sk
|
|
||||||
this.checkoutDialog.data.pubkey = this.customerPubkey
|
|
||||||
this.checkoutDialog.data.privkey = this.customerPrivKey
|
|
||||||
},
|
},
|
||||||
async placeOrder() {
|
async placeOrder() {
|
||||||
|
this.loading = true
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
.confirmDialog(
|
.confirmDialog(
|
||||||
`Send the order to the merchant? You should receive a message with the payment details.`
|
`Send the order to the merchant? You should receive a message with the payment details.`
|
||||||
|
|
@ -170,6 +152,7 @@ async function customerStall(path) {
|
||||||
':'
|
':'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
this.activeOrder = orderObj.id
|
||||||
let event = {
|
let event = {
|
||||||
...(await NostrTools.getBlankEvent()),
|
...(await NostrTools.getBlankEvent()),
|
||||||
kind: 4,
|
kind: 4,
|
||||||
|
|
@ -177,13 +160,13 @@ async function customerStall(path) {
|
||||||
tags: [['p', this.stall.pubkey]],
|
tags: [['p', this.stall.pubkey]],
|
||||||
pubkey: this.customerPubkey
|
pubkey: this.customerPubkey
|
||||||
}
|
}
|
||||||
if (this.customerPrivKey) {
|
if (this.customerPrivkey) {
|
||||||
event.content = await NostrTools.nip04.encrypt(
|
event.content = await NostrTools.nip04.encrypt(
|
||||||
this.customerPrivKey,
|
this.customerPrivkey,
|
||||||
this.stall.pubkey,
|
this.stall.pubkey,
|
||||||
JSON.stringify(orderObj)
|
JSON.stringify(orderObj)
|
||||||
)
|
)
|
||||||
} else {
|
} else if (this.customerUseExtension && this.hasNip07) {
|
||||||
event.content = await window.nostr.nip04.encrypt(
|
event.content = await window.nostr.nip04.encrypt(
|
||||||
this.stall.pubkey,
|
this.stall.pubkey,
|
||||||
JSON.stringify(orderObj)
|
JSON.stringify(orderObj)
|
||||||
|
|
@ -196,15 +179,15 @@ async function customerStall(path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.id = NostrTools.getEventHash(event)
|
event.id = NostrTools.getEventHash(event)
|
||||||
if (this.customerPrivKey) {
|
if (this.customerPrivkey) {
|
||||||
event.sig = await NostrTools.signEvent(
|
event.sig = await NostrTools.signEvent(
|
||||||
event,
|
event,
|
||||||
this.customerPrivKey
|
this.customerPrivkey
|
||||||
)
|
)
|
||||||
} else if (this.hasNip07) {
|
} else if (this.customerUseExtension && this.hasNip07) {
|
||||||
event = await window.nostr.signEvent(event)
|
event = await window.nostr.signEvent(event)
|
||||||
}
|
}
|
||||||
console.log(event, orderObj)
|
|
||||||
await this.sendOrder(event)
|
await this.sendOrder(event)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
@ -223,25 +206,32 @@ async function customerStall(path) {
|
||||||
let pub = relay.publish(order)
|
let pub = relay.publish(order)
|
||||||
pub.on('ok', () => {
|
pub.on('ok', () => {
|
||||||
console.log(`${relay.url} has accepted our event`)
|
console.log(`${relay.url} has accepted our event`)
|
||||||
|
relay.close()
|
||||||
})
|
})
|
||||||
pub.on('failed', reason => {
|
pub.on('failed', reason => {
|
||||||
console.log(`failed to publish to ${relay.url}: ${reason}`)
|
console.log(`failed to publish to ${relay.url}: ${reason}`)
|
||||||
|
relay.close()
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error: ${err}`)
|
console.error(`Error: ${err}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.loading = false
|
||||||
this.resetCheckout()
|
this.resetCheckout()
|
||||||
|
this.resetCart()
|
||||||
|
this.qrCodeDialog.show = true
|
||||||
|
this.qrCodeDialog.dismissMsg = this.$q.notify({
|
||||||
|
timeout: 0,
|
||||||
|
message: 'Waiting for invoice from merchant...'
|
||||||
|
})
|
||||||
this.listenMessages()
|
this.listenMessages()
|
||||||
},
|
},
|
||||||
async listenMessages() {
|
async listenMessages() {
|
||||||
|
console.log('LISTEN')
|
||||||
try {
|
try {
|
||||||
const pool = new NostrTools.SimplePool()
|
const pool = new NostrTools.SimplePool()
|
||||||
const filters = [
|
const filters = [
|
||||||
{
|
// /
|
||||||
kinds: [4],
|
|
||||||
authors: [this.customerPubkey]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
kinds: [4],
|
kinds: [4],
|
||||||
'#p': [this.customerPubkey]
|
'#p': [this.customerPubkey]
|
||||||
|
|
@ -254,38 +244,74 @@ async function customerStall(path) {
|
||||||
let sender = mine
|
let sender = mine
|
||||||
? event.tags.find(([k, v]) => k === 'p' && v && v !== '')[1]
|
? event.tags.find(([k, v]) => k === 'p' && v && v !== '')[1]
|
||||||
: event.pubkey
|
: event.pubkey
|
||||||
if (
|
|
||||||
(mine && sender != this.stall.pubkey) ||
|
|
||||||
(!mine && sender != this.customerPubkey)
|
|
||||||
) {
|
|
||||||
console.log(`Not relevant message!`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
let plaintext = this.customerPrivKey
|
let plaintext
|
||||||
? await NostrTools.nip04.decrypt(
|
if (this.customerPrivkey) {
|
||||||
this.customerPrivKey,
|
plaintext = await NostrTools.nip04.decrypt(
|
||||||
sender,
|
this.customerPrivkey,
|
||||||
event.content
|
sender,
|
||||||
)
|
event.content
|
||||||
: await window.nostr.nip04.decrypt(sender, event.content)
|
)
|
||||||
// console.log(`${mine ? 'Me' : 'Customer'}: ${plaintext}`)
|
} else if (this.customerUseExtension && this.hasNip07) {
|
||||||
this.nostrMessages.set(event.id, {
|
plaintext = await window.nostr.nip04.decrypt(
|
||||||
msg: plaintext,
|
sender,
|
||||||
timestamp: event.created_at,
|
event.content
|
||||||
sender: `${mine ? 'Me' : 'Merchant'}`
|
)
|
||||||
})
|
}
|
||||||
|
console.log(`${mine ? 'Me' : 'Merchant'}: ${plaintext}`)
|
||||||
|
|
||||||
|
// this.nostrMessages.set(event.id, {
|
||||||
|
// msg: plaintext,
|
||||||
|
// timestamp: event.created_at,
|
||||||
|
// sender: `${mine ? 'Me' : 'Merchant'}`
|
||||||
|
// })
|
||||||
|
this.messageFilter(plaintext, cb => Promise.resolve(pool.close))
|
||||||
} catch {
|
} catch {
|
||||||
console.error('Unable to decrypt message!')
|
console.error('Unable to decrypt message!')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error: ${err}`)
|
console.error(`Error: ${err}`)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
messageFilter(text, cb = () => {}) {
|
||||||
|
if (!isJson(text)) return
|
||||||
|
let json = JSON.parse(text)
|
||||||
|
if (json.id != this.activeOrder) return
|
||||||
|
if (json?.payment_options) {
|
||||||
|
// this.qrCodeDialog.show = true
|
||||||
|
this.qrCodeDialog.data.payment_request = json.payment_options.find(
|
||||||
|
o => o.type == 'ln'
|
||||||
|
).link
|
||||||
|
this.qrCodeDialog.dismissMsg = this.$q.notify({
|
||||||
|
timeout: 0,
|
||||||
|
message: 'Waiting for payment...'
|
||||||
|
})
|
||||||
|
} else if (json?.paid) {
|
||||||
|
this.qrCodeDialog.dismissMsg = this.$q.notify({
|
||||||
|
type: 'positive',
|
||||||
|
message: 'Sats received, thanks!',
|
||||||
|
icon: 'thumb_up'
|
||||||
|
})
|
||||||
|
this.closeQrCodeDialog()
|
||||||
|
this.activeOrder = null
|
||||||
|
Promise.resolve(cb())
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// async mockInit() {
|
||||||
|
// this.customerPubkey = await window.nostr.getPublicKey()
|
||||||
|
// this.activeOrder =
|
||||||
|
// 'e4a16aa0198022dc682b2b52ed15767438282c0e712f510332fc047eaf795313'
|
||||||
|
// await this.listenMessages()
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.customerPubkey = this.account.pubkey
|
||||||
|
this.customerPrivkey = this.account.privkey
|
||||||
|
this.customerUseExtension = this.account.useExtension
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (window.nostr) {
|
if (window.nostr) {
|
||||||
this.hasNip07 = true
|
this.hasNip07 = true
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<span class="text-h6">{{ product.formatedPrice }}</span>
|
<span class="text-h6">{{ product.formatedPrice }}</span>
|
||||||
<span v-if="exchangeRates" class="q-ml-sm text-grey-6"
|
|
||||||
>({{ product.priceInSats }} sats)</span
|
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
<span class="q-ml-md text-caption text-green-8 text-weight-bolder q-mt-md"
|
<span class="q-ml-md text-caption text-green-8 text-weight-bolder q-mt-md"
|
||||||
>{{ product.quantity }} left</span
|
>{{ product.quantity }} left</span
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,6 @@
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<span class="text-h6">{{ product.formatedPrice }}</span>
|
<span class="text-h6">{{ product.formatedPrice }}</span>
|
||||||
<span class="q-ml-sm text-grey-6"
|
|
||||||
>({{ product.priceInSats }} sats)</span
|
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
class="q-ml-md text-caption text-green-8 text-weight-bolder q-mt-md"
|
class="q-ml-md text-caption text-green-8 text-weight-bolder q-mt-md"
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ const market = async () => {
|
||||||
key: null
|
key: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
drawer: true,
|
drawer: false,
|
||||||
pubkeys: new Set(),
|
pubkeys: new Set(),
|
||||||
relays: new Set(),
|
relays: new Set(),
|
||||||
events: [],
|
events: [],
|
||||||
|
|
@ -49,7 +49,6 @@ const market = async () => {
|
||||||
products: [],
|
products: [],
|
||||||
profiles: new Map(),
|
profiles: new Map(),
|
||||||
searchText: null,
|
searchText: null,
|
||||||
exchangeRates: null,
|
|
||||||
inputPubkey: null,
|
inputPubkey: null,
|
||||||
inputRelay: null,
|
inputRelay: null,
|
||||||
activePage: 'market',
|
activePage: 'market',
|
||||||
|
|
@ -136,10 +135,8 @@ const market = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get notes from Nostr
|
// Get notes from Nostr
|
||||||
//await this.initNostr()
|
await this.initNostr()
|
||||||
|
|
||||||
// Get fiat rates (i think there's an LNbits endpoint for this)
|
|
||||||
//await this.getRates()
|
|
||||||
this.$q.loading.hide()
|
this.$q.loading.hide()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -233,23 +230,12 @@ const market = async () => {
|
||||||
obj.images = [obj.image]
|
obj.images = [obj.image]
|
||||||
if (obj.currency != 'sat') {
|
if (obj.currency != 'sat') {
|
||||||
obj.formatedPrice = this.getAmountFormated(obj.price, obj.currency)
|
obj.formatedPrice = this.getAmountFormated(obj.price, obj.currency)
|
||||||
obj.priceInSats = this.getValueInSats(obj.price, obj.currency)
|
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
pool.close(relays)
|
pool.close(relays)
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
async getRates() {
|
|
||||||
let noFiat = this.stalls.map(s => s.currency).every(c => c == 'sat')
|
|
||||||
if (noFiat) return
|
|
||||||
try {
|
|
||||||
let rates = await axios.get('https://api.opennode.co/v1/rates')
|
|
||||||
this.exchangeRates = rates.data.data
|
|
||||||
} catch (error) {
|
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
navigateTo(page, opts = {stall: null, product: null, pubkey: null}) {
|
navigateTo(page, opts = {stall: null, product: null, pubkey: null}) {
|
||||||
let {stall, product, pubkey} = opts
|
let {stall, product, pubkey} = opts
|
||||||
let url = new URL(window.location)
|
let url = new URL(window.location)
|
||||||
|
|
@ -283,13 +269,6 @@ const market = async () => {
|
||||||
window.history.pushState({}, '', url)
|
window.history.pushState({}, '', url)
|
||||||
this.activePage = page
|
this.activePage = page
|
||||||
},
|
},
|
||||||
|
|
||||||
getValueInSats(amount, unit = 'USD') {
|
|
||||||
if (!this.exchangeRates) return 0
|
|
||||||
return Math.ceil(
|
|
||||||
(amount / this.exchangeRates[`BTC${unit}`][unit]) * 1e8
|
|
||||||
)
|
|
||||||
},
|
|
||||||
getAmountFormated(amount, unit = 'USD') {
|
getAmountFormated(amount, unit = 'USD') {
|
||||||
return LNbits.utils.formatCurrency(amount, unit)
|
return LNbits.utils.formatCurrency(amount, unit)
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,15 @@ async function hash(string) {
|
||||||
.join('')
|
.join('')
|
||||||
return hashHex
|
return hashHex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isJson(str) {
|
||||||
|
if (typeof str !== 'string') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JSON.parse(str)
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,15 +169,14 @@
|
||||||
v-if="!isLoading && activeStall"
|
v-if="!isLoading && activeStall"
|
||||||
:stall="stalls.find(stall => stall.id == activeStall)"
|
:stall="stalls.find(stall => stall.id == activeStall)"
|
||||||
:products="filterProducts"
|
:products="filterProducts"
|
||||||
:exchange-rates="exchangeRates"
|
|
||||||
:product-detail="activeProduct"
|
:product-detail="activeProduct"
|
||||||
:relays="relays"
|
:relays="relays"
|
||||||
|
:account="account"
|
||||||
@change-page="navigateTo"
|
@change-page="navigateTo"
|
||||||
></customer-stall>
|
></customer-stall>
|
||||||
<customer-market
|
<customer-market
|
||||||
v-else
|
v-else
|
||||||
:products="filterProducts"
|
:products="filterProducts"
|
||||||
:exchange-rates="exchangeRates"
|
|
||||||
@change-page="navigateTo"
|
@change-page="navigateTo"
|
||||||
></customer-market>
|
></customer-market>
|
||||||
</q-page-container>
|
</q-page-container>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue