Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(points): add required request headers for trackPointsEvent call #5378

Merged
merged 7 commits into from
May 16, 2024
12 changes: 10 additions & 2 deletions src/points/saga.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { differenceInDays } from 'date-fns'
import { Actions as AppActions } from 'src/app/actions'
import { Actions as HomeActions } from 'src/home/actions'
import { retrieveSignedMessage } from 'src/pincode/authentication'
import { nextPageUrlSelector, pendingPointsEvents } from 'src/points/selectors'
import {
PointsConfig,
Expand Down Expand Up @@ -133,9 +134,16 @@
}
}

export async function fetchTrackPointsEventsEndpoint(event: PointsEvent) {
return fetchWithTimeout(networkConfig.trackPointsEventUrl, {
export function* fetchTrackPointsEventsEndpoint(event: PointsEvent) {
const address = yield* select(walletAddressSelector)
const signedMessage = yield* call(retrieveSignedMessage)

Check warning on line 139 in src/points/saga.ts

View check run for this annotation

Codecov / codecov/patch

src/points/saga.ts#L138-L139

Added lines #L138 - L139 were not covered by tests

return yield* call(fetchWithTimeout, networkConfig.trackPointsEventUrl, {

Check warning on line 141 in src/points/saga.ts

View check run for this annotation

Codecov / codecov/patch

src/points/saga.ts#L141

Added line #L141 was not covered by tests
method: 'POST',
headers: {
'Content-Type': 'application/json',
authorization: `Valora ${address}:${signedMessage}`,
},
body: JSON.stringify(event),
})
}
Expand Down