mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-14 11:15:50 +00:00
user wallet info added in
This commit is contained in:
parent
43a7ce7f82
commit
c02ffe4a72
@ -271,7 +271,7 @@ class WebBrowser extends LitElement {
|
|||||||
const name = parts[0]
|
const name = parts[0]
|
||||||
parts.shift()
|
parts.shift()
|
||||||
let identifier
|
let identifier
|
||||||
|
let path
|
||||||
if (parts.length > 0) {
|
if (parts.length > 0) {
|
||||||
identifier = parts[0] // Do not shift yet
|
identifier = parts[0] // Do not shift yet
|
||||||
// Check if a resource exists with this service, name and identifier combination
|
// Check if a resource exists with this service, name and identifier combination
|
||||||
@ -1100,7 +1100,7 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let list = JSON.parse(localStorage.getItem('friends-my-friend-list') || "[]")
|
let list = JSON.parse(localStorage.getItem('friends-my-friend-list') || "[]")
|
||||||
|
|
||||||
list = list.map((friend)=> friend.name || "")
|
list = list.map((friend)=> friend.name || "")
|
||||||
response = JSON.stringify(list)
|
response = JSON.stringify(list)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1108,7 +1108,7 @@ class WebBrowser extends LitElement {
|
|||||||
const errorMsg = "Error in retrieving friends list"
|
const errorMsg = "Error in retrieving friends list"
|
||||||
data['error'] = errorMsg
|
data['error'] = errorMsg
|
||||||
response = JSON.stringify(data)
|
response = JSON.stringify(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -1515,7 +1515,7 @@ class WebBrowser extends LitElement {
|
|||||||
const missingFields = []
|
const missingFields = []
|
||||||
|
|
||||||
requiredFields.forEach((field) => {
|
requiredFields.forEach((field) => {
|
||||||
if (!data[field]) {
|
if (!data[field] && data[field] !== 0) {
|
||||||
missingFields.push(field)
|
missingFields.push(field)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -2289,7 +2289,7 @@ class WebBrowser extends LitElement {
|
|||||||
const errorMsg = error.message || 'Failed to open profile';
|
const errorMsg = error.message || 'Failed to open profile';
|
||||||
obj['error'] = errorMsg;
|
obj['error'] = errorMsg;
|
||||||
response = JSON.stringify(obj);
|
response = JSON.stringify(obj);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2314,12 +2314,19 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
const res3 = await showModalAndWait(
|
const res3 = await showModalAndWait(
|
||||||
actions.GET_USER_WALLET
|
actions.GET_USER_WALLET
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res3.action === 'accept') {
|
|
||||||
let coin = data.coin;
|
|
||||||
let userWallet = {};
|
|
||||||
|
|
||||||
|
if (res3.action === 'accept') {
|
||||||
|
let coin = data.coin;
|
||||||
|
let userWallet = {};
|
||||||
|
let arrrAddress = "";
|
||||||
|
if (coin === "ARRR") {
|
||||||
|
arrrAddress = await parentEpml.request('apiCall', {
|
||||||
|
url: `/crosschain/arrr/walletaddress?apiKey=${this.getApiKey()}`,
|
||||||
|
method: 'POST',
|
||||||
|
body: `${window.parent.reduxStore.getState().app.selectedAddress.arrrWallet.seed58}`
|
||||||
|
})
|
||||||
|
}
|
||||||
switch (coin) {
|
switch (coin) {
|
||||||
case 'QORT':
|
case 'QORT':
|
||||||
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.address
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.address
|
||||||
@ -2346,6 +2353,7 @@ class WebBrowser extends LitElement {
|
|||||||
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.rvnWallet.derivedMasterPublicKey
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.rvnWallet.derivedMasterPublicKey
|
||||||
break
|
break
|
||||||
case 'ARRR':
|
case 'ARRR':
|
||||||
|
userWallet['address'] = arrrAddress
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
@ -2472,6 +2480,70 @@ class WebBrowser extends LitElement {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case actions.GET_USER_WALLET_INFO: {
|
||||||
|
const requiredFields = ['coin']
|
||||||
|
const missingFields = []
|
||||||
|
|
||||||
|
requiredFields.forEach((field) => {
|
||||||
|
if (!data[field]) {
|
||||||
|
missingFields.push(field)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (missingFields.length > 0) {
|
||||||
|
const missingFieldsString = missingFields.join(', ')
|
||||||
|
const errorMsg = `Missing fields: ${missingFieldsString}`
|
||||||
|
let data = {}
|
||||||
|
data['error'] = errorMsg
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
const userWallet = await showModalAndWait(
|
||||||
|
actions.GET_USER_WALLET
|
||||||
|
)
|
||||||
|
|
||||||
|
if (userWallet.action === 'accept') {
|
||||||
|
let coin = data.coin;
|
||||||
|
let walletKeys = this.getUserWallet(coin);
|
||||||
|
|
||||||
|
console.log( 'walletKeys print ... ' );
|
||||||
|
console.log( 'walletKeys = ' + JSON.stringify(walletKeys) );
|
||||||
|
let _url = `/crosschain/` + data.coin.toLowerCase() + `/addressinfos?apiKey=${this.getApiKey()}`
|
||||||
|
let _body = {
|
||||||
|
xpub58: walletKeys['publickey']
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.loader.show()
|
||||||
|
const bodyToString = JSON.stringify(_body);
|
||||||
|
const res = await parentEpml.request('apiCall', {
|
||||||
|
url: _url,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': '*/*',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: bodyToString,
|
||||||
|
})
|
||||||
|
response = JSON.stringify(res);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
const data = {}
|
||||||
|
const errorMsg = error.message || get("browserpage.bchange21")
|
||||||
|
data['error'] = errorMsg
|
||||||
|
response = JSON.stringify(data)
|
||||||
|
return
|
||||||
|
} finally {
|
||||||
|
this.loader.hide()
|
||||||
|
}
|
||||||
|
} else if (userWallet.action === 'reject') {
|
||||||
|
response = '{"error": "User declined request"}'
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
case actions.GET_DAY_SUMMARY: {
|
case actions.GET_DAY_SUMMARY: {
|
||||||
try {
|
try {
|
||||||
const summary = await parentEpml.request('apiCall', {
|
const summary = await parentEpml.request('apiCall', {
|
||||||
@ -3398,6 +3470,42 @@ class WebBrowser extends LitElement {
|
|||||||
}, 60000)
|
}, 60000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserWallet(coin) {
|
||||||
|
let userWallet = {};
|
||||||
|
|
||||||
|
switch (coin) {
|
||||||
|
case 'QORT':
|
||||||
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.address
|
||||||
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.base58PublicKey
|
||||||
|
break
|
||||||
|
case 'BTC':
|
||||||
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.btcWallet.address
|
||||||
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.btcWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
case 'LTC':
|
||||||
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.ltcWallet.address
|
||||||
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.ltcWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
case 'DOGE':
|
||||||
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.dogeWallet.address
|
||||||
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.dogeWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
case 'DGB':
|
||||||
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.dgbWallet.address
|
||||||
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.dgbWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
case 'RVN':
|
||||||
|
userWallet['address'] = window.parent.reduxStore.getState().app.selectedAddress.rvnWallet.address
|
||||||
|
userWallet['publickey'] = window.parent.reduxStore.getState().app.selectedAddress.rvnWallet.derivedMasterPublicKey
|
||||||
|
break
|
||||||
|
case 'ARRR':
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return userWallet;
|
||||||
|
}
|
||||||
|
|
||||||
clearConsole() {
|
clearConsole() {
|
||||||
if (!isElectron()) {
|
if (!isElectron()) {
|
||||||
} else {
|
} else {
|
||||||
@ -3837,7 +3945,7 @@ async function showModalAndWait(type, data) {
|
|||||||
${type === actions.GET_PROFILE_DATA ? `
|
${type === actions.GET_PROFILE_DATA ? `
|
||||||
<div class="modal-subcontainer">
|
<div class="modal-subcontainer">
|
||||||
<p class="modal-paragraph">${get("browserpage.bchange49")}: <span style="font-weight: bold"> ${data.property}</span></p>
|
<p class="modal-paragraph">${get("browserpage.bchange49")}: <span style="font-weight: bold"> ${data.property}</span></p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
` : ''}
|
` : ''}
|
||||||
${type === actions.SET_PROFILE_DATA ? `
|
${type === actions.SET_PROFILE_DATA ? `
|
||||||
|
Loading…
x
Reference in New Issue
Block a user