diff --git a/plugins/plugins/core/components/qdn-action-types.js b/plugins/plugins/core/components/qdn-action-types.js index 6a75af07..a90e1922 100644 --- a/plugins/plugins/core/components/qdn-action-types.js +++ b/plugins/plugins/core/components/qdn-action-types.js @@ -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'; diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index 8e9828cc..83a41a7a 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -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', {