mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-04-23 11:27:52 +00:00
Update appinfo
This commit is contained in:
parent
44cd02a45f
commit
326b21a269
@ -18,6 +18,7 @@ class AppInfo extends connect(store)(LitElement) {
|
|||||||
coreInfo: { type: Array },
|
coreInfo: { type: Array },
|
||||||
nodeConfig: { type: Object },
|
nodeConfig: { type: Object },
|
||||||
pageUrl: { type: String },
|
pageUrl: { type: String },
|
||||||
|
publicizeAddress: { type: String },
|
||||||
theme: { type: String, reflect: true }
|
theme: { type: String, reflect: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,6 +96,7 @@ class AppInfo extends connect(store)(LitElement) {
|
|||||||
this.coreInfo = []
|
this.coreInfo = []
|
||||||
this.nodeStatus = {}
|
this.nodeStatus = {}
|
||||||
this.pageUrl = ''
|
this.pageUrl = ''
|
||||||
|
this.publicizeAddress = ''
|
||||||
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
|
this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light'
|
||||||
this.publicKeyisOnChainConfirmation = false
|
this.publicKeyisOnChainConfirmation = false
|
||||||
this.interval
|
this.interval
|
||||||
@ -112,24 +114,46 @@ 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) {
|
async confirmPublicKeyOnChain(address) {
|
||||||
const _computePow2 = async (chatBytes) => {
|
const _computePow2 = async (chatBytes) => {
|
||||||
const difficulty = 14;
|
const difficulty = 14
|
||||||
const path = window.parent.location.origin + '/memory-pow/memory-pow.wasm.full'
|
const path = window.parent.location.origin + '/memory-pow/memory-pow.wasm.full'
|
||||||
const worker = new WebWorker();
|
const worker = new WebWorker();
|
||||||
let nonce = null
|
let nonce = null
|
||||||
let chatBytesArray = null
|
let chatBytesArray = null
|
||||||
await new Promise((res, rej) => {
|
await new Promise((res, rej) => {
|
||||||
worker.postMessage({chatBytes, path, difficulty});
|
worker.postMessage({chatBytes, path, difficulty})
|
||||||
|
|
||||||
worker.onmessage = e => {
|
worker.onmessage = e => {
|
||||||
worker.terminate()
|
worker.terminate()
|
||||||
chatBytesArray = e.data.chatBytesArray
|
chatBytesArray = e.data.chatBytesArray
|
||||||
nonce = e.data.nonce
|
nonce = e.data.nonce
|
||||||
res()
|
res()
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let _response = await routes.sign_chat({
|
let _response = await routes.sign_chat({
|
||||||
data: {
|
data: {
|
||||||
@ -137,93 +161,74 @@ class AppInfo extends connect(store)(LitElement) {
|
|||||||
chatBytesArray: chatBytesArray,
|
chatBytesArray: chatBytesArray,
|
||||||
chatNonce: nonce
|
chatNonce: nonce
|
||||||
},
|
},
|
||||||
|
})
|
||||||
});
|
return _response
|
||||||
return _response
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
let stop = false
|
||||||
let stop = false
|
const checkPublicKey = async () => {
|
||||||
const checkPublicKey = async () => {
|
if (!stop) {
|
||||||
if (!stop) {
|
stop = true
|
||||||
stop = true;
|
|
||||||
try {
|
|
||||||
if(this.publicKeyisOnChainConfirmation){
|
|
||||||
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 {
|
try {
|
||||||
data = await res.text();
|
if(localStorage.getItem(this.publicizeAddress) === 'true') {
|
||||||
} catch (error) {
|
clearInterval(this.interval)
|
||||||
data = {
|
return
|
||||||
error: 'error'
|
|
||||||
}
|
}
|
||||||
}
|
const myNode = store.getState().app.nodeConfig.knownNodes[store.getState().app.nodeConfig.node]
|
||||||
if(data === 'false' && this.nodeInfo.isSynchronizing !== true){
|
const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
|
||||||
let _reference = new Uint8Array(64);
|
const url = `${nodeUrl}/addresses/publickey/${address}`
|
||||||
window.crypto.getRandomValues(_reference);
|
const res = await fetch(url)
|
||||||
let reference = window.parent.Base58.encode(_reference);
|
let data = ''
|
||||||
const chatRes = await routes.chat({
|
try {
|
||||||
data: {
|
data = await res.text()
|
||||||
type: 19,
|
} catch (error) {
|
||||||
nonce: store.getState().app.selectedAddress.nonce,
|
data = {
|
||||||
params: {
|
error: 'error'
|
||||||
lastReference: reference,
|
}
|
||||||
proofOfWorkNonce: 0,
|
}
|
||||||
fee: 0,
|
if(data === 'false' && this.nodeInfo.isSynchronizing !== true) {
|
||||||
timestamp: Date.now(),
|
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
|
disableModal: true,
|
||||||
},
|
});
|
||||||
disableModal: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const powRes = await _computePow2(chatRes)
|
const powRes = await _computePow2(chatRes)
|
||||||
if(powRes === true){
|
if(powRes === true) {
|
||||||
clearInterval(this.interval)
|
clearInterval(this.interval)
|
||||||
|
localStorage.removeItem(this.publicizeAddress)
|
||||||
this.publicKeyisOnChainConfirmation = true
|
localStorage.setItem(this.publicizeAddress, 'true')
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.error && data !== 'false' && data) {
|
if (!data.error && data !== 'false' && data) {
|
||||||
clearInterval(this.interval)
|
clearInterval(this.interval)
|
||||||
|
localStorage.removeItem(this.publicizeAddress)
|
||||||
this.publicKeyisOnChainConfirmation = true
|
localStorage.setItem(this.publicizeAddress, 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
stop = false
|
stop = false
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
this.interval = setInterval(checkPublicKey, 5000);
|
this.interval = setInterval(checkPublicKey, 5000);
|
||||||
}
|
|
||||||
|
|
||||||
firstUpdated() {
|
|
||||||
this.getNodeInfo()
|
|
||||||
this.getCoreInfo()
|
|
||||||
try {
|
|
||||||
this.confirmPublicKeyOnChain(store.getState().app.selectedAddress.address)
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
this.getNodeInfo()
|
|
||||||
this.getCoreInfo()
|
|
||||||
}, 30000)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getNodeInfo() {
|
async getNodeInfo() {
|
||||||
|
@ -4686,10 +4686,10 @@ class MultiWallet extends LitElement {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const txsQort = await parentEpml.request('apiCall', {
|
const txsQort = await parentEpml.request('apiCall', {
|
||||||
url: `/transactions/search?address=${this.wallets.get('qort').wallet.address}&confirmationStatus=CONFIRMED&reverse=true&txType=PAYMENT&txType=REGISTER_NAME&txType=UPDATE_NAME&txType=SELL_NAME&txType=CANCEL_SELL_NAME&txType=BUY_NAME&txType=CREATE_POLL&txType=VOTE_ON_POLL&txType=ISSUE_ASSET&txType=TRANSFER_ASSET&txType=CREATE_ASSET_ORDER&txType=CANCEL_ASSET_ORDER&txType=MULTI_PAYMENT&txType=DEPLOY_AT&txType=MESSAGE&txType=PUBLICIZE&txType=AIRDROP&txType=AT&txType=CREATE_GROUP&txType=UPDATE_GROUP&txType=ADD_GROUP_ADMIN&txType=REMOVE_GROUP_ADMIN&txType=GROUP_BAN&txType=CANCEL_GROUP_BAN&txType=GROUP_KICK&txType=GROUP_INVITE&txType=CANCEL_GROUP_INVITE&txType=JOIN_GROUP&txType=LEAVE_GROUP&txType=GROUP_APPROVAL&txType=SET_GROUP&txType=UPDATE_ASSET&txType=ACCOUNT_FLAGS&txType=ENABLE_FORGING&txType=REWARD_SHARE&txType=ACCOUNT_LEVEL&txType=TRANSFER_PRIVS&txType=PRESENCE`,
|
url: `/transactions/search?address=${this.wallets.get('qort').wallet.address}&confirmationStatus=CONFIRMED&reverse=true&txType=PAYMENT&txType=REGISTER_NAME&txType=UPDATE_NAME&txType=SELL_NAME&txType=CANCEL_SELL_NAME&txType=BUY_NAME&txType=CREATE_POLL&txType=VOTE_ON_POLL&txType=ISSUE_ASSET&txType=TRANSFER_ASSET&txType=CREATE_ASSET_ORDER&txType=CANCEL_ASSET_ORDER&txType=MULTI_PAYMENT&txType=DEPLOY_AT&txType=MESSAGE&txType=AIRDROP&txType=AT&txType=CREATE_GROUP&txType=UPDATE_GROUP&txType=ADD_GROUP_ADMIN&txType=REMOVE_GROUP_ADMIN&txType=GROUP_BAN&txType=CANCEL_GROUP_BAN&txType=GROUP_KICK&txType=GROUP_INVITE&txType=CANCEL_GROUP_INVITE&txType=JOIN_GROUP&txType=LEAVE_GROUP&txType=GROUP_APPROVAL&txType=SET_GROUP&txType=UPDATE_ASSET&txType=ACCOUNT_FLAGS&txType=ENABLE_FORGING&txType=REWARD_SHARE&txType=ACCOUNT_LEVEL&txType=TRANSFER_PRIVS&txType=PRESENCE`,
|
||||||
})
|
})
|
||||||
const pendingTxsQort = await parentEpml.request('apiCall', {
|
const pendingTxsQort = await parentEpml.request('apiCall', {
|
||||||
url: `/transactions/unconfirmed?creator=${this.wallets.get('qort').wallet.base58PublicKey}&reverse=true&txType=PAYMENT&txType=REGISTER_NAME&txType=UPDATE_NAME&txType=SELL_NAME&txType=CANCEL_SELL_NAME&txType=BUY_NAME&txType=CREATE_POLL&txType=VOTE_ON_POLL&txType=ISSUE_ASSET&txType=TRANSFER_ASSET&txType=CREATE_ASSET_ORDER&txType=CANCEL_ASSET_ORDER&txType=MULTI_PAYMENT&txType=DEPLOY_AT&txType=MESSAGE&txType=PUBLICIZE&txType=AIRDROP&txType=AT&txType=CREATE_GROUP&txType=UPDATE_GROUP&txType=ADD_GROUP_ADMIN&txType=REMOVE_GROUP_ADMIN&txType=GROUP_BAN&txType=CANCEL_GROUP_BAN&txType=GROUP_KICK&txType=GROUP_INVITE&txType=CANCEL_GROUP_INVITE&txType=JOIN_GROUP&txType=LEAVE_GROUP&txType=GROUP_APPROVAL&txType=SET_GROUP&txType=UPDATE_ASSET&txType=ACCOUNT_FLAGS&txType=ENABLE_FORGING&txType=REWARD_SHARE&txType=ACCOUNT_LEVEL&txType=TRANSFER_PRIVS&txType=PRESENCE`,
|
url: `/transactions/unconfirmed?creator=${this.wallets.get('qort').wallet.base58PublicKey}&reverse=true&txType=PAYMENT&txType=REGISTER_NAME&txType=UPDATE_NAME&txType=SELL_NAME&txType=CANCEL_SELL_NAME&txType=BUY_NAME&txType=CREATE_POLL&txType=VOTE_ON_POLL&txType=ISSUE_ASSET&txType=TRANSFER_ASSET&txType=CREATE_ASSET_ORDER&txType=CANCEL_ASSET_ORDER&txType=MULTI_PAYMENT&txType=DEPLOY_AT&txType=MESSAGE&txType=AIRDROP&txType=AT&txType=CREATE_GROUP&txType=UPDATE_GROUP&txType=ADD_GROUP_ADMIN&txType=REMOVE_GROUP_ADMIN&txType=GROUP_BAN&txType=CANCEL_GROUP_BAN&txType=GROUP_KICK&txType=GROUP_INVITE&txType=CANCEL_GROUP_INVITE&txType=JOIN_GROUP&txType=LEAVE_GROUP&txType=GROUP_APPROVAL&txType=SET_GROUP&txType=UPDATE_ASSET&txType=ACCOUNT_FLAGS&txType=ENABLE_FORGING&txType=REWARD_SHARE&txType=ACCOUNT_LEVEL&txType=TRANSFER_PRIVS&txType=PRESENCE`,
|
||||||
})
|
})
|
||||||
if (this._selectedWallet == coin) {
|
if (this._selectedWallet == coin) {
|
||||||
this.wallets.get(coin).transactions = pendingTxsQort.concat(txsQort)
|
this.wallets.get(coin).transactions = pendingTxsQort.concat(txsQort)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user