From e9bd6bf4889a7b935c33f7c317ee56d9e8e7e51c Mon Sep 17 00:00:00 2001 From: kennycud Date: Sun, 21 Apr 2024 15:56:54 -0700 Subject: [PATCH 1/4] adding get and update foreign fee support for Q-apps --- .../core/components/qdn-action-types.js | 6 ++ .../plugins/core/qdn/browser/browser.src.js | 84 ++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) 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', { From 5cf52baa87153f037f664e08d5d6810d699792a9 Mon Sep 17 00:00:00 2001 From: kennycud Date: Tue, 28 May 2024 09:03:52 -0700 Subject: [PATCH 2/4] adding get foreign blockchain server history support for Q-apps --- .../core/components/qdn-action-types.js | 3 ++ .../plugins/core/qdn/browser/browser.src.js | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/plugins/plugins/core/components/qdn-action-types.js b/plugins/plugins/core/components/qdn-action-types.js index a90e1922..a4101b62 100644 --- a/plugins/plugins/core/components/qdn-action-types.js +++ b/plugins/plugins/core/components/qdn-action-types.js @@ -37,6 +37,9 @@ export const GET_FOREIGN_FEE = 'GET_FOREIGN_FEE'; // UPDATE_FOREIGN_FEE action export const UPDATE_FOREIGN_FEE = 'UPDATE_FOREIGN_FEE'; +// GET_SERVER_CONNECTION_HISTORY +export let GET_SERVER_CONNECTION_HISTORY = "GET_SERVER_CONNECTION_HISTORY"; + // 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 83a41a7a..14d367f7 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -2702,6 +2702,46 @@ class WebBrowser extends LitElement { } } + case actions.GET_SERVER_CONNECTION_HISTORY: { + 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.toLowerCase(); + + response = await parentEpml.request('apiCall', { + type: 'api', + method: 'GET', + url: `/crosschain/${coin}/serverconnectionhistory`, + headers: { + 'Accept': '*/*', + 'Content-Type': 'application/json' + }, + }) + } catch (error) { + const data = {} + data['error'] = "Error in get server connection history" + response = JSON.stringify(data) + } finally { + break + } + } + case actions.GET_DAY_SUMMARY: { try { response = await parentEpml.request('apiCall', { From 8f920cac42b1441499db1e11f4bb2dd3f6684f13 Mon Sep 17 00:00:00 2001 From: kennycud Date: Wed, 29 May 2024 17:14:30 -0700 Subject: [PATCH 3/4] adding get foreign blockchain server set connection support for Q-apps --- .../core/components/qdn-action-types.js | 3 ++ .../plugins/core/qdn/browser/browser.src.js | 52 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/plugins/plugins/core/components/qdn-action-types.js b/plugins/plugins/core/components/qdn-action-types.js index a4101b62..9925ec8b 100644 --- a/plugins/plugins/core/components/qdn-action-types.js +++ b/plugins/plugins/core/components/qdn-action-types.js @@ -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'; diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index 14d367f7..560122c4 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -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', { From 679f84a76fb5f31b4b641b6eb12cb252f7c177d7 Mon Sep 17 00:00:00 2001 From: kennycud Date: Thu, 30 May 2024 16:40:24 -0700 Subject: [PATCH 4/4] added add and remove server constants removed duplicate code from a sloppy merge yesterday --- .../core/components/qdn-action-types.js | 14 ++-- .../plugins/core/qdn/browser/browser.src.js | 67 +------------------ 2 files changed, 10 insertions(+), 71 deletions(-) diff --git a/plugins/plugins/core/components/qdn-action-types.js b/plugins/plugins/core/components/qdn-action-types.js index 6a823431..c574e1a5 100644 --- a/plugins/plugins/core/components/qdn-action-types.js +++ b/plugins/plugins/core/components/qdn-action-types.js @@ -43,6 +43,12 @@ export let GET_SERVER_CONNECTION_HISTORY = "GET_SERVER_CONNECTION_HISTORY"; // SET_CURRENT_FOREIGN_SERVER export let SET_CURRENT_FOREIGN_SERVER = "SET_CURRENT_FOREIGN_SERVER"; +// ADD_FOREIGN_SERVER +export let ADD_FOREIGN_SERVER = "ADD_FOREIGN_SERVER"; + +// REMOVE_FOREIGN_SERVER +export let REMOVE_FOREIGN_SERVER = "REMOVE_FOREIGN_SERVER"; + // GET_WALLET_BALANCE action export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE' @@ -103,11 +109,5 @@ export const GET_DAY_SUMMARY = 'GET_DAY_SUMMARY' // GET_FRIENDS_LIST export const GET_FRIENDS_LIST = 'GET_FRIENDS_LIST' -// GET_FOREIGN_FEE -export const GET_FOREIGN_FEE = 'GET_FOREIGN_FEE' - -// UPDATE_FOREIGN_FEE -export const UPDATE_FOREIGN_FEE = 'UPDATE_FOREIGN_FEE' - // OPEN_PROFILE -export const OPEN_PROFILE = 'OPEN_PROFILE' \ No newline at end of file +export const OPEN_PROFILE = 'OPEN_PROFILE' diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index 4200dd0c..f00843b8 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -1895,13 +1895,13 @@ class WebBrowser extends LitElement { const requiredFields = ['coin','type'] const missingFields = [] - requiredFields.forEach((field) => { + requiredFields.forEach((field) => { if (!data[field]) { missingFields.push(field) } }) - if (missingFields.length > 0) { + if (missingFields.length > 0) { const missingFieldsString = missingFields.join(', ') const errorMsg = `Missing fields: ${missingFieldsString}` let data = {} @@ -2065,67 +2065,6 @@ class WebBrowser extends LitElement { } } - case actions.GET_DAY_SUMMARY: { - 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', { @@ -4069,4 +4008,4 @@ async function showErrorAndWait(type, data, data1) { // Add the styles for the modal const styleSheet = new CSSStyleSheet() styleSheet.replaceSync(webBrowserModalStyles) -document.adoptedStyleSheets = [styleSheet] \ No newline at end of file +document.adoptedStyleSheets = [styleSheet]