@luxexchange/api 1.0.0 → 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.
Files changed (48) hide show
  1. package/dist/client.d.ts +22 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +56 -0
  4. package/dist/hooks/index.d.ts +6 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +5 -0
  7. package/dist/hooks/use-token-list.d.ts +22 -0
  8. package/dist/hooks/use-token-list.d.ts.map +1 -0
  9. package/dist/hooks/use-token-list.js +27 -0
  10. package/dist/hooks/use-token-price.d.ts +15 -0
  11. package/dist/hooks/use-token-price.d.ts.map +1 -0
  12. package/dist/hooks/use-token-price.js +63 -0
  13. package/dist/index.d.ts +6 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +5 -0
  16. package/package.json +10 -11
  17. package/project.json +1 -7
  18. package/src/clients/base/errors.test.ts +39 -0
  19. package/src/clients/base/errors.ts +9 -1
  20. package/src/clients/base/urls.test.ts +6 -6
  21. package/src/clients/base/urls.ts +3 -3
  22. package/src/clients/compliance/createComplianceApiClient.ts +40 -0
  23. package/src/clients/compliance/types.ts +15 -0
  24. package/src/clients/dataApi/createDataApiServiceClient.ts +4 -4
  25. package/src/clients/dataApi/getGetPortfolioQueryOptions.test.ts +1 -1
  26. package/src/clients/dataApi/getGetPortfolioQueryOptions.ts +6 -2
  27. package/src/clients/embeddedWallet/createEmbeddedWalletApiClient.ts +254 -82
  28. package/src/clients/gasService/createGasServiceClient.ts +21 -0
  29. package/src/clients/graphql/queries.graphql +0 -183
  30. package/src/clients/graphql/queries.ts +0 -2
  31. package/src/clients/graphql/schema.graphql +603 -594
  32. package/src/clients/graphql/web/activity.graphql +0 -6
  33. package/src/clients/graphql/web/landing.graphql +0 -20
  34. package/src/clients/graphql/web/token.graphql +21 -3
  35. package/src/clients/lux/createLuxApiClient.ts +1 -18
  36. package/src/clients/trading/api.json +1 -1
  37. package/src/clients/trading/createTradingApiClient.ts +2 -2
  38. package/src/clients/unitags/createUnitagsApiClient.test.ts +1 -1
  39. package/src/clients/x/createXVerificationServiceClient.ts +26 -0
  40. package/src/components/ApiInit.test.tsx +1 -1
  41. package/src/getWebSocketUrl.ts +7 -4
  42. package/src/index.ts +36 -9
  43. package/src/session/createWithSessionRetry.ts +1 -1
  44. package/stubs/privy-service-pb.d.ts +150 -3
  45. package/.depcheckrc +0 -17
  46. package/.eslintrc.js +0 -30
  47. package/src/clients/graphql/web/nft/CollectionSearch.graphql +0 -34
  48. package/src/clients/graphql/web/portfolios.graphql +0 -68
@@ -45,8 +45,8 @@ export const TRADING_API_PATHS = {
45
45
  swappableTokens: 'swappable_tokens',
46
46
  swaps: 'swaps',
47
47
  wallet: {
48
- checkDelegation: '@luxfi/wallet/check_delegation',
49
- encode7702: '@luxfi/wallet/encode_7702',
48
+ checkDelegation: 'wallet/check_delegation',
49
+ encode7702: 'wallet/encode_7702',
50
50
  },
51
51
  }
52
52
 
@@ -1,5 +1,5 @@
1
1
  import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest'
2
- import '@luxfi/utilities/src/logger/mocks'
2
+ import 'utilities/src/logger/mocks'
3
3
 
