forked from Qortal/qortal-ui
commit
a0d910f08d
@ -22,6 +22,9 @@ export const DEPLOY_AT = 'DEPLOY_AT';
|
|||||||
// GET_USER_WALLET action
|
// GET_USER_WALLET action
|
||||||
export const GET_USER_WALLET = 'GET_USER_WALLET';
|
export const GET_USER_WALLET = 'GET_USER_WALLET';
|
||||||
|
|
||||||
|
// GET_USER_WALLET_INFO action
|
||||||
|
export const GET_USER_WALLET_INFO = 'GET_USER_WALLET_INFO';
|
||||||
|
|
||||||
// GET_WALLET_BALANCE action
|
// GET_WALLET_BALANCE action
|
||||||
export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE';
|
export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE';
|
||||||
|
|
||||||
@ -80,4 +83,4 @@ export const SET_PROFILE_DATA= 'SET_PROFILE_DATA'
|
|||||||
export const GET_DAY_SUMMARY = 'GET_DAY_SUMMARY'
|
export const GET_DAY_SUMMARY = 'GET_DAY_SUMMARY'
|
||||||
|
|
||||||
//GET_FRIENDS_LIST
|
//GET_FRIENDS_LIST
|
||||||
export const GET_FRIENDS_LIST = 'GET_FRIENDS_LIST'
|
export const GET_FRIENDS_LIST = 'GET_FRIENDS_LIST'
|
||||||
|
@ -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
|
||||||
|
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2315,7 +2315,7 @@ class WebBrowser extends LitElement {
|
|||||||
const res3 = await showModalAndWait(
|
const res3 = await showModalAndWait(
|
||||||
actions.GET_USER_WALLET
|
actions.GET_USER_WALLET
|
||||||
);
|
);
|
||||||
|
|
||||||
if (res3.action === 'accept') {
|
if (res3.action === 'accept') {
|
||||||
let coin = data.coin;
|
let coin = data.coin;
|
||||||
let userWallet = {};
|
let userWallet = {};
|
||||||
@ -2479,6 +2479,67 @@ 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);
|
||||||
|
|
||||||
|
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 {
|
||||||
@ -3406,6 +3467,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 {
|
||||||
@ -3845,7 +3942,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