Browse Source

Specify API URLS

readme
Mayank 5 years ago
parent
commit
0910a3efb2
  1. 2
      .env
  2. 2
      .env.production
  3. 3
      .env.staging
  4. 4
      .gitignore
  5. 1
      src/App.vue
  6. 5
      src/components/BitcoinWallet.vue
  7. 12
      src/components/LightningWallet.vue
  8. 17
      src/layouts/DashboardLayout.vue
  9. 18
      src/store/modules/bitcoin.js
  10. 18
      src/store/modules/lightning.js
  11. 2
      src/store/modules/system.js
  12. 4
      src/views/Lightning.vue
  13. 6
      vue.config.js

2
.env

@ -0,0 +1,2 @@
VUE_APP_API_URL=https://testnet.getumbrel.com/
VUE_APP_NETWORK=testnet

2
.env.production

@ -0,0 +1,2 @@
VUE_APP_API_URL=/
VUE_APP_NETWORK=mainnet

3
.env.staging

@ -1 +1,2 @@
NODE_ENV=staging VUE_APP_API_URL=https://testnet.getumbrel.com/
VUE_APP_NETWORK=testnet

4
.gitignore

@ -2,10 +2,6 @@
node_modules node_modules
/dist /dist
# local env files
.env.local
.env.*.local
# Log files # Log files
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*

1
src/App.vue

