Skip to content

Commit

Permalink
Update/DF-20799 response payload (#3616)
Browse files Browse the repository at this point in the history
* DF-20799 update response payload

* add changeset
  • Loading branch information
mmcallister-cll authored Dec 12, 2024
1 parent f4f0ce9 commit c04b1e7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-seahorses-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/bitgo-reserves-adapter': patch
---

Update response payload to only reference totalReserve
16 changes: 13 additions & 3 deletions packages/sources/bitgo-reserves/src/transport/reserves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { BaseEndpointTypes } from '../endpoint/reserves'
import * as crypto from 'crypto'

export interface DataSchema {
totalReserve?: string
reserveAmount?: string
totalReserve: string
cashReserve: string
investedReserve: string
lastUpdated: string
Expand Down Expand Up @@ -82,9 +81,20 @@ export const httpTransport = new HttpTransport<HttpTransportTypes>({
const timestamps = {
providerIndicatedTimeUnixMs: new Date(data.lastUpdated).getTime(),
}
const result = Number(data.totalReserve)
if (result === undefined || isNaN(result)) {
return params.map((param) => {
return {
params: param,
response: {
errorMessage: `Missing totalReserve`,
statusCode: 502,
},
}
})
}

return params.map((param) => {
const result = Number(data.totalReserve) || Number(data.reserveAmount)
return {
params: param,
response: {
Expand Down
4 changes: 3 additions & 1 deletion packages/sources/bitgo-reserves/test-payload.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"requests": [{}]
"requests": [{
"endpoint": "reserves"
}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const mockResponseSuccess = (): nock.Scope =>
.reply(
200,
() => ({
data: '{"reserveAmount":"12345678.90","cashReserve":"2345678.90","investedReserve":"10000000.00","lastUpdated":"2024-12-10T01:23:45Z"}',
data: '{"totalReserve":"12345678.90","cashReserve":"2345678.90","investedReserve":"10000000.00","lastUpdated":"2024-12-10T01:23:45Z"}',
dataSignature: 'testsig',
lastUpdated: '2024-10-01T01:23:45Z',
}),
Expand Down

0 comments on commit c04b1e7

Please sign in to comment.