Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Oct 24, 2024
1 parent 622a2f5 commit c6c0599
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
11 changes: 6 additions & 5 deletions packages/core/src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export async function getRelayerRaw(url: string, headers = {}) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error('Response error:', error.response.data)
} else if (error.request) {
// The request was made but no response was received
console.error('Request error: No response received')
Expand All @@ -108,7 +109,7 @@ export async function postRelayerWithAuth(
const symmetricKey = getSymmetricKey(config)
invariant(symmetricKey, 'Failed to derive symmetric key')

const path = getUriPath(url)
const path = getPathFromUrl(url)
const headers = {
'Content-Type': 'application/json',
}
Expand All @@ -132,7 +133,7 @@ export async function postRelayerWithAdmin(
invariant(adminKey, 'Admin key is required')
const symmetricKey = config.utils.b64_to_hex_hmac_key(adminKey)

const path = getUriPath(url)
const path = getPathFromUrl(url)
const headers = {
'Content-Type': 'application/json',
}
Expand All @@ -151,7 +152,7 @@ export async function getRelayerWithAuth(config: Config, url: string) {
const symmetricKey = getSymmetricKey(config)
invariant(symmetricKey, 'Failed to derive symmetric key')

const path = getUriPath(url)
const path = getPathFromUrl(url)
const headers = {
'Content-Type': 'application/json',
}
Expand All @@ -171,7 +172,7 @@ export async function getRelayerWithAdmin(config: Config, url: string) {
invariant(adminKey, 'Admin key is required')
const symmetricKey = config.utils.b64_to_hex_hmac_key(adminKey)

const path = getUriPath(url)
const path = getPathFromUrl(url)
const headers = {
'Content-Type': 'application/json',
}
Expand All @@ -188,7 +189,7 @@ export async function getRelayerWithAdmin(config: Config, url: string) {
}

/// Get the path from a URL
function getUriPath(url: string): string {
function getPathFromUrl(url: string): string {
try {
const parsedUrl = new URL(url)
return parsedUrl.pathname || '/'
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/hooks/useOrderHistoryWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {
type Config,
type OrderMetadata,
SIG_EXPIRATION_BUFFER_MS,
type SubscriptionBody,
WS_WALLET_ORDERS_ROUTE,
addExpiringAuthToHeaders,
getSymmetricKey,
getSymmetricKey
} from '@renegade-fi/core'
import { useEffect } from 'react'
import useWebSocket, { ReadyState } from 'react-use-websocket'
Expand Down Expand Up @@ -73,7 +72,7 @@ export function useOrderHistoryWebSocket(
const body = {
method: 'subscribe',
topic: WS_WALLET_ORDERS_ROUTE(walletId),
} satisfies SubscriptionBody
}
const symmetricKey = getSymmetricKey(config)
const headers = addExpiringAuthToHeaders(
config,
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/hooks/useTaskHistoryWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import {
type Config,
SIG_EXPIRATION_BUFFER_MS,
type SubscriptionBody,
type Task,
WS_TASK_HISTORY_ROUTE,
addExpiringAuthToHeaders,
getSymmetricKey,
parseBigJSON,
parseBigJSON
} from '@renegade-fi/core'
import { useEffect } from 'react'
import useWebSocket, { ReadyState } from 'react-use-websocket'
Expand Down Expand Up @@ -68,7 +67,7 @@ export function useTaskHistoryWebSocket(
const body = {
method: 'subscribe',
topic: WS_TASK_HISTORY_ROUTE(walletId),
} satisfies SubscriptionBody
}
const symmetricKey = getSymmetricKey(config)
const headers = addExpiringAuthToHeaders(
config,
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/hooks/useWalletWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import {
type Config,
SIG_EXPIRATION_BUFFER_MS,
type SubscriptionBody,
WALLET_ROUTE,
type Wallet,
addExpiringAuthToHeaders,
getSymmetricKey,
parseBigJSON,
parseBigJSON
} from '@renegade-fi/core'
import { useEffect } from 'react'
import useWebSocket, { ReadyState } from 'react-use-websocket'
Expand Down Expand Up @@ -67,7 +66,7 @@ export function useWalletWebsocket(parameters: UseWalletParameters = {}) {
const body = {
method: 'subscribe',
topic: WALLET_ROUTE(walletId),
} satisfies SubscriptionBody
}
const symmetricKey = getSymmetricKey(config)
const headers = addExpiringAuthToHeaders(
config,
Expand Down

0 comments on commit c6c0599

Please sign in to comment.