diff --git a/app/background.js b/app/background.js index 93ae981..09c9281 100644 --- a/app/background.js +++ b/app/background.js @@ -1,579 +1,2 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/lib/applicationMenu.js": -/*!************************************!*\ - !*** ./src/lib/applicationMenu.js ***! - \************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ initApplicationMenu: () => (/* binding */ initApplicationMenu) -/* harmony export */ }); -/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electron */ "electron"); -/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_0__); - - -/** - * For configuring the electron window menu - */ -function initApplicationMenu(mainWindow) { - const template = [ - { - label: 'View', - submenu: [ - { - label: 'Send to tray', - click() { - mainWindow.minimize(); - } - }, - { label: 'Reload', role: 'reload' }, - { label: 'Dev tools', role: 'toggleDevTools' } - ] - } - ]; - const menu = electron__WEBPACK_IMPORTED_MODULE_0__.Menu.buildFromTemplate(template); - electron__WEBPACK_IMPORTED_MODULE_0__.Menu.setApplicationMenu(menu); -} - - -/***/ }), - -/***/ "./src/lib/deeplink.js": -/*!*****************************!*\ - !*** ./src/lib/deeplink.js ***! - \*****************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ generateDeepLink: () => (/* binding */ generateDeepLink) -/* harmony export */ }); -/* harmony import */ var bitsharesjs_ws__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! bitsharesjs-ws */ "bitsharesjs-ws"); -/* harmony import */ var bitsharesjs_ws__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(bitsharesjs_ws__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var bitsharesjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! bitsharesjs */ "bitsharesjs"); -/* harmony import */ var bitsharesjs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(bitsharesjs__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uuid */ "uuid"); -/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_2__); - - - - -const chains = { - bitshares: { - nodeList: [ - { - url: "wss://node.xbts.io/ws", - }, - { - url: "wss://api.bts.mobi/ws", - }, - { - url: "wss://api.bitshares.bhuz.info/ws", - }, - { - url: "wss://btsws.roelandp.nl/ws", - }, - ], - }, - bitshares_testnet: { - nodeList: [ - { - url: "wss://testnet.dex.trading/", - }, - { - url: "wss://testnet.xbts.io/ws", - }, - { - url: "wss://api-testnet.61bts.com/ws", - }, - ], - }, -}; - -async function generateDeepLink(chain, opType, operations) { - return new Promise(async (resolve, reject) => { - const _node = chains[chain].nodeList[0].url - - try { - await bitsharesjs_ws__WEBPACK_IMPORTED_MODULE_0__.Apis.instance( - _node, - true, - 4000, - { enableCrypto: false, enableOrders: true }, - (error) => console.log({ error }) - ).init_promise; - } catch (error) { - console.log({ error, location: "api instance failed" }); - return reject(error); - } - - const tr = new bitsharesjs__WEBPACK_IMPORTED_MODULE_1__.TransactionBuilder(); - for (let i = 0; i < operations.length; i++) { - tr.add_type_operation(opType, operations[i]); - } - - try { - await tr.update_head_block(); - } catch (error) { - console.log({ error, location: "update head block failed" }); - reject(error); - return; - } - - try { - await tr.set_required_fees(); - } catch (error) { - console.log({ error, location: "set required fees failed" }); - reject(error); - return; - } - - try { - tr.set_expire_seconds(7200); - } catch (error) { - console.log({ error, location: "set expire seconds failed" }); - reject(error); - return; - } - - try { - tr.finalize(); - } catch (error) { - console.log({ error, location: "finalize failed" }); - reject(error); - return; - } - - let id; - try { - id = await (0,uuid__WEBPACK_IMPORTED_MODULE_2__.v4)(); - } catch (error) { - console.log({ error, location: "uuid generation failed" }); - reject(error); - return; - } - - const request = { - type: "api", - id: id, - payload: { - method: "injectedCall", - params: ["signAndBroadcast", JSON.stringify(tr.toObject()), []], - appName: "Bitshares Astro UI", - chain: chain === "bitshares" ? "BTS" : "BTS_TEST", - browser: "web browser", - origin: "localhost", - }, - }; - - let encodedPayload; - try { - encodedPayload = encodeURIComponent(JSON.stringify(request)); - } catch (error) { - console.log({ error, location: "encode payload failed" }); - reject(error); - return; - } - - resolve(encodedPayload); - }); -} - - - -/***/ }), - -/***/ "bitsharesjs": -/*!******************************!*\ - !*** external "bitsharesjs" ***! - \******************************/ -/***/ ((module) => { - -module.exports = require("bitsharesjs"); - -/***/ }), - -/***/ "bitsharesjs-ws": -/*!*********************************!*\ - !*** external "bitsharesjs-ws" ***! - \*********************************/ -/***/ ((module) => { - -module.exports = require("bitsharesjs-ws"); - -/***/ }), - -/***/ "electron": -/*!***************************!*\ - !*** external "electron" ***! - \***************************/ -/***/ ((module) => { - -module.exports = require("electron"); - -/***/ }), - -/***/ "express": -/*!**************************!*\ - !*** external "express" ***! - \**************************/ -/***/ ((module) => { - -module.exports = require("express"); - -/***/ }), - -/***/ "uuid": -/*!***********************!*\ - !*** external "uuid" ***! - \***********************/ -/***/ ((module) => { - -module.exports = require("uuid"); - -/***/ }), - -/***/ "os": -/*!*********************!*\ - !*** external "os" ***! - \*********************/ -/***/ ((module) => { - -module.exports = require("os"); - -/***/ }), - -/***/ "path": -/*!***********************!*\ - !*** external "path" ***! - \***********************/ -/***/ ((module) => { - -module.exports = require("path"); - -/***/ }), - -/***/ "url": -/*!**********************!*\ - !*** external "url" ***! - \**********************/ -/***/ ((module) => { - -module.exports = require("url"); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -/*!***************************!*\ - !*** ./src/background.js ***! - \***************************/ -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ "path"); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! os */ "os"); -/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! url */ "url"); -/* harmony import */ var url__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(url__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! express */ "express"); -/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(express__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! electron */ "electron"); -/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _lib_applicationMenu_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./lib/applicationMenu.js */ "./src/lib/applicationMenu.js"); -/* harmony import */ var _lib_deeplink_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lib/deeplink.js */ "./src/lib/deeplink.js"); - - - - - - - - - - -let mainWindow = null; -let tray = null; - -const createWindow = async () => { - const { width, height } = electron__WEBPACK_IMPORTED_MODULE_4__.screen.getPrimaryDisplay().workAreaSize; - - mainWindow = new electron__WEBPACK_IMPORTED_MODULE_4__.BrowserWindow({ - width: width, - height: height, - minWidth: 480, - minHeight: 695, - maxWidth: width, - maximizable: true, - maxHeight: height, - useContentSize: true, - autoHideMenuBar: true, - webPreferences: { - nodeIntegration: false, - contextIsolation: true, - sandbox: true, - preload: path__WEBPACK_IMPORTED_MODULE_0___default().join(__dirname, "preload.js"), - }, - icon: __dirname + "/img/taskbar.png", - }); - - const expressApp = express__WEBPACK_IMPORTED_MODULE_3___default()(); - expressApp.use(express__WEBPACK_IMPORTED_MODULE_3___default()["static"]('astroDist')); - expressApp.listen(8080, () => { - console.log("Express server listening on port 8080"); - }); - - (0,_lib_applicationMenu_js__WEBPACK_IMPORTED_MODULE_5__.initApplicationMenu)(mainWindow); - - mainWindow.loadURL('http://localhost:8080/index.html'); - - tray = new electron__WEBPACK_IMPORTED_MODULE_4__.Tray(path__WEBPACK_IMPORTED_MODULE_0___default().join(__dirname, "img", "tray.png")); - const contextMenu = electron__WEBPACK_IMPORTED_MODULE_4__.Menu.buildFromTemplate([ - { - label: "Show App", - click: function () { - mainWindow?.show(); - }, - }, - { - label: "Quit", - click: function () { - tray = null; - electron__WEBPACK_IMPORTED_MODULE_4__.app.quit(); - }, - }, - ]); - - tray.setToolTip("Bitshares Astro UI"); - - tray.on("right-click", (event, bounds) => { - tray?.popUpContextMenu(contextMenu); - }); - - electron__WEBPACK_IMPORTED_MODULE_4__.ipcMain.handle("fetchTopMarkets", async (event, arg) => { - const { chain } = arg; - - let retrievedData; - try { - retrievedData = await fetch( - chain === "bitshares" - ? `https://api.bitshares.ws/openexplorer/top_markets?top_n=100` - : `https://api.testnet.bitshares.ws/openexplorer/top_markets?top_n=50` - ); - } catch (error) { - console.log({error}) - } - - if (!retrievedData || !retrievedData.ok) { - console.log("Failed to fetch top markets"); - return; - } - - const topMarkets = await retrievedData.json(); - return topMarkets ?? null; - }); - - electron__WEBPACK_IMPORTED_MODULE_4__.ipcMain.handle("fetchAccountHistory", async (event, arg) => { - const { chain, accountID } = arg; - - const from = arg.from ?? 0; - const size = arg.size ?? 100; - const from_date = arg.from_date ?? "2015-10-10"; - const to_date = arg.to_date ?? "now"; - const sort_by = arg.sort_by ?? "-operation_id_num"; - const type = arg.type ?? "data"; - const agg_field = arg.agg_field ?? "operation_type"; - - const url = `https://${ - chain === "bitshares" ? "api" : "api.testnet" - }.bitshares.ws/openexplorer/es/account_history` + - `?account_id=${accountID}` + - `&from_=${from}` + - `&size=${size}` + - `&from_date=${from_date}` + - `&to_date=${to_date}` + - `&sort_by=${sort_by}` + - `&type=${type}` + - `&agg_field=${agg_field}`; - - let history; - try { - history = await fetch(url, { method: "GET" }); - } catch (error) { - console.log({ error }); - return null; - } - - if (!history || !history.ok) { - console.log("Couldn't fetch account history."); - return null; - } - - const accountHistory = await history.json(); - return accountHistory ?? null; - }); - - electron__WEBPACK_IMPORTED_MODULE_4__.ipcMain.handle("generateDeepLink", async (event, arg) => { - const { usrChain, operationName, trxJSON } = arg; - - let deeplink; - try { - deeplink = await (0,_lib_deeplink_js__WEBPACK_IMPORTED_MODULE_6__.generateDeepLink)(usrChain, operationName, trxJSON); - } catch (error) { - console.log({ error }); - } - - return deeplink ?? null; - }); - - const safeDomains = [ - "https://blocksights.info/", - "https://bts.exchange/", - "https://ex.xbts.io/", - "https://kibana.bts.mobi/", - "https://www.bitsharescan.info/", - "https://github.com/bitshares/beet", - ]; - electron__WEBPACK_IMPORTED_MODULE_4__.ipcMain.on("openURL", (event, arg) => { - try { - const parsedUrl = new (url__WEBPACK_IMPORTED_MODULE_2___default().URL)(arg); - const domain = parsedUrl.hostname; - console.log({arg, domain}) - - const isSafeDomain = safeDomains.some(safeDomain => { - const safeDomainHostname = new (url__WEBPACK_IMPORTED_MODULE_2___default().URL)(safeDomain).hostname; - return safeDomainHostname === domain; - }); - - if (isSafeDomain) { - electron__WEBPACK_IMPORTED_MODULE_4__.shell.openExternal(arg); - } else { - console.error( - `Rejected opening URL with unsafe domain: ${domain}` - ); - } - } catch (err) { - console.error(`Failed to open URL: ${err.message}`); - } - }); - - tray.on("click", () => { - mainWindow?.setAlwaysOnTop(true); - mainWindow?.show(); - mainWindow?.focus(); - mainWindow?.setAlwaysOnTop(false); - }); - - tray.on("balloon-click", () => { - mainWindow?.setAlwaysOnTop(true); - mainWindow?.show(); - mainWindow?.focus(); - mainWindow?.setAlwaysOnTop(false); - }); -}; - -electron__WEBPACK_IMPORTED_MODULE_4__.app.disableHardwareAcceleration(); - -const currentOS = os__WEBPACK_IMPORTED_MODULE_1___default().platform(); -if (currentOS === "win32" || currentOS === "linux") { - // windows + linux setup phase - const gotTheLock = electron__WEBPACK_IMPORTED_MODULE_4__.app.requestSingleInstanceLock(); - - if (!gotTheLock) { - electron__WEBPACK_IMPORTED_MODULE_4__.app.quit(); - } - - electron__WEBPACK_IMPORTED_MODULE_4__.app.whenReady().then(() => { - createWindow(); - }); -} else { - electron__WEBPACK_IMPORTED_MODULE_4__.app.whenReady().then(() => { - createWindow(); - }); - - electron__WEBPACK_IMPORTED_MODULE_4__.app.on("window-all-closed", () => { - if (process.platform !== "darwin") { - electron__WEBPACK_IMPORTED_MODULE_4__.app.quit(); - } - }); - - electron__WEBPACK_IMPORTED_MODULE_4__.app.on("activate", () => { - if (mainWindow === null) { - createWindow(); - } - }); -} - -/******/ })() -; +(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=require("path");var o=e.n(t);const n=require("os");var r=e.n(n);const s=require("url");var a=e.n(s);const i=require("express");var l=e.n(i);const c=require("electron"),p=require("bitsharesjs-ws"),d=require("bitsharesjs"),h=require("uuid"),u={bitshares:{nodeList:[{url:"wss://node.xbts.io/ws"},{url:"wss://api.bts.mobi/ws"},{url:"wss://api.bitshares.bhuz.info/ws"},{url:"wss://btsws.roelandp.nl/ws"}]},bitshares_testnet:{nodeList:[{url:"wss://testnet.dex.trading/"},{url:"wss://testnet.xbts.io/ws"},{url:"wss://api-testnet.61bts.com/ws"}]}};let w=null,b=null;const m=async()=>{const{width:e,height:t}=c.screen.getPrimaryDisplay().workAreaSize;w=new c.BrowserWindow({width:e,height:t,minWidth:480,minHeight:695,maxWidth:e,maximizable:!0,maxHeight:t,useContentSize:!0,autoHideMenuBar:!0,webPreferences:{nodeIntegration:!1,contextIsolation:!0,sandbox:!0,preload:o().join(__dirname,"preload.js")},icon:__dirname+"/img/taskbar.png"});const n=l()();let r;r=o().join(process.resourcesPath,"astroDist"),n.use(l().static(r)),n.listen(8080,(()=>{console.log("Express server listening on port 8080")})),function(e){const t=[{label:"View",submenu:[{label:"Send to tray",click(){e.minimize()}},{label:"Reload",role:"reload"},{label:"Dev tools",role:"toggleDevTools"}]}],o=c.Menu.buildFromTemplate(t);c.Menu.setApplicationMenu(o)}(w),w.loadURL("http://localhost:8080/index.html"),b=new c.Tray(o().join(__dirname,"img","tray.png"));const s=c.Menu.buildFromTemplate([{label:"Show App",click:function(){w?.show()}},{label:"Quit",click:function(){b=null,c.app.quit()}}]);b.setToolTip("Bitshares Astro UI"),b.on("right-click",((e,t)=>{b?.popUpContextMenu(s)})),c.ipcMain.handle("fetchTopMarkets",(async(e,t)=>{const{chain:o}=t;let n;try{n=await fetch("bitshares"===o?"https://api.bitshares.ws/openexplorer/top_markets?top_n=100":"https://api.testnet.bitshares.ws/openexplorer/top_markets?top_n=50")}catch(e){console.log({error:e})}if(n&&n.ok)return await n.json()??null;console.log("Failed to fetch top markets")})),c.ipcMain.handle("fetchAccountHistory",(async(e,t)=>{const{chain:o,accountID:n}=t,r=`https://${"bitshares"===o?"api":"api.testnet"}.bitshares.ws/openexplorer/es/account_history?account_id=${n}&from_=${t.from??0}&size=${t.size??100}&from_date=${t.from_date??"2015-10-10"}&to_date=${t.to_date??"now"}&sort_by=${t.sort_by??"-operation_id_num"}&type=${t.type??"data"}&agg_field=${t.agg_field??"operation_type"}`;let s;try{s=await fetch(r,{method:"GET"})}catch(e){return console.log({error:e}),null}return s&&s.ok?await s.json()??null:(console.log("Couldn't fetch account history."),null)})),c.ipcMain.handle("generateDeepLink",(async(e,t)=>{const{usrChain:o,operationName:n,trxJSON:r}=t;let s;try{s=await async function(e,t,o){return new Promise((async(n,r)=>{const s=u[e].nodeList[0].url;try{await p.Apis.instance(s,!0,4e3,{enableCrypto:!1,enableOrders:!0},(e=>console.log({error:e}))).init_promise}catch(e){return console.log({error:e,location:"api instance failed"}),r(e)}const a=new d.TransactionBuilder;for(let e=0;e{try{const e=new(a().URL)(t).hostname;i.some((t=>new(a().URL)(t).hostname===e))?c.shell.openExternal(t):console.error(`Rejected opening URL with unsafe domain: ${e}`)}catch(e){console.error(`Failed to open URL: ${e.message}`)}})),b.on("click",(()=>{w?.setAlwaysOnTop(!0),w?.show(),w?.focus(),w?.setAlwaysOnTop(!1)})),b.on("balloon-click",(()=>{w?.setAlwaysOnTop(!0),w?.show(),w?.focus(),w?.setAlwaysOnTop(!1)}))};c.app.disableHardwareAcceleration();const g=r().platform();"win32"===g||"linux"===g?(c.app.requestSingleInstanceLock()||c.app.quit(),c.app.whenReady().then((()=>{m()}))):(c.app.whenReady().then((()=>{m()})),c.app.on("window-all-closed",(()=>{"darwin"!==process.platform&&c.app.quit()})),c.app.on("activate",(()=>{null===w&&m()})))})(); //# sourceMappingURL=background.js.map \ No newline at end of file diff --git a/app/background.js.map b/app/background.js.map index 54b53c7..cb44538 100644 --- a/app/background.js.map +++ b/app/background.js.map @@ -1 +1 @@ -{"version":3,"file":"background.js","mappings":";;;;;;;;;;;;;;;;AAAmC;AACnC;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,YAAY,iCAAiC;AAC7C,YAAY;AACZ;AACA;AACA;AACA,iBAAiB,0CAAI;AACrB,IAAI,0CAAI;AACR;;;;;;;;;;;;;;;;;;;;;ACvBsC;AACW;AACb;AACpC;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA;AACA,aAAa;AACb;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,gDAAI;AACtB;AACA;AACA;AACA,kBAAkB,yCAAyC;AAC3D,yCAAyC,OAAO;AAChD;AACA,UAAU;AACV,0BAA0B,wCAAwC;AAClE;AACA;AACA;AACA,uBAAuB,2DAAkB;AACzC,wBAAwB,uBAAuB;AAC/C;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,0BAA0B,6CAA6C;AACvE;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,0BAA0B,6CAA6C;AACvE;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,0BAA0B,8CAA8C;AACxE;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,0BAA0B,oCAAoC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,wCAAM;AAC7B,UAAU;AACV,0BAA0B,2CAA2C;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,0BAA0B,0CAA0C;AACpE;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;;;;;;;;;;AC5HA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;;;;;;ACNwB;AACJ;AACE;AACQ;AAC9B;AASkB;AAClB;AAC+D;AACV;AACrD;AACA;AACA;AACA;AACA;AACA,YAAY,gBAAgB,EAAE,4CAAM;AACpC;AACA,qBAAqB,mDAAa;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,gDAAS;AAC9B,SAAS;AACT;AACA,KAAK;AACL;AACA,uBAAuB,8CAAO;AAC9B,mBAAmB,wDAAc;AACjC;AACA;AACA,KAAK;AACL;AACA,IAAI,4EAAmB;AACvB;AACA;AACA;AACA,eAAe,0CAAI,CAAC,gDAAS;AAC7B,wBAAwB,0CAAI;AAC5B;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA,gBAAgB,yCAAG;AACnB,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,IAAI,6CAAO;AACX,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,yBAAyB,MAAM;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,IAAI,6CAAO;AACX,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,mCAAmC,UAAU;AAC7C,8BAA8B,KAAK;AACnC,6BAA6B,KAAK;AAClC,kCAAkC,UAAU;AAC5C,gCAAgC,QAAQ;AACxC,gCAAgC,QAAQ;AACxC,6BAA6B,KAAK;AAClC,kCAAkC,UAAU;AAC5C;AACA;AACA;AACA,yCAAyC,eAAe;AACxD,UAAU;AACV,0BAA0B,OAAO;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,IAAI,6CAAO;AACX,gBAAgB,mCAAmC;AACnD;AACA;AACA;AACA,6BAA6B,kEAAgB;AAC7C,UAAU;AACV,0BAA0B,OAAO;AACjC;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,6CAAO;AACX;AACA,kCAAkC,gDAAO;AACzC;AACA,yBAAyB,YAAY;AACrC;AACA;AACA,+CAA+C,gDAAO;AACtD;AACA,aAAa;AACb;AACA;AACA,gBAAgB,2CAAK;AACrB,cAAc;AACd;AACA,gEAAgE,OAAO;AACvE;AACA;AACA,UAAU;AACV,iDAAiD,YAAY;AAC7D;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,yCAAG;AACH;AACA,kBAAkB,kDAAW;AAC7B;AACA;AACA,uBAAuB,yCAAG;AAC1B;AACA;AACA,QAAQ,yCAAG;AACX;AACA;AACA,IAAI,yCAAG;AACP;AACA,KAAK;AACL,EAAE;AACF,IAAI,yCAAG;AACP;AACA,KAAK;AACL;AACA,IAAI,yCAAG;AACP;AACA,YAAY,yCAAG;AACf;AACA,KAAK;AACL;AACA,IAAI,yCAAG;AACP;AACA;AACA;AACA,KAAK;AACL","sources":["webpack://bitshares_astro_ui/./src/lib/applicationMenu.js","webpack://bitshares_astro_ui/./src/lib/deeplink.js","webpack://bitshares_astro_ui/external commonjs \"bitsharesjs\"","webpack://bitshares_astro_ui/external commonjs \"bitsharesjs-ws\"","webpack://bitshares_astro_ui/external commonjs \"electron\"","webpack://bitshares_astro_ui/external commonjs \"express\"","webpack://bitshares_astro_ui/external commonjs \"uuid\"","webpack://bitshares_astro_ui/external node-commonjs \"os\"","webpack://bitshares_astro_ui/external node-commonjs \"path\"","webpack://bitshares_astro_ui/external node-commonjs \"url\"","webpack://bitshares_astro_ui/webpack/bootstrap","webpack://bitshares_astro_ui/webpack/runtime/compat get default export","webpack://bitshares_astro_ui/webpack/runtime/define property getters","webpack://bitshares_astro_ui/webpack/runtime/hasOwnProperty shorthand","webpack://bitshares_astro_ui/webpack/runtime/make namespace object","webpack://bitshares_astro_ui/./src/background.js"],"sourcesContent":["import {app, Menu} from 'electron';\r\n\r\n/**\r\n * For configuring the electron window menu\r\n */\r\nexport function initApplicationMenu(mainWindow) {\r\n const template = [\r\n {\r\n label: 'View',\r\n submenu: [\r\n {\r\n label: 'Send to tray',\r\n click() {\r\n mainWindow.minimize();\r\n }\r\n },\r\n { label: 'Reload', role: 'reload' },\r\n { label: 'Dev tools', role: 'toggleDevTools' }\r\n ]\r\n }\r\n ];\r\n const menu = Menu.buildFromTemplate(template);\r\n Menu.setApplicationMenu(menu);\r\n}\r\n","import { Apis } from \"bitsharesjs-ws\";\r\nimport { TransactionBuilder } from \"bitsharesjs\";\r\nimport { v4 as uuidv4 } from \"uuid\";\r\n\r\nconst chains = {\r\n bitshares: {\r\n nodeList: [\r\n {\r\n url: \"wss://node.xbts.io/ws\",\r\n },\r\n {\r\n url: \"wss://api.bts.mobi/ws\",\r\n },\r\n {\r\n url: \"wss://api.bitshares.bhuz.info/ws\",\r\n },\r\n {\r\n url: \"wss://btsws.roelandp.nl/ws\",\r\n },\r\n ],\r\n },\r\n bitshares_testnet: {\r\n nodeList: [\r\n {\r\n url: \"wss://testnet.dex.trading/\",\r\n },\r\n {\r\n url: \"wss://testnet.xbts.io/ws\",\r\n },\r\n {\r\n url: \"wss://api-testnet.61bts.com/ws\",\r\n },\r\n ],\r\n },\r\n};\r\n\r\nasync function generateDeepLink(chain, opType, operations) {\r\n return new Promise(async (resolve, reject) => {\r\n const _node = chains[chain].nodeList[0].url\r\n\r\n try {\r\n await Apis.instance(\r\n _node,\r\n true,\r\n 4000,\r\n { enableCrypto: false, enableOrders: true },\r\n (error) => console.log({ error })\r\n ).init_promise;\r\n } catch (error) {\r\n console.log({ error, location: \"api instance failed\" });\r\n return reject(error);\r\n }\r\n\r\n const tr = new TransactionBuilder();\r\n for (let i = 0; i < operations.length; i++) {\r\n tr.add_type_operation(opType, operations[i]);\r\n }\r\n\r\n try {\r\n await tr.update_head_block();\r\n } catch (error) {\r\n console.log({ error, location: \"update head block failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n try {\r\n await tr.set_required_fees();\r\n } catch (error) {\r\n console.log({ error, location: \"set required fees failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n try {\r\n tr.set_expire_seconds(7200);\r\n } catch (error) {\r\n console.log({ error, location: \"set expire seconds failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n try {\r\n tr.finalize();\r\n } catch (error) {\r\n console.log({ error, location: \"finalize failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n let id;\r\n try {\r\n id = await uuidv4();\r\n } catch (error) {\r\n console.log({ error, location: \"uuid generation failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n const request = {\r\n type: \"api\",\r\n id: id,\r\n payload: {\r\n method: \"injectedCall\",\r\n params: [\"signAndBroadcast\", JSON.stringify(tr.toObject()), []],\r\n appName: \"Bitshares Astro UI\",\r\n chain: chain === \"bitshares\" ? \"BTS\" : \"BTS_TEST\",\r\n browser: \"web browser\",\r\n origin: \"localhost\",\r\n },\r\n };\r\n\r\n let encodedPayload;\r\n try {\r\n encodedPayload = encodeURIComponent(JSON.stringify(request));\r\n } catch (error) {\r\n console.log({ error, location: \"encode payload failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n resolve(encodedPayload);\r\n });\r\n}\r\n\r\nexport { generateDeepLink };","module.exports = require(\"bitsharesjs\");","module.exports = require(\"bitsharesjs-ws\");","module.exports = require(\"electron\");","module.exports = require(\"express\");","module.exports = require(\"uuid\");","module.exports = require(\"os\");","module.exports = require(\"path\");","module.exports = require(\"url\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import path from \"path\";\r\nimport os from \"os\";\r\nimport url from \"url\";\r\nimport express from \"express\";\r\n\r\nimport {\r\n app,\r\n BrowserWindow,\r\n Menu,\r\n Tray,\r\n ipcMain,\r\n screen,\r\n shell,\r\n} from \"electron\";\r\n\r\nimport { initApplicationMenu } from \"./lib/applicationMenu.js\";\r\nimport { generateDeepLink } from \"./lib/deeplink.js\";\r\n\r\nlet mainWindow = null;\r\nlet tray = null;\r\n\r\nconst createWindow = async () => {\r\n const { width, height } = screen.getPrimaryDisplay().workAreaSize;\r\n\r\n mainWindow = new BrowserWindow({\r\n width: width,\r\n height: height,\r\n minWidth: 480,\r\n minHeight: 695,\r\n maxWidth: width,\r\n maximizable: true,\r\n maxHeight: height,\r\n useContentSize: true,\r\n autoHideMenuBar: true,\r\n webPreferences: {\r\n nodeIntegration: false,\r\n contextIsolation: true,\r\n sandbox: true,\r\n preload: path.join(__dirname, \"preload.js\"),\r\n },\r\n icon: __dirname + \"/img/taskbar.png\",\r\n });\r\n \r\n const expressApp = express();\r\n expressApp.use(express.static('astroDist'));\r\n expressApp.listen(8080, () => {\r\n console.log(\"Express server listening on port 8080\");\r\n });\r\n\r\n initApplicationMenu(mainWindow);\r\n\r\n mainWindow.loadURL('http://localhost:8080/index.html');\r\n\r\n tray = new Tray(path.join(__dirname, \"img\", \"tray.png\"));\r\n const contextMenu = Menu.buildFromTemplate([\r\n {\r\n label: \"Show App\",\r\n click: function () {\r\n mainWindow?.show();\r\n },\r\n },\r\n {\r\n label: \"Quit\",\r\n click: function () {\r\n tray = null;\r\n app.quit();\r\n },\r\n },\r\n ]);\r\n\r\n tray.setToolTip(\"Bitshares Astro UI\");\r\n\r\n tray.on(\"right-click\", (event, bounds) => {\r\n tray?.popUpContextMenu(contextMenu);\r\n });\r\n\r\n ipcMain.handle(\"fetchTopMarkets\", async (event, arg) => {\r\n const { chain } = arg;\r\n\r\n let retrievedData;\r\n try {\r\n retrievedData = await fetch(\r\n chain === \"bitshares\"\r\n ? `https://api.bitshares.ws/openexplorer/top_markets?top_n=100`\r\n : `https://api.testnet.bitshares.ws/openexplorer/top_markets?top_n=50`\r\n );\r\n } catch (error) {\r\n console.log({error})\r\n }\r\n \r\n if (!retrievedData || !retrievedData.ok) {\r\n console.log(\"Failed to fetch top markets\");\r\n return;\r\n }\r\n \r\n const topMarkets = await retrievedData.json();\r\n return topMarkets ?? null;\r\n });\r\n\r\n ipcMain.handle(\"fetchAccountHistory\", async (event, arg) => {\r\n const { chain, accountID } = arg;\r\n\r\n const from = arg.from ?? 0;\r\n const size = arg.size ?? 100;\r\n const from_date = arg.from_date ?? \"2015-10-10\";\r\n const to_date = arg.to_date ?? \"now\";\r\n const sort_by = arg.sort_by ?? \"-operation_id_num\";\r\n const type = arg.type ?? \"data\";\r\n const agg_field = arg.agg_field ?? \"operation_type\";\r\n\r\n const url = `https://${\r\n chain === \"bitshares\" ? \"api\" : \"api.testnet\"\r\n }.bitshares.ws/openexplorer/es/account_history` +\r\n `?account_id=${accountID}` +\r\n `&from_=${from}` +\r\n `&size=${size}` +\r\n `&from_date=${from_date}` +\r\n `&to_date=${to_date}` +\r\n `&sort_by=${sort_by}` +\r\n `&type=${type}` +\r\n `&agg_field=${agg_field}`;\r\n\r\n let history;\r\n try {\r\n history = await fetch(url, { method: \"GET\" });\r\n } catch (error) {\r\n console.log({ error });\r\n return null;\r\n }\r\n\r\n if (!history || !history.ok) {\r\n console.log(\"Couldn't fetch account history.\");\r\n return null;\r\n }\r\n\r\n const accountHistory = await history.json(); \r\n return accountHistory ?? null;\r\n });\r\n\r\n ipcMain.handle(\"generateDeepLink\", async (event, arg) => {\r\n const { usrChain, operationName, trxJSON } = arg;\r\n\r\n let deeplink;\r\n try {\r\n deeplink = await generateDeepLink(usrChain, operationName, trxJSON);\r\n } catch (error) {\r\n console.log({ error });\r\n }\r\n\r\n return deeplink ?? null;\r\n });\r\n\r\n const safeDomains = [\r\n \"https://blocksights.info/\",\r\n \"https://bts.exchange/\",\r\n \"https://ex.xbts.io/\",\r\n \"https://kibana.bts.mobi/\",\r\n \"https://www.bitsharescan.info/\",\r\n \"https://github.com/bitshares/beet\",\r\n ];\r\n ipcMain.on(\"openURL\", (event, arg) => {\r\n try {\r\n const parsedUrl = new url.URL(arg);\r\n const domain = parsedUrl.hostname;\r\n console.log({arg, domain})\r\n\r\n const isSafeDomain = safeDomains.some(safeDomain => {\r\n const safeDomainHostname = new url.URL(safeDomain).hostname;\r\n return safeDomainHostname === domain;\r\n });\r\n\r\n if (isSafeDomain) {\r\n shell.openExternal(arg);\r\n } else {\r\n console.error(\r\n `Rejected opening URL with unsafe domain: ${domain}`\r\n );\r\n }\r\n } catch (err) {\r\n console.error(`Failed to open URL: ${err.message}`);\r\n }\r\n }); \r\n\r\n tray.on(\"click\", () => {\r\n mainWindow?.setAlwaysOnTop(true);\r\n mainWindow?.show();\r\n mainWindow?.focus();\r\n mainWindow?.setAlwaysOnTop(false);\r\n });\r\n\r\n tray.on(\"balloon-click\", () => {\r\n mainWindow?.setAlwaysOnTop(true);\r\n mainWindow?.show();\r\n mainWindow?.focus();\r\n mainWindow?.setAlwaysOnTop(false);\r\n });\r\n};\r\n\r\napp.disableHardwareAcceleration();\r\n\r\nconst currentOS = os.platform();\r\nif (currentOS === \"win32\" || currentOS === \"linux\") {\r\n // windows + linux setup phase\r\n const gotTheLock = app.requestSingleInstanceLock();\r\n\r\n if (!gotTheLock) {\r\n app.quit();\r\n }\r\n\r\n app.whenReady().then(() => {\r\n createWindow();\r\n });\r\n} else {\r\n app.whenReady().then(() => {\r\n createWindow();\r\n });\r\n\r\n app.on(\"window-all-closed\", () => {\r\n if (process.platform !== \"darwin\") {\r\n app.quit();\r\n }\r\n });\r\n\r\n app.on(\"activate\", () => {\r\n if (mainWindow === null) {\r\n createWindow();\r\n }\r\n });\r\n}\r\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"background.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KA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IG,GAAG,qBAAqB,KACC,WAArBxB,QAAQqG,UACR,EAAAhF,IAAIC,MACR,IAGJ,EAAAD,IAAIG,GAAG,YAAY,KACI,OAAflD,GACAE,GACJ,I","sources":["webpack://bitshares_astro_ui/webpack/bootstrap","webpack://bitshares_astro_ui/webpack/runtime/compat get default export","webpack://bitshares_astro_ui/webpack/runtime/define property getters","webpack://bitshares_astro_ui/webpack/runtime/hasOwnProperty shorthand","webpack://bitshares_astro_ui/external node-commonjs \"path\"","webpack://bitshares_astro_ui/external node-commonjs \"os\"","webpack://bitshares_astro_ui/external node-commonjs \"url\"","webpack://bitshares_astro_ui/external commonjs \"express\"","webpack://bitshares_astro_ui/external commonjs \"electron\"","webpack://bitshares_astro_ui/external commonjs \"bitsharesjs-ws\"","webpack://bitshares_astro_ui/external commonjs \"bitsharesjs\"","webpack://bitshares_astro_ui/external commonjs \"uuid\"","webpack://bitshares_astro_ui/./src/lib/deeplink.js","webpack://bitshares_astro_ui/./src/background.js","webpack://bitshares_astro_ui/./src/lib/applicationMenu.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"path\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"os\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"url\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"express\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"electron\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"bitsharesjs-ws\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"bitsharesjs\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"uuid\");","import { Apis } from \"bitsharesjs-ws\";\r\nimport { TransactionBuilder } from \"bitsharesjs\";\r\nimport { v4 as uuidv4 } from \"uuid\";\r\n\r\nconst chains = {\r\n bitshares: {\r\n nodeList: [\r\n {\r\n url: \"wss://node.xbts.io/ws\",\r\n },\r\n {\r\n url: \"wss://api.bts.mobi/ws\",\r\n },\r\n {\r\n url: \"wss://api.bitshares.bhuz.info/ws\",\r\n },\r\n {\r\n url: \"wss://btsws.roelandp.nl/ws\",\r\n },\r\n ],\r\n },\r\n bitshares_testnet: {\r\n nodeList: [\r\n {\r\n url: \"wss://testnet.dex.trading/\",\r\n },\r\n {\r\n url: \"wss://testnet.xbts.io/ws\",\r\n },\r\n {\r\n url: \"wss://api-testnet.61bts.com/ws\",\r\n },\r\n ],\r\n },\r\n};\r\n\r\nasync function generateDeepLink(chain, opType, operations) {\r\n return new Promise(async (resolve, reject) => {\r\n const _node = chains[chain].nodeList[0].url\r\n\r\n try {\r\n await Apis.instance(\r\n _node,\r\n true,\r\n 4000,\r\n { enableCrypto: false, enableOrders: true },\r\n (error) => console.log({ error })\r\n ).init_promise;\r\n } catch (error) {\r\n console.log({ error, location: \"api instance failed\" });\r\n return reject(error);\r\n }\r\n\r\n const tr = new TransactionBuilder();\r\n for (let i = 0; i < operations.length; i++) {\r\n tr.add_type_operation(opType, operations[i]);\r\n }\r\n\r\n try {\r\n await tr.update_head_block();\r\n } catch (error) {\r\n console.log({ error, location: \"update head block failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n try {\r\n await tr.set_required_fees();\r\n } catch (error) {\r\n console.log({ error, location: \"set required fees failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n try {\r\n tr.set_expire_seconds(7200);\r\n } catch (error) {\r\n console.log({ error, location: \"set expire seconds failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n try {\r\n tr.finalize();\r\n } catch (error) {\r\n console.log({ error, location: \"finalize failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n let id;\r\n try {\r\n id = await uuidv4();\r\n } catch (error) {\r\n console.log({ error, location: \"uuid generation failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n const request = {\r\n type: \"api\",\r\n id: id,\r\n payload: {\r\n method: \"injectedCall\",\r\n params: [\"signAndBroadcast\", JSON.stringify(tr.toObject()), []],\r\n appName: \"Bitshares Astro UI\",\r\n chain: chain === \"bitshares\" ? \"BTS\" : \"BTS_TEST\",\r\n browser: \"web browser\",\r\n origin: \"localhost\",\r\n },\r\n };\r\n\r\n let encodedPayload;\r\n try {\r\n encodedPayload = encodeURIComponent(JSON.stringify(request));\r\n } catch (error) {\r\n console.log({ error, location: \"encode payload failed\" });\r\n reject(error);\r\n return;\r\n }\r\n\r\n resolve(encodedPayload);\r\n });\r\n}\r\n\r\nexport { generateDeepLink };","import path from \"path\";\r\nimport os from \"os\";\r\nimport url from \"url\";\r\nimport express from \"express\";\r\n\r\nimport {\r\n app,\r\n BrowserWindow,\r\n Menu,\r\n Tray,\r\n ipcMain,\r\n screen,\r\n shell,\r\n} from \"electron\";\r\n\r\nimport { initApplicationMenu } from \"./lib/applicationMenu.js\";\r\nimport { generateDeepLink } from \"./lib/deeplink.js\";\r\n\r\nlet mainWindow = null;\r\nlet tray = null;\r\n\r\nconst createWindow = async () => {\r\n const { width, height } = screen.getPrimaryDisplay().workAreaSize;\r\n\r\n mainWindow = new BrowserWindow({\r\n width: width,\r\n height: height,\r\n minWidth: 480,\r\n minHeight: 695,\r\n maxWidth: width,\r\n maximizable: true,\r\n maxHeight: height,\r\n useContentSize: true,\r\n autoHideMenuBar: true,\r\n webPreferences: {\r\n nodeIntegration: false,\r\n contextIsolation: true,\r\n sandbox: true,\r\n preload: path.join(__dirname, \"preload.js\"),\r\n },\r\n icon: __dirname + \"/img/taskbar.png\",\r\n });\r\n \r\n const expressApp = express();\r\n\r\n let astroDistPath;\r\n if (process.env.NODE_ENV === 'development') {\r\n astroDistPath = 'astroDist';\r\n } else {\r\n astroDistPath = path.join(process.resourcesPath, 'astroDist');\r\n }\r\n\r\n expressApp.use(express.static(astroDistPath));\r\n expressApp.listen(8080, () => {\r\n console.log(\"Express server listening on port 8080\");\r\n });\r\n\r\n initApplicationMenu(mainWindow);\r\n\r\n mainWindow.loadURL('http://localhost:8080/index.html');\r\n\r\n tray = new Tray(path.join(__dirname, \"img\", \"tray.png\"));\r\n const contextMenu = Menu.buildFromTemplate([\r\n {\r\n label: \"Show App\",\r\n click: function () {\r\n mainWindow?.show();\r\n },\r\n },\r\n {\r\n label: \"Quit\",\r\n click: function () {\r\n tray = null;\r\n app.quit();\r\n },\r\n },\r\n ]);\r\n\r\n tray.setToolTip(\"Bitshares Astro UI\");\r\n\r\n tray.on(\"right-click\", (event, bounds) => {\r\n tray?.popUpContextMenu(contextMenu);\r\n });\r\n\r\n ipcMain.handle(\"fetchTopMarkets\", async (event, arg) => {\r\n const { chain } = arg;\r\n\r\n let retrievedData;\r\n try {\r\n retrievedData = await fetch(\r\n chain === \"bitshares\"\r\n ? `https://api.bitshares.ws/openexplorer/top_markets?top_n=100`\r\n : `https://api.testnet.bitshares.ws/openexplorer/top_markets?top_n=50`\r\n );\r\n } catch (error) {\r\n console.log({error})\r\n }\r\n \r\n if (!retrievedData || !retrievedData.ok) {\r\n console.log(\"Failed to fetch top markets\");\r\n return;\r\n }\r\n \r\n const topMarkets = await retrievedData.json();\r\n return topMarkets ?? null;\r\n });\r\n\r\n ipcMain.handle(\"fetchAccountHistory\", async (event, arg) => {\r\n const { chain, accountID } = arg;\r\n\r\n const from = arg.from ?? 0;\r\n const size = arg.size ?? 100;\r\n const from_date = arg.from_date ?? \"2015-10-10\";\r\n const to_date = arg.to_date ?? \"now\";\r\n const sort_by = arg.sort_by ?? \"-operation_id_num\";\r\n const type = arg.type ?? \"data\";\r\n const agg_field = arg.agg_field ?? \"operation_type\";\r\n\r\n const url = `https://${\r\n chain === \"bitshares\" ? \"api\" : \"api.testnet\"\r\n }.bitshares.ws/openexplorer/es/account_history` +\r\n `?account_id=${accountID}` +\r\n `&from_=${from}` +\r\n `&size=${size}` +\r\n `&from_date=${from_date}` +\r\n `&to_date=${to_date}` +\r\n `&sort_by=${sort_by}` +\r\n `&type=${type}` +\r\n `&agg_field=${agg_field}`;\r\n\r\n let history;\r\n try {\r\n history = await fetch(url, { method: \"GET\" });\r\n } catch (error) {\r\n console.log({ error });\r\n return null;\r\n }\r\n\r\n if (!history || !history.ok) {\r\n console.log(\"Couldn't fetch account history.\");\r\n return null;\r\n }\r\n\r\n const accountHistory = await history.json(); \r\n return accountHistory ?? null;\r\n });\r\n\r\n ipcMain.handle(\"generateDeepLink\", async (event, arg) => {\r\n const { usrChain, operationName, trxJSON } = arg;\r\n\r\n let deeplink;\r\n try {\r\n deeplink = await generateDeepLink(usrChain, operationName, trxJSON);\r\n } catch (error) {\r\n console.log({ error });\r\n }\r\n\r\n return deeplink ?? null;\r\n });\r\n\r\n const safeDomains = [\r\n \"https://blocksights.info/\",\r\n \"https://bts.exchange/\",\r\n \"https://ex.xbts.io/\",\r\n \"https://kibana.bts.mobi/\",\r\n \"https://www.bitsharescan.info/\",\r\n \"https://github.com/bitshares/beet\",\r\n ];\r\n ipcMain.on(\"openURL\", (event, arg) => {\r\n try {\r\n const parsedUrl = new url.URL(arg);\r\n const domain = parsedUrl.hostname;\r\n\r\n const isSafeDomain = safeDomains.some(safeDomain => {\r\n const safeDomainHostname = new url.URL(safeDomain).hostname;\r\n return safeDomainHostname === domain;\r\n });\r\n\r\n if (isSafeDomain) {\r\n shell.openExternal(arg);\r\n } else {\r\n console.error(\r\n `Rejected opening URL with unsafe domain: ${domain}`\r\n );\r\n }\r\n } catch (err) {\r\n console.error(`Failed to open URL: ${err.message}`);\r\n }\r\n }); \r\n\r\n tray.on(\"click\", () => {\r\n mainWindow?.setAlwaysOnTop(true);\r\n mainWindow?.show();\r\n mainWindow?.focus();\r\n mainWindow?.setAlwaysOnTop(false);\r\n });\r\n\r\n tray.on(\"balloon-click\", () => {\r\n mainWindow?.setAlwaysOnTop(true);\r\n mainWindow?.show();\r\n mainWindow?.focus();\r\n mainWindow?.setAlwaysOnTop(false);\r\n });\r\n};\r\n\r\napp.disableHardwareAcceleration();\r\n\r\nconst currentOS = os.platform();\r\nif (currentOS === \"win32\" || currentOS === \"linux\") {\r\n // windows + linux setup phase\r\n const gotTheLock = app.requestSingleInstanceLock();\r\n\r\n if (!gotTheLock) {\r\n app.quit();\r\n }\r\n\r\n app.whenReady().then(() => {\r\n createWindow();\r\n });\r\n} else {\r\n app.whenReady().then(() => {\r\n createWindow();\r\n });\r\n\r\n app.on(\"window-all-closed\", () => {\r\n if (process.platform !== \"darwin\") {\r\n app.quit();\r\n }\r\n });\r\n\r\n app.on(\"activate\", () => {\r\n if (mainWindow === null) {\r\n createWindow();\r\n }\r\n });\r\n}\r\n","import {app, Menu} from 'electron';\r\n\r\n/**\r\n * For configuring the electron window menu\r\n */\r\nexport function initApplicationMenu(mainWindow) {\r\n const template = [\r\n {\r\n label: 'View',\r\n submenu: [\r\n {\r\n label: 'Send to tray',\r\n click() {\r\n mainWindow.minimize();\r\n }\r\n },\r\n { label: 'Reload', role: 'reload' },\r\n { label: 'Dev tools', role: 'toggleDevTools' }\r\n ]\r\n }\r\n ];\r\n const menu = Menu.buildFromTemplate(template);\r\n Menu.setApplicationMenu(menu);\r\n}\r\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","require","chains","bitshares","nodeList","url","bitshares_testnet","mainWindow","tray","createWindow","async","width","height","screen","getPrimaryDisplay","workAreaSize","BrowserWindow","minWidth","minHeight","maxWidth","maximizable","maxHeight","useContentSize","autoHideMenuBar","webPreferences","nodeIntegration","contextIsolation","sandbox","preload","__dirname","icon","expressApp","astroDistPath","process","resourcesPath","use","listen","console","log","template","label","submenu","click","minimize","role","menu","Menu","buildFromTemplate","setApplicationMenu","initApplicationMenu","loadURL","Tray","contextMenu","show","app","quit","setToolTip","on","event","bounds","popUpContextMenu","ipcMain","handle","arg","chain","retrievedData","fetch","error","ok","json","accountID","from","size","from_date","to_date","sort_by","type","agg_field","history","method","usrChain","operationName","trxJSON","deeplink","opType","operations","Promise","resolve","reject","_node","Apis","instance","enableCrypto","enableOrders","init_promise","location","tr","TransactionBuilder","i","length","add_type_operation","update_head_block","set_required_fees","set_expire_seconds","finalize","id","request","payload","params","JSON","stringify","toObject","appName","browser","origin","encodedPayload","encodeURIComponent","generateDeepLink","safeDomains","domain","hostname","some","safeDomain","shell","openExternal","err","message","setAlwaysOnTop","focus","disableHardwareAcceleration","currentOS","requestSingleInstanceLock","whenReady","then","platform"],"sourceRoot":""} \ No newline at end of file diff --git a/app/preload.js b/app/preload.js index b1f1468..e5a75bd 100644 --- a/app/preload.js +++ b/app/preload.js @@ -1,120 +1,2 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "electron": -/*!***************************!*\ - !*** external "electron" ***! - \***************************/ -/***/ ((module) => { - -module.exports = require("electron"); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -/*!************************!*\ - !*** ./src/preload.js ***! - \************************/ -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! electron */ "electron"); -/* harmony import */ var electron__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(electron__WEBPACK_IMPORTED_MODULE_0__); - - -electron__WEBPACK_IMPORTED_MODULE_0__.contextBridge.exposeInMainWorld('electron', { - // MISC - openURL: async (target) => electron__WEBPACK_IMPORTED_MODULE_0__.ipcRenderer.send('openURL', target), // Links to explorers - //notify: async (msg) => ipcRenderer.send('notify', msg), // Triggering an electron notification prompt - /* - setNode: (func) => { // For storing the current connected blockchain node - ipcRenderer.on('setNode', (event, args) => { - func(args); - }); - }, - */ - // REST queries - fetchTopMarkets: async (args) => electron__WEBPACK_IMPORTED_MODULE_0__.ipcRenderer.invoke('fetchTopMarkets', args), - fetchAccountHistory: async (args) => electron__WEBPACK_IMPORTED_MODULE_0__.ipcRenderer.invoke('fetchAccountHistory', args), - // API queries - generateDeepLink: async (args) => electron__WEBPACK_IMPORTED_MODULE_0__.ipcRenderer.invoke('generateDeepLink', args), - /* - // For logging background issues to renderer dev console - onMainLog: async (func) => { - ipcRenderer.on("mainLog", (event, data) => { - func(data); - }) - }, - */ -}); - -/******/ })() -; +(()=>{"use strict";const e=require("electron");e.contextBridge.exposeInMainWorld("electron",{openURL:async n=>e.ipcRenderer.send("openURL",n),fetchTopMarkets:async n=>e.ipcRenderer.invoke("fetchTopMarkets",n),fetchAccountHistory:async n=>e.ipcRenderer.invoke("fetchAccountHistory",n),generateDeepLink:async n=>e.ipcRenderer.invoke("generateDeepLink",n)})})(); //# sourceMappingURL=preload.js.map \ No newline at end of file diff --git a/app/preload.js.map b/app/preload.js.map index 14d5a91..68644f3 100644 --- a/app/preload.js.map +++ b/app/preload.js.map @@ -1 +1 @@ -{"version":3,"file":"preload.js","mappings":";;;;;;;;;;AAAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;ACNsD;AACtD;AACA,mDAAa;AACb;AACA,+BAA+B,iDAAW;AAC1C;AACA;AACA,yBAAyB;AACzB;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA,qCAAqC,iDAAW;AAChD,yCAAyC,iDAAW;AACpD;AACA,sCAAsC,iDAAW;AACjD;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,CAAC","sources":["webpack://bitshares_astro_ui/external node-commonjs \"electron\"","webpack://bitshares_astro_ui/webpack/bootstrap","webpack://bitshares_astro_ui/webpack/runtime/compat get default export","webpack://bitshares_astro_ui/webpack/runtime/define property getters","webpack://bitshares_astro_ui/webpack/runtime/hasOwnProperty shorthand","webpack://bitshares_astro_ui/webpack/runtime/make namespace object","webpack://bitshares_astro_ui/./src/preload.js"],"sourcesContent":["module.exports = require(\"electron\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { ipcRenderer, contextBridge } from 'electron';\r\n\r\ncontextBridge.exposeInMainWorld('electron', {\r\n // MISC\r\n openURL: async (target) => ipcRenderer.send('openURL', target), // Links to explorers\r\n //notify: async (msg) => ipcRenderer.send('notify', msg), // Triggering an electron notification prompt\r\n /*\r\n setNode: (func) => { // For storing the current connected blockchain node\r\n ipcRenderer.on('setNode', (event, args) => {\r\n func(args);\r\n });\r\n },\r\n */\r\n // REST queries\r\n fetchTopMarkets: async (args) => ipcRenderer.invoke('fetchTopMarkets', args),\r\n fetchAccountHistory: async (args) => ipcRenderer.invoke('fetchAccountHistory', args),\r\n // API queries\r\n generateDeepLink: async (args) => ipcRenderer.invoke('generateDeepLink', args),\r\n /*\r\n // For logging background issues to renderer dev console\r\n onMainLog: async (func) => {\r\n ipcRenderer.on(\"mainLog\", (event, data) => {\r\n func(data);\r\n })\r\n },\r\n */\r\n});\r\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"preload.js","mappings":"mBAAA,MAAM,EAA+BA,QAAQ,YCE7C,EAAAC,cAAcC,kBAAkB,WAAY,CAExCC,QAASC,MAAOC,GAAW,EAAAC,YAAYC,KAAK,UAAWF,GAUvDG,gBAAiBJ,MAAOK,GAAS,EAAAH,YAAYI,OAAO,kBAAmBD,GACvEE,oBAAqBP,MAAOK,GAAS,EAAAH,YAAYI,OAAO,sBAAuBD,GAE/EG,iBAAkBR,MAAOK,GAAS,EAAAH,YAAYI,OAAO,mBAAoBD,I","sources":["webpack://bitshares_astro_ui/external node-commonjs \"electron\"","webpack://bitshares_astro_ui/./src/preload.js"],"sourcesContent":["const __WEBPACK_NAMESPACE_OBJECT__ = require(\"electron\");","import { ipcRenderer, contextBridge } from 'electron';\r\n\r\ncontextBridge.exposeInMainWorld('electron', {\r\n // MISC\r\n openURL: async (target) => ipcRenderer.send('openURL', target), // Links to explorers\r\n //notify: async (msg) => ipcRenderer.send('notify', msg), // Triggering an electron notification prompt\r\n /*\r\n setNode: (func) => { // For storing the current connected blockchain node\r\n ipcRenderer.on('setNode', (event, args) => {\r\n func(args);\r\n });\r\n },\r\n */\r\n // REST queries\r\n fetchTopMarkets: async (args) => ipcRenderer.invoke('fetchTopMarkets', args),\r\n fetchAccountHistory: async (args) => ipcRenderer.invoke('fetchAccountHistory', args),\r\n // API queries\r\n generateDeepLink: async (args) => ipcRenderer.invoke('generateDeepLink', args),\r\n /*\r\n // For logging background issues to renderer dev console\r\n onMainLog: async (func) => {\r\n ipcRenderer.on(\"mainLog\", (event, data) => {\r\n func(data);\r\n })\r\n },\r\n */\r\n});\r\n"],"names":["require","contextBridge","exposeInMainWorld","openURL","async","target","ipcRenderer","send","fetchTopMarkets","args","invoke","fetchAccountHistory","generateDeepLink"],"sourceRoot":""} \ No newline at end of file diff --git a/build/webpack.main.config.js b/build/webpack.main.config.js index 0b8ddd7..e8fd434 100644 --- a/build/webpack.main.config.js +++ b/build/webpack.main.config.js @@ -12,7 +12,7 @@ module.exports = function(env) { filename: "[name].js", path: path.resolve(__dirname, "../app"), }, - mode: env === "production" ? "production" : "development", + mode: env && env.length ? env : "production", node: { __dirname: false, __filename: false diff --git a/build/webpack.preload.config.js b/build/webpack.preload.config.js index 5916d4f..73e5d46 100644 --- a/build/webpack.preload.config.js +++ b/build/webpack.preload.config.js @@ -11,7 +11,7 @@ module.exports = function(env) { path: path.resolve(__dirname, "../app"), }, target: 'electron-preload', - mode: env === "production" ? "production" : "development", + mode: env && env.length ? env : "production", node: { __dirname: false, diff --git a/package.json b/package.json index 5e1ed99..1b672ce 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,15 @@ "node_modules/**/*", "package.json" ], + "extraResources": [ + { + "from": "./astroDist", + "to": "astroDist" + } + ], "directories": { - "buildResources": "resources" + "buildResources": "resources", + "output": "dist" }, "nsis": { "oneClick": false, diff --git a/src/background.js b/src/background.js index bfe48cf..a0db8a8 100644 --- a/src/background.js +++ b/src/background.js @@ -42,7 +42,15 @@ const createWindow = async () => { }); const expressApp = express(); - expressApp.use(express.static('astroDist')); + + let astroDistPath; + if (process.env.NODE_ENV === 'development') { + astroDistPath = 'astroDist'; + } else { + astroDistPath = path.join(process.resourcesPath, 'astroDist'); + } + + expressApp.use(express.static(astroDistPath)); expressApp.listen(8080, () => { console.log("Express server listening on port 8080"); });