forked from Qortal/qortal-ui
adding get and update foreign fee support for Q-apps
This commit is contained in:
parent
2059bf666a
commit
e9bd6bf488
@ -31,6 +31,12 @@ export const GET_CROSSCHAIN_SERVER_INFO = 'GET_CROSSCHAIN_SERVER_INFO';
|
||||
// GET_TX_ACTIVITY_SUMMARY action
|
||||
export const GET_TX_ACTIVITY_SUMMARY = 'GET_TX_ACTIVITY_SUMMARY';
|
||||
|
||||
// GET_FOREIGN_FEE action
|
||||
export const GET_FOREIGN_FEE = 'GET_FOREIGN_FEE';
|
||||
|
||||
// UPDATE_FOREIGN_FEE action
|
||||
export const UPDATE_FOREIGN_FEE = 'UPDATE_FOREIGN_FEE';
|
||||
|
||||
// GET_WALLET_BALANCE action
|
||||
export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE';
|
||||
|
||||
|
@ -1556,7 +1556,7 @@ class WebBrowser extends LitElement {
|
||||
try {
|
||||
pollInfo = await parentEpml.request("apiCall", {
|
||||
type: "api",
|
||||
url: `/polls/${pollName}`,
|
||||
url: `/polls/${encodeURIComponent(pollName)}`,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMsg = (error && error.message) || 'Poll not found'
|
||||
@ -2620,6 +2620,88 @@ class WebBrowser extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
case actions.GET_FOREIGN_FEE: {
|
||||
const requiredFields = ['coin','type']
|
||||
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 type = data.type;
|
||||
response = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
method: 'GET',
|
||||
url: `/crosschain/${coin}/${type}?apiKey=${this.getApiKey()}`,
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
const data = {}
|
||||
data['error'] = "Error in get foreign fee"
|
||||
response = JSON.stringify(data)
|
||||
} finally {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
case actions.UPDATE_FOREIGN_FEE: {
|
||||
const requiredFields = ['coin','type']
|
||||
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 type = data.type;
|
||||
let value = data.value;
|
||||
response = await parentEpml.request('apiCall', {
|
||||
type: 'api',
|
||||
method: 'POST',
|
||||
url: `/crosschain/${coin}/update${type}?apiKey=${this.getApiKey()}`,
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: `${value}`
|
||||
})
|
||||
} catch (error) {
|
||||
const data = {}
|
||||
data['error'] = "Error in update foreign fee"
|
||||
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