From be9d5a6fcf86976651f2da3939c8789273ace7cc Mon Sep 17 00:00:00 2001 From: kennycud Date: Thu, 14 Mar 2024 15:31:49 -0700 Subject: [PATCH] adding transaction activity summary 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 e6aeb21f..6a75af07 100644 --- a/plugins/plugins/core/components/qdn-action-types.js +++ b/plugins/plugins/core/components/qdn-action-types.js @@ -28,6 +28,9 @@ export const GET_USER_WALLET_INFO = 'GET_USER_WALLET_INFO'; // GET_CROSSCHAIN_SERVER_INFO action 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_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 b5354bf9..c1701d82 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -2655,6 +2655,46 @@ class WebBrowser extends LitElement { break } + case actions.GET_TX_ACTIVITY_SUMMARY: { + 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; + response = await parentEpml.request('apiCall', { + type: 'api', + method: 'POST', + url: `/crosschain/txactivity?apiKey=${this.getApiKey()}&foreignBlockchain=${coin}`, + headers: { + 'Accept': '*/*', + 'Content-Type': 'application/json' + }, + }) + } catch (error) { + const data = {} + const errorMsg = "Error in tx activity summary" + data['error'] = errorMsg + response = JSON.stringify(data) + } finally { + break + } + } + case actions.GET_DAY_SUMMARY: { try { const summary = await parentEpml.request('apiCall', {