@luxexchange/prices 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/project.json +1 -1
- package/src/context/PriceServiceContext.test.tsx +3 -3
- package/src/context/PriceServiceContext.tsx +2 -2
- package/src/hooks/useConnectionStatus.ts +2 -2
- package/src/hooks/usePrice.ts +4 -4
- package/src/index.ts +5 -5
- package/src/queries/priceKeys.test.ts +2 -2
- package/src/queries/priceKeys.ts +1 -1
- package/src/queries/tokenPriceQueryOptions.ts +2 -2
- package/src/sources/websocket/messageParser.ts +2 -2
- package/src/sources/websocket/subscriptionApi.ts +3 -3
- package/src/utils/tokenIdentifier.test.ts +2 -2
- package/src/utils/tokenIdentifier.ts +2 -2
package/package.json
CHANGED
package/project.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import type { QueryClient } from '@tanstack/react-query'
|
|
4
4
|
import { renderHook } from '@testing-library/react'
|
|
5
|
-
import { PriceServiceProvider, usePricesContext } from '@
|
|
6
|
-
import type { TokenPriceMessage, TokenSubscriptionParams } from '@
|
|
7
|
-
import type { WebSocketClient } from '@
|
|
5
|
+
import { PriceServiceProvider, usePricesContext } from '@luxexchange/prices/src/context/PriceServiceContext'
|
|
6
|
+
import type { TokenPriceMessage, TokenSubscriptionParams } from '@luxexchange/prices/src/types'
|
|
7
|
+
import type { WebSocketClient } from '@luxexchange/websocket'
|
|
8
8
|
import type { ReactNode } from 'react'
|
|
9
9
|
import { describe, expect, it, vi } from 'vitest'
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QueryClient } from '@tanstack/react-query'
|
|
2
|
-
import type { TokenPriceMessage, TokenSubscriptionParams } from '@
|
|
3
|
-
import type { WebSocketClient } from '@
|
|
2
|
+
import type { TokenPriceMessage, TokenSubscriptionParams } from '@luxexchange/prices/src/types'
|
|
3
|
+
import type { WebSocketClient } from '@luxexchange/websocket'
|
|
4
4
|
import { createContext, type ReactElement, type ReactNode, useContext } from 'react'
|
|
5
5
|
|
|
6
6
|
interface PricesContextValue {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { usePricesContext } from '@
|
|
2
|
-
import type { ConnectionStatus } from '@
|
|
1
|
+
import { usePricesContext } from '@luxexchange/prices/src/context/PriceServiceContext'
|
|
2
|
+
import type { ConnectionStatus } from '@luxexchange/websocket'
|
|
3
3
|
import { useSyncExternalStore } from 'react'
|
|
4
4
|
|
|
5
5
|
/**
|
package/src/hooks/usePrice.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { queryOptions, skipToken, useQuery } from '@tanstack/react-query'
|
|
2
|
-
import { usePricesContext } from '@
|
|
3
|
-
import { priceKeys } from '@
|
|
4
|
-
import { tokenPriceQueryOptions } from '@
|
|
5
|
-
import type { TokenPriceData } from '@
|
|
2
|
+
import { usePricesContext } from '@luxexchange/prices/src/context/PriceServiceContext'
|
|
3
|
+
import { priceKeys } from '@luxexchange/prices/src/queries/priceKeys'
|
|
4
|
+
import { tokenPriceQueryOptions } from '@luxexchange/prices/src/queries/tokenPriceQueryOptions'
|
|
5
|
+
import type { TokenPriceData } from '@luxexchange/prices/src/types'
|
|
6
6
|
import { useEffect } from 'react'
|
|
7
7
|
|
|
8
8
|
interface UsePriceOptions {
|
package/src/index.ts
CHANGED
|
@@ -5,9 +5,9 @@ export {
|
|
|
5
5
|
isRawTokenPriceMessage,
|
|
6
6
|
parseConnectionMessage,
|
|
7
7
|
parseTokenPriceMessage,
|
|
8
|
-
} from '@
|
|
8
|
+
} from '@luxexchange/prices/src/sources/websocket/messageParser'
|
|
9
9
|
// Internals (testing / custom setups)
|
|
10
|
-
export { createPriceSubscriptionHandler } from '@
|
|
10
|
+
export { createPriceSubscriptionHandler } from '@luxexchange/prices/src/sources/websocket/subscriptionApi'
|
|
11
11
|
export type {
|
|
12
12
|
ConnectionEstablishedMessage,
|
|
13
13
|
Logger,
|
|
@@ -19,7 +19,7 @@ export type {
|
|
|
19
19
|
TokenPriceData,
|
|
20
20
|
TokenPriceMessage,
|
|
21
21
|
TokenSubscriptionParams,
|
|
22
|
-
} from '@
|
|
22
|
+
} from '@luxexchange/prices/src/types'
|
|
23
23
|
export {
|
|
24
24
|
createPriceKey,
|
|
25
25
|
createPriceKeyFromToken,
|
|
@@ -29,8 +29,8 @@ export {
|
|
|
29
29
|
normalizeToken,
|
|
30
30
|
parsePriceKey,
|
|
31
31
|
toSubscriptionParams,
|
|
32
|
-
} from '@
|
|
33
|
-
export type { ConnectionStatus } from '@
|
|
32
|
+
} from '@luxexchange/prices/src/utils/tokenIdentifier'
|
|
33
|
+
export type { ConnectionStatus } from '@luxexchange/websocket'
|
|
34
34
|
export { PriceServiceProvider, usePricesContext } from './context/PriceServiceContext'
|
|
35
35
|
export { useConnectionStatus } from './hooks/useConnectionStatus'
|
|
36
36
|
// Consumer hooks
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { priceKeys } from '@
|
|
2
|
-
import { ReactQueryCacheKey } from 'utilities/src/reactQuery/cache'
|
|
1
|
+
import { priceKeys } from '@luxexchange/prices/src/queries/priceKeys'
|
|
2
|
+
import { ReactQueryCacheKey } from '@luxfi/utilities/src/reactQuery/cache'
|
|
3
3
|
import { describe, expect, it } from 'vitest'
|
|
4
4
|
|
|
5
5
|
describe('priceKeys', () => {
|
package/src/queries/priceKeys.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { queryOptions, skipToken } from '@tanstack/react-query'
|
|
2
|
-
import { priceKeys } from '@
|
|
3
|
-
import type { TokenPriceData } from '@
|
|
2
|
+
import { priceKeys } from '@luxexchange/prices/src/queries/priceKeys'
|
|
3
|
+
import type { TokenPriceData } from '@luxexchange/prices/src/types'
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
6
6
|
export function tokenPriceQueryOptions(chainId: number, address: string) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConnectionEstablishedMessage, RawTokenPriceMessage, TokenPriceMessage } from '@
|
|
2
|
-
import { createPriceKey } from '@
|
|
1
|
+
import type { ConnectionEstablishedMessage, RawTokenPriceMessage, TokenPriceMessage } from '@luxexchange/prices/src/types'
|
|
2
|
+
import { createPriceKey } from '@luxexchange/prices/src/utils/tokenIdentifier'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Type guard for RawTokenPriceMessage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FetchClient } from '@
|
|
2
|
-
import type { TokenSubscriptionParams } from '@
|
|
3
|
-
import type { SubscriptionHandler } from '@
|
|
1
|
+
import type { FetchClient } from '@luxexchange/api'
|
|
2
|
+
import type { TokenSubscriptionParams } from '@luxexchange/prices/src/types'
|
|
3
|
+
import type { SubscriptionHandler } from '@luxexchange/websocket'
|
|
4
4
|
|
|
5
5
|
const EVENT_SUBSCRIPTION_TYPE_TOKEN_PRICE = 'EVENT_SUBSCRIPTION_TYPE_TOKEN_PRICE'
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Token } from '@uniswap/sdk-core'
|
|
2
|
-
import type { TokenIdentifier } from '@
|
|
2
|
+
import type { TokenIdentifier } from '@luxexchange/prices'
|
|
3
3
|
import {
|
|
4
4
|
createPriceKey,
|
|
5
5
|
createPriceKeyFromToken,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
normalizeToken,
|
|
10
10
|
parsePriceKey,
|
|
11
11
|
toSubscriptionParams,
|
|
12
|
-
} from '@
|
|
12
|
+
} from '@luxexchange/prices'
|
|
13
13
|
import { describe, expect, it } from 'vitest'
|
|
14
14
|
|
|
15
15
|
const WETH_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Currency, Token } from '@uniswap/sdk-core'
|
|
2
|
-
import type { PriceKey, TokenIdentifier, TokenInput, TokenSubscriptionParams } from '@
|
|
3
|
-
import { isEVMAddress } from 'utilities/src/addresses/evm/evm'
|
|
2
|
+
import type { PriceKey, TokenIdentifier, TokenInput, TokenSubscriptionParams } from '@luxexchange/prices'
|
|
3
|
+
import { isEVMAddress } from '@luxfi/utilities/src/addresses/evm/evm'
|
|
4
4
|
|
|
5
5
|
/** Address that represents native currencies on ETH, Arbitrum, etc. */
|
|
6
6
|
const DEFAULT_NATIVE_ADDRESS_LEGACY = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
|