Skip to content

Commit

Permalink
common: parse gateway response in obtainReceiptsVoucher function
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Aug 2, 2023
1 parent b953657 commit ce29a5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/indexer-common/src/allocations/query-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,13 @@ export class AllocationReceiptCollector implements ReceiptCollector {
allocation,
})

const voucher = response.data as {
// Depending of which Gateway endpoint was used, fee information can come in different fields
let fees = response.data.fees ?? response.data.amount
if (!fees || !response.data.allocation || !response.data.signature) {
throw new Error('Failed to parse response from Gateay')
}

const voucher = { ...response.data, fees } as {
allocation: string
fees: string
signature: string
Expand Down

0 comments on commit ce29a5c

Please sign in to comment.