From a39c440ff81970178258348cc9ea5969a74f9048 Mon Sep 17 00:00:00 2001 From: Lisa Jetton Date: Sun, 4 Feb 2024 18:00:49 -0600 Subject: [PATCH] Refactor/sl api param (#88) * update happ_id casing * update happ_ids when signing payload * fix happ_ids param * make sig happ_id a string; * parse happ_ids for url * add log * make paylaod order dependeant --------- Co-authored-by: Patrick Winfield --- src/services/servicelogApi.js | 7 ++++--- src/stores/useHoloStore.js | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/servicelogApi.js b/src/services/servicelogApi.js index 07c1d44..f624c1e 100644 --- a/src/services/servicelogApi.js +++ b/src/services/servicelogApi.js @@ -22,7 +22,7 @@ async function serviceLogApiCall(args, signature, nonce, timestamp, pubkey, envi export async function hAppServiceLogs(payload, signature, pubkey, environment, serviceLogPort) { try { const result = await serviceLogApiCall({ - params: { happId: payload.payload.happ_id }, + params: { happ_id: payload.payload.happ_id }, endpoint: 'service_logs', }, signature, @@ -46,7 +46,7 @@ export async function hAppServiceLogs(payload, signature, pubkey, environment, s export async function hAppStats(payload, signature, pubkey, environment, serviceLogPort) { try { const result = await serviceLogApiCall({ - params: { happId: payload.payload.happ_id, days: payload.payload.days }, + params: { happ_id: payload.payload.happ_id, days: payload.payload.days }, endpoint: 'stats/happ', }, signature, @@ -69,8 +69,9 @@ export async function hAppStats(payload, signature, pubkey, environment, service export async function allHappStats(payload, signature, pubkey, environment, serviceLogPort) { try { + const happIds = JSON.parse(payload.payload.happ_ids) const result = await serviceLogApiCall({ - params: { happIds: payload.payload.happIds, days: payload.payload.days }, + params: { happ_ids: happIds, days: payload.payload.days }, endpoint: 'stats/happs', }, signature, diff --git a/src/stores/useHoloStore.js b/src/stores/useHoloStore.js index 3ac29bb..4c1af96 100644 --- a/src/stores/useHoloStore.js +++ b/src/stores/useHoloStore.js @@ -133,7 +133,10 @@ const makeUseHoloStore = ({ connectionArgs, MockWebSdk }) => defineStore('holo', return hAppStatistics }, async fetchAllHAppStats(happIds, days, environment, serviceLogPort) { - const payload = generateServiceLogPayload({ "happIds": happIds, "days": days.toString() }) + // NB: The happ_ids param needs to be a string to succeed the msgpack serialization + // and validation check in the server. + const happIdsString = JSON.stringify(happIds) + const payload = generateServiceLogPayload({ "days": days.toString(), "happ_ids": happIdsString }) const { _, signature } = await client.signPayload(payload) const hAppStatistics = await allHappStats(payload, signature, this.agentKey, environment, serviceLogPort)