From 5cf52baa87153f037f664e08d5d6810d699792a9 Mon Sep 17 00:00:00 2001 From: kennycud Date: Tue, 28 May 2024 09:03:52 -0700 Subject: [PATCH] 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', {