From 732f3f97f2e8720935310a028cf62bfac487309a Mon Sep 17 00:00:00 2001
From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com>
Date: Sun, 17 Mar 2024 12:48:05 +0100
Subject: [PATCH] Rollback electron and cleanup code
---
README.md | 2 +-
core/src/components/app-info.js | 251 +--
core/src/components/wallet-profile.js | 137 +-
electron.js | 78 +-
package-lock.json | 489 ++---
package.json | 26 +-
plugins/plugins/core/components/ChatHead.js | 44 +-
.../core/messaging/q-chat/q-chat-css.src.js | 934 ++++----
.../core/messaging/q-chat/q-chat.src.js | 1917 ++++++++---------
9 files changed, 1838 insertions(+), 2040 deletions(-)
diff --git a/README.md b/README.md
index 2449f9cf..6af149dc 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Easiest way to install the lastest required packages on Linux is via nvm.
``` source ~/.profile ``` (For Debian based distro)
``` source ~/.bashrc ``` (For Fedora / CentOS)
``` nvm ls-remote ``` (Fetch list of available versions)
-``` nvm install v20.9.0 ``` (LTS: Iron supported by Electron)
+``` nvm install v18.17.1 ``` (LTS: Hydrogen supported by Electron V27)
``` npm --location=global install npm@10.5.0 ```
Adding via binary package mirror will only work if you have set the package path. You can do a node or java build via ports instead by downloading ports with portsnap fetch method.
diff --git a/core/src/components/app-info.js b/core/src/components/app-info.js
index c3cc86da..c5d4aa95 100644
--- a/core/src/components/app-info.js
+++ b/core/src/components/app-info.js
@@ -1,105 +1,70 @@
import {css, html, LitElement} from 'lit'
import {connect} from 'pwa-helpers'
import {store} from '../store.js'
-import {doPageUrl} from '../redux/app/app-actions.js'
-import {translate} from '../../translate/index.js'
-import WebWorker from 'web-worker:./computePowWorker.js';
-import {routes} from '../plugins/routes.js';
-
-import '@material/mwc-icon'
-import '@material/mwc-button'
+import {translate} from '../../translate'
class AppInfo extends connect(store)(LitElement) {
static get properties() {
return {
- blockInfo: { type: Object },
- nodeStatus: { type: Object },
nodeInfo: { type: Array },
coreInfo: { type: Array },
nodeConfig: { type: Object },
- pageUrl: { type: String },
- publicizeAddress: { type: String },
theme: { type: String, reflect: true }
}
}
static get styles() {
- return [
- css`
- * {
- --mdc-theme-primary: rgb(3, 169, 244);
- --paper-input-container-focus-color: var(--mdc-theme-primary);
- }
- .normal {
- --mdc-theme-primary: rgb(3, 169, 244);
- }
+ return css`
+ * {
+ --mdc-theme-primary: rgb(3, 169, 244);
+ --paper-input-container-focus-color: var(--mdc-theme-primary);
+ }
- .normal-button {
- --mdc-theme-primary: rgb(3, 169, 244);
- --mdc-theme-on-primary: white;
- }
+ .normal {
+ --mdc-theme-primary: rgb(3, 169, 244);
+ }
- mwc-button.normal-button {
- --mdc-theme-primary: rgb(3, 169, 244);
- --mdc-theme-on-primary: white;
- }
- .test-net {
- --mdc-theme-primary: black;
- }
+ #profileInMenu {
+ flex: 0 0 100px;
+ padding:12px;
+ border-top: 1px solid var(--border);
+ background: var(--sidetopbar);
+ }
- .test-net-button {
- --mdc-theme-primary: black;
- --mdc-theme-on-primary: white;
- }
+ .info {
+ margin: 0;
+ font-size: 14px;
+ font-weight: 100;
+ display: inline-block;
+ width: 100%;
+ padding-bottom: 8px;
+ color: var(--black);
+ }
- mwc-button.test-net-button {
- --mdc-theme-primary: black;
- --mdc-theme-on-primary: white;
- }
- #profileInMenu {
- flex: 0 0 100px;
- padding:12px;
- border-top: 1px solid var(--border);
- background: var(--sidetopbar);
- }
- .info {
- margin: 0;
- font-size: 14px;
- font-weight:100;
- display: inline-block;
- width:100%;
- padding-bottom:8px;
- color: var(--black);
- }
- .blue {
- color: #03a9f4;
- margin: 0;
- font-size: 14px;
- font-weight:200;
- display: inline;
- }
- .black {
- color: var(--black);
- margin: 0;
- font-size: 14px;
- font-weight:200;
- display: inline;
- }
- `
- ]
+ .blue {
+ color: #03a9f4;
+ margin: 0;
+ font-size: 14px;
+ font-weight: 200;
+ display: inline;
+ }
+
+ .black {
+ color: var(--black);
+ margin: 0;
+ font-size: 14px;
+ font-weight: 200;
+ display: inline;
+ }
+ `
}
constructor() {
super()
- this.blockInfo = {}
this.nodeInfo = []
this.coreInfo = []
this.nodeStatus = {}
- this.pageUrl = ''
- this.publicizeAddress = ''
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
- this.publicKeyisOnChainConfirmation = false
- this.interval
}
render() {
@@ -115,133 +80,25 @@ class AppInfo extends connect(store)(LitElement) {
}
firstUpdated() {
- this.publicizeAddress = store.getState().app.selectedAddress.address + '_publicize'
- this.setStorage()
this.getNodeInfo()
this.getCoreInfo()
- // try {
- // this.confirmPublicKeyOnChain(store.getState().app.selectedAddress.address)
- // } catch (error) {
- // console.error(error)
- // }
setInterval(() => {
this.getNodeInfo()
this.getCoreInfo()
- }, 30000)
- }
-
- setStorage() {
- if (localStorage.getItem(this.publicizeAddress) === null) {
- localStorage.setItem(this.publicizeAddress, 'false')
- }
- }
-
- async confirmPublicKeyOnChain(address) {
- const _computePow2 = async (chatBytes) => {
- const difficulty = 14
- const path = window.parent.location.origin + '/memory-pow/memory-pow.wasm.full'
- const worker = new WebWorker();
- let nonce = null
- let chatBytesArray = null
- await new Promise((res, rej) => {
- worker.postMessage({chatBytes, path, difficulty})
-
- worker.onmessage = e => {
- worker.terminate()
- chatBytesArray = e.data.chatBytesArray
- nonce = e.data.nonce
- res()
- }
- })
-
- let _response = await routes.sign_chat({
- data: {
- nonce: store.getState().app.selectedAddress.nonce,
- chatBytesArray: chatBytesArray,
- chatNonce: nonce
- },
- })
- return _response
- }
-
- let stop = false
- const checkPublicKey = async () => {
- if (!stop) {
- stop = true
- try {
- if(localStorage.getItem(this.publicizeAddress) === 'true') {
- clearInterval(this.interval)
- return
- }
- const myNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]
- const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
- const url = `${nodeUrl}/addresses/publickey/${address}`
- const res = await fetch(url)
- let data = ''
- try {
- data = await res.text()
- } catch (error) {
- data = {
- error: 'error'
- }
- }
- if(data === 'false' && this.nodeInfo.isSynchronizing !== true) {
- let _reference = new Uint8Array(64)
- window.crypto.getRandomValues(_reference)
- let reference = window.parent.Base58.encode(_reference)
- const chatRes = await routes.chat({
- data: {
- type: 19,
- nonce: store.getState().app.selectedAddress.nonce,
- params: {
- lastReference: reference,
- proofOfWorkNonce: 0,
- fee: 0,
- timestamp: Date.now(),
- },
- disableModal: true
- },
- disableModal: true,
- });
-
- try {
- const powRes = await _computePow2(chatRes)
- if(powRes === true) {
- clearInterval(this.interval)
- localStorage.removeItem(this.publicizeAddress)
- localStorage.setItem(this.publicizeAddress, 'true')
- }
- } catch (error) {
- console.error(error)
- }
- }
-
- if (!data.error && data !== 'false' && data) {
- clearInterval(this.interval)
- localStorage.removeItem(this.publicizeAddress)
- localStorage.setItem(this.publicizeAddress, 'true')
- }
-
- } catch (error) {
- }
- stop = false
- }
- }
- this.interval = setInterval(checkPublicKey, 5000);
+ }, 60000)
}
async getNodeInfo() {
const appinfoNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]
const appinfoUrl = appinfoNode.protocol + '://' + appinfoNode.domain + ':' + appinfoNode.port
const url = `${appinfoUrl}/admin/status`
+
await fetch(url).then(response => {
return response.json()
- })
- .then(data => {
+ }).then(data => {
this.nodeInfo = data
- })
- .catch(err => {
+ }).catch(err => {
console.error('Request failed', err)
})
}
@@ -250,13 +107,12 @@ class AppInfo extends connect(store)(LitElement) {
const appinfoNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]
const appinfoUrl = appinfoNode.protocol + '://' + appinfoNode.domain + ':' + appinfoNode.port
const url = `${appinfoUrl}/admin/info`
+
await fetch(url).then(response => {
return response.json()
- })
- .then(data => {
+ }).then(data => {
this.coreInfo = data
- })
- .catch(err => {
+ }).catch(err => {
console.error('Request failed', err)
})
}
@@ -283,21 +139,8 @@ class AppInfo extends connect(store)(LitElement) {
return html`${translate("appinfo.coreversion")}: ${this.coreInfo.buildVersion ? this.coreInfo.buildVersion : ''}`
}
- gotoPage(url) {
- const myLink = this.shadowRoot.querySelector('#pageLink')
- myLink.href = url
- myLink.click()
- store.dispatch(doPageUrl(''))
- }
-
stateChanged(state) {
- this.blockInfo = state.app.blockInfo
- this.nodeStatus = state.app.nodeStatus
this.nodeConfig = state.app.nodeConfig
- this.pageUrl = state.app.pageUrl
- if (this.pageUrl.length > 5) {
- this.gotoPage(this.pageUrl)
- }
}
}
diff --git a/core/src/components/wallet-profile.js b/core/src/components/wallet-profile.js
index 83e8c01d..33d92282 100644
--- a/core/src/components/wallet-profile.js
+++ b/core/src/components/wallet-profile.js
@@ -1,10 +1,7 @@
import {css, html, LitElement} from 'lit'
import {connect} from 'pwa-helpers'
import {store} from '../store.js'
-import {translate} from '../../translate/index.js'
-
-import '@polymer/paper-toast'
-import '@material/mwc-icon-button'
+import {translate} from '../../translate'
class WalletProfile extends connect(store)(LitElement) {
static get properties() {
@@ -12,82 +9,76 @@ class WalletProfile extends connect(store)(LitElement) {
wallet: { type: Object },
nodeConfig: { type: Object },
accountInfo: { type: Object },
- imageUrl: { type: String },
theme: { type: String, reflect: true }
}
}
static get styles() {
- return [
- css`
- `
- ]
+ return css`
+ #profileInMenu {
+ padding: 12px;
+ border-top: var(--border);
+ background: var(--sidetopbar);
+ color: var(--black);
+ }
+
+ #accountName {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 500;
+ width: 100%;
+ padding-bottom: 8px;
+ display: flex;
+ }
+
+ #blocksMinted {
+ margin:0;
+ margin-top: 0;
+ font-size: 12px;
+ color: #03a9f4;
+ }
+
+ #address {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ margin:0;
+ margin-top: 8px;
+ font-size: 11px;
+ }
+
+ .round-fullinfo {
+ position: relative;
+ width: 68px;
+ height: 68px;
+ border-radius: 50%;
+ }
+
+ .full-info-logo {
+ width: 68px;
+ height: 68px;
+ border-radius: 50%;
+ }
+
+ .inline-block-child {
+ flex: 1;
+ }
+ `
}
constructor() {
super()
+ this.wallet = {}
this.nodeConfig = {}
this.accountInfo = {
names: [],
addressInfo: {}
}
- this.imageUrl = ''
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
}
render() {
return html`
-
${this.wallet.addresses[0].address}
${translate("chatpage.cchange6")}
-${translate("chatpage.cchange38")}
-${translate("chatpage.cchange6")}
+${translate("chatpage.cchange38")}
+