From 5dc7a77e43f7a8e6e696ca1c09a43d5c2e0044de Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Fri, 6 Jan 2023 00:41:15 +0100 Subject: [PATCH] running format and adding sqlite db to mock_data.zip --- .../deezy/templates/deezy/index.html | 181 +++++++++++++----- tests/data/mock_data.zip | Bin 42862 -> 43064 bytes 2 files changed, 130 insertions(+), 51 deletions(-) diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 6dcad038..3b7a205a 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -5,15 +5,26 @@
Deezy
-

Due to regulatory reasons you need to get a access token from deezy. Contact - support@deezy.io or @dannydeezy on telegram

+

+ Due to regulatory reasons you need to get a access token from deezy. + Contact - support@deezy.io or @dannydeezy on telegram +

Deezy token - Add or Update token + Add or Update token

- + - + @@ -239,22 +246,83 @@ data: function () { return { columnsLnToBtc: [ - { name: 'amount_sats',label: 'Amount Sats', align: 'left', field: 'amount_sats', sortable: true}, - { name: 'on_chain_address', align: 'left', label: 'On chain address', field: 'on_chain_address' }, - { name: 'on_chain_sats_per_vbyte', align: 'left', label: 'Onchin sats per vbyte', field: 'on_chain_sats_per_vbyte', sortable: true }, - { name: 'fee_sats', label: 'Fee sats', align: 'left',field: 'fee_sats' }, - { name: 'txid', label: 'Tx Id',align: 'left', field: 'txid' }, - { name: 'tx_hex', label: 'Tx Hex',align: 'left', field: 'tx_hex' }, - { name: 'created_at', label: 'Created at',align: 'left', field: 'created_at', sortable: true, sort: true } + { + name: 'amount_sats', + label: 'Amount Sats', + align: 'left', + field: 'amount_sats', + sortable: true + }, + { + name: 'on_chain_address', + align: 'left', + label: 'On chain address', + field: 'on_chain_address' + }, + { + name: 'on_chain_sats_per_vbyte', + align: 'left', + label: 'Onchin sats per vbyte', + field: 'on_chain_sats_per_vbyte', + sortable: true + }, + { + name: 'fee_sats', + label: 'Fee sats', + align: 'left', + field: 'fee_sats' + }, + {name: 'txid', label: 'Tx Id', align: 'left', field: 'txid'}, + {name: 'tx_hex', label: 'Tx Hex', align: 'left', field: 'tx_hex'}, + { + name: 'created_at', + label: 'Created at', + align: 'left', + field: 'created_at', + sortable: true, + sort: true + } ], rowsLnToBtc: [], columnsBtcToLn: [ - { name: 'ln_address', align: 'left', label: 'Ln Address or Invoice', field: 'ln_address' }, - { name: 'on_chain_address', align: 'left', label: 'Onchain Address', field: 'on_chain_address' }, - { name: 'secret_access_key', align: 'left', label: 'Onchain Address', field: 'secret_access_key' }, - { name: 'commitment', align: 'left', label: 'Commitment', field: 'commitment' }, - { name: 'signature', align: 'left', label: 'Signature', field: 'signature' }, - { name: 'created_at', label: 'Created at', field: 'created_at', align: 'left', sortable: true, sort: true } + { + name: 'ln_address', + align: 'left', + label: 'Ln Address or Invoice', + field: 'ln_address' + }, + { + name: 'on_chain_address', + align: 'left', + label: 'Onchain Address', + field: 'on_chain_address' + }, + { + name: 'secret_access_key', + align: 'left', + label: 'Onchain Address', + field: 'secret_access_key' + }, + { + name: 'commitment', + align: 'left', + label: 'Commitment', + field: 'commitment' + }, + { + name: 'signature', + align: 'left', + label: 'Signature', + field: 'signature' + }, + { + name: 'created_at', + label: 'Created at', + field: 'created_at', + align: 'left', + sortable: true, + sort: true + } ], rowsBtcToLn: [], showDeezyTokenForm: false, @@ -304,7 +372,7 @@ var self = this axios({ method: 'GET', - url: '/deezy/api/v1/token', + url: '/deezy/api/v1/token' }).then(function (response) { self.storedDeezyToken = response.data.deezy_token if (!self.storeDeezyToken) { @@ -357,13 +425,15 @@ invoicePaid: true, onchainTxId: response.data.on_chain_txid } - self.updateLnToBtc({ - txid: response.data.on_chain_txid, - tx_hex: response.data.tx_hex, - bolt11_invoice: self.swapLnToBtc.response - }).then(() => { - self.getLnToBtc() - }) + self + .updateLnToBtc({ + txid: response.data.on_chain_txid, + tx_hex: response.data.tx_hex, + bolt11_invoice: self.swapLnToBtc.response + }) + .then(() => { + self.getLnToBtc() + }) clearInterval(interval) } }) @@ -376,17 +446,21 @@ sendLnToBtc() { var self = this axios - .post('https://api.deezy.io/v1/swap', { - amount_sats: parseInt(self.swapLnToBtc.data.amount), - on_chain_address: self.swapLnToBtc.data.on_chain_address, - on_chain_sats_per_vbyte: parseInt( - self.swapLnToBtc.data.on_chain_sats_per_vbyte - ) - }, { - headers: { - "x-api-token": self.storedDeezyToken, + .post( + 'https://api.deezy.io/v1/swap', + { + amount_sats: parseInt(self.swapLnToBtc.data.amount), + on_chain_address: self.swapLnToBtc.data.on_chain_address, + on_chain_sats_per_vbyte: parseInt( + self.swapLnToBtc.data.on_chain_sats_per_vbyte + ) + }, + { + headers: { + 'x-api-token': self.storedDeezyToken + } } - }) + ) .then(function (response) { self.swapLnToBtc = { ...self.swapLnToBtc, @@ -394,11 +468,12 @@ response: response.data.bolt11_invoice } const payload = { - amount_sats: parseInt(self.swapLnToBtc.data.amount), - on_chain_address: self.swapLnToBtc.data.on_chain_address, - on_chain_sats_per_vbyte: self.swapLnToBtc.data.on_chain_sats_per_vbyte, + amount_sats: parseInt(self.swapLnToBtc.data.amount), + on_chain_address: self.swapLnToBtc.data.on_chain_address, + on_chain_sats_per_vbyte: + self.swapLnToBtc.data.on_chain_sats_per_vbyte, bolt11_invoice: response.data.bolt11_invoice, - fee_sats: response.data.fee_sats, + fee_sats: response.data.fee_sats } self.storeLnToBtc(payload) self.checkIfInvoiceIsPaid() @@ -410,13 +485,17 @@ sendBtcToLn() { var self = this axios - .post('https://api.deezy.io/v1/source', { - lnurl_or_lnaddress: self.swapBtcToLn.data.lnurl_or_lnaddress - }, { - headers: { - "x-api-token": self.storedDeezyToken, + .post( + 'https://api.deezy.io/v1/source', + { + lnurl_or_lnaddress: self.swapBtcToLn.data.lnurl_or_lnaddress + }, + { + headers: { + 'x-api-token': self.storedDeezyToken + } } - }) + ) .then(function (response) { self.swapBtcToLn = { ...self.swapBtcToLn, @@ -427,7 +506,7 @@ ln_address: self.swapBtcToLn.data.lnurl_or_lnaddress, on_chain_address: response.data.address, secret_access_key: response.data.secret_access_key, - commitment:response.data.commitment, + commitment: response.data.commitment, signature: response.data.signature } self.storeBtcToLn(payload) @@ -470,7 +549,7 @@ }) .then(function (response) { self.storedDeezyToken = response.data - self.showDeezyTokenForm = false + self.showDeezyTokenForm = false }) .catch(function (error) { console.log(error) diff --git a/tests/data/mock_data.zip b/tests/data/mock_data.zip index 4070bee77ec1fa4608772d0a0410320ea798e860..d5169e128e9d84563a8f8e090ea1e0346bb03308 100644 GIT binary patch delta 1915 zcmb7FZERCz6n^i$-CDb}uG$t%Z$D68n;(TFtjrzXK;KwSGM4d2pU<#71w zU0Vc&APNuYJvh^;e}n?Y^}usUSZfGq-@vjkDLidh#Fh2rmn6YBB_4c=0f))IBFI{w0KyoBgJ`#!no{M zMZ)rmMq1rg5yVdh2P>PIa8H#7E7)GOfdZf^MDUlZH`4GP4}I>JeXR^%>Gxv5R(}Hp zyzb9(oC&-&57Tf@%`wkGJ)Sc{Z)@BV-B01mhFqxk`FM9Uv8#Vquxnp`G||f>r^e^i-lI!yHu`d=roZGR7EhC1m6$=Q?)?%{2$ z>Py1la3eD(LEzMl;b!JelDaVq@sY>bp%EFbjBH_HPKNcPML9T}8I@SW85t_ZS{V3# z8Iof~s;6XF9xH0cVLTgVXMdlCud>BP0c`K_t&9qX?~g|q_>2s-rsyIsGYJ1hhqpr zF`wGbS&!TOav@&#J^mX&8xaz3k$es2rc_3e_a@=yl*l*6!IlfC416#G&*ns-p%20J zy&g5~I)RA|_C(-Q9uv1AWWR;je-wVr6`5OPXu?j7q!5@={sKqw5zg)y2-7*jnQ4n~ zK8>I!U9WcHu^sJstPUWQuT{_9;Z8n&6W*P&!YBDvDxIDz@yFetzmVYIyR4b_4ubV` W(EG1eE-59d-1t*nj?f<`N%R*mGIf3c delta 1799 zcmb7DZD?C%6n^i$amgB*w%X72Cb^M@CXH?EWZJCDbi(=-w?^7Tn-QDtZc}i`I-jQ~c9g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