@ -107,6 +107,7 @@ export default {
} }
}, },
created() { created() {
console.log(process.env.VUE_APP_API_URL, process.env.VUE_APP_NETWORK);
this.updateViewPortHeightCSS(); this.updateViewPortHeightCSS();
//for 100vh consistency //for 100vh consistency
window.addEventListener("resize", this.updateViewPortHeightCSS); window.addEventListener("resize", this.updateViewPortHeightCSS);

5
src/components/BitcoinWallet.vue

@ -589,7 +589,10 @@ export default {
}; };
try { try {
const res = await API.post(`api/v1/lnd/transaction`, payload); const res = await API.post(
`${process.env.VUE_APP_API_URL}api/v1/lnd/transaction`,
payload
);
const withdrawTx = res.data; const withdrawTx = res.data;
this.state.withdraw.txHash = withdrawTx.txid; this.state.withdraw.txHash = withdrawTx.txid;
this.changeMode("withdrawn"); this.changeMode("withdrawn");

12
src/components/LightningWallet.vue

@ -517,7 +517,10 @@ export default {
}; };
try { try {
const res = await API.post(`api/v1/lnd/lightning/payInvoice`, payload); const res = await API.post(
`${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/payInvoice`,
payload
);
if (res.data.paymentError) { if (res.data.paymentError) {
return (this.state.error = res.data.paymentError); return (this.state.error = res.data.paymentError);
} }
@ -557,7 +560,10 @@ export default {
}; };
try { try {
const res = await API.post(`api/v1/lnd/lightning/addInvoice`, payload); const res = await API.post(
`${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/addInvoice`,
payload
);
this.state.receive.invoiceQR = this.state.receive.invoiceText = this.state.receive.invoiceQR = this.state.receive.invoiceText =
res.data.paymentRequest; res.data.paymentRequest;
@ -603,7 +609,7 @@ export default {
this.state.loading = true; this.state.loading = true;
const fetchedInvoice = await API.get( const fetchedInvoice = await API.get(
`api/v1/lnd/lightning/invoice?paymentRequest=${this.state.send.invoiceText}` `${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/invoice?paymentRequest=${this.state.send.invoiceText}`
); );
if (!fetchedInvoice) { if (!fetchedInvoice) {

17
src/layouts/DashboardLayout.vue

@ -26,17 +26,12 @@
<!-- Right aligned nav items --> <!-- Right aligned nav items -->
<b-navbar-nav class="ml-auto"> <b-navbar-nav class="ml-auto">
<!-- Testnet/Development badges --> <!-- Testnet badge -->
<b-badge <b-badge
variant="success" variant="success"
v-if="environment === 'development'" v-if="network !== 'mainnet'"
class="align-self-center mr-2" class="align-self-center mr-2 text-capitalize"
>Development</b-badge> >{{ network }}</b-badge>
<b-badge
variant="success"
v-else-if="environment === 'staging'"
class="align-self-center mr-2"
>Testnet</b-badge>
<div <div
class="nav-hamburger-icon d-lg-none d-xl-none ml-1" class="nav-hamburger-icon d-lg-none d-xl-none ml-1"
@ -98,7 +93,8 @@ import AuthenticatedVerticalNavbar from "@/components/AuthenticatedVerticalNavba
export default { export default {
data() { data() {
return { return {
environment: process.env.NODE_ENV environment: process.env.NODE_ENV,
network: process.env.VUE_APP_NETWORK
}; };
}, },
computed: { computed: {
@ -115,6 +111,7 @@ export default {
this.$router.push("/"); this.$router.push("/");
}, },
toggleMobileMenu() { toggleMobileMenu() {
console.log(process.env.VUE_APP_API_URL);
this.$store.commit("toggleMobileMenu"); this.$store.commit("toggleMobileMenu");
} }
}, },

18
src/store/modules/bitcoin.js

@ -158,7 +158,7 @@ const mutations = {
// Functions to get data from the API // Functions to get data from the API
const actions = { const actions = {
async getStatus({ commit, dispatch }) { async getStatus({ commit, dispatch }) {
const status = await API.get(`api/v1/bitcoind/info/status`); const status = await API.get(`${process.env.VUE_APP_API_URL}api/v1/bitcoind/info/status`);
if (status) { if (status) {
commit('isOperational', status.operational); commit('isOperational', status.operational);
@ -172,7 +172,7 @@ const actions = {
async getAddresses({ commit, state }) { async getAddresses({ commit, state }) {
// We can only make this request when bitcoind is operational // We can only make this request when bitcoind is operational
if (state.operational) { if (state.operational) {
const addresses = await API.get(`api/v1/bitcoind/info/addresses`); const addresses = await API.get(`${process.env.VUE_APP_API_URL}api/v1/bitcoind/info/addresses`);
// Default onion address to not found. // Default onion address to not found.
commit('onionAddress', 'Could not determine bitcoin onion address'); commit('onionAddress', 'Could not determine bitcoin onion address');
@ -191,7 +191,7 @@ const actions = {
async getSync({ commit, state }) { async getSync({ commit, state }) {
if (state.operational) { if (state.operational) {
const sync = await API.get(`api/v1/bitcoind/info/sync`); const sync = await API.get(`${process.env.VUE_APP_API_URL}api/v1/bitcoind/info/sync`);
if (sync) { if (sync) {
commit('syncStatus', sync); commit('syncStatus', sync);
@ -201,7 +201,7 @@ const actions = {
async getVersion({ commit, state }) { async getVersion({ commit, state }) {
if (state.operational) { if (state.operational) {
const version = await API.get(`api/v1/bitcoind/info/version`); const version = await API.get(`${process.env.VUE_APP_API_URL}api/v1/bitcoind/info/version`);
if (version) { if (version) {
commit('setVersion', version); commit('setVersion', version);
@ -211,7 +211,7 @@ const actions = {
async getPeers({ commit, state }) { async getPeers({ commit, state }) {
if (state.operational) { if (state.operational) {
const peers = await API.get(`api/v1/bitcoind/info/connections`); const peers = await API.get(`${process.env.VUE_APP_API_URL}api/v1/bitcoind/info/connections`);
if (peers) { if (peers) {
commit('peers', peers); commit('peers', peers);
@ -221,7 +221,7 @@ const actions = {
async getBalance({ commit, state }) { async getBalance({ commit, state }) {
if (state.operational) { if (state.operational) {
const balance = await API.get(`api/v1/lnd/wallet/btc`); const balance = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/wallet/btc`);
if (balance) { if (balance) {
commit('balance', balance); commit('balance', balance);
@ -231,7 +231,7 @@ const actions = {
async getTransactions({ commit, state }) { async getTransactions({ commit, state }) {
if (state.operational) { if (state.operational) {
const transactions = await API.get(`api/v1/lnd/transaction`); const transactions = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/transaction`);
commit('transactions', transactions); commit('transactions', transactions);
} }
}, },
@ -247,7 +247,7 @@ const actions = {
async getDepositAddress({ commit, state }) { async getDepositAddress({ commit, state }) {
if (state.operational) { if (state.operational) {
const { address } = await API.get(`api/v1/lnd/address`); const { address } = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/address`);
if (address) { if (address) {
commit('depositAddress', address); commit('depositAddress', address);
@ -257,7 +257,7 @@ const actions = {
async getFees({ commit, state }, { address, confTarget, amt, sweep }) { async getFees({ commit, state }, { address, confTarget, amt, sweep }) {
if (state.operational) { if (state.operational) {
const fees = await API.get(`api/v1/lnd/transaction/estimateFee`, { const fees = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/transaction/estimateFee`, {
params: { address, confTarget, amt, sweep } params: { address, confTarget, amt, sweep }
}); });

18
src/store/modules/lightning.js

@ -99,14 +99,14 @@ const mutations = {
// Functions to get data from the API // Functions to get data from the API
const actions = { const actions = {
async getStatus({ commit }) { async getStatus({ commit }) {
const status = await API.get(`api/v1/lnd/info/status`); const status = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/info/status`);
commit('isOperational', status.operational); commit('isOperational', status.operational);
commit('isUnlocked', status.unlocked); commit('isUnlocked', status.unlocked);
// launch unlock modal after 30 sec // launch unlock modal after 30 sec
// if (!status.unlocked) { // if (!status.unlocked) {
// await sleep(30000); // await sleep(30000);
// const { unlocked } = await API.get(`api/v1/lnd/info/status`); // const { unlocked } = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/info/status`);
// commit('isUnlocked', unlocked); // commit('isUnlocked', unlocked);
// if (!unlocked) { // if (!unlocked) {
// Events.$emit('unlock-modal-open'); // Events.$emit('unlock-modal-open');
@ -115,7 +115,7 @@ const actions = {
}, },
async getLndPageData({ commit }) { async getLndPageData({ commit }) {
const lightning = await API.get(`api/v1/pages/lnd`); const lightning = await API.get(`${process.env.VUE_APP_API_URL}api/v1/pages/lnd`);
if (lightning) { if (lightning) {
const lightningInfo = lightning.lightningInfo; const lightningInfo = lightning.lightningInfo;
@ -125,7 +125,7 @@ const actions = {
}, },
async getConnectionCode({ commit }) { async getConnectionCode({ commit }) {
const uris = await API.get(`api/v1/lnd/info/uris`); const uris = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/info/uris`);
if (uris && uris.length > 0) { if (uris && uris.length > 0) {
commit('setConnectionCode', uris[0]); commit('setConnectionCode', uris[0]);
@ -139,7 +139,7 @@ const actions = {
// Instead we can calculate our total balance by getting the sum of each channel's localBalance // Instead we can calculate our total balance by getting the sum of each channel's localBalance
async getBalance({ commit, state }) { async getBalance({ commit, state }) {
if (state.operational && state.unlocked) { if (state.operational && state.unlocked) {
const balance = await API.get(`api/v1/lnd/wallet/lightning`); const balance = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/wallet/lightning`);
if (balance) { if (balance) {
commit('setBalance', { confirmed: balance.balance }); commit('setBalance', { confirmed: balance.balance });
@ -149,7 +149,7 @@ const actions = {
async getChannels({ commit, state }) { async getChannels({ commit, state }) {
if (state.operational && state.unlocked) { if (state.operational && state.unlocked) {
const rawChannels = await API.get(`api/v1/lnd/channel`); const rawChannels = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/channel`);
const channels = []; const channels = [];
let confirmedBalance = 0; let confirmedBalance = 0;
let pendingBalance = 0; let pendingBalance = 0;
@ -217,8 +217,8 @@ const actions = {
async getTransactions({ commit, state }) { async getTransactions({ commit, state }) {
if (state.operational && state.unlocked) { if (state.operational && state.unlocked) {
// Get invoices and payments // Get invoices and payments
const invoices = await API.get(`api/v1/lnd/lightning/invoices`); const invoices = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/invoices`);
const payments = await API.get(`api/v1/lnd/lightning/payments`); const payments = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/payments`);
let transactions = []; let transactions = [];
if (invoices) { if (invoices) {
@ -270,7 +270,7 @@ const actions = {
} else { } else {
try { try {
const invoiceDetails = await API.get( const invoiceDetails = await API.get(
`api/v1/lnd/lightning/invoice?paymentRequest=${tx.description}` `${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/invoice?paymentRequest=${tx.description}`
); );
tx.description = invoiceDetails.description; tx.description = invoiceDetails.description;
} catch (error) { } catch (error) {

2
src/store/modules/system.js

@ -18,7 +18,7 @@ const mutations = {
// Functions to get data from the API // Functions to get data from the API
const actions = { const actions = {
async getApi({ commit }) { async getApi({ commit }) {
const api = await API.get(`api/ping`); const api = await API.get(`${process.env.VUE_APP_API_URL}api/ping`);
commit('setApi', { commit('setApi', {
operational: !!(api && api.version), operational: !!(api && api.version),
version: api && api.version ? api.version : "" version: api && api.version ? api.version : ""

4
src/views/Lightning.vue

@ -226,7 +226,7 @@ export default {
created() { created() {
//Get LND Status //Get LND Status
// axios // axios
// .get(`api/v1/lnd/info/status`) // .get(`${process.env.VUE_APP_API_URL}api/v1/lnd/info/status`)
// .then(res => { // .then(res => {
// const { operational, unlocked } = res.data; // const { operational, unlocked } = res.data;
@ -249,7 +249,7 @@ export default {
// }); // });
//Get LND Info for showing stats //Get LND Info for showing stats
API.get(`api/v1/pages/lnd/`) API.get(`${process.env.VUE_APP_API_URL}api/v1/pages/lnd/`)
.then(res => { .then(res => {
this.state.pubKey = res.lightningInfo.identityPubkey; this.state.pubKey = res.lightningInfo.identityPubkey;
this.state.lndVersion = res.lightningInfo.version; this.state.lndVersion = res.lightningInfo.version;

6
vue.config.js

@ -8,7 +8,7 @@ module.exports = {
// } // }
// } // }
// } // }
devServer: { // devServer: {
proxy: 'http://umbrel.local/', // proxy: 'http://umbrel.local/',
} // }
} }
Loading…
Cancel
Save