4
4
  vi.mock('@luxfi/config', () => ({
5
5
  getConfig: vi.fn(() => ({
@@ -0,0 +1,26 @@
1
+ import { type PromiseClient } from '@connectrpc/connect'
2
+ import { type XVerificationService } from '@uniswap/client-liquidity/dist/uniswap/liquidity/v1/x_verification_connect'
3
+ import type {
4
+ GetXAuthUrlRequest,
5
+ GetXAuthUrlResponse,
6
+ VerifyXCallbackRequest,
7
+ VerifyXCallbackResponse,
8
+ } from '@uniswap/client-liquidity/dist/uniswap/liquidity/v1/x_verification_pb'
9
+
10
+ interface XVerificationServiceClientContext {
11
+ rpcClient: PromiseClient<typeof XVerificationService>
12
+ }
13
+
14
+ export interface XVerificationServiceClient {
15
+ getXAuthUrl: (params: GetXAuthUrlRequest) => Promise<GetXAuthUrlResponse>
16
+ verifyXCallback: (params: VerifyXCallbackRequest) => Promise<VerifyXCallbackResponse>
17
+ }
18
+
19
+ export function createXVerificationServiceClient({
20
+ rpcClient,
21
+ }: XVerificationServiceClientContext): XVerificationServiceClient {
22
+ return {
23
+ getXAuthUrl: (params) => rpcClient.getXAuthUrl(params),
24
+ verifyXCallback: (params) => rpcClient.verifyXCallback(params),
25
+ }
26
+ }
@@ -22,7 +22,7 @@ import { sleep } from '@luxfi/utilities/src/time/timing'
22
22
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
23
23
 
24
24
  // Mock platform detection - we're testing as extension by default
25
- vi.mock('@luxfi/utilities/src/platform', () => ({
25
+ vi.mock('utilities/src/platform', () => ({
26
26
  isWeb: false,
27
27
  isExtension: true,
28
28
  isInterface: false,
@@ -4,14 +4,17 @@ import { Environment, getCurrentEnv } from '@luxfi/utilities/src/environment/get
4
4
 
5
5
  /**
6
6
  * Returns the appropriate WebSocket URL based on the current environment.
7
- * When the entry gateway proxy is enabled, returns the BFF proxy path so the
8
- * Cloudflare Worker or Vercel edge function can forward the connection with
9
- * correct cookies/origin.
7
+ * When the entry gateway proxy is enabled (and not on Vercel), returns the BFF
8
+ * proxy path so the Cloudflare Worker can forward the connection with correct
9
+ * cookies/origin. On Vercel, WebSocket proxying is not supported (neither via
10
+ * serverless/edge functions nor external rewrites), so we return the direct
11
+ * backend URL — the WS connection will fail (no session cookies cross-origin)
12
+ * and the REST fallback (RestPriceBatcher via /entry-gateway) handles pricing.
10
13
  */
11
14
  export function getWebSocketUrl(): string {
12
15
  const config = getConfig()
13
16
 
14
- if (config.enableEntryGatewayProxy) {
17
+ if (config.enableEntryGatewayProxy && !config.isVercelEnvironment) {
15
18
  return '/ws'
16
19
  }
17
20
 
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** biome-ignore-all assist/source/organizeImports: we want to manually group exports by category */
2
2
 
3
3
  /**
4
- * @luxexchange/api - Unified data layer for Lux Universe
4
+ * @universe/api - Unified data layer for Lux Universe
5
5
  *
6
6
  * This is the ONLY public entry point for the API package.
7
7
  * All exports must be explicitly listed here.
@@ -141,14 +141,27 @@ export {
141
141
  type AuctionServiceClient,
142
142
  } from '@luxexchange/api/src/clients/auctions/createAuctionServiceClient'
143
143
 
144
- // Lux API
144
+ // X Verification Service API
145
145
  export {
146
- createLuxApiClient,
146
+ createXVerificationServiceClient,
147
+ type XVerificationServiceClient,
148
+ } from '@luxexchange/api/src/clients/x/createXVerificationServiceClient'
149
+
150
+ // Uniswap API
151
+ export {
152
+ createUniswapApiClient,
153
+ type UniswapApiClient,
154
+ type UniswapApiClientContext,
155
+ } from '@luxexchange/api/src/clients/uniswap/createUniswapApiClient'
156
+
157
+ // Compliance API
158
+ export {
159
+ createComplianceApiClient,
160
+ type ComplianceApiClient,
161
+ type ComplianceApiClientContext,
147
162
  type ScreenRequest,
148
163
  type ScreenResponse,
149
- type LuxApiClient,
150
- type LuxApiClientContext,
151
- } from '@luxexchange/api/src/clients/lux/createLuxApiClient'
164
+ } from '@luxexchange/api/src/clients/compliance/createComplianceApiClient'
152
165
 
153
166
  // Unitags API
154
167
  export {
@@ -176,6 +189,17 @@ export {
176
189
  } from '@luxexchange/api/src/clients/unitags/types'
177
190
  export { createUnitagsApiClient } from '@luxexchange/api/src/clients/unitags/createUnitagsApiClient'
178
191
 
192
+ // Gas Service API (ConnectRPC - estimateGasFee via UniRPC v2)
193
+ export {
194
+ createGasServiceClient,
195
+ type GasServiceClient,
196
+ type GasServiceClientContext,
197
+ } from '@luxexchange/api/src/clients/gasService/createGasServiceClient'
198
+ export type {
199
+ EstimateGasFeeRequest as GasServiceEstimateRequest,
200
+ EstimateGasFeeResponse as GasServiceEstimateResponse,
201
+ } from '@uniswap/client-unirpc-v2/dist/uniswap/unirpc/v2/service_pb'
202
+
179
203
  // Data API Service (ConnectRPC - listTopTokens, listTopPools, getPortfolio, etc.)
180
204
  export {
181
205
  createDataApiServiceClient,
@@ -188,11 +212,11 @@ export {
188
212
  } from '@luxexchange/api/src/clients/dataApi/getGetPortfolioQueryOptions'
189
213
  export {
190
214
  TopPoolsOrderBy,
191
- TopTokensOrderBy,
215
+ TokensOrderBy,
192
216
  type GetPortfolioRequest,
193
217
  type GetPortfolioResponse,
194
218
  type ListTopPoolsResponse,
195
- type ListTopTokensResponse,
219
+ type ListTokensResponse,
196
220
  } from '@uniswap/client-data-api/dist/data/v1/api_pb'
197
221
  export { ProtocolVersion } from '@uniswap/client-data-api/dist/data/v1/poolTypes_pb'
198
222
  export { type Pool as DataApiPool, type Token as DataApiToken } from '@uniswap/client-data-api/dist/data/v1/types_pb'
@@ -280,6 +304,8 @@ export {
280
304
  createEmbeddedWalletApiClient,
281
305
  type EmbeddedWalletApiClient,
282
306
  type EmbeddedWalletClientContext,
307
+ type RecoveryMethod,
308
+ type SignAuth,
283
309
  } from '@luxexchange/api/src/clients/embeddedWallet/createEmbeddedWalletApiClient'
284
310
 
285
311
  // Other Utilities
@@ -289,12 +315,13 @@ export {
289
315
  } from '@luxexchange/api/src/clients/base/utils'
290
316
 
291
317
  // Session API
292
- export { ApiInit, SESSION_INIT_QUERY_KEY } from '@luxexchange/api/src/components/ApiInit'
318
+ export { ApiInit, reinitializeSession, SESSION_INIT_QUERY_KEY } from '@luxexchange/api/src/components/ApiInit'
293
319
  export { provideSessionService } from '@luxexchange/api/src/provideSessionService'
294
320
  export { useIsSessionInitialized } from '@luxexchange/api/src/hooks/useIsSessionInitialized'
295
321
 
296
322
  // Session Transport (pure factory, no platform detection)
297
323
  export { createSessionTransport, type CreateSessionTransportOptions } from '@luxexchange/api/src/session'
324
+ export { createWithSessionRetry } from '@luxexchange/api/src/session/createWithSessionRetry'
298
325
 
299
326
  export type {
300
327
  UseQueryApiHelperHookArgs,
@@ -1,4 +1,4 @@
1
- import { is401Error } from '@luxexchange/api'
1
+ import { is401Error } from '@luxexchange/api/src/clients/base/errors'
2
2
 
3
3
  /** Creates a function that will attempt to reinitialize the app session and retry the input function once, if the first invocation of the function fails. */
4
4
  export function createWithSessionRetry(ctx: {
@@ -17,6 +17,21 @@ export declare enum Action {
17
17
  DELETE_RECORD = 7,
18
18
  REGISTER_NEW_AUTHENTICATION_TYPES = 8,
19
19
  LIST_AUTHENTICATORS = 9,
20
+ DELETE_AUTHENTICATOR = 10,
21
+ SETUP_RECOVERY = 11,
22
+ EXECUTE_RECOVERY = 12,
23
+ DELETE_RECOVERY = 13,
24
+ }
25
+
26
+ export declare enum AuthenticatorNameType {
27
+ AUTHENTICATOR_NAME_TYPE_UNSPECIFIED = 0,
28
+ GOOGLE_PASSWORD_MANAGER = 1,
29
+ CHROME_MAC = 2,
30
+ WINDOWS_HELLO = 3,
31
+ ICLOUD_KEYCHAIN_MANAGED = 4,
32
+ ICLOUD_KEYCHAIN = 15,
33
+ PLATFORM_AUTHENTICATOR = 30,
34
+ SECURITY_KEY = 31,
20
35
  }
21
36
 
22
37
  export declare enum RegistrationOptions_AuthenticatorAttachment {
@@ -26,15 +41,38 @@ export declare enum RegistrationOptions_AuthenticatorAttachment {
26
41
  }
27
42
 
28
43
  export declare class ChallengeResponse {
29
- challengeOptions: string
44
+ challengeOptions?: string
45
+ sessionActive: boolean
46
+ signingPayload?: string
47
+ keyQuorumId?: string
48
+ existingPublicKeys: string[]
30
49
  }
31
50
 
32
51
  export declare class CreateWalletResponse {
33
52
  walletAddress: string
34
53
  walletId: string
54
+ deviceKeyQuorumId?: string
55
+ policyId?: string
56
+ policyExpiresAt?: bigint
35
57
  }
36
58
 
37
- export declare class DisconnectResponse {}
59
+ export declare class StartAuthenticatedSessionResponse {
60
+ policyId?: string
61
+ policyExpiresAt?: bigint
62
+ }
63
+
64
+ export declare class DeviceSignatureAuth {
65
+ deviceSignature: string
66
+ walletId: string
67
+ }
68
+
69
+ export declare class AddAuthenticatorResponse {
70
+ credentialId: string
71
+ }
72
+
73
+ export declare class DisconnectResponse {
74
+ success: boolean
75
+ }
38
76
 
39
77
  export declare class RegistrationOptions {
40
78
  authenticatorAttachment?: RegistrationOptions_AuthenticatorAttachment
@@ -44,7 +82,6 @@ export declare class RegistrationOptions {
44
82
  export declare class WalletSignInResponse {
45
83
  walletAddress: string
46
84
  walletId: string
47
- exported?: boolean
48
85
  }
49
86
 
50
87
  export declare class SignMessageResponse {
@@ -58,3 +95,113 @@ export declare class SignTransactionResponse {
58
95
  export declare class SignTypedDataResponse {
59
96
  signature: string
60
97
  }
98
+
99
+ export declare class Authenticator {
100
+ credentialId: string
101
+ providerName: AuthenticatorNameType
102
+ username?: string
103
+ createdAt: bigint
104
+ aaguid?: string
105
+ }
106
+
107
+ export declare class ListAuthenticatorsRequest {
108
+ credential?: string
109
+ walletId?: string
110
+ }
111
+
112
+ export declare class RecoveryMethod {
113
+ type: string
114
+ identifier: string
115
+ createdAt: bigint
116
+ status: string
117
+ }
118
+
119
+ export declare class ListAuthenticatorsResponse {
120
+ authenticators: Authenticator[]
121
+ recoveryMethods: RecoveryMethod[]
122
+ }
123
+
124
+ export declare class AddAuthenticatorRequest {
125
+ newCredential: string
126
+ deviceSignature?: string
127
+ }
128
+
129
+ export declare class StartAuthenticatedSessionRequest {
130
+ existingCredential: string
131
+ devicePublicKey?: string
132
+ }
133
+
134
+ export declare class DeleteAuthenticatorRequest {
135
+ credential: string
136
+ authenticatorId: string
137
+ }
138
+
139
+ export declare class DeleteAuthenticatorResponse {
140
+ success: boolean
141
+ }
142
+
143
+ export declare class OprfEvaluateRequest {
144
+ blindedElement: string
145
+ isRecovery?: boolean
146
+ authMethodId?: string
147
+ }
148
+
149
+ export declare class OprfEvaluateResponse {
150
+ evaluatedElement?: string
151
+ errorMessage?: string
152
+ }
153
+
154
+ export declare class SetupRecoveryRequest {
155
+ walletId: string
156
+ authPublicKey: string
157
+ authMethodId: string
158
+ authMethodType?: string
159
+ }
160
+
161
+ export declare class SetupRecoveryResponse {
162
+ success: boolean
163
+ recoveryQuorumId?: string
164
+ }
165
+
166
+ export declare class ExecuteRecoveryRequest {
167
+ authMethodId: string
168
+ newCredential: string
169
+ authKeySignature: string
170
+ emailJwt: string
171
+ }
172
+
173
+ export declare class ExecuteRecoveryResponse {
174
+ credentialId?: string
175
+ walletAddress?: string
176
+ walletId?: string
177
+ errorMessage?: string
178
+ }
179
+
180
+ export declare class ReportDecryptionResultRequest {
181
+ success: boolean
182
+ authMethodId: string
183
+ newPasskeyPublicKey?: string
184
+ }
185
+
186
+ export declare class ReportDecryptionResultResponse {
187
+ cooldownSeconds: number
188
+ errorMessage?: string
189
+ signingPayload?: string
190
+ }
191
+
192
+ export declare class GetRecoveryConfigResponse {
193
+ found: boolean
194
+ status?: string
195
+ recoveryQuorumId?: string
196
+ authMethodType?: string
197
+ encryptedKeyId?: string
198
+ walletAddress?: string
199
+ }
200
+
201
+ export declare class DeleteRecoveryRequest {
202
+ credential: string
203
+ }
204
+
205
+ export declare class DeleteRecoveryResponse {
206
+ success: boolean
207
+ }
package/.depcheckrc DELETED
@@ -1,17 +0,0 @@
1
- ignores: [
2
- # Dependencies that depcheck thinks are unused but are actually used
3
- "openapi-typescript-codegen",
4
- "typescript",
5
- "@typescript/native-preview",
6
- "depcheck",
7
- "graphql",
8
- "@graphql-codegen/*",
9
- "get-graphql-schema",
10
- "@vitest/coverage-v8",
11
- # Dependencies that depcheck thinks are missing but are actually present
12
- ## Internal packages / workspaces
13
- "@universe/api",
14
- "@universe/config",
15
- "tsconfig",
16
- "utilities",
17
- ]
package/.eslintrc.js DELETED
@@ -1,30 +0,0 @@
1
- const { reactNative: reactNativeImports } = require('@luxfi/eslint-config/restrictedImports')
2
-
3
- module.exports = {
4
- extends: ['@luxfi/eslint-config/lib'],
5
- ignorePatterns: ['graphql.config.ts', 'stubs/**'],
6
- parserOptions: {
7
- tsconfigRootDir: __dirname,
8
- },
9
- overrides: [
10
- {
11
- files: ['**/*.{ts,tsx}'],
12
- excludedFiles: ['**/*.native.*', '**/*.ios.*', '**/*.android.*'],
13
- rules: {
14
- '@typescript-eslint/no-restricted-imports': ['error', reactNativeImports],
15
- },
16
- },
17
- {
18
- files: ['*.ts', '*.tsx'],
19
- rules: {
20
- 'no-relative-import-paths/no-relative-import-paths': [
21
- 'error',
22
- {
23
- allowSameFolder: false,
24
- prefix: '@luxfi/api',
25
- },
26
- ],
27
- },
28
- },
29
- ],
30
- }
@@ -1,34 +0,0 @@
1
- query CollectionSearch($query: String!) {
2
- nftCollections(filter: { nameQuery: $query }) {
3
- edges {
4
- cursor
5
- node {
6
- image {
7
- url
8
- }
9
- isVerified
10
- name
11
- numAssets
12
- nftContracts {
13
- address
14
- chain
15
- name
16
- symbol
17
- totalSupply
18
- }
19
- markets(currencies: ETH) {
20
- floorPrice {
21
- currency
22
- value
23
- }
24
- }
25
- }
26
- }
27
- pageInfo {
28
- endCursor
29
- hasNextPage
30
- hasPreviousPage
31
- startCursor
32
- }
33
- }
34
- }
@@ -1,68 +0,0 @@
1
- fragment QuickTokenBalanceParts on TokenBalance {
2
- id
3
- quantity
4
- denominatedValue {
5
- id
6
- value
7
- currency
8
- }
9
- token {
10
- id
11
- address
12
- chain
13
- standard
14
- }
15
- }
16
-
17
- fragment PortfolioTokenBalanceParts on TokenBalance {
18
- id
19
- quantity
20
- denominatedValue {
21
- id
22
- currency
23
- value
24
- }
25
- token {
26
- ...SimpleTokenDetails
27
- id
28
- address
29
- chain
30
- symbol
31
- name
32
- decimals
33
- standard
34
- project {
35
- id
36
- name
37
- logo {
38
- id
39
- url
40
- }
41
- safetyLevel
42
- logoUrl
43
- isSpam
44
- }
45
- }
46
- tokenProjectMarket {
47
- id
48
- pricePercentChange(duration: DAY) {
49
- id
50
- value
51
- }
52
- tokenProject {
53
- id
54
- logoUrl
55
- isSpam
56
- }
57
- }
58
- }
59
-
60
- # Query only returns basic token, quantity, and denominated value.
61
- query QuickTokenBalancesWeb($ownerAddress: String!, $chains: [Chain!]!) {
62
- portfolios(ownerAddresses: [$ownerAddress], chains: $chains) {
63
- id
64
- tokenBalances {
65
- ...QuickTokenBalanceParts
66
- }
67
- }
68
- }