Skip to content

Commit

Permalink
Refactor/sl api param (#88)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
JettTech and Paterick authored Feb 5, 2024
1 parent 32a1bc7 commit a39c440
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/services/servicelogApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/stores/useHoloStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a39c440

Please sign in to comment.