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';
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user