refactor: renamings

This commit is contained in:
Vlad Stan 2022-10-10 13:45:53 +03:00
parent 13a46c1ebe
commit 4a046d5745
2 changed files with 34 additions and 40 deletions

View File

@ -1092,7 +1092,6 @@
mod, mod,
invert, invert,
sha256: async (...messages) => { sha256: async (...messages) => {
console.log('### sha256 messages', messages)
if (crypto.web) { if (crypto.web) {
const buffer = await crypto.web.subtle.digest( const buffer = await crypto.web.subtle.digest(
'SHA-256', 'SHA-256',

View File

@ -67,7 +67,7 @@ page_container %}
<q-table <q-table
dense dense
flat flat
:data="tokenBuys" :data="buyOrders"
:columns="buysTable.columns" :columns="buysTable.columns"
:pagination.sync="buysTable.pagination" :pagination.sync="buysTable.pagination"
no-data-label="No buys made yet" no-data-label="No buys made yet"
@ -379,11 +379,11 @@ page_container %}
</q-card> </q-card>
</q-dialog> </q-dialog>
<q-dialog v-model="buyTokens.showDialog" position="top"> <q-dialog v-model="showInvoiceDetails" position="top">
{% raw %} {% raw %}
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card"> <q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<div v-if="!buyTokens.data.bolt11"> <div v-if="!buyData.bolt11">
<div class="row items-center no-wrap q-mb-sm"> <div class="row items-center no-wrap q-mb-sm">
<div class="col-12"> <div class="col-12">
<span class="text-subtitle1" <span class="text-subtitle1"
@ -394,7 +394,7 @@ page_container %}
<q-input <q-input
filled filled
dense dense
v-model.number="buyTokens.data.amount" v-model.number="buyData.amount"
label="Amount (sats) *" label="Amount (sats) *"
type="number" type="number"
class="q-mb-lg" class="q-mb-lg"
@ -403,15 +403,15 @@ page_container %}
<q-input <q-input
filled filled
dense dense
v-model.trim="buyTokens.data.memo" v-model.trim="buyData.memo"
label="Memo" label="Memo"
></q-input> ></q-input>
</div> </div>
<div v-else class="text-center q-mb-lg"> <div v-else class="text-center q-mb-lg">
<a :href="'lightning:' + buyTokens.data.bolt11"> <a :href="'lightning:' + buyData.bolt11">
<q-responsive :ratio="1" class="q-mx-xl"> <q-responsive :ratio="1" class="q-mx-xl">
<qrcode <qrcode
:value="buyTokens.data.bolt11" :value="buyData.bolt11"
:options="{width: 340}" :options="{width: 340}"
class="rounded-borders" class="rounded-borders"
> >
@ -421,8 +421,8 @@ page_container %}
</div> </div>
<div class="row q-mt-lg"> <div class="row q-mt-lg">
<q-btn <q-btn
v-if="buyTokens.data.bolt11" v-if="buyData.bolt11"
@click="copyText(buyTokens.data.bolt11)" @click="copyText(buyData.bolt11)"
outline outline
color="grey" color="grey"
>Copy invoice</q-btn >Copy invoice</q-btn
@ -489,16 +489,14 @@ page_container %}
mintId: '', mintId: '',
mintName: '', mintName: '',
tokenBuys: [], buyOrders: [],
buyTokens: { buyData: {
showDialog: false,
data: {
amount: 0, amount: 0,
memo: '', memo: '',
bolt11: '', bolt11: '',
hash: '' hash: '',
}
}, },
showInvoiceDetails: false,
tokens: [], tokens: [],
receive: { receive: {
@ -589,9 +587,6 @@ page_container %}
formattedBalance: function () { formattedBalance: function () {
return this.balance / 100 return this.balance / 100
}, },
// tokenBuys: function() {
// return []
// },
canPay: function () { canPay: function () {
if (!this.parse.invoice) return false if (!this.parse.invoice) return false
@ -837,16 +832,16 @@ page_container %}
/////////////////////////////////// WALLET /////////////////////////////////// /////////////////////////////////// WALLET ///////////////////////////////////
showBuyTokensDialog: async function () { showBuyTokensDialog: async function () {
console.log('##### showBuyTokensDialog') console.log('##### showBuyTokensDialog')
this.buyTokens.data.amount = 0 this.buyData.amount = 0
this.buyTokens.data.bolt11 = '' this.buyData.bolt11 = ''
this.buyTokens.data.hash = '' this.buyData.hash = ''
this.buyTokens.data.memo = '' this.buyData.memo = ''
this.buyTokens.showDialog = true this.showInvoiceDetails = true
}, },
showInvoiceDialog: async function (data) { showInvoiceDialog: async function (data) {
this.buyTokens.data = data this.buyData = data
this.buyTokens.showDialog = true this.showInvoiceDetails = true
}, },
@ -854,23 +849,23 @@ page_container %}
try { try {
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
'GET', 'GET',
`/cashu/api/v1/cashu/${this.mintId}/mint?amount=${this.buyTokens.data.amount}` `/cashu/api/v1/cashu/${this.mintId}/mint?amount=${this.buyData.amount}`
) )
console.log('### data', data) console.log('### data', data)
this.buyTokens.data.bolt11 = data.pr this.buyData.bolt11 = data.pr
this.buyTokens.data.hash = data.hash this.buyData.hash = data.hash
this.tokenBuys.push({ this.buyOrders.push({
...this.buyTokens.data, ...this.buyData,
date: currentDateStr(), date: currentDateStr(),
status: 'pending' status: 'pending'
}) })
localStorage.setItem( localStorage.setItem(
'cashu.tokenBuys', 'cashu.buyOrders',
JSON.stringify(this.tokenBuys) JSON.stringify(this.buyOrders)
) )
const amounts = splitAmount(this.buyTokens.data.amount) const amounts = splitAmount(this.buyData.amount)
await this.requestTokens(amounts, this.buyTokens.data.hash) await this.requestTokens(amounts, this.buyData.hash)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
@ -878,7 +873,7 @@ page_container %}
}, },
checkXXXXXX: async function () { checkXXXXXX: async function () {
for (const tokenBuy of this.tokenBuys) { for (const tokenBuy of this.buyOrders) {
if (tokenBuy.status === 'pending') { if (tokenBuy.status === 'pending') {
try { try {
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
@ -1035,11 +1030,11 @@ page_container %}
this.mintName = this.$q.localStorage.getItem('cashu.name') this.mintName = this.$q.localStorage.getItem('cashu.name')
} }
this.tokenBuys = JSON.parse( this.buyOrders = JSON.parse(
localStorage.getItem('cashu.tokenBuys') || '[]' localStorage.getItem('cashu.buyOrders') || '[]'
) )
this.tokens = JSON.parse(localStorage.getItem('cashu.tokens') || '[]') this.tokens = JSON.parse(localStorage.getItem('cashu.tokens') || '[]')
console.log('#### this.tokenBuys', this.tokenBuys) console.log('#### this.buyOrders', this.buyOrders)
console.log('#### this.mintId', this.mintId) console.log('#### this.mintId', this.mintId)
console.log('#### this.mintName', this.mintName) console.log('#### this.mintName', this.mintName)