Skip to content

Commit

Permalink
chore: updated createSigMsgQuery to generateAuthQueryParam
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi-bams committed Dec 19, 2023
1 parent eea43d8 commit 3c7d71c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/components/AddContentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { api } from '~/network/api'
import { useModal } from '~/stores/useModalStore'
import { useUserStore } from '~/stores/useUserStore'
import { SubmitErrRes } from '~/types'
import { createSigMsgQuery, executeIfProd, getLSat, payLsat, updateBudget } from '~/utils'
import { executeIfProd, generateAuthQueryParam, getLSat, payLsat, updateBudget } from '~/utils'
import { BudgetStep } from './BudgetStep'
import { LocationStep } from './LocationStep'
import { SourceStep } from './SourceStep'
Expand Down Expand Up @@ -106,7 +106,7 @@ const handleSubmitForm = async (
let query = ''

if (endPoint === 'radar') {
const result = await createSigMsgQuery()
const result = await generateAuthQueryParam()

query = `?${result}`
}
Expand Down
20 changes: 10 additions & 10 deletions src/network/fetchSourcesData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RadarRequest,
SubmitErrRes,
} from '~/types'
import { createSigMsgQuery } from '~/utils'
import { generateAuthQueryParam } from '~/utils'
import { api } from '../api'

type TradarParams = {
Expand Down Expand Up @@ -69,7 +69,7 @@ export const getRadarData = async (queryParams: TradarParams = defaultParams) =>
}

export const getTopicsData = async (queryParams: TtopicsParams = defaultParams) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.get<FetchTopicResponse>(
`/topics?${new URLSearchParams({ ...defaultParams, ...queryParams }).toString()}${query}`,
Expand All @@ -91,31 +91,31 @@ export const getStats = async () => {
}

export const getEdgeTypes = async () => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.get<FetchEdgesResponse>(`curation/edge/type?${query}`)

return response
}

export const postEdgeType = async (data: TAddEdgeParams) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.post(`/curation/edge?${query}`, JSON.stringify(data))

return response
}

export const postAboutData = async (data: TAboutParams) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.post(`/about?${query}`, JSON.stringify(data))

return response
}

export const postMergeTopics = async (data: TMergeTopicsParams) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.post(`/curation/merge?${query}`, JSON.stringify(data))

Expand All @@ -125,31 +125,31 @@ export const postMergeTopics = async (data: TMergeTopicsParams) => {
export const triggerRadarJob = async () => api.get<SubmitErrRes>(`/radar/trigger-job`)

export const putRadarData = async (id: string, data: RadarRequest) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.put(`/radar/${id}?${query}`, JSON.stringify(data))

return response
}

export const putNodeData = async (data: NodeRequest) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.put(`/node?${query}`, JSON.stringify(data))

return response
}

export const approveRadarData = async (id: string, pubkey: string) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.put(`/radar/${id}/approve?${query}`, JSON.stringify({ approve: 'True', pubkey }))

return response
}

export const deleteRadarData = async (id: string) => {
const query = await createSigMsgQuery()
const query = await generateAuthQueryParam()

const response = await api.delete(`/radar/${id}?${query}`)

Expand Down
2 changes: 1 addition & 1 deletion src/utils/getSignedMessage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function getSignedMessageFromRelay(): Promise<{ message: string; si
}
}

export async function createSigMsgQuery() {
export async function generateAuthQueryParam() {
const res = await getSignedMessageFromRelay()

return `sig=${res.signature}&msg=${res.message}`
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { timeToMilliseconds } from './timeToMilliseconds'
import { useIsMatchBreakpoint } from './useIsMatchBreakpoint'
// import APP_VERSION from './versionHelper'
import { extractUuidAndHost } from './auth'
import { createSigMsgQuery, getSignedMessageFromRelay } from './getSignedMessage'
import { generateAuthQueryParam, getSignedMessageFromRelay } from './getSignedMessage'
import { videoTimeToSeconds } from './videoTimetoSeconds'

export {
Expand Down Expand Up @@ -47,5 +47,5 @@ export {
videoTimeToSeconds,
getSignedMessageFromRelay,
extractUuidAndHost,
createSigMsgQuery,
generateAuthQueryParam,
}

0 comments on commit 3c7d71c

Please sign in to comment.