mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 09:45:52 +00:00
adding get foreign blockchain server set connection support for Q-apps
This commit is contained in:
parent
5cf52baa87
commit
8f920cac42
@ -40,6 +40,9 @@ export const UPDATE_FOREIGN_FEE = 'UPDATE_FOREIGN_FEE';
|
||||
// GET_SERVER_CONNECTION_HISTORY
|
||||
export let GET_SERVER_CONNECTION_HISTORY = "GET_SERVER_CONNECTION_HISTORY";
|
||||
|
||||
// SET_CURRENT_FOREIGN_SERVER
|
||||
export let SET_CURRENT_FOREIGN_SERVER = "SET_CURRENT_FOREIGN_SERVER";
|
||||
|
||||
// GET_WALLET_BALANCE action
|
||||
export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE';
|
||||
|
||||
|
@ -2742,6 +2742,58 @@ class WebBrowser extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
case actions.SET_CURRENT_FOREIGN_SERVER: {
|
||||
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
|
||||
}
|
||||
|
||||
try {
|
||||
let coin = data.coin;
|
||||
let host = data.host;
|
||||
let port = data.port;
|
||||
let type = data.type;
|
||||
|
||||
const body = {
|
||||
hostName: host,
|
||||
port: port,
|
||||
connectionType: type
|
||||
}
|
||||
|
||||
const bodyToString = JSON.stringify(body)
|
||||
|
||||
response = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
method: 'POST',
|
||||
url: `/crosschain/${coin}/setcurrentserver?apiKey=${this.getApiKey()}`,
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: `${bodyToString}`
|
||||
})
|
||||
} catch (error) {
|
||||
const data = {}
|
||||
data['error'] = "Error in set current server"
|
||||
response = JSON.stringify(data)
|
||||
} finally {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
case actions.GET_DAY_SUMMARY: {
|
||||
try {
|
||||
response = await parentEpml.request('apiCall', {
|
||||
|
Loading…
x
Reference in New Issue
Block a user