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
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*

1
src/App.vue

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

5
src/components/BitcoinWallet.vue

@ -589,7 +589,10 @@ export default {
};
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;
this.state.withdraw.txHash = withdrawTx.txid;
this.changeMode("withdrawn");

12
src/components/LightningWallet.vue

@ -517,7 +517,10 @@ export default {
};
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) {
return (this.state.error = res.data.paymentError);
}
@ -557,7 +560,10 @@ export default {
};
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 =
res.data.paymentRequest;
@ -603,7 +609,7 @@ export default {
this.state.loading = true;
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) {

17
src/layouts/DashboardLayout.vue

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

18
src/store/modules/bitcoin.js

@ -158,7 +158,7 @@ const mutations = {
// Functions to get data from the API
const actions = {
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) {
commit('isOperational', status.operational);
@ -172,7 +172,7 @@ const actions = {
async getAddresses({ commit, state }) {
// We can only make this request when bitcoind is 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.
commit('onionAddress', 'Could not determine bitcoin onion address');
@ -191,7 +191,7 @@ const actions = {
async getSync({ commit, state }) {
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) {
commit('syncStatus', sync);
@ -201,7 +201,7 @@ const actions = {
async getVersion({ commit, state }) {
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) {
commit('setVersion', version);
@ -211,7 +211,7 @@ const actions = {
async getPeers({ commit, state }) {
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) {
commit('peers', peers);
@ -221,7 +221,7 @@ const actions = {
async getBalance({ commit, state }) {
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) {
commit('balance', balance);
@ -231,7 +231,7 @@ const actions = {
async getTransactions({ commit, state }) {
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);
}
},
@ -247,7 +247,7 @@ const actions = {
async getDepositAddress({ commit, state }) {
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) {
commit('depositAddress', address);
@ -257,7 +257,7 @@ const actions = {
async getFees({ commit, state }, { address, confTarget, amt, sweep }) {
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 }
});

18
src/store/modules/lightning.js

@ -99,14 +99,14 @@ const mutations = {
// Functions to get data from the API
const actions = {
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('isUnlocked', status.unlocked);
// launch unlock modal after 30 sec
// if (!status.unlocked) {
// 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);
// if (!unlocked) {
// Events.$emit('unlock-modal-open');
@ -115,7 +115,7 @@ const actions = {
},
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) {
const lightningInfo = lightning.lightningInfo;
@ -125,7 +125,7 @@ const actions = {
},
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) {
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
async getBalance({ commit, state }) {
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) {
commit('setBalance', { confirmed: balance.balance });
@ -149,7 +149,7 @@ const actions = {
async getChannels({ commit, state }) {
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 = [];
let confirmedBalance = 0;
let pendingBalance = 0;
@ -217,8 +217,8 @@ const actions = {
async getTransactions({ commit, state }) {
if (state.operational && state.unlocked) {
// Get invoices and payments
const invoices = await API.get(`api/v1/lnd/lightning/invoices`);
const payments = await API.get(`api/v1/lnd/lightning/payments`);
const invoices = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/invoices`);
const payments = await API.get(`${process.env.VUE_APP_API_URL}api/v1/lnd/lightning/payments`);
let transactions = [];
if (invoices) {
@ -270,7 +270,7 @@ const actions = {
} else {
try {
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;
} catch (error) {

2
src/store/modules/system.js

@ -18,7 +18,7 @@ const mutations = {
// Functions to get data from the API
const actions = {
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', {
operational: !!(api && api.version),
version: api && api.version ? api.version : ""

4
src/views/Lightning.vue

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

6
vue.config.js

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